Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Shawn Guo and committed by
Vinod Koul
9479e17c add93b57

+96
+56
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
··· 4 4 - compatible : Should be "fsl,<chip>-sdma" 5 5 - reg : Should contain SDMA registers location and length 6 6 - interrupts : Should contain SDMA interrupt 7 + - #dma-cells : Must be <3>. 8 + The first cell specifies the DMA request/event ID. See details below 9 + about the second and third cell. 7 10 - fsl,sdma-ram-script-name : Should contain the full path of SDMA RAM 8 11 scripts firmware 12 + 13 + The second cell of dma phandle specifies the peripheral type of DMA transfer. 14 + The full ID of peripheral types can be found below. 15 + 16 + ID transfer type 17 + --------------------- 18 + 0 MCU domain SSI 19 + 1 Shared SSI 20 + 2 MMC 21 + 3 SDHC 22 + 4 MCU domain UART 23 + 5 Shared UART 24 + 6 FIRI 25 + 7 MCU domain CSPI 26 + 8 Shared CSPI 27 + 9 SIM 28 + 10 ATA 29 + 11 CCM 30 + 12 External peripheral 31 + 13 Memory Stick Host Controller 32 + 14 Shared Memory Stick Host Controller 33 + 15 DSP 34 + 16 Memory 35 + 17 FIFO type Memory 36 + 18 SPDIF 37 + 19 IPU Memory 38 + 20 ASRC 39 + 21 ESAI 40 + 41 + The third cell specifies the transfer priority as below. 42 + 43 + ID transfer priority 44 + ------------------------- 45 + 0 High 46 + 1 Medium 47 + 2 Low 9 48 10 49 Examples: 11 50 ··· 52 13 compatible = "fsl,imx51-sdma", "fsl,imx35-sdma"; 53 14 reg = <0x83fb0000 0x4000>; 54 15 interrupts = <6>; 16 + #dma-cells = <3>; 55 17 fsl,sdma-ram-script-name = "sdma-imx51.bin"; 18 + }; 19 + 20 + DMA clients connected to the i.MX SDMA controller must use the format 21 + described in the dma.txt file. 22 + 23 + Examples: 24 + 25 + ssi2: ssi@70014000 { 26 + compatible = "fsl,imx51-ssi", "fsl,imx21-ssi"; 27 + reg = <0x70014000 0x4000>; 28 + interrupts = <30>; 29 + clocks = <&clks 49>; 30 + dmas = <&sdma 24 1 0>, 31 + <&sdma 25 1 0>; 32 + dma-names = "rx", "tx"; 33 + fsl,fifo-depth = <15>; 56 34 };
+40
drivers/dma/imx-sdma.c
··· 36 36 #include <linux/dmaengine.h> 37 37 #include <linux/of.h> 38 38 #include <linux/of_device.h> 39 + #include <linux/of_dma.h> 39 40 40 41 #include <asm/irq.h> 41 42 #include <linux/platform_data/dma-imx-sdma.h> ··· 1297 1296 return ret; 1298 1297 } 1299 1298 1299 + static bool sdma_filter_fn(struct dma_chan *chan, void *fn_param) 1300 + { 1301 + struct imx_dma_data *data = fn_param; 1302 + 1303 + if (!imx_dma_is_general_purpose(chan)) 1304 + return false; 1305 + 1306 + chan->private = data; 1307 + 1308 + return true; 1309 + } 1310 + 1311 + static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec, 1312 + struct of_dma *ofdma) 1313 + { 1314 + struct sdma_engine *sdma = ofdma->of_dma_data; 1315 + dma_cap_mask_t mask = sdma->dma_device.cap_mask; 1316 + struct imx_dma_data data; 1317 + 1318 + if (dma_spec->args_count != 3) 1319 + return NULL; 1320 + 1321 + data.dma_request = dma_spec->args[0]; 1322 + data.peripheral_type = dma_spec->args[1]; 1323 + data.priority = dma_spec->args[2]; 1324 + 1325 + return dma_request_channel(mask, sdma_filter_fn, &data); 1326 + } 1327 + 1300 1328 static int __init sdma_probe(struct platform_device *pdev) 1301 1329 { 1302 1330 const struct of_device_id *of_id = ··· 1473 1443 goto err_init; 1474 1444 } 1475 1445 1446 + if (np) { 1447 + ret = of_dma_controller_register(np, sdma_xlate, sdma); 1448 + if (ret) { 1449 + dev_err(&pdev->dev, "failed to register controller\n"); 1450 + goto err_register; 1451 + } 1452 + } 1453 + 1476 1454 dev_info(sdma->dev, "initialized\n"); 1477 1455 1478 1456 return 0; 1479 1457 1458 + err_register: 1459 + dma_async_device_unregister(&sdma->dma_device); 1480 1460 err_init: 1481 1461 kfree(sdma->script_addrs); 1482 1462 err_alloc: