From: Sugar Zhang Date: Fri, 24 Jul 2015 10:04:31 +0000 (+0800) Subject: ASoC: rockchip: i2s: add pcm transfer mode support. X-Git-Tag: firefly_0821_release~3877 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=26ea8b87f09e367aec6a655176e6983706e7ae7d;p=firefly-linux-kernel-4.4.55.git ASoC: rockchip: i2s: add pcm transfer mode support. usage: add i2s dts property "rockchip,xfer-mode" rockchip,xfer-mode = <0>: i2s transfer mode. rockchip,xfer-mode = <1>: pcm transfer mode. if not define, use i2s transfer mode default. pcm transfer mode is usually used for bt/modem voice. Signed-off-by: Sugar Zhang --- diff --git a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt index 6915841b1928..10adac26c593 100644 --- a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt +++ b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt @@ -6,6 +6,7 @@ Required SoC Specific Properties: - reg: physical base address of the controller and length of memory mapped region. - i2s-id: i2s controller id, +- rockchip,xfer-mode: transfer mode select, 0:i2s, 1: pcm. - clocks: must include clock specifiers corresponding to entries in the clock-names property. - clocks-names: list of clock names sorted in the same order as the clocks diff --git a/sound/soc/rockchip/rk_i2s.c b/sound/soc/rockchip/rk_i2s.c index f241e082d58d..3e0fe9c59f39 100755 --- a/sound/soc/rockchip/rk_i2s.c +++ b/sound/soc/rockchip/rk_i2s.c @@ -63,6 +63,7 @@ struct rk_i2s_dev { struct regmap *regmap; bool tx_start; bool rx_start; + int xfer_mode; /* 0: i2s, 1: pcm */ #ifdef CLK_SET_LATER struct delayed_work clk_delayed_work; #endif @@ -709,6 +710,19 @@ static int rockchip_i2s_probe(struct platform_device *pdev) goto err_unregister_component; } + ret = of_property_read_u32(node, "rockchip,xfer-mode", &i2s->xfer_mode); + if (ret < 0) + i2s->xfer_mode = I2S_XFER_MODE; + + if (PCM_XFER_MODE == i2s->xfer_mode) { + regmap_update_bits(i2s->regmap, I2S_TXCR, + I2S_TXCR_TFS_MASK, + I2S_TXCR_TFS_PCM); + regmap_update_bits(i2s->regmap, I2S_RXCR, + I2S_RXCR_TFS_MASK, + I2S_RXCR_TFS_PCM); + } + rockchip_snd_txctrl(i2s, 0); rockchip_snd_rxctrl(i2s, 0); @@ -774,6 +788,15 @@ static int rockchip_i2s_resume(struct device *dev) return ret; ret = regmap_reinit_cache(i2s->regmap, &rockchip_i2s_regmap_config); + if (PCM_XFER_MODE == i2s->xfer_mode) { + regmap_update_bits(i2s->regmap, I2S_TXCR, + I2S_TXCR_TFS_MASK, + I2S_TXCR_TFS_PCM); + regmap_update_bits(i2s->regmap, I2S_RXCR, + I2S_RXCR_TFS_MASK, + I2S_RXCR_TFS_PCM); + } + pm_runtime_put(dev); dev_dbg(i2s->dev, "%s\n", __func__); diff --git a/sound/soc/rockchip/rk_i2s.h b/sound/soc/rockchip/rk_i2s.h index 9cec8821274a..d2dcfb74b2e0 100644 --- a/sound/soc/rockchip/rk_i2s.h +++ b/sound/soc/rockchip/rk_i2s.h @@ -48,6 +48,7 @@ #define I2S_TXCR_TFS_SHIFT 5 #define I2S_TXCR_TFS_I2S (0 << I2S_TXCR_TFS_SHIFT) #define I2S_TXCR_TFS_PCM (1 << I2S_TXCR_TFS_SHIFT) +#define I2S_TXCR_TFS_MASK (1 << I2S_TXCR_TFS_SHIFT) #define I2S_TXCR_VDW_SHIFT 0 #define I2S_TXCR_VDW(x) ((x - 1) << I2S_TXCR_VDW_SHIFT) #define I2S_TXCR_VDW_MASK (0x1f << I2S_TXCR_VDW_SHIFT) @@ -74,6 +75,7 @@ #define I2S_RXCR_TFS_SHIFT 5 #define I2S_RXCR_TFS_I2S (0 << I2S_RXCR_TFS_SHIFT) #define I2S_RXCR_TFS_PCM (1 << I2S_RXCR_TFS_SHIFT) +#define I2S_RXCR_TFS_MASK (1 << I2S_RXCR_TFS_SHIFT) #define I2S_RXCR_VDW_SHIFT 0 #define I2S_RXCR_VDW(x) ((x - 1) << I2S_RXCR_VDW_SHIFT) #define I2S_RXCR_VDW_MASK (0x1f << I2S_RXCR_VDW_SHIFT) @@ -223,4 +225,7 @@ #define I2S_CHANNEL_4 4 #define I2S_CHANNEL_2 2 +#define I2S_XFER_MODE 0 +#define PCM_XFER_MODE 1 + #endif /* __RK_I2S_H__ */