All of lore.kernel.org
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 25/34] dma: imx-dma: remove mach/hardware.h inclusion
Date: Mon, 17 Sep 2012 13:34:54 +0800	[thread overview]
Message-ID: <1347860103-4141-26-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1347860103-4141-1-git-send-email-shawn.guo@linaro.org>

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>
Cc: Vinod Koul <vinod.koul@linux.intel.com>
---
 arch/arm/mach-imx/devices/devices-common.h   |    2 +-
 arch/arm/mach-imx/devices/platform-imx-dma.c |    4 +-
 arch/arm/mach-imx/mm-imx1.c                  |    3 +-
 arch/arm/mach-imx/mm-imx21.c                 |    3 +-
 arch/arm/mach-imx/mm-imx27.c                 |    3 +-
 drivers/dma/imx-dma.c                        |   54 +++++++++++++++++++++++---
 6 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
index a330159..7f2698c 100644
--- a/arch/arm/mach-imx/devices/devices-common.h
+++ b/arch/arm/mach-imx/devices/devices-common.h
@@ -311,7 +311,7 @@ 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(resource_size_t iobase,
+struct platform_device *imx_add_imx_dma(char *name, 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 f9003e4..ccdb5dc 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 @@
  */
 #include "devices-common.h"
 
-struct platform_device __init __maybe_unused *imx_add_imx_dma(
+struct platform_device __init __maybe_unused *imx_add_imx_dma(char *name,
 	resource_size_t iobase, int irq, int irq_err)
 {
 	struct resource res[] = {
@@ -28,7 +28,7 @@ struct platform_device __init __maybe_unused *imx_add_imx_dma(
 	};
 
 	return platform_device_register_resndata(&mxc_ahb_bus,
-			"imx-dma", -1, res, ARRAY_SIZE(res), NULL, 0);
+			name, -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 9de81bf..79f6c0b 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)
 						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);
+	imx_add_imx_dma("imx1-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 1c29515..3b97ea6 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)
 	mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
 
 	pinctrl_provide_dummies();
-	imx_add_imx_dma(MX21_DMA_BASE_ADDR, MX21_INT_DMACH0, 0); /* No ERR irq */
+	imx_add_imx_dma("imx21-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 d389f4a..91e8da8 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)
 	mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0);
 
 	pinctrl_provide_dummies();
-	imx_add_imx_dma(MX27_DMA_BASE_ADDR, MX27_INT_DMACH0, 0); /* No ERR irq */
+	imx_add_imx_dma("imx27-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 a947ce2..960c88b 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -29,7 +29,6 @@
 
 #include <asm/irq.h>
 #include <linux/platform_data/dma-imx.h>
-#include <mach/hardware.h>
 
 #include "dmaengine.h"
 #define IMXDMA_MAX_CHAN_DESCRIPTORS	16
@@ -167,6 +166,12 @@ struct imxdma_channel {
 	int				slot_2d;
 };
 
+enum imx_dma_type {
+	IMX1_DMA,
+	IMX21_DMA,
+	IMX27_DMA,
+};
+
 struct imxdma_engine {
 	struct device			*dev;
 	struct device_dma_parameters	dma_parms;
@@ -177,8 +182,40 @@ struct imxdma_engine {
 	spinlock_t			lock;
 	struct imx_dma_2d_config	slots_2d[IMX_DMA_2D_SLOTS];
 	struct imxdma_channel		channel[IMX_DMA_CHANNELS];
+	enum imx_dma_type		devtype;
 };
 
+static struct platform_device_id imx_dma_devtype[] = {
+	{
+		.name = "imx1-dma",
+		.driver_data = IMX1_DMA,
+	}, {
+		.name = "imx21-dma",
+		.driver_data = IMX21_DMA,
+	}, {
+		.name = "imx27-dma",
+		.driver_data = IMX27_DMA,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, imx_dma_devtype);
+
+static inline int is_imx1_dma(struct imxdma_engine *imxdma)
+{
+	return imxdma->devtype == IMX1_DMA;
+}
+
+static inline int is_imx21_dma(struct imxdma_engine *imxdma)
+{
+	return imxdma->devtype == IMX21_DMA;
+}
+
+static inline int is_imx27_dma(struct imxdma_engine *imxdma)
+{
+	return imxdma->devtype == IMX27_DMA;
+}
+
 static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan)
 {
 	return container_of(chan, struct imxdma_channel, chan);
@@ -212,7 +249,9 @@ static unsigned imx_dmav1_readl(struct imxdma_engine *imxdma, unsigned offset)
 
 static int imxdma_hw_chain(struct imxdma_channel *imxdmac)
 {
-	if (cpu_is_mx27())
+	struct imxdma_engine *imxdma = imxdmac->imxdma;
+
+	if (is_imx27_dma(imxdma))
 		return imxdmac->hw_chaining;
 	else
 		return 0;
@@ -267,7 +306,7 @@ static void imxdma_enable_hw(struct imxdma_desc *d)
 	imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) |
 			 CCR_CEN | CCR_ACRPT, DMA_CCR(channel));
 
-	if ((cpu_is_mx21() || cpu_is_mx27()) &&
+	if (!is_imx1_dma(imxdma) &&
 			d->sg && imxdma_hw_chain(imxdmac)) {
 		d->sg = sg_next(d->sg);
 		if (d->sg) {
@@ -436,7 +475,7 @@ static irqreturn_t dma_irq_handler(int irq, void *dev_id)
 	struct imxdma_engine *imxdma = dev_id;
 	int i, disr;
 
-	if (cpu_is_mx21() || cpu_is_mx27())
+	if (!is_imx1_dma(imxdma))
 		imxdma_err_handler(irq, dev_id);
 
 	disr = imx_dmav1_readl(imxdma, DMA_DISR);
@@ -967,6 +1006,8 @@ static int __init imxdma_probe(struct platform_device *pdev)
 	if (!imxdma)
 		return -ENOMEM;
 
+	imxdma->devtype = pdev->id_entry->driver_data;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	imxdma->base = devm_request_and_ioremap(&pdev->dev, res);
 	if (!imxdma->base)
@@ -990,7 +1031,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
 	/* reset DMA module */
 	imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR);
 
-	if (cpu_is_mx1()) {
+	if (is_imx1_dma(imxdma)) {
 		ret = devm_request_irq(&pdev->dev, irq,
 				       dma_irq_handler, 0, "DMA", imxdma);
 		if (ret) {
@@ -1038,7 +1079,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
 	for (i = 0; i < IMX_DMA_CHANNELS; i++) {
 		struct imxdma_channel *imxdmac = &imxdma->channel[i];
 
-		if (cpu_is_mx21() || cpu_is_mx27()) {
+		if (!is_imx1_dma(imxdma)) {
 			ret = devm_request_irq(&pdev->dev, irq + i,
 					dma_irq_handler, 0, "DMA", imxdma);
 			if (ret) {
@@ -1118,6 +1159,7 @@ static struct platform_driver imxdma_driver = {
 	.driver		= {
 		.name	= "imx-dma",
 	},
+	.id_table	= imx_dma_devtype,
 	.remove		= __exit_p(imxdma_remove),
 };
 
-- 
1.7.9.5

  parent reply	other threads:[~2012-09-17  5:34 UTC|newest]

Thread overview: 157+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17  5:34 [PATCH 00/34] i.MX multi-platform support Shawn Guo
2012-09-17  5:34 ` Shawn Guo
2012-09-17  5:34 ` Shawn Guo
2012-09-17  5:34 ` Shawn Guo
2012-09-17  5:34 ` Shawn Guo
2012-09-17  5:34 ` [PATCH 01/34] ARM: imx: include board headers in the same folder Shawn Guo
2012-09-17  5:34 ` [PATCH 02/34] ASoC: mx27vis: retrieve gpio numbers from platform_data Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  9:19   ` javier Martin
2012-09-17  9:19     ` javier Martin
2012-09-17 11:07   ` Mark Brown
2012-09-17 11:07     ` Mark Brown
2012-09-20  1:14     ` Shawn Guo
2012-09-20  1:14       ` Shawn Guo
2012-09-20  1:26       ` Mark Brown
2012-09-20  1:26         ` Mark Brown
2012-09-20  2:20         ` Shawn Guo
2012-09-20  2:20           ` Shawn Guo
2012-09-17  5:34 ` [PATCH 03/34] ARM: imx: move iomux drivers and headers into mach-imx Shawn Guo
2012-09-17  5:34 ` [PATCH 04/34] ARM: imx: remove unnecessary inclusion from device-imx*.h Shawn Guo
2012-09-17  5:34 ` [PATCH 05/34] ARM: imx: move platform device code into mach-imx Shawn Guo
2012-09-17  5:34 ` [PATCH 06/34] ARM: imx: merge plat-mxc " Shawn Guo
2012-09-18  8:08   ` Shawn Guo
2012-09-17  5:34 ` [PATCH 07/34] ARM: imx: include common.h rather than mach/common.h Shawn Guo
2012-09-17  5:34 ` [PATCH 08/34] ARM: imx: ARM: imx: include cpuidle.h rather than mach/cpuidle.h Shawn Guo
2012-09-17  5:34 ` [PATCH 09/34] ARM: imx: include iim.h rather than mach/iim.h Shawn Guo
2012-09-17  5:34 ` [PATCH 10/34] ARM: imx: include iram.h rather than mach/iram.h Shawn Guo
2012-09-17  5:34 ` [PATCH 11/34] ARM: imx: include ulpi.h rather than mach/ulpi.h Shawn Guo
2012-09-17  5:34 ` [PATCH 12/34] media: mx1_camera: remove the driver Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  8:33   ` Guennadi Liakhovetski
2012-09-17  8:33     ` Guennadi Liakhovetski
2012-09-18  1:28     ` Shawn Guo
2012-09-18  1:28       ` Shawn Guo
2012-09-18  9:13       ` Arnd Bergmann
2012-09-18  9:13         ` Arnd Bergmann
2012-09-20  1:35         ` Shawn Guo
2012-09-20  1:35           ` Shawn Guo
2012-09-17  5:34 ` [PATCH 13/34] ARM: imx: remove mach/dma-mx1-mx2.h Shawn Guo
2012-09-17  5:34 ` [PATCH 14/34] dma: ipu: rename mach/ipu.h to include/linux/dma/ipu-dma.h Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  9:26   ` Guennadi Liakhovetski
2012-09-17  9:26     ` Guennadi Liakhovetski
2012-09-17  9:26     ` Guennadi Liakhovetski
2012-09-27  7:38     ` Mauro Carvalho Chehab
2012-09-27  7:38       ` Mauro Carvalho Chehab
2012-09-27  7:38       ` Mauro Carvalho Chehab
2012-09-17  5:34 ` [PATCH 15/34] dma: imx-sdma: remove unneeded mach/hardware.h inclusion Shawn Guo
2012-09-17  5:34 ` [PATCH 16/34] ASoC: imx-ssi: " Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17 11:45   ` Mark Brown
2012-09-17 11:45     ` Mark Brown
2012-09-17 14:30     ` Arnd Bergmann
2012-09-17 14:30       ` Arnd Bergmann
2012-09-19  3:23       ` Mark Brown
2012-09-19  3:23         ` Mark Brown
2012-09-19  8:01         ` Arnd Bergmann
2012-09-19  8:01           ` Arnd Bergmann
2012-09-19 11:44           ` Mark Brown
2012-09-19 11:44             ` Mark Brown
2012-09-17  5:34 ` [PATCH 17/34] usb: ehci-mxc: " Shawn Guo
2012-09-17 11:18   ` Greg Kroah-Hartman
2012-09-17  5:34 ` [PATCH 18/34] video: mx3fb: " Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  5:34 ` [PATCH 19/34] watchdog: imx2_wdt: " Shawn Guo
2012-09-17  5:34   ` Shawn Guo
     [not found] ` <1347860103-4141-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-09-17  5:34   ` [PATCH 20/34] i2c: imx: remove " Shawn Guo
2012-09-17  5:34     ` Shawn Guo
2012-09-17  5:34 ` [PATCH 21/34] mtd: mxc_nand: " Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  5:34 ` [PATCH 22/34] rtc: mxc_rtc: " Shawn Guo
2012-09-17  5:34 ` [PATCH 23/34] dma: imx-dma: use devm_kzalloc and devm_request_irq Shawn Guo
2012-09-17  5:34 ` [PATCH 24/34] dma: imx-dma: retrieve MEM and IRQ from resources Shawn Guo
2012-09-17  5:34 ` Shawn Guo [this message]
2012-09-17  7:58   ` [PATCH 25/34] dma: imx-dma: remove mach/hardware.h inclusion Sascha Hauer
2012-09-18  1:40     ` Shawn Guo
2012-09-21  2:49     ` Shawn Guo
2012-09-17  5:34 ` [PATCH 26/34] media: mx2_camera: remove dead code in mx2_camera_add_device Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  8:18   ` Guennadi Liakhovetski
2012-09-17  8:18     ` Guennadi Liakhovetski
2012-09-17 13:36     ` javier Martin
2012-09-17 13:36       ` javier Martin
2012-09-18  1:49     ` Shawn Guo
2012-09-18  1:49       ` Shawn Guo
2012-09-17  5:34 ` [PATCH 27/34] media: mx2_camera: use managed functions to clean up code Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  9:11   ` Guennadi Liakhovetski
2012-09-17  9:11     ` Guennadi Liakhovetski
2012-09-17 13:36     ` javier Martin
2012-09-17 13:36       ` javier Martin
2012-09-18  7:43       ` Shawn Guo
2012-09-18  7:43         ` Shawn Guo
2012-09-18  8:34         ` javier Martin
2012-09-18  8:34           ` javier Martin
2012-09-17  5:34 ` [PATCH 28/34] media: mx2_camera: remove mach/hardware.h inclusion Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  9:21   ` Guennadi Liakhovetski
2012-09-17  9:21     ` Guennadi Liakhovetski
2012-09-17 13:43     ` javier Martin
2012-09-17 13:43       ` javier Martin
2012-09-17 13:59       ` Guennadi Liakhovetski
2012-09-17 13:59         ` Guennadi Liakhovetski
2012-09-18  8:35         ` javier Martin
2012-09-18  8:35           ` javier Martin
2012-09-27  7:36           ` Mauro Carvalho Chehab
2012-09-27  7:36             ` Mauro Carvalho Chehab
2012-10-06  8:16             ` Shawn Guo
2012-10-06  8:16               ` Shawn Guo
2012-09-17  5:34 ` [PATCH 29/34] mmc: mxcmmc: " Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  5:41   ` Chris Ball
2012-09-17  5:41     ` Chris Ball
2012-09-18  9:18     ` javier Martin
2012-09-18  9:18       ` javier Martin
2012-09-17  5:34 ` [PATCH 30/34] video: imxfb: " Shawn Guo
2012-09-17  5:34   ` Shawn Guo
2012-09-17  5:35 ` [PATCH 31/34] ARM: imx: move debug macros to include/debug Shawn Guo
2012-09-17  5:35 ` [PATCH 32/34] ARM: imx: include hardware.h rather than mach/hardware.h Shawn Guo
2012-09-17  5:35 ` [PATCH 33/34] ARM: imx: remove header file mach/irqs.h Shawn Guo
2012-09-17  5:35   ` Shawn Guo
2012-09-17 11:32   ` Arnd Bergmann
2012-09-17 11:32     ` Arnd Bergmann
2012-09-18  8:13     ` Shawn Guo
2012-09-18  8:13       ` Shawn Guo
2012-09-17 11:46   ` Mark Brown
2012-09-17 11:46     ` Mark Brown
2012-09-17  5:35 ` [PATCH 34/34] ARM: imx: enable multi-platform build Shawn Guo
2012-09-17 11:44   ` Arnd Bergmann
2012-09-17  7:51 ` [PATCH 00/34] i.MX multi-platform support Sascha Hauer
2012-09-17  7:51   ` Sascha Hauer
2012-09-17  7:51   ` Sascha Hauer
2012-09-17  7:51   ` Sascha Hauer
2012-09-17  7:51   ` Sascha Hauer
2012-09-17 11:38   ` Arnd Bergmann
2012-09-17 11:38     ` Arnd Bergmann
2012-09-17 11:38     ` Arnd Bergmann
2012-09-17 11:38     ` Arnd Bergmann
2012-09-18  8:20   ` Shawn Guo
2012-09-18  8:20     ` Shawn Guo
2012-09-18  8:20     ` Shawn Guo
2012-09-18  8:20     ` Shawn Guo
2012-09-18  8:20     ` Shawn Guo
2012-09-18  7:52 ` Sascha Hauer
2012-09-18  7:52   ` Sascha Hauer
2012-09-18  7:52   ` Sascha Hauer
2012-09-18  7:52   ` Sascha Hauer
2012-09-18  7:52   ` Sascha Hauer
2012-09-18  8:05   ` [alsa-devel] " Shawn Guo
2012-09-18  8:05     ` Shawn Guo
2012-09-18  8:05     ` Shawn Guo
2012-09-18  8:05     ` Shawn Guo
2012-09-18  8:05     ` Shawn Guo
2012-09-17 15:35 [PATCH 25/34] dma: imx-dma: remove mach/hardware.h inclusion javier Martin
2012-09-18  7:23 ` javier Martin
2012-09-18  7:44   ` Shawn Guo

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=1347860103-4141-26-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.