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

dmaengine: imx-sdma: add device tree probe support

It adds device tree probe support for imx-sdma driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Vinod Koul <vinod.koul@intel.com>

Shawn Guo 580975d7 40ad5b37

+56 -3
+17
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
··· 1 + * Freescale Smart Direct Memory Access (SDMA) Controller for i.MX 2 + 3 + Required properties: 4 + - compatible : Should be "fsl,<chip>-sdma" 5 + - reg : Should contain SDMA registers location and length 6 + - interrupts : Should contain SDMA interrupt 7 + - fsl,sdma-ram-script-name : Should contain the full path of SDMA RAM 8 + scripts firmware 9 + 10 + Examples: 11 + 12 + sdma@83fb0000 { 13 + compatible = "fsl,imx51-sdma", "fsl,imx35-sdma"; 14 + reg = <0x83fb0000 0x4000>; 15 + interrupts = <6>; 16 + fsl,sdma-ram-script-name = "sdma-imx51.bin"; 17 + };
+39 -3
drivers/dma/imx-sdma.c
··· 32 32 #include <linux/slab.h> 33 33 #include <linux/platform_device.h> 34 34 #include <linux/dmaengine.h> 35 + #include <linux/of.h> 36 + #include <linux/of_device.h> 35 37 36 38 #include <asm/irq.h> 37 39 #include <mach/sdma.h> ··· 333 331 } 334 332 }; 335 333 MODULE_DEVICE_TABLE(platform, sdma_devtypes); 334 + 335 + static const struct of_device_id sdma_dt_ids[] = { 336 + { .compatible = "fsl,imx31-sdma", .data = &sdma_devtypes[IMX31_SDMA], }, 337 + { .compatible = "fsl,imx35-sdma", .data = &sdma_devtypes[IMX35_SDMA], }, 338 + { /* sentinel */ } 339 + }; 340 + MODULE_DEVICE_TABLE(of, sdma_dt_ids); 336 341 337 342 #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ 338 343 #define SDMA_H_CONFIG_RTD_PINS (1 << 11) /* indicates if Real-Time Debug pins are enabled */ ··· 1259 1250 1260 1251 static int __init sdma_probe(struct platform_device *pdev) 1261 1252 { 1253 + const struct of_device_id *of_id = 1254 + of_match_device(sdma_dt_ids, &pdev->dev); 1255 + struct device_node *np = pdev->dev.of_node; 1256 + const char *fw_name; 1262 1257 int ret; 1263 1258 int irq; 1264 1259 struct resource *iores; ··· 1278 1265 1279 1266 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1280 1267 irq = platform_get_irq(pdev, 0); 1281 - if (!iores || irq < 0 || !pdata) { 1268 + if (!iores || irq < 0) { 1282 1269 ret = -EINVAL; 1283 1270 goto err_irq; 1284 1271 } ··· 1308 1295 if (!sdma->script_addrs) 1309 1296 goto err_alloc; 1310 1297 1298 + if (of_id) 1299 + pdev->id_entry = of_id->data; 1311 1300 sdma->devtype = pdev->id_entry->driver_data; 1312 1301 1313 1302 dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); ··· 1340 1325 if (ret) 1341 1326 goto err_init; 1342 1327 1343 - if (pdata->script_addrs) 1328 + if (pdata && pdata->script_addrs) 1344 1329 sdma_add_scripts(sdma, pdata->script_addrs); 1345 1330 1346 - sdma_get_firmware(sdma, pdata->fw_name); 1331 + if (pdata) { 1332 + sdma_get_firmware(sdma, pdata->fw_name); 1333 + } else { 1334 + /* 1335 + * Because that device tree does not encode ROM script address, 1336 + * the RAM script in firmware is mandatory for device tree 1337 + * probe, otherwise it fails. 1338 + */ 1339 + ret = of_property_read_string(np, "fsl,sdma-ram-script-name", 1340 + &fw_name); 1341 + if (ret) { 1342 + dev_err(&pdev->dev, "failed to get firmware name\n"); 1343 + goto err_init; 1344 + } 1345 + 1346 + ret = sdma_get_firmware(sdma, fw_name); 1347 + if (ret) { 1348 + dev_err(&pdev->dev, "failed to get firmware\n"); 1349 + goto err_init; 1350 + } 1351 + } 1347 1352 1348 1353 sdma->dma_device.dev = &pdev->dev; 1349 1354 ··· 1411 1376 static struct platform_driver sdma_driver = { 1412 1377 .driver = { 1413 1378 .name = "imx-sdma", 1379 + .of_match_table = sdma_dt_ids, 1414 1380 }, 1415 1381 .id_table = sdma_devtypes, 1416 1382 .remove = __exit_p(sdma_remove),