aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap2/dma.c4
-rw-r--r--drivers/dma/omap-dma.c38
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
72static struct of_dma_filter_info omap_dma_info = {
73 .filter_fn = omap_dma_filter_fn,
74};
75
70static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d) 76static 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
674static 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};
682MODULE_DEVICE_TABLE(of, omap_dma_match);
683
651static struct platform_driver omap_dma_driver = { 684static 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