diff options
author | Jon Hunter <jon-hunter@ti.com> | 2013-02-26 13:27:24 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-04-15 00:21:19 -0400 |
commit | 8d30662aac256eb61bc2f1d9cf1191825ef96328 (patch) | |
tree | fd39f755ea7cd13fbc79e2d3b06310caf2f07c62 | |
parent | f5b9b77eea1f9aaf7725872be4b382f5530bb41e (diff) |
dmaengine: OMAP: Register SDMA controller with Device Tree DMA driver
If the device-tree blob is present during boot, then register the SDMA
controller with the device-tree DMA driver so that we can use device-tree
to look-up DMA client information.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r-- | arch/arm/mach-omap2/dma.c | 4 | ||||
-rw-r--r-- | drivers/dma/omap-dma.c | 38 |
2 files changed, 40 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c index dab9fc014b97..49fd0d501c9b 100644 --- a/arch/arm/mach-omap2/dma.c +++ b/arch/arm/mach-omap2/dma.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/device.h> | 29 | #include <linux/device.h> |
30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
31 | #include <linux/of.h> | ||
31 | #include <linux/omap-dma.h> | 32 | #include <linux/omap-dma.h> |
32 | 33 | ||
33 | #include "soc.h" | 34 | #include "soc.h" |
@@ -304,6 +305,9 @@ static int __init omap2_system_dma_init(void) | |||
304 | if (res) | 305 | if (res) |
305 | return res; | 306 | return res; |
306 | 307 | ||
308 | if (of_have_populated_dt()) | ||
309 | return res; | ||
310 | |||
307 | pdev = platform_device_register_full(&omap_dma_dev_info); | 311 | pdev = platform_device_register_full(&omap_dma_dev_info); |
308 | if (IS_ERR(pdev)) | 312 | if (IS_ERR(pdev)) |
309 | return PTR_ERR(pdev); | 313 | return PTR_ERR(pdev); |
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index 08b43bf37158..ec3fc4fd9160 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/of_dma.h> | ||
20 | #include <linux/of_device.h> | ||
19 | 21 | ||
20 | #include "virt-dma.h" | 22 | #include "virt-dma.h" |
21 | 23 | ||
@@ -67,6 +69,10 @@ static const unsigned es_bytes[] = { | |||
67 | [OMAP_DMA_DATA_TYPE_S32] = 4, | 69 | [OMAP_DMA_DATA_TYPE_S32] = 4, |
68 | }; | 70 | }; |
69 | 71 | ||
72 | static struct of_dma_filter_info omap_dma_info = { | ||
73 | .filter_fn = omap_dma_filter_fn, | ||
74 | }; | ||
75 | |||
70 | static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d) | 76 | static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d) |
71 | { | 77 | { |
72 | return container_of(d, struct omap_dmadev, ddev); | 78 | return container_of(d, struct omap_dmadev, ddev); |
@@ -629,8 +635,22 @@ static int omap_dma_probe(struct platform_device *pdev) | |||
629 | pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n", | 635 | pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n", |
630 | rc); | 636 | rc); |
631 | omap_dma_free(od); | 637 | omap_dma_free(od); |
632 | } else { | 638 | return rc; |
633 | platform_set_drvdata(pdev, od); | 639 | } |
640 | |||
641 | platform_set_drvdata(pdev, od); | ||
642 | |||
643 | if (pdev->dev.of_node) { | ||
644 | omap_dma_info.dma_cap = od->ddev.cap_mask; | ||
645 | |||
646 | /* Device-tree DMA controller registration */ | ||
647 | rc = of_dma_controller_register(pdev->dev.of_node, | ||
648 | of_dma_simple_xlate, &omap_dma_info); | ||
649 | if (rc) { | ||
650 | pr_warn("OMAP-DMA: failed to register DMA controller\n"); | ||
651 | dma_async_device_unregister(&od->ddev); | ||
652 | omap_dma_free(od); | ||
653 | } | ||
634 | } | 654 | } |
635 | 655 | ||
636 | dev_info(&pdev->dev, "OMAP DMA engine driver\n"); | 656 | dev_info(&pdev->dev, "OMAP DMA engine driver\n"); |
@@ -642,18 +662,32 @@ static int omap_dma_remove(struct platform_device *pdev) | |||
642 | { | 662 | { |
643 | struct omap_dmadev *od = platform_get_drvdata(pdev); | 663 | struct omap_dmadev *od = platform_get_drvdata(pdev); |
644 | 664 | ||
665 | if (pdev->dev.of_node) | ||
666 | of_dma_controller_free(pdev->dev.of_node); | ||
667 | |||
645 | dma_async_device_unregister(&od->ddev); | 668 | dma_async_device_unregister(&od->ddev); |
646 | omap_dma_free(od); | 669 | omap_dma_free(od); |
647 | 670 | ||
648 | return 0; | 671 | return 0; |
649 | } | 672 | } |
650 | 673 | ||
674 | static const struct of_device_id omap_dma_match[] = { | ||
675 | { .compatible = "ti,omap2420-sdma", }, | ||
676 | { .compatible = "ti,omap2430-sdma", }, | ||
677 | { .compatible = "ti,omap3430-sdma", }, | ||
678 | { .compatible = "ti,omap3630-sdma", }, | ||
679 | { .compatible = "ti,omap4430-sdma", }, | ||
680 | {}, | ||
681 | }; | ||
682 | MODULE_DEVICE_TABLE(of, omap_dma_match); | ||
683 | |||
651 | static struct platform_driver omap_dma_driver = { | 684 | static struct platform_driver omap_dma_driver = { |
652 | .probe = omap_dma_probe, | 685 | .probe = omap_dma_probe, |
653 | .remove = omap_dma_remove, | 686 | .remove = omap_dma_remove, |
654 | .driver = { | 687 | .driver = { |
655 | .name = "omap-dma-engine", | 688 | .name = "omap-dma-engine", |
656 | .owner = THIS_MODULE, | 689 | .owner = THIS_MODULE, |
690 | .of_match_table = of_match_ptr(omap_dma_match), | ||
657 | }, | 691 | }, |
658 | }; | 692 | }; |
659 | 693 | ||