aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Moysan <olivier.moysan@st.com>2017-10-19 09:03:19 -0400
committerMark Brown <broonie@kernel.org>2017-10-21 06:16:32 -0400
commita4529d2b885747bb9393d507cd28649052d733f3 (patch)
tree6da1721497087bc09e5eafc1281bd0f116f3bcb9
parentd807cdfb48c4d925b269f5b0f818864766e17389 (diff)
ASoC: stm32: sai: Fix DMA burst size
Set best burst size tradeoff for 8, 16, 32 bits transfers. Signed-off-by: olivier moysan <olivier.moysan@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/stm/stm32_sai_sub.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 5e66bf310351..dde8ddf9e777 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -446,12 +446,16 @@ static int stm32_sai_set_config(struct snd_soc_dai *cpu_dai,
446{ 446{
447 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); 447 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
448 int cr1, cr1_mask, ret; 448 int cr1, cr1_mask, ret;
449 int fth = STM_SAI_FIFO_TH_HALF;
450 449
451 /* FIFO config */ 450 /*
451 * DMA bursts increment is set to 4 words.
452 * SAI fifo threshold is set to half fifo, to keep enough space
453 * for DMA incoming bursts.
454 */
452 regmap_update_bits(sai->regmap, STM_SAI_CR2_REGX, 455 regmap_update_bits(sai->regmap, STM_SAI_CR2_REGX,
453 SAI_XCR2_FFLUSH | SAI_XCR2_FTH_MASK, 456 SAI_XCR2_FFLUSH | SAI_XCR2_FTH_MASK,
454 SAI_XCR2_FFLUSH | SAI_XCR2_FTH_SET(fth)); 457 SAI_XCR2_FFLUSH |
458 SAI_XCR2_FTH_SET(STM_SAI_FIFO_TH_HALF));
455 459
456 /* Mode, data format and channel config */ 460 /* Mode, data format and channel config */
457 cr1 = SAI_XCR1_PRTCFG_SET(SAI_FREE_PROTOCOL); 461 cr1 = SAI_XCR1_PRTCFG_SET(SAI_FREE_PROTOCOL);
@@ -485,10 +489,6 @@ static int stm32_sai_set_config(struct snd_soc_dai *cpu_dai,
485 return ret; 489 return ret;
486 } 490 }
487 491
488 /* DMA config */
489 sai->dma_params.maxburst = STM_SAI_FIFO_SIZE * fth / sizeof(u32);
490 snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)&sai->dma_params);
491
492 return 0; 492 return 0;
493} 493}
494 494
@@ -731,7 +731,12 @@ static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai)
731 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); 731 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
732 732
733 sai->dma_params.addr = (dma_addr_t)(sai->phys_addr + STM_SAI_DR_REGX); 733 sai->dma_params.addr = (dma_addr_t)(sai->phys_addr + STM_SAI_DR_REGX);
734 sai->dma_params.maxburst = 1; 734 /*
735 * DMA supports 4, 8 or 16 burst sizes. Burst size 4 is the best choice,
736 * as it allows bytes, half-word and words transfers. (See DMA fifos
737 * constraints).
738 */
739 sai->dma_params.maxburst = 4;
735 /* Buswidth will be set by framework at runtime */ 740 /* Buswidth will be set by framework at runtime */
736 sai->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED; 741 sai->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED;
737 742