dmaengine: imx-sdma: add fifo offset/words_per_fifo for sais script
authorRobin Gong <yibin.gong@nxp.com>
Tue, 23 Mar 2021 16:48:27 +0000 (00:48 +0800)
committerShengjiu Wang <shengjiu.wang@nxp.com>
Wed, 21 Apr 2021 08:00:09 +0000 (16:00 +0800)
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 <yibin.gong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit b59cc564e30dc789a78ea3abf8ae1920369b5e56)

drivers/dma/imx-sdma.c

index 92d2373..b112a61 100644 (file)
                                 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)