[alsa-devel] [PATCH 5/7] ASoC: amd: add ACP3x TDM mode support

Ravulapati Vishnu vardhan rao Vishnuvardhanrao.Ravulapati at amd.com
Tue Oct 1 02:58:13 CEST 2019


ACP3x I2S (CPU DAI) can act in normal I2S and TDM modes. Added support
for TDM mode. Desired mode can be selected from ASoC machine driver.

Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati at amd.com>
---
 sound/soc/amd/raven/acp3x-i2s.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c
index 4511b9b..312207b 100644
--- a/sound/soc/amd/raven/acp3x-i2s.c
+++ b/sound/soc/amd/raven/acp3x-i2s.c
@@ -43,7 +43,8 @@ static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
 		u32 rx_mask, int slots, int slot_width)
 {
 	u32 val = 0;
-	u16 slot_len;
+	u32 mode = 0;
+	u16 slot_len, flen;
 
 	struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai);
 
@@ -64,16 +65,31 @@ static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
 		return -EINVAL;
 	}
 
-	val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER);
-	rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER);
-	val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER);
-	rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER);
-
-	val = (FRM_LEN | (slots << 15) | (slot_len << 18));
-	rv_writel(val, adata->acp3x_base + mmACP_BTTDM_TXFRMT);
-	rv_writel(val, adata->acp3x_base + mmACP_BTTDM_RXFRMT);
+	/* Enable I2S / BT channels TDM and respective
+	 * I2S/BT`s TX/RX Formats frame lengths.
+	 */
+	flen = (FRM_LEN | (slots << 15) | (slot_len << 18));
+
+	mode = rv_readl(adata->acp3x_base + mmACP_BTTDM_IER);
+	if (mode) {
+		val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER);
+		rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER);
+		rv_writel(flen, adata->acp3x_base + mmACP_BTTDM_TXFRMT);
+		val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER);
+		rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER);
+		rv_writel(flen, adata->acp3x_base + mmACP_BTTDM_RXFRMT);
+	}
 
-	adata->tdm_fmt = val;
+	mode = rv_readl(adata->acp3x_base + mmACP_I2STDM_IER);
+	if (mode) {
+		val = rv_readl(adata->acp3x_base + mmACP_I2STDM_ITER);
+		rv_writel((val | 0x2), adata->acp3x_base + mmACP_I2STDM_ITER);
+		rv_writel(flen, adata->acp3x_base + mmACP_I2STDM_TXFRMT);
+		val = rv_readl(adata->acp3x_base + mmACP_I2STDM_IRER);
+		rv_writel((val | 0x2), adata->acp3x_base + mmACP_I2STDM_IRER);
+		rv_writel(flen, adata->acp3x_base + mmACP_I2STDM_RXFRMT);
+	}
+	adata->tdm_fmt = flen;
 	return 0;
 }
 
-- 
2.7.4



More information about the Alsa-devel mailing list