linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 23/34] dma: imx-dma: retrieve MEM and IRQ from resources
Date: Thu, 20 Sep 2012 14:45:36 +0800	[thread overview]
Message-ID: <1348123547-31082-24-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1348123547-31082-1-git-send-email-shawn.guo@linaro.org>

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   |    3 ++-
 arch/arm/mach-imx/devices/platform-imx-dma.c |   21 ++++++++++++++--
 arch/arm/mach-imx/mm-imx1.c                  |    2 ++
 arch/arm/mach-imx/mm-imx21.c                 |    2 +-
 arch/arm/mach-imx/mm-imx27.c                 |    2 +-
 drivers/dma/imx-dma.c                        |   35 +++++++++++++++-----------
 6 files changed, 45 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
index 73ae524..a330159 100644
--- a/arch/arm/mach-imx/devices/devices-common.h
+++ b/arch/arm/mach-imx/devices/devices-common.h
@@ -311,7 +311,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);
 
diff --git a/arch/arm/mach-imx/devices/platform-imx-dma.c b/arch/arm/mach-imx/devices/platform-imx-dma.c
index c35c99d..f9003e4 100644
--- a/arch/arm/mach-imx/devices/platform-imx-dma.c
+++ b/arch/arm/mach-imx/devices/platform-imx-dma.c
@@ -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,
diff --git a/arch/arm/mach-imx/mm-imx1.c b/arch/arm/mach-imx/mm-imx1.c
index 118aa92..9de81bf 100644
--- a/arch/arm/mach-imx/mm-imx1.c
+++ b/arch/arm/mach-imx/mm-imx1.c
@@ -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();
 }
diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c
index 0c24556..1c29515 100644
--- a/arch/arm/mach-imx/mm-imx21.c
+++ b/arch/arm/mach-imx/mm-imx21.c
@@ -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));
 }
diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
index 3241314..d389f4a 100644
--- a/arch/arm/mach-imx/mm-imx27.c
+++ b/arch/arm/mach-imx/mm-imx27.c
@@ -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));
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index 64ba65b..a947ce2 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -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);
-- 
1.7.9.5

  parent reply	other threads:[~2012-09-20  6:45 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-20  6:45 [PATCH v2 00/34] i.MX multi-platform support Shawn Guo
2012-09-20  6:45 ` [PATCH v2 01/34] ARM: imx: include board headers in the same folder Shawn Guo
2012-09-20  6:45 ` [PATCH v2 02/34] ARM: imx: move iomux drivers and headers into mach-imx Shawn Guo
2012-09-20  6:45 ` [PATCH v2 03/34] ARM: imx: remove unnecessary inclusion from device-imx*.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 04/34] ARM: imx: move platform device code into mach-imx Shawn Guo
2012-09-20  6:45 ` [PATCH v2 05/34] ARM: imx: merge plat-mxc " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 06/34] ARM: imx: include common.h rather than mach/common.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 07/34] ARM: imx: ARM: imx: include cpuidle.h rather than mach/cpuidle.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 08/34] ARM: imx: include iim.h rather than mach/iim.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 09/34] ARM: imx: include iram.h rather than mach/iram.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 10/34] ARM: imx: include ulpi.h rather than mach/ulpi.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 11/34] media: mx1_camera: remove the driver Shawn Guo
2012-09-20 12:56   ` Mauro Carvalho Chehab
2012-09-20 14:47     ` Shawn Guo
2012-09-20  6:45 ` [PATCH v2 12/34] ARM: imx: remove mach/dma-mx1-mx2.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 13/34] dma: ipu: rename mach/ipu.h to include/linux/dma/ipu-dma.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 14/34] dma: imx-sdma: remove unneeded mach/hardware.h inclusion Shawn Guo
2012-09-20  6:45 ` [PATCH v2 15/34] ASoC: imx-ssi: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 16/34] usb: ehci-mxc: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 17/34] video: mx3fb: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 18/34] watchdog: imx2_wdt: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 19/34] i2c: imx: remove cpu_is_xxx by using platform_device_id Shawn Guo
2012-09-20  6:45 ` [PATCH v2 20/34] mtd: mxc_nand: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 21/34] rtc: mxc_rtc: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 22/34] dma: imx-dma: use devm_kzalloc and devm_request_irq Shawn Guo
2012-09-20  6:45 ` Shawn Guo [this message]
2012-09-20  6:45 ` [PATCH v2 24/34] dma: imx-dma: remove cpu_is_xxx by using platform_device_id Shawn Guo
2012-09-20  6:45 ` [PATCH v2 25/34] media: mx2_camera: remove dead code in mx2_camera_add_device Shawn Guo
2012-09-20  6:45 ` [PATCH v2 26/34] media: mx2_camera: use managed functions to clean up code Shawn Guo
2012-09-20  6:45 ` [PATCH v2 27/34] media: mx2_camera: remove cpu_is_xxx by using platform_device_id Shawn Guo
2012-09-27 19:03   ` Mauro Carvalho Chehab
2012-10-06  8:26     ` Shawn Guo
2012-10-06 14:39       ` Mauro Carvalho Chehab
2012-09-20  6:45 ` [PATCH v2 28/34] mmc: mxcmmc: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 29/34] video: imxfb: " Shawn Guo
2012-09-20  6:45 ` [PATCH v2 30/34] ARM: imx: move debug macros to include/debug Shawn Guo
2012-09-20  6:45 ` [PATCH v2 31/34] ARM: imx: include hardware.h rather than mach/hardware.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 32/34] ARM: imx: remove header file mach/irqs.h Shawn Guo
2012-09-20  6:45 ` [PATCH v2 33/34] ARM: imx: call mxc_device_init() in soc specific function Shawn Guo
2012-09-20  6:45 ` [PATCH v2 34/34] ARM: imx: enable multi-platform build Shawn Guo
2012-09-20  7:39 ` [PATCH v2 00/34] i.MX multi-platform support Arnd Bergmann
2012-09-20 11:41   ` Mark Brown
2012-09-20 11:52     ` Shawn Guo
2012-09-20 12:47       ` Mark Brown
2012-09-20 13:36         ` Shawn Guo
2012-09-20 14:53   ` Shawn Guo
2012-09-20 15:56     ` Arnd Bergmann
2012-09-21  8:01       ` [alsa-devel] " Shawn Guo
2012-09-21  8:26         ` Olof Johansson
2012-09-21 16:46           ` Shawn Guo
2012-09-21 16:53             ` Shawn Guo
2012-09-22  7:41               ` Olof Johansson
2012-09-22  8:09                 ` Olof Johansson
2012-09-22  9:34                   ` Shawn Guo
2012-09-22 15:43           ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348123547-31082-24-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).