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>
This commit is contained in:
Jon Hunter 2013-02-26 12:27:24 -06:00 коммит произвёл Vinod Koul
Родитель f5b9b77eea
Коммит 8d30662aac
2 изменённых файлов: 40 добавлений и 2 удалений

Просмотреть файл

@ -28,6 +28,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/of.h>
#include <linux/omap-dma.h> #include <linux/omap-dma.h>
#include "soc.h" #include "soc.h"
@ -304,6 +305,9 @@ static int __init omap2_system_dma_init(void)
if (res) if (res)
return res; return res;
if (of_have_populated_dt())
return res;
pdev = platform_device_register_full(&omap_dma_dev_info); pdev = platform_device_register_full(&omap_dma_dev_info);
if (IS_ERR(pdev)) if (IS_ERR(pdev))
return PTR_ERR(pdev); return PTR_ERR(pdev);

Просмотреть файл

@ -16,6 +16,8 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/of_dma.h>
#include <linux/of_device.h>
#include "virt-dma.h" #include "virt-dma.h"
@ -67,6 +69,10 @@ static const unsigned es_bytes[] = {
[OMAP_DMA_DATA_TYPE_S32] = 4, [OMAP_DMA_DATA_TYPE_S32] = 4,
}; };
static struct of_dma_filter_info omap_dma_info = {
.filter_fn = omap_dma_filter_fn,
};
static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d) static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d)
{ {
return container_of(d, struct omap_dmadev, ddev); return container_of(d, struct omap_dmadev, ddev);
@ -629,8 +635,22 @@ static int omap_dma_probe(struct platform_device *pdev)
pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n", pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n",
rc); rc);
omap_dma_free(od); omap_dma_free(od);
} else { return rc;
platform_set_drvdata(pdev, od); }
platform_set_drvdata(pdev, od);
if (pdev->dev.of_node) {
omap_dma_info.dma_cap = od->ddev.cap_mask;
/* Device-tree DMA controller registration */
rc = of_dma_controller_register(pdev->dev.of_node,
of_dma_simple_xlate, &omap_dma_info);
if (rc) {
pr_warn("OMAP-DMA: failed to register DMA controller\n");
dma_async_device_unregister(&od->ddev);
omap_dma_free(od);
}
} }
dev_info(&pdev->dev, "OMAP DMA engine driver\n"); dev_info(&pdev->dev, "OMAP DMA engine driver\n");
@ -642,18 +662,32 @@ static int omap_dma_remove(struct platform_device *pdev)
{ {
struct omap_dmadev *od = platform_get_drvdata(pdev); struct omap_dmadev *od = platform_get_drvdata(pdev);
if (pdev->dev.of_node)
of_dma_controller_free(pdev->dev.of_node);
dma_async_device_unregister(&od->ddev); dma_async_device_unregister(&od->ddev);
omap_dma_free(od); omap_dma_free(od);
return 0; return 0;
} }
static const struct of_device_id omap_dma_match[] = {
{ .compatible = "ti,omap2420-sdma", },
{ .compatible = "ti,omap2430-sdma", },
{ .compatible = "ti,omap3430-sdma", },
{ .compatible = "ti,omap3630-sdma", },
{ .compatible = "ti,omap4430-sdma", },
{},
};
MODULE_DEVICE_TABLE(of, omap_dma_match);
static struct platform_driver omap_dma_driver = { static struct platform_driver omap_dma_driver = {
.probe = omap_dma_probe, .probe = omap_dma_probe,
.remove = omap_dma_remove, .remove = omap_dma_remove,
.driver = { .driver = {
.name = "omap-dma-engine", .name = "omap-dma-engine",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_match_ptr(omap_dma_match),
}, },
}; };