dma: imx-dma: retrieve MEM and IRQ from resources
authorShawn Guo <shawn.guo@linaro.org>
Sat, 15 Sep 2012 07:57:00 +0000 (15:57 +0800)
committerShawn Guo <shawn.guo@linaro.org>
Mon, 15 Oct 2012 02:03:17 +0000 (10:03 +0800)
Retrieve MEM and IRQ from resources rather than directly using the
value by including machine header.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Vinod Koul <vinod.koul@linux.intel.com>
arch/arm/mach-imx/devices/devices-common.h
arch/arm/mach-imx/devices/platform-imx-dma.c
arch/arm/mach-imx/mm-imx1.c
arch/arm/mach-imx/mm-imx21.c
arch/arm/mach-imx/mm-imx27.c
drivers/dma/imx-dma.c

index 1472f0fc325cafb76c9012ad3aff091a01e8b0d9..e4368f6c5fb4630139076f5825cd423c01210508 100644 (file)
@@ -329,7 +329,8 @@ struct platform_device *__init imx_add_spi_imx(
                const struct imx_spi_imx_data *data,
                const struct spi_imx_master *pdata);
 
-struct platform_device *imx_add_imx_dma(void);
+struct platform_device *imx_add_imx_dma(resource_size_t iobase,
+                                       int irq, int irq_err);
 struct platform_device *imx_add_imx_sdma(char *name,
        resource_size_t iobase, int irq, struct sdma_platform_data *pdata);
 
index c35c99d218203c7e0fd5baffbb068fb53497c2f6..f9003e4d0f5759c4731801894216ee7bb02e2306 100644 (file)
@@ -8,10 +8,27 @@
  */
 #include "devices-common.h"
 
-struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
+struct platform_device __init __maybe_unused *imx_add_imx_dma(
+       resource_size_t iobase, int irq, int irq_err)
 {
+       struct resource res[] = {
+               {
+                       .start = iobase,
+                       .end = iobase + SZ_4K - 1,
+                       .flags = IORESOURCE_MEM,
+               }, {
+                       .start = irq,
+                       .end = irq,
+                       .flags = IORESOURCE_IRQ,
+               }, {
+                       .start = irq_err,
+                       .end = irq_err,
+                       .flags = IORESOURCE_IRQ,
+               },
+       };
+
        return platform_device_register_resndata(&mxc_ahb_bus,
-                       "imx-dma", -1, NULL, 0, NULL, 0);
+                       "imx-dma", -1, res, ARRAY_SIZE(res), NULL, 0);
 }
 
 struct platform_device __init __maybe_unused *imx_add_imx_sdma(char *name,
index 118aa928cd8b6a0fe330d24c0b97fe7263c6346d..9de81bf6de96046808eb22612846ff69f029d39f 100644 (file)
@@ -25,6 +25,7 @@
 #include <mach/hardware.h>
 
 #include "common.h"
+#include "devices/devices-common.h"
 #include "iomux-v1.h"
 
 static struct map_desc imx_io_desc[] __initdata = {
@@ -59,5 +60,6 @@ void __init imx1_soc_init(void)
                                                MX1_GPIO_INT_PORTC, 0);
        mxc_register_gpio("imx1-gpio", 3, MX1_GPIO4_BASE_ADDR, SZ_256,
                                                MX1_GPIO_INT_PORTD, 0);
+       imx_add_imx_dma(MX1_DMA_BASE_ADDR, MX1_DMA_INT, MX1_DMA_ERR);
        pinctrl_provide_dummies();
 }
index 0c24556f299b8b37e54b2a8f7435a684053c11f7..1c295154c296ed93e829b6c3d610781d490afeb7 100644 (file)
@@ -90,7 +90,7 @@ void __init imx21_soc_init(void)
        mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
 
        pinctrl_provide_dummies();
