MLK-16104-2 dma: imx-sdma: add index for multi sdma devices case
authorRobin Gong <yibin.gong@nxp.com>
Mon, 31 Jul 2017 08:44:32 +0000 (16:44 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:36:13 +0000 (15:36 -0500)
On i.mx8mscale, there are two sdma instances here, and common dma
frameowrk will get channel dynamicly from any available channel whatever
it's from the first sdma device or the second sdma device. But actually,
some IP like SAI only work in sdma2 not sdma1. To make sure get sdma
channel from the right sdma device, add index to match.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
drivers/dma/imx-sdma.c
include/linux/platform_data/dma-imx.h

index 4cbd002..9968d02 100644 (file)
@@ -425,6 +425,7 @@ struct sdma_engine {
        bool                            bd0_iram;
        struct sdma_buffer_descriptor   *bd0;
        bool                            suspend_off;
+       int                             idx;
 };
 
 static struct sdma_driver_data sdma_imx31 = {
@@ -613,6 +614,8 @@ static const struct of_device_id sdma_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, sdma_dt_ids);
 
+static int sdma_dev_idx;
+
 #define SDMA_H_CONFIG_DSPDMA   BIT(12) /* indicates if the DSPDMA is used */
 #define SDMA_H_CONFIG_RTD_PINS BIT(11) /* indicates if Real-Time Debug pins are enabled */
 #define SDMA_H_CONFIG_ACR      BIT(4)  /* indicates if AHB freq /core freq = 2 or 1 */
@@ -2124,6 +2127,10 @@ static bool sdma_filter_fn(struct dma_chan *chan, void *fn_param)
 
        if (!imx_dma_is_general_purpose(chan))
                return false;
+       /* return false if it's not the right device */
+       if ((sdmac->sdma->drvdata == &sdma_imx8m)
+               && (sdmac->sdma->idx != data->idx))
+               return false;
 
        sdmac->data = *data;
        chan->private = &sdmac->data;
@@ -2146,6 +2153,7 @@ static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec,
        data.dma_request = dma_spec->args[0];
        data.peripheral_type = dma_spec->args[1];
        data.priority = dma_spec->args[2];
+       data.idx = sdma->idx;
 
        return dma_request_channel(mask, sdma_filter_fn, &data);
 }
@@ -2337,6 +2345,8 @@ static int sdma_probe(struct platform_device *pdev)
                }
                of_node_put(spba_bus);
        }
+       /* There maybe multi sdma devices such as i.mx8mscale */
+       sdma->idx = sdma_dev_idx++;
 
        return 0;
 
index bee13cf..18ed10c 100644 (file)
@@ -58,6 +58,7 @@ struct imx_dma_data {
        int priority;
        bool src_dualfifo;
        bool dst_dualfifo;
+       int idx;
 };
 
 static inline int imx_dma_is_ipu(struct dma_chan *chan)