diff options
author | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2012-10-29 11:54:49 -0400 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2012-11-20 09:58:56 -0500 |
commit | 60d151f38799d5e15845ee04b73cbf3839f1b06c (patch) | |
tree | e360fb470a5ba59e6a5363d964b355d3fdae5456 | |
parent | a6b4a9d2c1063ffc52ca94b6c1b24f9b6d5b79c5 (diff) |
dma: mv_xor: allow channels to be registered directly from the main device
Extend the XOR engine driver (currently called "mv_xor_shared") so
that XOR channels can be passed in the platform_data structure, and be
registered from there.
This will allow the users of the driver to be converted to the single
platform_driver variant of the mv_xor driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-rw-r--r-- | drivers/dma/mv_xor.c | 45 | ||||
-rw-r--r-- | drivers/dma/mv_xor.h | 8 | ||||
-rw-r--r-- | include/linux/platform_data/dma-mv_xor.h | 3 |
3 files changed, 53 insertions, 3 deletions
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index f7b99193e884..6ed3162cccc9 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c | |||
@@ -1292,7 +1292,9 @@ static int mv_xor_shared_probe(struct platform_device *pdev) | |||
1292 | { | 1292 | { |
1293 | const struct mbus_dram_target_info *dram; | 1293 | const struct mbus_dram_target_info *dram; |
1294 | struct mv_xor_shared_private *msp; | 1294 | struct mv_xor_shared_private *msp; |
1295 | struct mv_xor_shared_platform_data *pdata = pdev->dev.platform_data; | ||
1295 | struct resource *res; | 1296 | struct resource *res; |
1297 | int i, ret; | ||
1296 | 1298 | ||
1297 | dev_notice(&pdev->dev, "Marvell shared XOR driver\n"); | 1299 | dev_notice(&pdev->dev, "Marvell shared XOR driver\n"); |
1298 | 1300 | ||
@@ -1334,12 +1336,55 @@ static int mv_xor_shared_probe(struct platform_device *pdev) | |||
1334 | if (!IS_ERR(msp->clk)) | 1336 | if (!IS_ERR(msp->clk)) |
1335 | clk_prepare_enable(msp->clk); | 1337 | clk_prepare_enable(msp->clk); |
1336 | 1338 | ||
1339 | if (pdata && pdata->channels) { | ||
1340 | for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { | ||
1341 | struct mv_xor_platform_data *cd; | ||
1342 | int irq; | ||
1343 | |||
1344 | cd = &pdata->channels[i]; | ||
1345 | if (!cd) { | ||
1346 | ret = -ENODEV; | ||
1347 | goto err_channel_add; | ||
1348 | } | ||
1349 | |||
1350 | irq = platform_get_irq(pdev, i); | ||
1351 | if (irq < 0) { | ||
1352 | ret = irq; | ||
1353 | goto err_channel_add; | ||
1354 | } | ||
1355 | |||
1356 | msp->channels[i] = | ||
1357 | mv_xor_channel_add(msp, pdev, cd->hw_id, | ||
1358 | cd->cap_mask, | ||
1359 | cd->pool_size, irq); | ||
1360 | if (IS_ERR(msp->channels[i])) { | ||
1361 | ret = PTR_ERR(msp->channels[i]); | ||
1362 | goto err_channel_add; | ||
1363 | } | ||
1364 | } | ||
1365 | } | ||
1366 | |||
1337 | return 0; | 1367 | return 0; |
1368 | |||
1369 | err_channel_add: | ||
1370 | for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) | ||
1371 | if (msp->channels[i]) | ||
1372 | mv_xor_channel_remove(msp->channels[i]); | ||
1373 | |||
1374 | clk_disable_unprepare(msp->clk); | ||
1375 | clk_put(msp->clk); | ||
1376 | return ret; | ||
1338 | } | 1377 | } |
1339 | 1378 | ||
1340 | static int mv_xor_shared_remove(struct platform_device *pdev) | 1379 | static int mv_xor_shared_remove(struct platform_device *pdev) |
1341 | { | 1380 | { |
1342 | struct mv_xor_shared_private *msp = platform_get_drvdata(pdev); | 1381 | struct mv_xor_shared_private *msp = platform_get_drvdata(pdev); |
1382 | int i; | ||
1383 | |||
1384 | for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { | ||
1385 | if (msp->channels[i]) | ||
1386 | mv_xor_channel_remove(msp->channels[i]); | ||
1387 | } | ||
1343 | 1388 | ||
1344 | if (!IS_ERR(msp->clk)) { | 1389 | if (!IS_ERR(msp->clk)) { |
1345 | clk_disable_unprepare(msp->clk); | 1390 | clk_disable_unprepare(msp->clk); |
diff --git a/drivers/dma/mv_xor.h b/drivers/dma/mv_xor.h index a0641aebbdef..686575f6b9f5 100644 --- a/drivers/dma/mv_xor.h +++ b/drivers/dma/mv_xor.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #define USE_TIMER | 26 | #define USE_TIMER |
27 | #define MV_XOR_SLOT_SIZE 64 | 27 | #define MV_XOR_SLOT_SIZE 64 |
28 | #define MV_XOR_THRESHOLD 1 | 28 | #define MV_XOR_THRESHOLD 1 |
29 | #define MV_XOR_MAX_CHANNELS 2 | ||
29 | 30 | ||
30 | #define XOR_OPERATION_MODE_XOR 0 | 31 | #define XOR_OPERATION_MODE_XOR 0 |
31 | #define XOR_OPERATION_MODE_MEMCPY 2 | 32 | #define XOR_OPERATION_MODE_MEMCPY 2 |
@@ -53,9 +54,10 @@ | |||
53 | #define WINDOW_BAR_ENABLE(chan) (0x240 + ((chan) << 2)) | 54 | #define WINDOW_BAR_ENABLE(chan) (0x240 + ((chan) << 2)) |
54 | 55 | ||
55 | struct mv_xor_shared_private { | 56 | struct mv_xor_shared_private { |
56 | void __iomem *xor_base; | 57 | void __iomem *xor_base; |
57 | void __iomem *xor_high_base; | 58 | void __iomem *xor_high_base; |
58 | struct clk *clk; | 59 | struct clk *clk; |
60 | struct mv_xor_device *channels[MV_XOR_MAX_CHANNELS]; | ||
59 | }; | 61 | }; |
60 | 62 | ||
61 | 63 | ||
diff --git a/include/linux/platform_data/dma-mv_xor.h b/include/linux/platform_data/dma-mv_xor.h index 2ba1f7d76eef..f2aed978ca25 100644 --- a/include/linux/platform_data/dma-mv_xor.h +++ b/include/linux/platform_data/dma-mv_xor.h | |||
@@ -20,5 +20,8 @@ struct mv_xor_platform_data { | |||
20 | size_t pool_size; | 20 | size_t pool_size; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | struct mv_xor_shared_platform_data { | ||
24 | struct mv_xor_platform_data *channels; | ||
25 | }; | ||
23 | 26 | ||
24 | #endif | 27 | #endif |