Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jon Hunter and committed by
Vinod Koul
8d30662a f5b9b77e

+40 -2
+4
arch/arm/mach-omap2/dma.c
··· 28 28 #include <linux/init.h> 29 29 #include <linux/device.h> 30 30 #include <linux/dma-mapping.h> 31 + #include <linux/of.h> 31 32 #include <linux/omap-dma.h> 32 33 33 34 #include "soc.h" ··· 303 302 res = omap_hwmod_for_each_by_class("dma", 304 303 omap2_system_dma_init_dev, NULL); 305 304 if (res) 305 + return res; 306 + 307 + if (of_have_populated_dt()) 306 308 return res; 307 309 308 310 pdev = platform_device_register_full(&omap_dma_dev_info);
+36 -2
drivers/dma/omap-dma.c
··· 16 16 #include <linux/platform_device.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/spinlock.h> 19 + #include <linux/of_dma.h> 20 + #include <linux/of_device.h> 19 21 20 22 #include "virt-dma.h" 21 23 ··· 67 65 [OMAP_DMA_DATA_TYPE_S8] = 1, 68 66 [OMAP_DMA_DATA_TYPE_S16] = 2, 69 67 [OMAP_DMA_DATA_TYPE_S32] = 4, 68 + }; 69 + 70 + static struct of_dma_filter_info omap_dma_info = { 71 + .filter_fn = omap_dma_filter_fn, 70 72 }; 71 73 72 74 static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d) ··· 635 629 pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n", 636 630 rc); 637 631 omap_dma_free(od); 638 - } else { 639 - platform_set_drvdata(pdev, od); 632 + return rc; 633 + } 634 + 635 + platform_set_drvdata(pdev, od); 636 + 637 + if (pdev->dev.of_node) { 638 + omap_dma_info.dma_cap = od->ddev.cap_mask; 639 + 640 + /* Device-tree DMA controller registration */ 641 + rc = of_dma_controller_register(pdev->dev.of_node, 642 + of_dma_simple_xlate, &omap_dma_info); 643 + if (rc) { 644 + pr_warn("OMAP-DMA: failed to register DMA controller\n"); 645 + dma_async_device_unregister(&od->ddev); 646 + omap_dma_free(od); 647 + } 640 648 } 641 649 642 650 dev_info(&pdev->dev, "OMAP DMA engine driver\n"); ··· 662 642 { 663 643 struct omap_dmadev *od = platform_get_drvdata(pdev); 664 644 645 + if (pdev->dev.of_node) 646 + of_dma_controller_free(pdev->dev.of_node); 647 + 665 648 dma_async_device_unregister(&od->ddev); 666 649 omap_dma_free(od); 667 650 668 651 return 0; 669 652 } 653 + 654 + static const struct of_device_id omap_dma_match[] = { 655 + { .compatible = "ti,omap2420-sdma", }, 656 + { .compatible = "ti,omap2430-sdma", }, 657 + { .compatible = "ti,omap3430-sdma", }, 658 + { .compatible = "ti,omap3630-sdma", }, 659 + { .compatible = "ti,omap4430-sdma", }, 660 + {}, 661 + }; 662 + MODULE_DEVICE_TABLE(of, omap_dma_match); 670 663 671 664 static struct platform_driver omap_dma_driver = { 672 665 .probe = omap_dma_probe, ··· 687 654 .driver = { 688 655 .name = "omap-dma-engine", 689 656 .owner = THIS_MODULE, 657 + .of_match_table = of_match_ptr(omap_dma_match), 690 658 }, 691 659 }; 692 660