diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2011-07-13 20:35:48 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2011-07-26 21:31:56 -0400 |
commit | 580975d7f48d7d047e22bb0f42adf7557801d8d4 (patch) | |
tree | 811134cad5d6d051d853e48f2d84e6f25fab49d0 | |
parent | 40ad5b37914368a4f2c5ff1e72712375d6f1188b (diff) |
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>
-rw-r--r-- | Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt | 17 | ||||
-rw-r--r-- | drivers/dma/imx-sdma.c | 42 |
2 files changed, 56 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt new file mode 100644 index 00000000000..d1e3f443e20 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt | |||
@@ -0,0 +1,17 @@ | |||
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 | }; | ||
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index df400691f9a..1eb60ded2f0 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/dmaengine.h> | 34 | #include <linux/dmaengine.h> |
35 | #include <linux/of.h> | ||
36 | #include <linux/of_device.h> | ||
35 | 37 | ||
36 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
37 | #include <mach/sdma.h> | 39 | #include <mach/sdma.h> |
@@ -332,6 +334,13 @@ static struct platform_device_id sdma_devtypes[] = { | |||
332 | }; | 334 | }; |
333 | MODULE_DEVICE_TABLE(platform, sdma_devtypes); | 335 | MODULE_DEVICE_TABLE(platform, sdma_devtypes); |
334 | 336 | ||
337 | static const struct of_device_id sdma_dt_ids[] = { | ||
338 | { .compatible = "fsl,imx31-sdma", .data = &sdma_devtypes[IMX31_SDMA], }, | ||
339 | { .compatible = "fsl,imx35-sdma", .data = &sdma_devtypes[IMX35_SDMA], }, | ||
340 | { /* sentinel */ } | ||
341 | }; | ||
342 | MODULE_DEVICE_TABLE(of, sdma_dt_ids); | ||
343 | |||
335 | #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ | 344 | #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ |
336 | #define SDMA_H_CONFIG_RTD_PINS (1 << 11) /* indicates if Real-Time Debug pins are enabled */ | 345 | #define SDMA_H_CONFIG_RTD_PINS (1 << 11) /* indicates if Real-Time Debug pins are enabled */ |
337 | #define SDMA_H_CONFIG_ACR (1 << 4) /* indicates if AHB freq /core freq = 2 or 1 */ | 346 | #define SDMA_H_CONFIG_ACR (1 << 4) /* indicates if AHB freq /core freq = 2 or 1 */ |
@@ -1250,6 +1259,10 @@ err_dma_alloc: | |||
1250 | 1259 | ||
1251 | static int __init sdma_probe(struct platform_device *pdev) | 1260 | static int __init sdma_probe(struct platform_device *pdev) |
1252 | { | 1261 | { |
1262 | const struct of_device_id *of_id = | ||
1263 | of_match_device(sdma_dt_ids, &pdev->dev); | ||
1264 | struct device_node *np = pdev->dev.of_node; | ||
1265 | const char *fw_name; | ||
1253 | int ret; | 1266 | int ret; |
1254 | int irq; | 1267 | int irq; |
1255 | struct resource *iores; | 1268 | struct resource *iores; |
@@ -1265,7 +1278,7 @@ static int __init sdma_probe(struct platform_device *pdev) | |||
1265 | 1278 | ||
1266 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1279 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1267 | irq = platform_get_irq(pdev, 0); | 1280 | irq = platform_get_irq(pdev, 0); |
1268 | if (!iores || irq < 0 || !pdata) { | 1281 | if (!iores || irq < 0) { |
1269 | ret = -EINVAL; | 1282 | ret = -EINVAL; |
1270 | goto err_irq; | 1283 | goto err_irq; |
1271 | } | 1284 | } |
@@ -1295,6 +1308,8 @@ static int __init sdma_probe(struct platform_device *pdev) | |||
1295 | if (!sdma->script_addrs) | 1308 | if (!sdma->script_addrs) |
1296 | goto err_alloc; | 1309 | goto err_alloc; |
1297 | 1310 | ||
1311 | if (of_id) | ||
1312 | pdev->id_entry = of_id->data; | ||
1298 | sdma->devtype = pdev->id_entry->driver_data; | 1313 | sdma->devtype = pdev->id_entry->driver_data; |
1299 | 1314 | ||
1300 | dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); | 1315 | dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); |
@@ -1325,10 +1340,30 @@ static int __init sdma_probe(struct platform_device *pdev) | |||
1325 | if (ret) | 1340 | if (ret) |
1326 | goto err_init; | 1341 | goto err_init; |
1327 | 1342 | ||
1328 | if (pdata->script_addrs) | 1343 | if (pdata && pdata->script_addrs) |
1329 | sdma_add_scripts(sdma, pdata->script_addrs); | 1344 | sdma_add_scripts(sdma, pdata->script_addrs); |
1330 | 1345 | ||
1331 | sdma_get_firmware(sdma, pdata->fw_name); | 1346 | if (pdata) { |
1347 | sdma_get_firmware(sdma, pdata->fw_name); | ||
1348 | } else { | ||
1349 | /* | ||
1350 | * Because that device tree does not encode ROM script address, | ||
1351 | * the RAM script in firmware is mandatory for device tree | ||
1352 | * probe, otherwise it fails. | ||
1353 | */ | ||
1354 | ret = of_property_read_string(np, "fsl,sdma-ram-script-name", | ||
1355 | &fw_name); | ||
1356 | if (ret) { | ||
1357 | dev_err(&pdev->dev, "failed to get firmware name\n"); | ||
1358 | goto err_init; | ||
1359 | } | ||
1360 | |||
1361 | ret = sdma_get_firmware(sdma, fw_name); | ||
1362 | if (ret) { | ||
1363 | dev_err(&pdev->dev, "failed to get firmware\n"); | ||
1364 | goto err_init; | ||
1365 | } | ||
1366 | } | ||
1332 | 1367 | ||
1333 | sdma->dma_device.dev = &pdev->dev; | 1368 | sdma->dma_device.dev = &pdev->dev; |
1334 | 1369 | ||
@@ -1376,6 +1411,7 @@ static int __exit sdma_remove(struct platform_device *pdev) | |||
1376 | static struct platform_driver sdma_driver = { | 1411 | static struct platform_driver sdma_driver = { |
1377 | .driver = { | 1412 | .driver = { |
1378 | .name = "imx-sdma", | 1413 | .name = "imx-sdma", |
1414 | .of_match_table = sdma_dt_ids, | ||
1379 | }, | 1415 | }, |
1380 | .id_table = sdma_devtypes, | 1416 | .id_table = sdma_devtypes, |
1381 | .remove = __exit_p(sdma_remove), | 1417 | .remove = __exit_p(sdma_remove), |