From 708743594b6cb7dc9044f6ab0e8a1eb928bd9bb1 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Thu, 9 Apr 2020 23:02:37 +0300 Subject: [PATCH] drivers: imx: sdma: Remove src_may_change and dst_may_change We extract this information from config->direction. This makes code easier to understand. Notice here that we add BD_DONE for all cases, and remove BD_EXTD as it doesn't make sense for device2memory and memory2device. Will have m2m case later, it is not yet supported. Signed-off-by: Daniel Baluta --- src/drivers/imx/sdma.c | 53 +++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/src/drivers/imx/sdma.c b/src/drivers/imx/sdma.c index 0ca3eb68d..6e46880d3 100644 --- a/src/drivers/imx/sdma.c +++ b/src/drivers/imx/sdma.c @@ -705,8 +705,6 @@ static int sdma_prep_desc(struct dma_chan_data *channel, int width; int watermark; uint32_t sdma_script_addr; - bool src_may_change = 0, dst_may_change = 0; - struct sdma_chan *pdata = dma_chan_get_data(channel); struct sdma_bd *bd; @@ -730,47 +728,38 @@ static int sdma_prep_desc(struct dma_chan_data *channel, * For MEM2MEM the source is stored in buf_addr and destination * is in buf_xaddr. */ - bd->buf_xaddr = 0; - bd->buf_addr = config->elem_array.elems[i].src; - if (!src_may_change) - bd->buf_addr = - config->elem_array.elems[i].dest; - if (src_may_change && dst_may_change) { - /* M2M copy */ - bd->buf_xaddr = - config->elem_array.elems[i].dest; - } - - /* We are interested in the element width on the hardware side; - * on RAM side we can adjust. - */ - width = config->src_width; - if (!dst_may_change) + switch (config->direction) { + case DMA_DIR_MEM_TO_DEV: + bd->buf_addr = config->elem_array.elems[i].src; + width = config->src_width; + break; + case DMA_DIR_DEV_TO_MEM: + bd->buf_addr = config->elem_array.elems[i].dest; width = config->dest_width; + break; + case DMA_DIR_MEM_TO_MEM: + bd->buf_addr = config->elem_array.elems[i].src; + bd->buf_xaddr = config->elem_array.elems[i].dest; + width = config->dest_width; + break; + default: + return -EINVAL; + } bd->config = SDMA_BD_COUNT(config->elem_array.elems[i].size) | SDMA_BD_CMD(SDMA_CMD_XFER_SIZE(width)) | SDMA_BD_CONT; + if (!config->irq_disabled) bd->config |= SDMA_BD_INT; - if (dst_may_change) { - /* Capture or M2M, enable this descriptor to be - * used by SDMAC - */ - bd->config |= SDMA_BD_DONE; - /* On playback we don't do this and instead wait - * for copy() to let us know the data is ready. - * copy() is called during preload. - */ - } - if (src_may_change && dst_may_change) - bd->config |= SDMA_BD_EXTD; + + bd->config |= SDMA_BD_DONE | SDMA_BD_CONT; } + /* Configure last BD to account for cyclic transfers */ if (config->cyclic) bd->config |= SDMA_BD_WRAP; - else - bd->config &= ~SDMA_BD_CONT; + bd->config &= ~SDMA_BD_CONT; /* CCB must point to buffer descriptors array */ memset(pdata->ccb, 0, sizeof(*pdata->ccb));