diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-09-15 09:11:28 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2012-10-14 22:03:17 -0400 |
commit | e51d0f0ac4b7f513808743c6a62f0387eebd0144 (patch) | |
tree | 1efe37ce7bf87694ea8c79fe06256b131db5658d /drivers/dma/imx-dma.c | |
parent | 73930eb31b2ecb0177c9bf81a35b4d2d73716951 (diff) |
dma: imx-dma: remove cpu_is_xxx by using platform_device_id
It changes the driver to use platform_device_id rather than cpu_is_xxx
to determine the controller type, and updates the platform code
accordingly.
As the result, mach/hardware.h inclusion gets removed from the driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Javier Martin <javier.martin@vista-silicon.com>
Cc: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma/imx-dma.c')
-rw-r--r-- | drivers/dma/imx-dma.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index 88e8a8d89b56..a3a8270e76fb 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
31 | #include <linux/platform_data/dma-imx.h> | 31 | #include <linux/platform_data/dma-imx.h> |
32 | #include <mach/hardware.h> | ||
33 | 32 | ||
34 | #include "dmaengine.h" | 33 | #include "dmaengine.h" |
35 | #define IMXDMA_MAX_CHAN_DESCRIPTORS 16 | 34 | #define IMXDMA_MAX_CHAN_DESCRIPTORS 16 |
@@ -167,6 +166,12 @@ struct imxdma_channel { | |||
167 | int slot_2d; | 166 | int slot_2d; |
168 | }; | 167 | }; |
169 | 168 | ||
169 | enum imx_dma_type { | ||
170 | IMX1_DMA, | ||
171 | IMX21_DMA, | ||
172 | IMX27_DMA, | ||
173 | }; | ||
174 | |||
170 | struct imxdma_engine { | 175 | struct imxdma_engine { |
171 | struct device *dev; | 176 | struct device *dev; |
172 | struct device_dma_parameters dma_parms; | 177 | struct device_dma_parameters dma_parms; |
@@ -177,8 +182,40 @@ struct imxdma_engine { | |||
177 | spinlock_t lock; | 182 | spinlock_t lock; |
178 | struct imx_dma_2d_config slots_2d[IMX_DMA_2D_SLOTS]; | 183 | struct imx_dma_2d_config slots_2d[IMX_DMA_2D_SLOTS]; |
179 | struct imxdma_channel channel[IMX_DMA_CHANNELS]; | 184 | struct imxdma_channel channel[IMX_DMA_CHANNELS]; |
185 | enum imx_dma_type devtype; | ||
180 | }; | 186 | }; |
181 | 187 | ||
188 | static struct platform_device_id imx_dma_devtype[] = { | ||
189 | { | ||
190 | .name = "imx1-dma", | ||
191 | .driver_data = IMX1_DMA, | ||
192 | }, { | ||
193 | .name = "imx21-dma", | ||
194 | .driver_data = IMX21_DMA, | ||
195 | }, { | ||
196 | .name = "imx27-dma", | ||
197 | .driver_data = IMX27_DMA, | ||
198 | }, { | ||
199 | /* sentinel */ | ||
200 | } | ||
201 | }; | ||
202 | MODULE_DEVICE_TABLE(platform, imx_dma_devtype); | ||
203 | |||
204 | static inline int is_imx1_dma(struct imxdma_engine *imxdma) | ||
205 | { | ||
206 | return imxdma->devtype == IMX1_DMA; | ||
207 | } | ||
208 | |||
209 | static inline int is_imx21_dma(struct imxdma_engine *imxdma) | ||
210 | { | ||
211 | return imxdma->devtype == IMX21_DMA; | ||
212 | } | ||
213 | |||
214 | static inline int is_imx27_dma(struct imxdma_engine *imxdma) | ||
215 | { | ||
216 | return imxdma->devtype == IMX27_DMA; | ||
217 | } | ||
218 | |||
182 | static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan) | 219 | static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan) |
183 | { | 220 | { |
184 | return container_of(chan, struct imxdma_channel, chan); | 221 | return container_of(chan, struct imxdma_channel, chan); |
@@ -212,7 +249,9 @@ static unsigned imx_dmav1_readl(struct imxdma_engine *imxdma, unsigned offset) | |||
212 | 249 | ||
213 | static int imxdma_hw_chain(struct imxdma_channel *imxdmac) | 250 | static int imxdma_hw_chain(struct imxdma_channel *imxdmac) |
214 | { | 251 | { |
215 | if (cpu_is_mx27()) | 252 | struct imxdma_engine *imxdma = imxdmac->imxdma; |
253 | |||
254 | if (is_imx27_dma(imxdma)) | ||
216 | return imxdmac->hw_chaining; | 255 | return imxdmac->hw_chaining; |
217 | else | 256 | else |
218 | return 0; | 257 | return 0; |
@@ -267,7 +306,7 @@ static void imxdma_enable_hw(struct imxdma_desc *d) | |||
267 | imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) | | 306 | imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) | |
268 | CCR_CEN | CCR_ACRPT, DMA_CCR(channel)); | 307 | CCR_CEN | CCR_ACRPT, DMA_CCR(channel)); |
269 | 308 | ||
270 | if ((cpu_is_mx21() || cpu_is_mx27()) && | 309 | if (!is_imx1_dma(imxdma) && |
271 | d->sg && imxdma_hw_chain(imxdmac)) { | 310 | d->sg && imxdma_hw_chain(imxdmac)) { |
272 | d->sg = sg_next(d->sg); | 311 | d->sg = sg_next(d->sg); |
273 | if (d->sg) { | 312 | if (d->sg) { |
@@ -436,7 +475,7 @@ static irqreturn_t dma_irq_handler(int irq, void *dev_id) | |||
436 | struct imxdma_engine *imxdma = dev_id; | 475 | struct imxdma_engine *imxdma = dev_id; |
437 | int i, disr; | 476 | int i, disr; |
438 | 477 | ||
439 | if (cpu_is_mx21() || cpu_is_mx27()) | 478 | if (!is_imx1_dma(imxdma)) |
440 | imxdma_err_handler(irq, dev_id); | 479 | imxdma_err_handler(irq, dev_id); |
441 | 480 | ||
442 | disr = imx_dmav1_readl(imxdma, DMA_DISR); | 481 | disr = imx_dmav1_readl(imxdma, DMA_DISR); |
@@ -967,6 +1006,8 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
967 | if (!imxdma) | 1006 | if (!imxdma) |
968 | return -ENOMEM; | 1007 | return -ENOMEM; |
969 | 1008 | ||
1009 | imxdma->devtype = pdev->id_entry->driver_data; | ||
1010 | |||
970 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1011 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
971 | imxdma->base = devm_request_and_ioremap(&pdev->dev, res); | 1012 | imxdma->base = devm_request_and_ioremap(&pdev->dev, res); |
972 | if (!imxdma->base) | 1013 | if (!imxdma->base) |
@@ -990,7 +1031,7 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
990 | /* reset DMA module */ | 1031 | /* reset DMA module */ |
991 | imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); | 1032 | imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); |
992 | 1033 | ||
993 | if (cpu_is_mx1()) { | 1034 | if (is_imx1_dma(imxdma)) { |
994 | ret = devm_request_irq(&pdev->dev, irq, | 1035 | ret = devm_request_irq(&pdev->dev, irq, |
995 | dma_irq_handler, 0, "DMA", imxdma); | 1036 | dma_irq_handler, 0, "DMA", imxdma); |
996 | if (ret) { | 1037 | if (ret) { |
@@ -1038,7 +1079,7 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
1038 | for (i = 0; i < IMX_DMA_CHANNELS; i++) { | 1079 | for (i = 0; i < IMX_DMA_CHANNELS; i++) { |
1039 | struct imxdma_channel *imxdmac = &imxdma->channel[i]; | 1080 | struct imxdma_channel *imxdmac = &imxdma->channel[i]; |
1040 | 1081 | ||
1041 | if (cpu_is_mx21() || cpu_is_mx27()) { | 1082 | if (!is_imx1_dma(imxdma)) { |
1042 | ret = devm_request_irq(&pdev->dev, irq + i, | 1083 | ret = devm_request_irq(&pdev->dev, irq + i, |
1043 | dma_irq_handler, 0, "DMA", imxdma); | 1084 | dma_irq_handler, 0, "DMA", imxdma); |
1044 | if (ret) { | 1085 | if (ret) { |
@@ -1118,6 +1159,7 @@ static struct platform_driver imxdma_driver = { | |||
1118 | .driver = { | 1159 | .driver = { |
1119 | .name = "imx-dma", | 1160 | .name = "imx-dma", |
1120 | }, | 1161 | }, |
1162 | .id_table = imx_dma_devtype, | ||
1121 | .remove = __exit_p(imxdma_remove), | 1163 | .remove = __exit_p(imxdma_remove), |
1122 | }; | 1164 | }; |
1123 | 1165 | ||