diff options
author | Dong Aisheng <dong.aisheng@linaro.org> | 2012-05-04 08:12:17 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2012-05-12 01:32:18 -0400 |
commit | 90c9abc5b74d7f7d8226b5dd0d8b6da3a03fe860 (patch) | |
tree | 8576ca33550eb9c03021876b99c9d653d4d34beb /drivers/dma/mxs-dma.c | |
parent | 8c92013643f5c40633d61ae331cef49c1069af10 (diff) |
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>
Diffstat (limited to 'drivers/dma/mxs-dma.c')
-rw-r--r-- | drivers/dma/mxs-dma.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index b1cab087cd04..1cb9b974493f 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c | |||
@@ -22,8 +22,11 @@ | |||
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/dmaengine.h> | 23 | #include <linux/dmaengine.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/module.h> | ||
25 | #include <linux/fsl/mxs-dma.h> | 26 | #include <linux/fsl/mxs-dma.h> |
26 | #include <linux/stmp_device.h> | 27 | #include <linux/stmp_device.h> |
28 | #include <linux/of.h> | ||
29 | #include <linux/of_device.h> | ||
27 | 30 | ||
28 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
29 | #include <mach/mxs.h> | 32 | #include <mach/mxs.h> |
@@ -177,6 +180,15 @@ static struct platform_device_id mxs_dma_ids[] = { | |||
177 | } | 180 | } |
178 | }; | 181 | }; |
179 | 182 | ||
183 | static const struct of_device_id mxs_dma_dt_ids[] = { | ||
184 | { .compatible = "fsl,imx23-dma-apbh", .data = &mxs_dma_ids[0], }, | ||
185 | { .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], }, | ||
186 | { .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], }, | ||
187 | { .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], }, | ||
188 | { /* sentinel */ } | ||
189 | }; | ||
190 | MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids); | ||
191 | |||
180 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) | 192 | static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan) |
181 | { | 193 | { |
182 | return container_of(chan, struct mxs_dma_chan, chan); | 194 | return container_of(chan, struct mxs_dma_chan, chan); |
@@ -652,10 +664,9 @@ err_out: | |||
652 | 664 | ||
653 | static int __init mxs_dma_probe(struct platform_device *pdev) | 665 | static int __init mxs_dma_probe(struct platform_device *pdev) |
654 | { | 666 | { |
655 | const struct platform_device_id *id_entry = | 667 | const struct platform_device_id *id_entry; |
656 | platform_get_device_id(pdev); | 668 | const struct of_device_id *of_id; |
657 | const struct mxs_dma_type *dma_type = | 669 | const struct mxs_dma_type *dma_type; |
658 | (struct mxs_dma_type *)id_entry->driver_data; | ||
659 | struct mxs_dma_engine *mxs_dma; | 670 | struct mxs_dma_engine *mxs_dma; |
660 | struct resource *iores; | 671 | struct resource *iores; |
661 | int ret, i; | 672 | int ret, i; |
@@ -664,8 +675,15 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
664 | if (!mxs_dma) | 675 | if (!mxs_dma) |
665 | return -ENOMEM; | 676 | return -ENOMEM; |
666 | 677 | ||
667 | mxs_dma->dev_id = dma_type->id; | 678 | of_id = of_match_device(mxs_dma_dt_ids, &pdev->dev); |
679 | if (of_id) | ||
680 | id_entry = of_id->data; | ||
681 | else | ||
682 | id_entry = platform_get_device_id(pdev); | ||
683 | |||
684 | dma_type = (struct mxs_dma_type *)id_entry->driver_data; | ||
668 | mxs_dma->type = dma_type->type; | 685 | mxs_dma->type = dma_type->type; |
686 | mxs_dma->dev_id = dma_type->id; | ||
669 | 687 | ||
670 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 688 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
671 | 689 | ||
@@ -751,6 +769,7 @@ err_request_region: | |||
751 | static struct platform_driver mxs_dma_driver = { | 769 | static struct platform_driver mxs_dma_driver = { |
752 | .driver = { | 770 | .driver = { |
753 | .name = "mxs-dma", | 771 | .name = "mxs-dma", |
772 | .of_match_table = mxs_dma_dt_ids, | ||
754 | }, | 773 | }, |
755 | .id_table = mxs_dma_ids, | 774 | .id_table = mxs_dma_ids, |
756 | }; | 775 | }; |