-       imx_add_imx_dma();
+       imx_add_imx_dma(MX21_DMA_BASE_ADDR, MX21_INT_DMACH0, 0); /* No ERR irq */
        platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res,
                                        ARRAY_SIZE(imx21_audmux_res));
 }
index 3241314b4f2f5efbe863cc36f45652618f79152c..d389f4af33c02d58526d641a441d5da0459beca2 100644 (file)
@@ -91,7 +91,7 @@ void __init imx27_soc_init(void)
        mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0);
 
        pinctrl_provide_dummies();
-       imx_add_imx_dma();
+       imx_add_imx_dma(MX27_DMA_BASE_ADDR, MX27_INT_DMACH0, 0); /* No ERR irq */
        /* imx27 has the imx21 type audmux */
        platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res,
                                        ARRAY_SIZE(imx27_audmux_res));
index 1f2b79009d6957d1905ecbf7d896eb9af0eb3ab2..88e8a8d89b56dc6d86fd6957c3edf97e33bcd0a4 100644 (file)
@@ -959,23 +959,22 @@ static void imxdma_issue_pending(struct dma_chan *chan)
 static int __init imxdma_probe(struct platform_device *pdev)
        {
        struct imxdma_engine *imxdma;
+       struct resource *res;
        int ret, i;
-
+       int irq, irq_err;
 
        imxdma = devm_kzalloc(&pdev->dev, sizeof(*imxdma), GFP_KERNEL);
        if (!imxdma)
                return -ENOMEM;
 
-       if (cpu_is_mx1()) {
-               imxdma->base = MX1_IO_ADDRESS(MX1_DMA_BASE_ADDR);
-       } else if (cpu_is_mx21()) {
-               imxdma->base = MX21_IO_ADDRESS(MX21_DMA_BASE_ADDR);
-       } else if (cpu_is_mx27()) {
-               imxdma->base = MX27_IO_ADDRESS(MX27_DMA_BASE_ADDR);
-       } else {
-               kfree(imxdma);
-               return 0;
-       }
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       imxdma->base = devm_request_and_ioremap(&pdev->dev, res);
+       if (!imxdma->base)
+               return -EADDRNOTAVAIL;
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0)
+               return irq;
 
        imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg");
        if (IS_ERR(imxdma->dma_ipg))
@@ -992,14 +991,20 @@ static int __init imxdma_probe(struct platform_device *pdev)
        imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR);
 
        if (cpu_is_mx1()) {
-               ret = devm_request_irq(&pdev->dev, MX1_DMA_INT,
+               ret = devm_request_irq(&pdev->dev, irq,
                                       dma_irq_handler, 0, "DMA", imxdma);
                if (ret) {
                        dev_warn(imxdma->dev, "Can't register IRQ for DMA\n");
                        goto err;
                }
 
-               ret = devm_request_irq(&pdev->dev, MX1_DMA_ERR,
+               irq_err = platform_get_irq(pdev, 1);
+               if (irq_err < 0) {
+                       ret = irq_err;
+                       goto err;
+               }
+
+               ret = devm_request_irq(&pdev->dev, irq_err,
                                       imxdma_err_handler, 0, "DMA", imxdma);
                if (ret) {
                        dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n");
@@ -1034,12 +1039,12 @@ static int __init imxdma_probe(struct platform_device *pdev)
                struct imxdma_channel *imxdmac = &imxdma->channel[i];
 
                if (cpu_is_mx21() || cpu_is_mx27()) {
-                       ret = devm_request_irq(&pdev->dev, MX2x_INT_DMACH0 + i,
+                       ret = devm_request_irq(&pdev->dev, irq + i,
                                        dma_irq_handler, 0, "DMA", imxdma);
                        if (ret) {
                                dev_warn(imxdma->dev, "Can't register IRQ %d "
                                         "for DMA channel %d\n",
-                                        MX2x_INT_DMACH0 + i, i);
+                                        irq + i, i);
                                goto err;
                        }
                        init_timer(&imxdmac->watchdog);