dma: mxs-dma: add device tree probe support

Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Rob Landley <rob@landley.net>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Huang Shijie <b32955@freescale.com>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
Dong Aisheng 2012-05-04 20:12:17 +08:00 committed by Shawn Guo
parent 8c92013643
commit 90c9abc5b7
2 changed files with 43 additions and 5 deletions

View File

@ -0,0 +1,19 @@
* Freescale MXS DMA
Required properties:
- compatible : Should be "fsl,<chip>-dma-apbh" or "fsl,<chip>-dma-apbx"
- reg : Should contain registers location and length
Supported chips:
imx23, imx28.
Examples:
dma-apbh@80004000 {
compatible = "fsl,imx28-dma-apbh";
reg = <0x80004000 2000>;
};
dma-apbx@80024000 {
compatible = "fsl,imx28-dma-apbx";
reg = <0x80024000 2000>;
};

View File

@ -22,8 +22,11 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h>
#include <linux/fsl/mxs-dma.h> #include <linux/fsl/mxs-dma.h>
#include <linux/stmp_device.h> #include <linux/stmp_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <mach/mxs.h> #include <mach/mxs.h>
@ -177,6 +180,15 @@ static struct platform_device_id mxs_dma_ids[] = {
} }
}; };
static const struct of_device_id mxs_dma_dt_ids[] = {
{ .compatible = "fsl,imx23-dma-apbh", .data = &mxs_dma_ids[0], },
{ .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], },
{ .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], },
{ .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids);
static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
{ {
return container_of(chan, struct mxs_dma_chan, chan); return container_of(chan, struct mxs_dma_chan, chan);
@ -652,10 +664,9 @@ err_out:
static int __init mxs_dma_probe(struct platform_device *pdev) static int __init mxs_dma_probe(struct platform_device *pdev)
{ {
const struct platform_device_id *id_entry = const struct platform_device_id *id_entry;
platform_get_device_id(pdev); const struct of_device_id *of_id;
const struct mxs_dma_type *dma_type = const struct mxs_dma_type *dma_type;
(struct mxs_dma_type *)id_entry->driver_data;
struct mxs_dma_engine *mxs_dma; struct mxs_dma_engine *mxs_dma;
struct resource *iores; struct resource *iores;
int ret, i; int ret, i;
@ -664,8 +675,15 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
if (!mxs_dma) if (!mxs_dma)
return -ENOMEM; return -ENOMEM;
mxs_dma->dev_id = dma_type->id; of_id = of_match_device(mxs_dma_dt_ids, &pdev->dev);
if (of_id)
id_entry = of_id->data;
else
id_entry = platform_get_device_id(pdev);
dma_type = (struct mxs_dma_type *)id_entry->driver_data;
mxs_dma->type = dma_type->type; mxs_dma->type = dma_type->type;
mxs_dma->dev_id = dma_type->id;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@ -751,6 +769,7 @@ err_request_region:
static struct platform_driver mxs_dma_driver = { static struct platform_driver mxs_dma_driver = {
.driver = { .driver = {
.name = "mxs-dma", .name = "mxs-dma",
.of_match_table = mxs_dma_dt_ids,
}, },
.id_table = mxs_dma_ids, .id_table = mxs_dma_ids,
}; };