aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/mv_xor.c
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2012-11-15 10:47:58 -0500
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2012-11-20 09:59:00 -0500
commitf7d12ef53ddfd8175933af42bfc477376d19e19e (patch)
treeb4fa58b8dfd5003e9fd182fc1e01b66654f18bf3 /drivers/dma/mv_xor.c
parent88eb92cb4d0a1520c2f9a653fba0f838871af3ab (diff)
dma: mv_xor: add Device Tree binding
This patch finally adds a Device Tree binding to the mv_xor driver. Thanks to the previous cleanup patches, the Device Tree binding is relatively simply: one DT node per XOR engine, with sub-nodes for each XOR channel of the XOR engine. The binding obviously comes with the necessary documentation. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: devicetree-discuss@lists.ozlabs.org
Diffstat (limited to 'drivers/dma/mv_xor.c')
-rw-r--r--drivers/dma/mv_xor.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index d48245c0b0b0..b1c4edd56ebc 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -26,6 +26,9 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/memory.h> 27#include <linux/memory.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/of.h>
30#include <linux/of_irq.h>
31#include <linux/irqdomain.h>
29#include <linux/platform_data/dma-mv_xor.h> 32#include <linux/platform_data/dma-mv_xor.h>
30 33
31#include "dmaengine.h" 34#include "dmaengine.h"
@@ -1278,7 +1281,42 @@ static int mv_xor_probe(struct platform_device *pdev)
1278 if (!IS_ERR(xordev->clk)) 1281 if (!IS_ERR(xordev->clk))
1279 clk_prepare_enable(xordev->clk); 1282 clk_prepare_enable(xordev->clk);
1280 1283
1281 if (pdata && pdata->channels) { 1284 if (pdev->dev.of_node) {
1285 struct device_node *np;
1286 int i = 0;
1287
1288 for_each_child_of_node(pdev->dev.of_node, np) {
1289 dma_cap_mask_t cap_mask;
1290 int irq;
1291
1292 dma_cap_zero(cap_mask);
1293 if (of_property_read_bool(np, "dmacap,memcpy"))
1294 dma_cap_set(DMA_MEMCPY, cap_mask);
1295 if (of_property_read_bool(np, "dmacap,xor"))
1296 dma_cap_set(DMA_XOR, cap_mask);
1297 if (of_property_read_bool(np, "dmacap,memset"))
1298 dma_cap_set(DMA_MEMSET, cap_mask);
1299 if (of_property_read_bool(np, "dmacap,interrupt"))
1300 dma_cap_set(DMA_INTERRUPT, cap_mask);
1301
1302 irq = irq_of_parse_and_map(np, 0);
1303 if (irq < 0) {
1304 ret = irq;
1305 goto err_channel_add;
1306 }
1307
1308 xordev->channels[i] =
1309 mv_xor_channel_add(xordev, pdev, i,
1310 cap_mask, irq);
1311 if (IS_ERR(xordev->channels[i])) {
1312 ret = PTR_ERR(xordev->channels[i]);
1313 irq_dispose_mapping(irq);
1314 goto err_channel_add;
1315 }
1316
1317 i++;
1318 }
1319 } else if (pdata && pdata->channels) {
1282 for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { 1320 for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) {
1283 struct mv_xor_channel_data *cd; 1321 struct mv_xor_channel_data *cd;
1284 int irq; 1322 int irq;
@@ -1309,8 +1347,11 @@ static int mv_xor_probe(struct platform_device *pdev)
1309 1347
1310err_channel_add: 1348err_channel_add:
1311 for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) 1349 for (i = 0; i < MV_XOR_MAX_CHANNELS; i++)
1312 if (xordev->channels[i]) 1350 if (xordev->channels[i]) {
1351 if (pdev->dev.of_node)
1352 irq_dispose_mapping(xordev->channels[i]->irq);
1313 mv_xor_channel_remove(xordev->channels[i]); 1353 mv_xor_channel_remove(xordev->channels[i]);
1354 }
1314 1355
1315 clk_disable_unprepare(xordev->clk); 1356 clk_disable_unprepare(xordev->clk);
1316 clk_put(xordev->clk); 1357 clk_put(xordev->clk);
@@ -1335,12 +1376,21 @@ static int mv_xor_remove(struct platform_device *pdev)
1335 return 0; 1376 return 0;
1336} 1377}
1337 1378
1379#ifdef CONFIG_OF
1380static struct of_device_id mv_xor_dt_ids[] __devinitdata = {
1381 { .compatible = "marvell,orion-xor", },
1382 {},
1383};
1384MODULE_DEVICE_TABLE(of, mv_xor_dt_ids);
1385#endif
1386
1338static struct platform_driver mv_xor_driver = { 1387static struct platform_driver mv_xor_driver = {
1339 .probe = mv_xor_probe, 1388 .probe = mv_xor_probe,
1340 .remove = mv_xor_remove, 1389 .remove = mv_xor_remove,
1341 .driver = { 1390 .driver = {
1342 .owner = THIS_MODULE, 1391 .owner = THIS_MODULE,
1343 .name = MV_XOR_NAME, 1392 .name = MV_XOR_NAME,
1393 .of_match_table = of_match_ptr(mv_xor_dt_ids),
1344 }, 1394 },
1345}; 1395};
1346 1396