From: Robin Gong Date: Mon, 31 Jul 2017 08:44:32 +0000 (+0800) Subject: MLK-16104-2 dma: imx-sdma: add index for multi sdma devices case X-Git-Tag: C0P2-H0.0--20200415~1955 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=7ab52e64a6b8045d50fb45c3c168cfd40ace7105;p=linux.git MLK-16104-2 dma: imx-sdma: add index for multi sdma devices case 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 --- diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 4cbd0024e584..9968d02cf399 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -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; diff --git a/include/linux/platform_data/dma-imx.h b/include/linux/platform_data/dma-imx.h index bee13cf86387..18ed10c57e19 100644 --- a/include/linux/platform_data/dma-imx.h +++ b/include/linux/platform_data/dma-imx.h @@ -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)