aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-09-15 09:11:28 -0400
committerShawn Guo <shawn.guo@linaro.org>2012-10-14 22:03:17 -0400
commite51d0f0ac4b7f513808743c6a62f0387eebd0144 (patch)
tree1efe37ce7bf87694ea8c79fe06256b131db5658d
parent73930eb31b2ecb0177c9bf81a35b4d2d73716951 (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>
-rw-r--r--arch/arm/mach-imx/clk-imx1.c3
-rw-r--r--arch/arm/mach-imx/clk-imx21.c4
-rw-r--r--arch/arm/mach-imx/clk-imx27.c4
-rw-r--r--arch/arm/mach-imx/devices/devices-common.h2
-rw-r--r--arch/arm/mach-imx/devices/platform-imx-dma.c4
-rw-r--r--arch/arm/mach-imx/mm-imx1.c3
-rw-r--r--arch/arm/mach-imx/mm-imx21.c3
-rw-r--r--arch/arm/mach-imx/mm-imx27.c3
-rw-r--r--drivers/dma/imx-dma.c54
-rw-r--r--include/linux/platform_data/dma-imx.h4
10 files changed, 66 insertions, 18 deletions
diff --git a/arch/arm/mach-imx/clk-imx1.c b/arch/arm/mach-imx/clk-imx1.c
index 1cc7a735ed19..49a74440bc48 100644
--- a/arch/arm/mach-imx/clk-imx1.c
+++ b/arch/arm/mach-imx/clk-imx1.c
@@ -83,7 +83,8 @@ int __init mx1_clocks_init(unsigned long fref)
83 pr_err("imx1 clk %d: register failed with %ld\n", 83 pr_err("imx1 clk %d: register failed with %ld\n",
84 i, PTR_ERR(clk[i])); 84 i, PTR_ERR(clk[i]));
85 85
86 clk_register_clkdev(clk[dma_gate], "ahb", "imx-dma"); 86 clk_register_clkdev(clk[dma_gate], "ahb", "imx1-dma");
87 clk_register_clkdev(clk[hclk], "ipg", "imx1-dma");
87 clk_register_clkdev(clk[csi_gate], NULL, "mx1-camera.0"); 88 clk_register_clkdev(clk[csi_gate], NULL, "mx1-camera.0");
88 clk_register_clkdev(clk[mma_gate], "mma", NULL); 89 clk_register_clkdev(clk[mma_gate], "mma", NULL);
89 clk_register_clkdev(clk[usbd_gate], NULL, "imx_udc.0"); 90 clk_register_clkdev(clk[usbd_gate], NULL, "imx_udc.0");
diff --git a/arch/arm/mach-imx/clk-imx21.c b/arch/arm/mach-imx/clk-imx21.c
index 96a4788032d1..8aec572f84fe 100644
--- a/arch/arm/mach-imx/clk-imx21.c
+++ b/arch/arm/mach-imx/clk-imx21.c
@@ -163,8 +163,8 @@ int __init mx21_clocks_init(unsigned long lref, unsigned long href)
163 clk_register_clkdev(clk[usb_gate], "per", "imx21-hcd.0"); 163 clk_register_clkdev(clk[usb_gate], "per", "imx21-hcd.0");
164 clk_register_clkdev(clk[usb_hclk_gate], "ahb", "imx21-hcd.0"); 164 clk_register_clkdev(clk[usb_hclk_gate], "ahb", "imx21-hcd.0");
165 clk_register_clkdev(clk[nfc_gate], NULL, "imx21-nand.0"); 165 clk_register_clkdev(clk[nfc_gate], NULL, "imx21-nand.0");
166 clk_register_clkdev(clk[dma_hclk_gate], "ahb", "imx-dma"); 166 clk_register_clkdev(clk[dma_hclk_gate], "ahb", "imx21-dma");
167 clk_register_clkdev(clk[dma_gate], "ipg", "imx-dma"); 167 clk_register_clkdev(clk[dma_gate], "ipg", "imx21-dma");
168 clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); 168 clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
169 clk_register_clkdev(clk[i2c_gate], NULL, "imx21-i2c.0"); 169 clk_register_clkdev(clk[i2c_gate], NULL, "imx21-i2c.0");
170 clk_register_clkdev(clk[kpp_gate], NULL, "mxc-keypad"); 170 clk_register_clkdev(clk[kpp_gate], NULL, "mxc-keypad");
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index 86a0c4262471..a5f0e3b6dec6 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -242,8 +242,8 @@ int __init mx27_clocks_init(unsigned long fref)
242 clk_register_clkdev(clk[nfc_baud_gate], NULL, "imx27-nand.0"); 242 clk_register_clkdev(clk[nfc_baud_gate], NULL, "imx27-nand.0");
243 clk_register_clkdev(clk[vpu_baud_gate], "per", "coda-imx27.0"); 243 clk_register_clkdev(clk[vpu_baud_gate], "per", "coda-imx27.0");
244 clk_register_clkdev(clk[vpu_ahb_gate], "ahb", "coda-imx27.0"); 244 clk_register_clkdev(clk[vpu_ahb_gate], "ahb", "coda-imx27.0");
245 clk_register_clkdev(clk[dma_ahb_gate], "ahb", "imx-dma"); 245 clk_register_clkdev(clk[dma_ahb_gate], "ahb", "imx27-dma");
246 clk_register_clkdev(clk[dma_ipg_gate], "ipg", "imx-dma"); 246 clk_register_clkdev(clk[dma_ipg_gate], "ipg", "imx27-dma");
247 clk_register_clkdev(clk[fec_ipg_gate], "ipg", "imx27-fec.0"); 247 clk_register_clkdev(clk[fec_ipg_gate], "ipg", "imx27-fec.0");
248 clk_register_clkdev(clk[fec_ahb_gate], "ahb", "imx27-fec.0"); 248 clk_register_clkdev(clk[fec_ahb_gate], "ahb", "imx27-fec.0");
249 clk_register_clkdev(clk[wdog_ipg_gate], NULL, "imx2-wdt.0"); 249 clk_register_clkdev(clk[wdog_ipg_gate], NULL, "imx2-wdt.0");
diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
index e4368f6c5fb4..36eb3f09f5d7 100644
--- a/arch/arm/mach-imx/devices/devices-common.h
+++ b/arch/arm/mach-imx/devices/devices-common.h
@@ -329,7 +329,7 @@ struct platform_device *__init imx_add_spi_imx(
329 const struct imx_spi_imx_data *data, 329 const struct imx_spi_imx_data *data,
330 const struct spi_imx_master *pdata); 330 const struct spi_imx_master *pdata);
331 331
332struct platform_device *imx_add_imx_dma(resource_size_t iobase, 332struct platform_device *imx_add_imx_dma(char *name, resource_size_t iobase,
333 int irq, int irq_err); 333 int irq, int irq_err);
334struct platform_device *imx_add_imx_sdma(char *name, 334struct platform_device *imx_add_imx_sdma(char *name,
335 resource_size_t iobase, int irq, struct sdma_platform_data *pdata); 335 resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
diff --git a/arch/arm/mach-imx/devices/platform-imx-dma.c b/arch/arm/mach-imx/devices/platform-imx-dma.c
index f9003e4d0f57..ccdb5dc4ddbd 100644
--- a/arch/arm/mach-imx/devices/platform-imx-dma.c
+++ b/arch/arm/mach-imx/devices/platform-imx-dma.c
@@ -8,7 +8,7 @@
8 */ 8 */
9#include "devices-common.h" 9#include "devices-common.h"
10 10
11struct platform_device __init __maybe_unused *imx_add_imx_dma( 11struct platform_device __init __maybe_unused *imx_add_imx_dma(char *name,
12 resource_size_t iobase, int irq, int irq_err) 12 resource_size_t iobase, int irq, int irq_err)
13{ 13{
14 struct resource res[] = { 14 struct resource res[] = {
@@ -28,7 +28,7 @@ struct platform_device __init __maybe_unused *imx_add_imx_dma(
28 }; 28 };
29 29
30 return platform_device_register_resndata(&mxc_ahb_bus, 30 return platform_device_register_resndata(&mxc_ahb_bus,
31 "imx-dma", -1, res, ARRAY_SIZE(res), NULL, 0); 31 name, -1, res, ARRAY_SIZE(res), NULL, 0);
32} 32}
33 33
34struct platform_device __init __maybe_unused *imx_add_imx_sdma(char *name, 34struct platform_device __init __maybe_unused *imx_add_imx_sdma(char *name,
diff --git a/arch/arm/mach-imx/mm-imx1.c b/arch/arm/mach-imx/mm-imx1.c
index 9de81bf6de96..79f6c0b8f69f 100644
--- a/arch/arm/mach-imx/mm-imx1.c
+++ b/arch/arm/mach-imx/mm-imx1.c
@@ -60,6 +60,7 @@ void __init imx1_soc_init(void)
60 MX1_GPIO_INT_PORTC, 0); 60 MX1_GPIO_INT_PORTC, 0);
61 mxc_register_gpio("imx1-gpio", 3, MX1_GPIO4_BASE_ADDR, SZ_256, 61 mxc_register_gpio("imx1-gpio", 3, MX1_GPIO4_BASE_ADDR, SZ_256,
62 MX1_GPIO_INT_PORTD, 0); 62 MX1_GPIO_INT_PORTD, 0);
63 imx_add_imx_dma(MX1_DMA_BASE_ADDR, MX1_DMA_INT, MX1_DMA_ERR); 63 imx_add_imx_dma("imx1-dma", MX1_DMA_BASE_ADDR,
64 MX1_DMA_INT, MX1_DMA_ERR);
64 pinctrl_provide_dummies(); 65 pinctrl_provide_dummies();
65} 66}
diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c
index 1c295154c296..3b97ea63b5fb 100644
--- a/arch/arm/mach-imx/mm-imx21.c
+++ b/arch/arm/mach-imx/mm-imx21.c
@@ -90,7 +90,8 @@ void __init imx21_soc_init(void)
90 mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); 90 mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
91 91
92 pinctrl_provide_dummies(); 92 pinctrl_provide_dummies();
93 imx_add_imx_dma(MX21_DMA_BASE_ADDR, MX21_INT_DMACH0, 0); /* No ERR irq */ 93 imx_add_imx_dma("imx21-dma", MX21_DMA_BASE_ADDR,
94 MX21_INT_DMACH0, 0); /* No ERR irq */
94 platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res, 95 platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res,
95 ARRAY_SIZE(imx21_audmux_res)); 96 ARRAY_SIZE(imx21_audmux_res));
96} 97}
diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
index d389f4af33c0..91e8da832810 100644
--- a/arch/arm/mach-imx/mm-imx27.c
+++ b/arch/arm/mach-imx/mm-imx27.c
@@ -91,7 +91,8 @@ void __init imx27_soc_init(void)
91 mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); 91 mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0);
92 92
93 pinctrl_provide_dummies(); 93 pinctrl_provide_dummies();
94 imx_add_imx_dma(MX27_DMA_BASE_ADDR, MX27_INT_DMACH0, 0); /* No ERR irq */ 94 imx_add_imx_dma("imx27-dma", MX27_DMA_BASE_ADDR,
95 MX27_INT_DMACH0, 0); /* No ERR irq */
95 /* imx27 has the imx21 type audmux */ 96 /* imx27 has the imx21 type audmux */
96 platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res, 97 platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res,
97 ARRAY_SIZE(imx27_audmux_res)); 98 ARRAY_SIZE(imx27_audmux_res));
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
169enum imx_dma_type {
170 IMX1_DMA,
171 IMX21_DMA,
172 IMX27_DMA,
173};
174
170struct imxdma_engine { 175struct 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
188static 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};
202MODULE_DEVICE_TABLE(platform, imx_dma_devtype);
203
204static inline int is_imx1_dma(struct imxdma_engine *imxdma)
205{
206 return imxdma->devtype == IMX1_DMA;
207}
208
209static inline int is_imx21_dma(struct imxdma_engine *imxdma)
210{
211 return imxdma->devtype == IMX21_DMA;
212}
213
214static inline int is_imx27_dma(struct imxdma_engine *imxdma)
215{
216 return imxdma->devtype == IMX27_DMA;
217}
218
182static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan) 219static 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
213static int imxdma_hw_chain(struct imxdma_channel *imxdmac) 250static 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
diff --git a/include/linux/platform_data/dma-imx.h b/include/linux/platform_data/dma-imx.h
index 1b9080385b46..f6d30cc1cb77 100644
--- a/include/linux/platform_data/dma-imx.h
+++ b/include/linux/platform_data/dma-imx.h
@@ -61,7 +61,9 @@ static inline int imx_dma_is_ipu(struct dma_chan *chan)
61static inline int imx_dma_is_general_purpose(struct dma_chan *chan) 61static inline int imx_dma_is_general_purpose(struct dma_chan *chan)
62{ 62{
63 return strstr(dev_name(chan->device->dev), "sdma") || 63 return strstr(dev_name(chan->device->dev), "sdma") ||
64 !strcmp(dev_name(chan->device->dev), "imx-dma"); 64 !strcmp(dev_name(chan->device->dev), "imx1-dma") ||
65 !strcmp(dev_name(chan->device->dev), "imx21-dma") ||
66 !strcmp(dev_name(chan->device->dev), "imx27-dma");
65} 67}
66 68
67#endif 69#endif