diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-05-30 10:23:32 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-07-05 02:10:40 -0400 |
commit | 9479e17c9bb455c01b369d294e01de8fa9b0a8d3 (patch) | |
tree | a451ce4afb0c68c4a206f35d23cd899131f60a5d /drivers/dma | |
parent | add93b578edda2a952b9b481ce8da2a9dc412cee (diff) |
dma: imx-sdma: move to generic device tree bindings
Update imx-sdma driver to adopt generic DMA device tree bindings. It
calls of_dma_controller_register() with imx-sdma specific of_dma_xlate
to get the generic DMA device tree helper support. The #dma-cells for
imx-sdma must be 3, which includes request ID, peripheral type and
priority.
The existing way of requesting channel, clients directly call
dma_request_channel(), still work there, and will be removed after
all imx-sdma clients get converted to generic DMA device tree helper.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/imx-sdma.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 092867bf795c..1e44b8cf95da 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/dmaengine.h> | 36 | #include <linux/dmaengine.h> |
37 | #include <linux/of.h> | 37 | #include <linux/of.h> |
38 | #include <linux/of_device.h> | 38 | #include <linux/of_device.h> |
39 | #include <linux/of_dma.h> | ||
39 | 40 | ||
40 | #include <asm/irq.h> | 41 | #include <asm/irq.h> |
41 | #include <linux/platform_data/dma-imx-sdma.h> | 42 | #include <linux/platform_data/dma-imx-sdma.h> |
@@ -1296,6 +1297,35 @@ err_dma_alloc: | |||
1296 | return ret; | 1297 | return ret; |
1297 | } | 1298 | } |
1298 | 1299 | ||
1300 | static bool sdma_filter_fn(struct dma_chan *chan, void *fn_param) | ||
1301 | { | ||
1302 | struct imx_dma_data *data = fn_param; | ||
1303 | |||
1304 | if (!imx_dma_is_general_purpose(chan)) | ||
1305 | return false; | ||
1306 | |||
1307 | chan->private = data; | ||
1308 | |||
1309 | return true; | ||
1310 | } | ||
1311 | |||
1312 | static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec, | ||
1313 | struct of_dma *ofdma) | ||
1314 | { | ||
1315 | struct sdma_engine *sdma = ofdma->of_dma_data; | ||
1316 | dma_cap_mask_t mask = sdma->dma_device.cap_mask; | ||
1317 | struct imx_dma_data data; | ||
1318 | |||
1319 | if (dma_spec->args_count != 3) | ||
1320 | return NULL; | ||
1321 | |||
1322 | data.dma_request = dma_spec->args[0]; | ||
1323 | data.peripheral_type = dma_spec->args[1]; | ||
1324 | data.priority = dma_spec->args[2]; | ||
1325 | |||
1326 | return dma_request_channel(mask, sdma_filter_fn, &data); | ||
1327 | } | ||
1328 | |||
1299 | static int __init sdma_probe(struct platform_device *pdev) | 1329 | static int __init sdma_probe(struct platform_device *pdev) |
1300 | { | 1330 | { |
1301 | const struct of_device_id *of_id = | 1331 | const struct of_device_id *of_id = |
@@ -1443,10 +1473,20 @@ static int __init sdma_probe(struct platform_device *pdev) | |||
1443 | goto err_init; | 1473 | goto err_init; |
1444 | } | 1474 | } |
1445 | 1475 | ||
1476 | if (np) { | ||
1477 | ret = of_dma_controller_register(np, sdma_xlate, sdma); | ||
1478 | if (ret) { | ||
1479 | dev_err(&pdev->dev, "failed to register controller\n"); | ||
1480 | goto err_register; | ||
1481 | } | ||
1482 | } | ||
1483 | |||
1446 | dev_info(sdma->dev, "initialized\n"); | 1484 | dev_info(sdma->dev, "initialized\n"); |
1447 | 1485 | ||
1448 | return 0; | 1486 | return 0; |
1449 | 1487 | ||
1488 | err_register: | ||
1489 | dma_async_device_unregister(&sdma->dma_device); | ||
1450 | err_init: | 1490 | err_init: |
1451 | kfree(sdma->script_addrs); | 1491 | kfree(sdma->script_addrs); |
1452 | err_alloc: | 1492 | err_alloc: |