diff options
author | Zhangfei Gao <zhangfei.gao@marvell.com> | 2012-09-02 23:03:46 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@linux.intel.com> | 2012-09-13 22:44:08 -0400 |
commit | f1a7757008b810217b2380d01b740244f21c09bd (patch) | |
tree | ad9a9bcfab0590f83dbef05e5f2bb4f4fce9002b /drivers/dma/mmp_tdma.c | |
parent | c8acd6aa6bed3c0fd7898202f4ebc534db9085f2 (diff) |
dmaengine: mmp_tdma: add dt support
Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma/mmp_tdma.c')
-rw-r--r-- | drivers/dma/mmp_tdma.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c index 8a15cf2163dc..b93d73ca84ff 100644 --- a/drivers/dma/mmp_tdma.c +++ b/drivers/dma/mmp_tdma.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <mach/regs-icu.h> | 21 | #include <mach/regs-icu.h> |
22 | #include <mach/sram.h> | 22 | #include <mach/sram.h> |
23 | #include <linux/of_device.h> | ||
23 | 24 | ||
24 | #include "dmaengine.h" | 25 | #include "dmaengine.h" |
25 | 26 | ||
@@ -127,7 +128,6 @@ struct mmp_tdma_device { | |||
127 | void __iomem *base; | 128 | void __iomem *base; |
128 | struct dma_device device; | 129 | struct dma_device device; |
129 | struct mmp_tdma_chan *tdmac[TDMA_CHANNEL_NUM]; | 130 | struct mmp_tdma_chan *tdmac[TDMA_CHANNEL_NUM]; |
130 | int irq; | ||
131 | }; | 131 | }; |
132 | 132 | ||
133 | #define to_mmp_tdma_chan(dchan) container_of(dchan, struct mmp_tdma_chan, chan) | 133 | #define to_mmp_tdma_chan(dchan) container_of(dchan, struct mmp_tdma_chan, chan) |
@@ -492,7 +492,7 @@ static int __devinit mmp_tdma_chan_init(struct mmp_tdma_device *tdev, | |||
492 | return -ENOMEM; | 492 | return -ENOMEM; |
493 | } | 493 | } |
494 | if (irq) | 494 | if (irq) |
495 | tdmac->irq = irq + idx; | 495 | tdmac->irq = irq; |
496 | tdmac->dev = tdev->dev; | 496 | tdmac->dev = tdev->dev; |
497 | tdmac->chan.device = &tdev->device; | 497 | tdmac->chan.device = &tdev->device; |
498 | tdmac->idx = idx; | 498 | tdmac->idx = idx; |
@@ -505,34 +505,43 @@ static int __devinit mmp_tdma_chan_init(struct mmp_tdma_device *tdev, | |||
505 | /* add the channel to tdma_chan list */ | 505 | /* add the channel to tdma_chan list */ |
506 | list_add_tail(&tdmac->chan.device_node, | 506 | list_add_tail(&tdmac->chan.device_node, |
507 | &tdev->device.channels); | 507 | &tdev->device.channels); |
508 | |||
509 | return 0; | 508 | return 0; |
510 | } | 509 | } |
511 | 510 | ||
511 | static struct of_device_id mmp_tdma_dt_ids[] = { | ||
512 | { .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA}, | ||
513 | { .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU}, | ||
514 | {} | ||
515 | }; | ||
516 | MODULE_DEVICE_TABLE(of, mmp_tdma_dt_ids); | ||
517 | |||
512 | static int __devinit mmp_tdma_probe(struct platform_device *pdev) | 518 | static int __devinit mmp_tdma_probe(struct platform_device *pdev) |
513 | { | 519 | { |
514 | const struct platform_device_id *id = platform_get_device_id(pdev); | 520 | enum mmp_tdma_type type; |
515 | enum mmp_tdma_type type = id->driver_data; | 521 | const struct of_device_id *of_id; |
516 | struct mmp_tdma_device *tdev; | 522 | struct mmp_tdma_device *tdev; |
517 | struct resource *iores; | 523 | struct resource *iores; |
518 | int i, ret; | 524 | int i, ret; |
519 | int irq = 0; | 525 | int irq = 0, irq_num = 0; |
520 | int chan_num = TDMA_CHANNEL_NUM; | 526 | int chan_num = TDMA_CHANNEL_NUM; |
521 | 527 | ||
528 | of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev); | ||
529 | if (of_id) | ||
530 | type = (enum mmp_tdma_type) of_id->data; | ||
531 | else | ||
532 | type = platform_get_device_id(pdev)->driver_data; | ||
533 | |||
522 | /* always have couple channels */ | 534 | /* always have couple channels */ |
523 | tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); | 535 | tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); |
524 | if (!tdev) | 536 | if (!tdev) |
525 | return -ENOMEM; | 537 | return -ENOMEM; |
526 | 538 | ||
527 | tdev->dev = &pdev->dev; | 539 | tdev->dev = &pdev->dev; |
528 | iores = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
529 | if (!iores) | ||
530 | return -EINVAL; | ||
531 | 540 | ||
532 | if (resource_size(iores) != chan_num) | 541 | for (i = 0; i < chan_num; i++) { |
533 | tdev->irq = iores->start; | 542 | if (platform_get_irq(pdev, i) > 0) |
534 | else | 543 | irq_num++; |
535 | irq = iores->start; | 544 | } |
536 | 545 | ||
537 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 546 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
538 | if (!iores) | 547 | if (!iores) |
@@ -542,25 +551,26 @@ static int __devinit mmp_tdma_probe(struct platform_device *pdev) | |||
542 | if (!tdev->base) | 551 | if (!tdev->base) |
543 | return -EADDRNOTAVAIL; | 552 | return -EADDRNOTAVAIL; |
544 | 553 | ||
545 | if (tdev->irq) { | 554 | INIT_LIST_HEAD(&tdev->device.channels); |
546 | ret = devm_request_irq(&pdev->dev, tdev->irq, | 555 | |
556 | if (irq_num != chan_num) { | ||
557 | irq = platform_get_irq(pdev, 0); | ||
558 | ret = devm_request_irq(&pdev->dev, irq, | ||
547 | mmp_tdma_int_handler, IRQF_DISABLED, "tdma", tdev); | 559 | mmp_tdma_int_handler, IRQF_DISABLED, "tdma", tdev); |
548 | if (ret) | 560 | if (ret) |
549 | return ret; | 561 | return ret; |
550 | } | 562 | } |
551 | 563 | ||
552 | dma_cap_set(DMA_SLAVE, tdev->device.cap_mask); | ||
553 | dma_cap_set(DMA_CYCLIC, tdev->device.cap_mask); | ||
554 | |||
555 | INIT_LIST_HEAD(&tdev->device.channels); | ||
556 | |||
557 | /* initialize channel parameters */ | 564 | /* initialize channel parameters */ |
558 | for (i = 0; i < chan_num; i++) { | 565 | for (i = 0; i < chan_num; i++) { |
566 | irq = (irq_num != chan_num) ? 0 : platform_get_irq(pdev, i); | ||
559 | ret = mmp_tdma_chan_init(tdev, i, irq, type); | 567 | ret = mmp_tdma_chan_init(tdev, i, irq, type); |
560 | if (ret) | 568 | if (ret) |
561 | return ret; | 569 | return ret; |
562 | } | 570 | } |
563 | 571 | ||
572 | dma_cap_set(DMA_SLAVE, tdev->device.cap_mask); | ||
573 | dma_cap_set(DMA_CYCLIC, tdev->device.cap_mask); | ||
564 | tdev->device.dev = &pdev->dev; | 574 | tdev->device.dev = &pdev->dev; |
565 | tdev->device.device_alloc_chan_resources = | 575 | tdev->device.device_alloc_chan_resources = |
566 | mmp_tdma_alloc_chan_resources; | 576 | mmp_tdma_alloc_chan_resources; |
@@ -595,6 +605,7 @@ static struct platform_driver mmp_tdma_driver = { | |||
595 | .driver = { | 605 | .driver = { |
596 | .name = "mmp-tdma", | 606 | .name = "mmp-tdma", |
597 | .owner = THIS_MODULE, | 607 | .owner = THIS_MODULE, |
608 | .of_match_table = mmp_tdma_dt_ids, | ||
598 | }, | 609 | }, |
599 | .id_table = mmp_tdma_id_table, | 610 | .id_table = mmp_tdma_id_table, |
600 | .probe = mmp_tdma_probe, | 611 | .probe = mmp_tdma_probe, |