aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijendar Mukunda <Vijendar.Mukunda@amd.com>2017-10-18 12:13:58 -0400
committerMark Brown <broonie@kernel.org>2017-10-19 14:46:02 -0400
commitaac89748ee2746656848d30dd1855ab9804acd72 (patch)
treebbe9ed930a5f6ec3981fd33655d028103c4216f0
parent607b39ef7f5be3036e4f66a932bedb334832722f (diff)
ASoC: AMD: DMA driver changes for Stoney Platform
Added DMA driver changes for Stoney platform. Below are the key differences between Stoney and CZ In Stoney, Memory Gating is disabled.SRAM Banks won't be turned off.No Of SRAM Banks reduced to 6. DAGB Garlic Interface used and 16 bit resolution is supported. SRAM bank 1 & SRAM bank 2 will be used for playback scenario. SRAM Bank 3 & SRAM Bank 4 will be used for Capture scenario. Acked-by: Mark Brown <broonie@kernel.org> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/amd/acp-pcm-dma.c87
-rw-r--r--sound/soc/amd/acp.h2
2 files changed, 67 insertions, 22 deletions
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index f00b6b92e076..f16e0b8e2ed7 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -137,8 +137,8 @@ static void config_dma_descriptor_in_sram(void __iomem *acp_mmio,
137 * system memory <-> ACP SRAM 137 * system memory <-> ACP SRAM
138 */ 138 */
139static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, 139static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
140 u32 size, int direction, 140 u32 size, int direction,
141 u32 pte_offset) 141 u32 pte_offset, u32 asic_type)
142{ 142{
143 u16 i; 143 u16 i;
144 u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; 144 u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12;
@@ -152,20 +152,42 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
152 (size / 2) - (i * (size/2)); 152 (size / 2) - (i * (size/2));
153 dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS 153 dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS
154 + (pte_offset * SZ_4K) + (i * (size/2)); 154 + (pte_offset * SZ_4K) + (i * (size/2));
155 dmadscr[i].xfer_val |= 155 switch (asic_type) {
156 (ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM << 16) | 156 case CHIP_STONEY:
157 (size / 2); 157 dmadscr[i].xfer_val |=
158 (ACP_DMA_ATTRIBUTES_DAGB_GARLIC_TO_SHAREDMEM << 16) |
159 (size / 2);
160 break;
161 default:
162 dmadscr[i].xfer_val |=
163 (ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM << 16) |
164 (size / 2);
165 }
158 } else { 166 } else {
159 dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i; 167 dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i;
160 dmadscr[i].src = ACP_SHARED_RAM_BANK_5_ADDRESS + 168 switch (asic_type) {
161 (i * (size/2)); 169 case CHIP_STONEY:
162 dmadscr[i].dest = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS 170 dmadscr[i].src = ACP_SHARED_RAM_BANK_3_ADDRESS +
163 + (pte_offset * SZ_4K) + 171 (i * (size/2));
164 (i * (size/2)); 172 dmadscr[i].dest =
165 dmadscr[i].xfer_val |= 173 ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS +
166 BIT(22) | 174 (pte_offset * SZ_4K) + (i * (size/2));
167 (ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION << 16) | 175 dmadscr[i].xfer_val |=
168 (size / 2); 176 BIT(22) |
177 (ACP_DMA_ATTRIBUTES_SHARED_MEM_TO_DAGB_GARLIC << 16) |
178 (size / 2);
179 break;
180 default:
181 dmadscr[i].src = ACP_SHARED_RAM_BANK_5_ADDRESS +
182 (i * (size/2));
183 dmadscr[i].dest =
184 ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS +
185 (pte_offset * SZ_4K) + (i * (size/2));
186 dmadscr[i].xfer_val |=
187 BIT(22) |
188 (ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION << 16) |
189 (size / 2);
190 }
169 } 191 }
170 config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx, 192 config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx,
171 &dmadscr[i]); 193 &dmadscr[i]);
@@ -186,7 +208,8 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
186 * ACP SRAM <-> I2S 208 * ACP SRAM <-> I2S
187 */ 209 */
188static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, 210static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio,
189 u32 size, int direction) 211 u32 size, int direction,
212 u32 asic_type)
190{ 213{
191 214
192 u16 i; 215 u16 i;
@@ -207,8 +230,17 @@ static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio,
207 dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i; 230 dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i;
208 /* dmadscr[i].src is unused by hardware. */ 231 /* dmadscr[i].src is unused by hardware. */
209 dmadscr[i].src = 0; 232 dmadscr[i].src = 0;
210 dmadscr[i].dest = ACP_SHARED_RAM_BANK_5_ADDRESS + 233 switch (asic_type) {
234 case CHIP_STONEY:
235 dmadscr[i].dest =
236 ACP_SHARED_RAM_BANK_3_ADDRESS +
211 (i * (size / 2)); 237 (i * (size / 2));
238 break;
239 default:
240 dmadscr[i].dest =
241 ACP_SHARED_RAM_BANK_5_ADDRESS +
242 (i * (size / 2));
243 }
212 dmadscr[i].xfer_val |= BIT(22) | 244 dmadscr[i].xfer_val |= BIT(22) |
213 (FROM_ACP_I2S_1 << 16) | (size / 2); 245 (FROM_ACP_I2S_1 << 16) | (size / 2);
214 } 246 }
@@ -264,7 +296,8 @@ static void acp_pte_config(void __iomem *acp_mmio, struct page *pg,
264} 296}
265 297
266static void config_acp_dma(void __iomem *acp_mmio, 298static void config_acp_dma(void __iomem *acp_mmio,
267 struct audio_substream_data *audio_config) 299 struct audio_substream_data *audio_config,
300 u32 asic_type)
268{ 301{
269 u32 pte_offset; 302 u32 pte_offset;
270 303
@@ -278,11 +311,11 @@ static void config_acp_dma(void __iomem *acp_mmio,
278 311
279 /* Configure System memory <-> ACP SRAM DMA descriptors */ 312 /* Configure System memory <-> ACP SRAM DMA descriptors */
280 set_acp_sysmem_dma_descriptors(acp_mmio, audio_config->size, 313 set_acp_sysmem_dma_descriptors(acp_mmio, audio_config->size,
281 audio_config->direction, pte_offset); 314 audio_config->direction, pte_offset, asic_type);
282 315
283 /* Configure ACP SRAM <-> I2S DMA descriptors */ 316 /* Configure ACP SRAM <-> I2S DMA descriptors */
284 set_acp_to_i2s_dma_descriptors(acp_mmio, audio_config->size, 317 set_acp_to_i2s_dma_descriptors(acp_mmio, audio_config->size,
285 audio_config->direction); 318 audio_config->direction, asic_type);
286} 319}
287 320
288/* Start a given DMA channel transfer */ 321/* Start a given DMA channel transfer */
@@ -502,6 +535,12 @@ static int acp_init(void __iomem *acp_mmio, u32 asic_type)
502 acp_set_sram_bank_state(acp_mmio, bank, false); 535 acp_set_sram_bank_state(acp_mmio, bank, false);
503 } 536 }
504 537
538 /* Stoney supports 16bit resolution */
539 if (asic_type == CHIP_STONEY) {
540 val = acp_reg_read(acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
541 val |= 0x03;
542 acp_reg_write(val, acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
543 }
505 return 0; 544 return 0;
506} 545}
507 546
@@ -680,6 +719,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
680 struct page *pg; 719 struct page *pg;
681 struct snd_pcm_runtime *runtime; 720 struct snd_pcm_runtime *runtime;
682 struct audio_substream_data *rtd; 721 struct audio_substream_data *rtd;
722 struct snd_soc_pcm_runtime *prtd = substream->private_data;
723 struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev);
683 724
684 runtime = substream->runtime; 725 runtime = substream->runtime;
685 rtd = runtime->private_data; 726 rtd = runtime->private_data;
@@ -707,7 +748,7 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
707 rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; 748 rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
708 rtd->direction = substream->stream; 749 rtd->direction = substream->stream;
709 750
710 config_acp_dma(rtd->acp_mmio, rtd); 751 config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type);
711 status = 0; 752 status = 0;
712 } else { 753 } else {
713 status = -ENOMEM; 754 status = -ENOMEM;
@@ -1011,7 +1052,8 @@ static int acp_pcm_resume(struct device *dev)
1011 true); 1052 true);
1012 } 1053 }
1013 config_acp_dma(adata->acp_mmio, 1054 config_acp_dma(adata->acp_mmio,
1014 adata->play_stream->runtime->private_data); 1055 adata->play_stream->runtime->private_data,
1056 adata->asic_type);
1015 } 1057 }
1016 if (adata->capture_stream && adata->capture_stream->runtime) { 1058 if (adata->capture_stream && adata->capture_stream->runtime) {
1017 if (adata->asic_type != CHIP_STONEY) { 1059 if (adata->asic_type != CHIP_STONEY) {
@@ -1020,7 +1062,8 @@ static int acp_pcm_resume(struct device *dev)
1020 true); 1062 true);
1021 } 1063 }
1022 config_acp_dma(adata->acp_mmio, 1064 config_acp_dma(adata->acp_mmio,
1023 adata->capture_stream->runtime->private_data); 1065 adata->capture_stream->runtime->private_data,
1066 adata->asic_type);
1024 } 1067 }
1025 acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); 1068 acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
1026 return 0; 1069 return 0;
diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h
index 28cf9140f49c..a330a99bfff8 100644
--- a/sound/soc/amd/acp.h
+++ b/sound/soc/amd/acp.h
@@ -19,6 +19,7 @@
19 19
20/* Capture SRAM address (as a source in dma descriptor) */ 20/* Capture SRAM address (as a source in dma descriptor) */
21#define ACP_SHARED_RAM_BANK_5_ADDRESS 0x400A000 21#define ACP_SHARED_RAM_BANK_5_ADDRESS 0x400A000
22#define ACP_SHARED_RAM_BANK_3_ADDRESS 0x4006000
22 23
23#define ACP_DMA_RESET_TIME 10000 24#define ACP_DMA_RESET_TIME 10000
24#define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF 25#define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF
@@ -67,6 +68,7 @@
67#define CAPTURE_START_DMA_DESCR_CH15 6 68#define CAPTURE_START_DMA_DESCR_CH15 6
68#define CAPTURE_END_DMA_DESCR_CH15 7 69#define CAPTURE_END_DMA_DESCR_CH15 7
69 70
71#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
70enum acp_dma_priority_level { 72enum acp_dma_priority_level {
71 /* 0x0 Specifies the DMA channel is given normal priority */ 73 /* 0x0 Specifies the DMA channel is given normal priority */
72 ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0, 74 ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,