diff options
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.14.71/1106-ASoC-AMD-add-ACP3x-TDM-mode-support.patch')
-rw-r--r-- | common/recipes-kernel/linux/linux-yocto-4.14.71/1106-ASoC-AMD-add-ACP3x-TDM-mode-support.patch | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.14.71/1106-ASoC-AMD-add-ACP3x-TDM-mode-support.patch b/common/recipes-kernel/linux/linux-yocto-4.14.71/1106-ASoC-AMD-add-ACP3x-TDM-mode-support.patch new file mode 100644 index 00000000..83a39fb0 --- /dev/null +++ b/common/recipes-kernel/linux/linux-yocto-4.14.71/1106-ASoC-AMD-add-ACP3x-TDM-mode-support.patch @@ -0,0 +1,126 @@ +From 8c762c42530c4add00702868922036264e249a32 Mon Sep 17 00:00:00 2001 +From: Maruthi Srinivas Bayyavarapu <Maruthi.Bayyavarapu@amd.com> +Date: Thu, 30 Mar 2017 15:20:28 +0530 +Subject: [PATCH 1106/4131] ASoC: AMD: add ACP3x TDM mode support + +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: Maruthi Bayyavarapu <maruthi.bayyavarapu@amd.com> +Signed-off-by: Alex Deucher <alexander.deucher@amd.com> +--- + sound/soc/amd/raven/acp3x-pcm-dma.c | 63 ++++++++++++++++++++++++++++++++++++- + sound/soc/amd/raven/acp3x.h | 1 + + 2 files changed, 63 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c +index 5e589dc..f62bb7f 100644 +--- a/sound/soc/amd/raven/acp3x-pcm-dma.c ++++ b/sound/soc/amd/raven/acp3x-pcm-dma.c +@@ -25,7 +25,9 @@ + #include "acp3x.h" + + struct i2s_dev_data { ++ bool tdm_mode; + unsigned int i2s_irq; ++ u32 tdm_fmt; + void __iomem *acp3x_base; + struct snd_pcm_substream *play_stream; + struct snd_pcm_substream *capture_stream; +@@ -35,7 +37,6 @@ struct i2s_stream_instance { + u16 num_pages; + u16 channels; + u32 xfer_resolution; +- u32 fmt; + u32 val; + struct page *pg; + void __iomem *acp3x_base; +@@ -436,6 +437,64 @@ static struct snd_soc_platform_driver acp3x_asoc_platform = { + .pcm_new = acp3x_dma_new, + }; + ++static int acp3x_dai_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) ++{ ++ ++ struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); ++ ++ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { ++ case SND_SOC_DAIFMT_I2S: ++ adata->tdm_mode = false; ++ break; ++ case SND_SOC_DAIFMT_DSP_A: ++ adata->tdm_mode = true; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static int acp3x_dai_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, ++ u32 rx_mask, int slots, int slot_width) ++{ ++ u32 val = 0; ++ u16 resolution; ++ ++ struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); ++ ++ switch (slot_width) { ++ case 8: ++ resolution = 0; ++ break; ++ case 16: ++ resolution = 2; ++ break; ++ case 24: ++ resolution = 4; ++ break; ++ case 32: ++ resolution = 5; ++ break; ++ default: ++ return -EINVAL; ++ break; ++ } ++ ++ 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-1) << 15) | (resolution << 18)); ++ rv_writel(val, adata->acp3x_base + mmACP_BTTDM_TXFRMT); ++ rv_writel(val, adata->acp3x_base + mmACP_BTTDM_RXFRMT); ++ ++ adata->tdm_fmt = val; ++ return 0; ++} ++ + static int acp3x_dai_i2s_hwparams(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +@@ -519,6 +578,8 @@ static int acp3x_dai_i2s_trigger(struct snd_pcm_substream *substream, + struct snd_soc_dai_ops acp3x_dai_i2s_ops = { + .hw_params = acp3x_dai_i2s_hwparams, + .trigger = acp3x_dai_i2s_trigger, ++ .set_fmt = acp3x_dai_i2s_set_fmt, ++ .set_tdm_slot = acp3x_dai_set_tdm_slot, + }; + + static struct snd_soc_dai_driver acp3x_i2s_dai_driver = { +diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h +index d35d252..70fed97 100644 +--- a/sound/soc/amd/raven/acp3x.h ++++ b/sound/soc/amd/raven/acp3x.h +@@ -9,6 +9,7 @@ + #define ACP_SRAM_PTE_OFFSET 0x02050000 + #define PAGE_SIZE_4K_ENABLE 0x2 + #define MEM_WINDOW_START 0x4000000 ++#define FRM_LEN 256 + + #define PLAYBACK_MIN_NUM_PERIODS 2 + #define PLAYBACK_MAX_NUM_PERIODS 2 +-- +2.7.4 + |