From 2a7e500e7fa0f21c80e42e09ae6651732f3d4ff8 Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Wed, 24 Mar 2021 00:48:27 +0800 Subject: [PATCH] dmaengine: imx-sdma: add fifo offset/words_per_fifo for sais script Add fifo offset and words_per_fifo for mcu_2_sai/sai_2_mcu scripts. fifo offset: 0: no offset between fifos, means all fifos are continuous. 1: means 1 word offset between fifos. 2: means 2 word offset between fifos. ... n: means n word offset between fifos, n max is 15. words_per_fifo means how many times of fill/fetch fifo before jump to next fifo, such as 2 audio channels need to be filled per lane. 0: only one time(audio channel) of fill/fetch per fifo before jump. 1: two times(audio channels) of fill/fetch per fifo before jump. ... n: means n + 1 times(audio channels) of fill/fetch per fifo before jump. n max is 15. Signed-off-by: Robin Gong Reviewed-by: Shengjiu Wang (cherry picked from commit b59cc564e30dc789a78ea3abf8ae1920369b5e56) --- drivers/dma/imx-sdma.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 92d23730032c..b112a6176033 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -191,8 +191,10 @@ BIT(DMA_DEV_TO_DEV)) #define SDMA_WATERMARK_LEVEL_FIFOS_OFF 12 +#define SDMA_WATERMARK_LEVEL_FIFO_OFF_OFF 16 #define SDMA_WATERMARK_LEVEL_SW_DONE BIT(23) #define SDMA_WATERMARK_LEVEL_SW_DONE_SEL_OFF 24 +#define SDMA_WATERMARK_LEVEL_WORDS_PER_FIFO_OFF 28 /* * Mode/Count of data node descriptors - IPCv2 @@ -1313,10 +1315,15 @@ static void sdma_set_watermarklevel_for_sais(struct sdma_channel *sdmac) { u8 fifo_num = sdmac->audio_config->src_fifo_num | sdmac->audio_config->dst_fifo_num; + u8 fifo_offset = sdmac->audio_config->src_fifo_off | + sdmac->audio_config->dst_fifo_off; + u8 words_per_fifo = sdmac->audio_config->words_per_fifo; sdmac->watermark_level &= ~(0xFF << SDMA_WATERMARK_LEVEL_FIFOS_OFF | SDMA_WATERMARK_LEVEL_SW_DONE | - 0xf << SDMA_WATERMARK_LEVEL_SW_DONE_SEL_OFF); + 0xf << SDMA_WATERMARK_LEVEL_SW_DONE_SEL_OFF | + 0xf << SDMA_WATERMARK_LEVEL_FIFO_OFF_OFF | + 0xf << SDMA_WATERMARK_LEVEL_WORDS_PER_FIFO_OFF); if (sdmac->audio_config->sw_done_sel & BIT(31)) sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_SW_DONE | @@ -1332,6 +1339,14 @@ static void sdma_set_watermarklevel_for_sais(struct sdma_channel *sdmac) if (fifo_num) sdmac->watermark_level |= fifo_num << SDMA_WATERMARK_LEVEL_FIFOS_OFF; + + if (fifo_offset) + sdmac->watermark_level |= fifo_offset << + SDMA_WATERMARK_LEVEL_FIFO_OFF_OFF; + + if (words_per_fifo) + sdmac->watermark_level |= (words_per_fifo - 1) << + SDMA_WATERMARK_LEVEL_WORDS_PER_FIFO_OFF; } static int sdma_config_channel(struct dma_chan *chan) -- 2.17.1