All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Add device tree support for mxs-mmc
@ 2012-05-07 14:43 ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

This series adds device tree support for mxs-mmc based on mxs
common-clk, pinctrl, and DT support for mxs gpio and dma.

Shawn Guo (10):
  mmc: mxs-mmc: use global stmp_device functionality
  mmc: mxs-mmc: let ssp_is_old take host as parameter
  mmc: mxs-mmc: get rid of the use of cpu_is_xxx
  mmc: mxs-mmc: move header from mach into linux folder
  mmc: mxs-mmc: use devm_* helper to make cleanup simpler
  mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host
  mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
  mmc: mxs-mmc: add device tree support
  ARM: dts: enable mmc for imx23-evk
  ARM: dts: enable mmc for imx28-evk

 Documentation/devicetree/bindings/mmc/mxs-mmc.txt  |   26 +++
 arch/arm/boot/dts/imx23-evk.dts                    |   11 +
 arch/arm/boot/dts/imx23.dtsi                       |   19 ++
 arch/arm/boot/dts/imx28-evk.dts                    |   19 ++
 arch/arm/boot/dts/imx28.dtsi                       |   25 +++
 arch/arm/mach-mxs/devices/platform-mxs-mmc.c       |   21 +-
 arch/arm/mach-mxs/include/mach/devices-common.h    |    3 +-
 drivers/clk/mxs/clk-imx23.c                        |    4 +-
 drivers/clk/mxs/clk-imx28.c                        |    8 +-
 drivers/mmc/host/mxs-mmc.c                         |  199 +++++++++++---------
 .../mach/mmc.h => include/linux/mmc/mxs-mmc.h      |    7 +-
 11 files changed, 235 insertions(+), 107 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
 rename arch/arm/mach-mxs/include/mach/mmc.h => include/linux/mmc/mxs-mmc.h (81%)

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 00/10] Add device tree support for mxs-mmc
@ 2012-05-07 14:43 ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

This series adds device tree support for mxs-mmc based on mxs
common-clk, pinctrl, and DT support for mxs gpio and dma.

Shawn Guo (10):
  mmc: mxs-mmc: use global stmp_device functionality
  mmc: mxs-mmc: let ssp_is_old take host as parameter
  mmc: mxs-mmc: get rid of the use of cpu_is_xxx
  mmc: mxs-mmc: move header from mach into linux folder
  mmc: mxs-mmc: use devm_* helper to make cleanup simpler
  mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host
  mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
  mmc: mxs-mmc: add device tree support
  ARM: dts: enable mmc for imx23-evk
  ARM: dts: enable mmc for imx28-evk

 Documentation/devicetree/bindings/mmc/mxs-mmc.txt  |   26 +++
 arch/arm/boot/dts/imx23-evk.dts                    |   11 +
 arch/arm/boot/dts/imx23.dtsi                       |   19 ++
 arch/arm/boot/dts/imx28-evk.dts                    |   19 ++
 arch/arm/boot/dts/imx28.dtsi                       |   25 +++
 arch/arm/mach-mxs/devices/platform-mxs-mmc.c       |   21 +-
 arch/arm/mach-mxs/include/mach/devices-common.h    |    3 +-
 drivers/clk/mxs/clk-imx23.c                        |    4 +-
 drivers/clk/mxs/clk-imx28.c                        |    8 +-
 drivers/mmc/host/mxs-mmc.c                         |  199 +++++++++++---------
 .../mach/mmc.h => include/linux/mmc/mxs-mmc.h      |    7 +-
 11 files changed, 235 insertions(+), 107 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
 rename arch/arm/mach-mxs/include/mach/mmc.h => include/linux/mmc/mxs-mmc.h (81%)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 01/10] mmc: mxs-mmc: use global stmp_device functionality
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

Use global stmp_device functionality to reduce mach-dependency.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index bb03ddd..2ea5361 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -40,9 +40,9 @@
 #include <linux/module.h>
 #include <linux/fsl/mxs-dma.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/stmp_device.h>
 
 #include <mach/mxs.h>
-#include <mach/common.h>
 #include <mach/mmc.h>
 
 #define DRIVER_NAME	"mxs-mmc"
@@ -191,7 +191,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 {
 	u32 ctrl0, ctrl1;
 
-	mxs_reset_block(host->base);
+	stmp_reset_block(host->base);
 
 	ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
 	ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
@@ -279,7 +279,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
 
 	stat = readl(host->base + HW_SSP_CTRL1);
 	writel(stat & MXS_MMC_IRQ_BITS,
-	       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
+	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
 
 	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
 		mmc_signal_sdio_irq(host->mmc);
@@ -637,18 +637,18 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 
 	if (enable) {
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
-		       host->base + HW_SSP_CTRL0 + MXS_SET_ADDR);
+		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + MXS_SET_ADDR);
+		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
 
 		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
 			mmc_signal_sdio_irq(host->mmc);
 
 	} else {
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
-		       host->base + HW_SSP_CTRL0 + MXS_CLR_ADDR);
+		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
+		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
 	}
 
 	spin_unlock_irqrestore(&host->lock, flags);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 01/10] mmc: mxs-mmc: use global stmp_device functionality
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Use global stmp_device functionality to reduce mach-dependency.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index bb03ddd..2ea5361 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -40,9 +40,9 @@
 #include <linux/module.h>
 #include <linux/fsl/mxs-dma.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/stmp_device.h>
 
 #include <mach/mxs.h>
-#include <mach/common.h>
 #include <mach/mmc.h>
 
 #define DRIVER_NAME	"mxs-mmc"
@@ -191,7 +191,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 {
 	u32 ctrl0, ctrl1;
 
-	mxs_reset_block(host->base);
+	stmp_reset_block(host->base);
 
 	ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
 	ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
@@ -279,7 +279,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
 
 	stat = readl(host->base + HW_SSP_CTRL1);
 	writel(stat & MXS_MMC_IRQ_BITS,
-	       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
+	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
 
 	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
 		mmc_signal_sdio_irq(host->mmc);
@@ -637,18 +637,18 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 
 	if (enable) {
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
-		       host->base + HW_SSP_CTRL0 + MXS_SET_ADDR);
+		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + MXS_SET_ADDR);
+		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
 
 		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
 			mmc_signal_sdio_irq(host->mmc);
 
 	} else {
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
-		       host->base + HW_SSP_CTRL0 + MXS_CLR_ADDR);
+		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
+		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
 	}
 
 	spin_unlock_irqrestore(&host->lock, flags);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

Let macro ssp_is_old take host as parameter to make the code easy
to read.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   59 ++++++++++++++++++++++---------------------
 1 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 2ea5361..13907e4 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -51,7 +51,7 @@
 #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
 
 #define SSP_VERSION_LATEST	4
-#define ssp_is_old()		(host->version < SSP_VERSION_LATEST)
+#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
 
 /* SSP registers */
 #define HW_SSP_CTRL0				0x000
@@ -86,14 +86,14 @@
 #define  BM_SSP_BLOCK_SIZE_BLOCK_COUNT		(0xffffff << 4)
 #define  BP_SSP_BLOCK_SIZE_BLOCK_SIZE		(0)
 #define  BM_SSP_BLOCK_SIZE_BLOCK_SIZE		(0xf)
-#define HW_SSP_TIMING				(ssp_is_old() ? 0x050 : 0x070)
+#define HW_SSP_TIMING(h)			(ssp_is_old(h) ? 0x050 : 0x070)
 #define  BP_SSP_TIMING_TIMEOUT			(16)
 #define  BM_SSP_TIMING_TIMEOUT			(0xffff << 16)
 #define  BP_SSP_TIMING_CLOCK_DIVIDE		(8)
 #define  BM_SSP_TIMING_CLOCK_DIVIDE		(0xff << 8)
 #define  BP_SSP_TIMING_CLOCK_RATE		(0)
 #define  BM_SSP_TIMING_CLOCK_RATE		(0xff)
-#define HW_SSP_CTRL1				(ssp_is_old() ? 0x060 : 0x080)
+#define HW_SSP_CTRL1(h)				(ssp_is_old(h) ? 0x060 : 0x080)
 #define  BM_SSP_CTRL1_SDIO_IRQ			(1 << 31)
 #define  BM_SSP_CTRL1_SDIO_IRQ_EN		(1 << 30)
 #define  BM_SSP_CTRL1_RESP_ERR_IRQ		(1 << 29)
@@ -116,11 +116,11 @@
 #define  BM_SSP_CTRL1_WORD_LENGTH		(0xf << 4)
 #define  BP_SSP_CTRL1_SSP_MODE			(0)
 #define  BM_SSP_CTRL1_SSP_MODE			(0xf)
-#define HW_SSP_SDRESP0				(ssp_is_old() ? 0x080 : 0x0a0)
-#define HW_SSP_SDRESP1				(ssp_is_old() ? 0x090 : 0x0b0)
-#define HW_SSP_SDRESP2				(ssp_is_old() ? 0x0a0 : 0x0c0)
-#define HW_SSP_SDRESP3				(ssp_is_old() ? 0x0b0 : 0x0d0)
-#define HW_SSP_STATUS				(ssp_is_old() ? 0x0c0 : 0x100)
+#define HW_SSP_SDRESP0(h)			(ssp_is_old(h) ? 0x080 : 0x0a0)
+#define HW_SSP_SDRESP1(h)			(ssp_is_old(h) ? 0x090 : 0x0b0)
+#define HW_SSP_SDRESP2(h)			(ssp_is_old(h) ? 0x0a0 : 0x0c0)
+#define HW_SSP_SDRESP3(h)			(ssp_is_old(h) ? 0x0b0 : 0x0d0)
+#define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
 #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
 #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
 #define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 0x130)
@@ -183,7 +183,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
 {
 	struct mxs_mmc_host *host = mmc_priv(mmc);
 
-	return !(readl(host->base + HW_SSP_STATUS) &
+	return !(readl(host->base + HW_SSP_STATUS(host)) &
 		 BM_SSP_STATUS_CARD_DETECT);
 }
 
@@ -207,7 +207,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 	writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
 	       BF_SSP(2, TIMING_CLOCK_DIVIDE) |
 	       BF_SSP(0, TIMING_CLOCK_RATE),
-	       host->base + HW_SSP_TIMING);
+	       host->base + HW_SSP_TIMING(host));
 
 	if (host->sdio_irq_en) {
 		ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
@@ -215,7 +215,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 	}
 
 	writel(ctrl0, host->base + HW_SSP_CTRL0);
-	writel(ctrl1, host->base + HW_SSP_CTRL1);
+	writel(ctrl1, host->base + HW_SSP_CTRL1(host));
 }
 
 static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
@@ -229,12 +229,12 @@ static void mxs_mmc_request_done(struct mxs_mmc_host *host)
 
 	if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
 		if (mmc_resp_type(cmd) & MMC_RSP_136) {
-			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0);
-			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1);
-			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2);
-			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3);
+			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0(host));
+			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1(host));
+			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2(host));
+			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3(host));
 		} else {
-			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0);
+			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0(host));
 		}
 	}
 
@@ -277,11 +277,11 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
 
 	spin_lock(&host->lock);
 
-	stat = readl(host->base + HW_SSP_CTRL1);
+	stat = readl(host->base + HW_SSP_CTRL1(host));
 	writel(stat & MXS_MMC_IRQ_BITS,
-	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
+	       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
 
-	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
+	if ((sta & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
 		mmc_signal_sdio_irq(host->mmc);
 
 	spin_unlock(&host->lock);
@@ -485,7 +485,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
 		blocks = 1;
 
 	/* xfer count, block size and count need to be set differently */
-	if (ssp_is_old()) {
+	if (ssp_is_old(host)) {
 		ctrl0 |= BF_SSP(data_size, CTRL0_XFER_COUNT);
 		cmd0 |= BF_SSP(log2_blksz, CMD0_BLOCK_SIZE) |
 			BF_SSP(blocks - 1, CMD0_BLOCK_COUNT);
@@ -509,10 +509,10 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
 
 	/* set the timeout count */
 	timeout = mxs_ns_to_ssp_ticks(host->clk_rate, data->timeout_ns);
-	val = readl(host->base + HW_SSP_TIMING);
+	val = readl(host->base + HW_SSP_TIMING(host));
 	val &= ~(BM_SSP_TIMING_TIMEOUT);
 	val |= BF_SSP(timeout, TIMING_TIMEOUT);
-	writel(val, host->base + HW_SSP_TIMING);
+	writel(val, host->base + HW_SSP_TIMING(host));
 
 	/* pio */
 	host->ssp_pio_words[0] = ctrl0;
@@ -598,11 +598,11 @@ static void mxs_mmc_set_clk_rate(struct mxs_mmc_host *host, unsigned int rate)
 
 	ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
 
-	val = readl(host->base + HW_SSP_TIMING);
+	val = readl(host->base + HW_SSP_TIMING(host));
 	val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
 	val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
 	val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
-	writel(val, host->base + HW_SSP_TIMING);
+	writel(val, host->base + HW_SSP_TIMING(host));
 
 	host->clk_rate = ssp_sck;
 
@@ -639,16 +639,17 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
 		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
+		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_SET);
 
-		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
+		if (readl(host->base + HW_SSP_STATUS(host)) &
+				BM_SSP_STATUS_SDIO_IRQ)
 			mmc_signal_sdio_irq(host->mmc);
 
 	} else {
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
 		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
+		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
 	}
 
 	spin_unlock_irqrestore(&host->lock, flags);
@@ -765,8 +766,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	mmc->max_segs = 52;
 	mmc->max_blk_size = 1 << 0xf;
-	mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff;
-	mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff;
+	mmc->max_blk_count = (ssp_is_old(host)) ? 0xff : 0xffffff;
+	mmc->max_req_size = (ssp_is_old(host)) ? 0xffff : 0xffffffff;
 	mmc->max_seg_size = dma_get_max_seg_size(host->dmach->device->dev);
 
 	platform_set_drvdata(pdev, mmc);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Let macro ssp_is_old take host as parameter to make the code easy
to read.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   59 ++++++++++++++++++++++---------------------
 1 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 2ea5361..13907e4 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -51,7 +51,7 @@
 #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
 
 #define SSP_VERSION_LATEST	4
-#define ssp_is_old()		(host->version < SSP_VERSION_LATEST)
+#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
 
 /* SSP registers */
 #define HW_SSP_CTRL0				0x000
@@ -86,14 +86,14 @@
 #define  BM_SSP_BLOCK_SIZE_BLOCK_COUNT		(0xffffff << 4)
 #define  BP_SSP_BLOCK_SIZE_BLOCK_SIZE		(0)
 #define  BM_SSP_BLOCK_SIZE_BLOCK_SIZE		(0xf)
-#define HW_SSP_TIMING				(ssp_is_old() ? 0x050 : 0x070)
+#define HW_SSP_TIMING(h)			(ssp_is_old(h) ? 0x050 : 0x070)
 #define  BP_SSP_TIMING_TIMEOUT			(16)
 #define  BM_SSP_TIMING_TIMEOUT			(0xffff << 16)
 #define  BP_SSP_TIMING_CLOCK_DIVIDE		(8)
 #define  BM_SSP_TIMING_CLOCK_DIVIDE		(0xff << 8)
 #define  BP_SSP_TIMING_CLOCK_RATE		(0)
 #define  BM_SSP_TIMING_CLOCK_RATE		(0xff)
-#define HW_SSP_CTRL1				(ssp_is_old() ? 0x060 : 0x080)
+#define HW_SSP_CTRL1(h)				(ssp_is_old(h) ? 0x060 : 0x080)
 #define  BM_SSP_CTRL1_SDIO_IRQ			(1 << 31)
 #define  BM_SSP_CTRL1_SDIO_IRQ_EN		(1 << 30)
 #define  BM_SSP_CTRL1_RESP_ERR_IRQ		(1 << 29)
@@ -116,11 +116,11 @@
 #define  BM_SSP_CTRL1_WORD_LENGTH		(0xf << 4)
 #define  BP_SSP_CTRL1_SSP_MODE			(0)
 #define  BM_SSP_CTRL1_SSP_MODE			(0xf)
-#define HW_SSP_SDRESP0				(ssp_is_old() ? 0x080 : 0x0a0)
-#define HW_SSP_SDRESP1				(ssp_is_old() ? 0x090 : 0x0b0)
-#define HW_SSP_SDRESP2				(ssp_is_old() ? 0x0a0 : 0x0c0)
-#define HW_SSP_SDRESP3				(ssp_is_old() ? 0x0b0 : 0x0d0)
-#define HW_SSP_STATUS				(ssp_is_old() ? 0x0c0 : 0x100)
+#define HW_SSP_SDRESP0(h)			(ssp_is_old(h) ? 0x080 : 0x0a0)
+#define HW_SSP_SDRESP1(h)			(ssp_is_old(h) ? 0x090 : 0x0b0)
+#define HW_SSP_SDRESP2(h)			(ssp_is_old(h) ? 0x0a0 : 0x0c0)
+#define HW_SSP_SDRESP3(h)			(ssp_is_old(h) ? 0x0b0 : 0x0d0)
+#define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
 #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
 #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
 #define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 0x130)
@@ -183,7 +183,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
 {
 	struct mxs_mmc_host *host = mmc_priv(mmc);
 
-	return !(readl(host->base + HW_SSP_STATUS) &
+	return !(readl(host->base + HW_SSP_STATUS(host)) &
 		 BM_SSP_STATUS_CARD_DETECT);
 }
 
@@ -207,7 +207,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 	writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
 	       BF_SSP(2, TIMING_CLOCK_DIVIDE) |
 	       BF_SSP(0, TIMING_CLOCK_RATE),
-	       host->base + HW_SSP_TIMING);
+	       host->base + HW_SSP_TIMING(host));
 
 	if (host->sdio_irq_en) {
 		ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
@@ -215,7 +215,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 	}
 
 	writel(ctrl0, host->base + HW_SSP_CTRL0);
-	writel(ctrl1, host->base + HW_SSP_CTRL1);
+	writel(ctrl1, host->base + HW_SSP_CTRL1(host));
 }
 
 static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
@@ -229,12 +229,12 @@ static void mxs_mmc_request_done(struct mxs_mmc_host *host)
 
 	if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
 		if (mmc_resp_type(cmd) & MMC_RSP_136) {
-			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0);
-			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1);
-			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2);
-			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3);
+			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0(host));
+			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1(host));
+			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2(host));
+			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3(host));
 		} else {
-			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0);
+			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0(host));
 		}
 	}
 
@@ -277,11 +277,11 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
 
 	spin_lock(&host->lock);
 
-	stat = readl(host->base + HW_SSP_CTRL1);
+	stat = readl(host->base + HW_SSP_CTRL1(host));
 	writel(stat & MXS_MMC_IRQ_BITS,
-	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
+	       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
 
-	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
+	if ((sta & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
 		mmc_signal_sdio_irq(host->mmc);
 
 	spin_unlock(&host->lock);
@@ -485,7 +485,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
 		blocks = 1;
 
 	/* xfer count, block size and count need to be set differently */
-	if (ssp_is_old()) {
+	if (ssp_is_old(host)) {
 		ctrl0 |= BF_SSP(data_size, CTRL0_XFER_COUNT);
 		cmd0 |= BF_SSP(log2_blksz, CMD0_BLOCK_SIZE) |
 			BF_SSP(blocks - 1, CMD0_BLOCK_COUNT);
@@ -509,10 +509,10 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
 
 	/* set the timeout count */
 	timeout = mxs_ns_to_ssp_ticks(host->clk_rate, data->timeout_ns);
-	val = readl(host->base + HW_SSP_TIMING);
+	val = readl(host->base + HW_SSP_TIMING(host));
 	val &= ~(BM_SSP_TIMING_TIMEOUT);
 	val |= BF_SSP(timeout, TIMING_TIMEOUT);
-	writel(val, host->base + HW_SSP_TIMING);
+	writel(val, host->base + HW_SSP_TIMING(host));
 
 	/* pio */
 	host->ssp_pio_words[0] = ctrl0;
@@ -598,11 +598,11 @@ static void mxs_mmc_set_clk_rate(struct mxs_mmc_host *host, unsigned int rate)
 
 	ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
 
-	val = readl(host->base + HW_SSP_TIMING);
+	val = readl(host->base + HW_SSP_TIMING(host));
 	val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
 	val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
 	val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
-	writel(val, host->base + HW_SSP_TIMING);
+	writel(val, host->base + HW_SSP_TIMING(host));
 
 	host->clk_rate = ssp_sck;
 
@@ -639,16 +639,17 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
 		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
+		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_SET);
 
-		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
+		if (readl(host->base + HW_SSP_STATUS(host)) &
+				BM_SSP_STATUS_SDIO_IRQ)
 			mmc_signal_sdio_irq(host->mmc);
 
 	} else {
 		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
 		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
 		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
-		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
+		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
 	}
 
 	spin_unlock_irqrestore(&host->lock, flags);
@@ -765,8 +766,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	mmc->max_segs = 52;
 	mmc->max_blk_size = 1 << 0xf;
-	mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff;
-	mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff;
+	mmc->max_blk_count = (ssp_is_old(host)) ? 0xff : 0xffffff;
+	mmc->max_req_size = (ssp_is_old(host)) ? 0xffff : 0xffffffff;
 	mmc->max_seg_size = dma_get_max_seg_size(host->dmach->device->dev);
 
 	platform_set_drvdata(pdev, mmc);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

The register HW_SSP_VERSION is broken for ssp version detection,
as the address of the register is different between imx23 and imx28.
Let's use platform_device_id to detect the device, so that the use
of cpu_is_xxx can be removed.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/mach-mxs/devices/platform-mxs-mmc.c    |   21 ++++++++-------
 arch/arm/mach-mxs/include/mach/devices-common.h |    1 +
 drivers/clk/mxs/clk-imx23.c                     |    4 +-
 drivers/clk/mxs/clk-imx28.c                     |    8 +++---
 drivers/mmc/host/mxs-mmc.c                      |   32 +++++++++++++++-------
 5 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
index bef9d92..b33c9d0 100644
--- a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
+++ b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
@@ -17,8 +17,9 @@
 #include <mach/mx28.h>
 #include <mach/devices-common.h>
 
-#define mxs_mxs_mmc_data_entry_single(soc, _id, hwid)			\
+#define mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)		\
 	{								\
+		.devid = _devid,					\
 		.id = _id,						\
 		.iobase = soc ## _SSP ## hwid ## _BASE_ADDR,		\
 		.dma = soc ## _DMA_SSP ## hwid,				\
@@ -26,23 +27,23 @@
 		.irq_dma = soc ## _INT_SSP ## hwid ## _DMA,		\
 	}
 
-#define mxs_mxs_mmc_data_entry(soc, _id, hwid)				\
-	[_id] = mxs_mxs_mmc_data_entry_single(soc, _id, hwid)
+#define mxs_mxs_mmc_data_entry(soc, _devid, _id, hwid)			\
+	[_id] = mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)
 
 
 #ifdef CONFIG_SOC_IMX23
 const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
-	mxs_mxs_mmc_data_entry(MX23, 0, 1),
-	mxs_mxs_mmc_data_entry(MX23, 1, 2),
+	mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 0, 1),
+	mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 1, 2),
 };
 #endif
 
 #ifdef CONFIG_SOC_IMX28
 const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
-	mxs_mxs_mmc_data_entry(MX28, 0, 0),
-	mxs_mxs_mmc_data_entry(MX28, 1, 1),
-	mxs_mxs_mmc_data_entry(MX28, 2, 2),
-	mxs_mxs_mmc_data_entry(MX28, 3, 3),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 0, 0),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 1, 1),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 2, 2),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 3, 3),
 };
 #endif
 
@@ -70,6 +71,6 @@ struct platform_device *__init mxs_add_mxs_mmc(
 		},
 	};
 
-	return mxs_add_platform_device("mxs-mmc", data->id,
+	return mxs_add_platform_device(data->devid, data->id,
 			res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
 }
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index f2e3839..2b37689 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -89,6 +89,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
 /* mmc */
 #include <mach/mmc.h>
 struct mxs_mxs_mmc_data {
+	const char *devid;
 	int id;
 	resource_size_t iobase;
 	resource_size_t dma;
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index 96562f5..f7be225 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -93,8 +93,8 @@ static struct clk_lookup xbus_lookups[] __initdata = {
 };
 
 static struct clk_lookup ssp_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.0", },
-	{ .dev_id = "mxs-mmc.1", },
+	{ .dev_id = "imx23-mmc.0", },
+	{ .dev_id = "imx23-mmc.1", },
 	{ .dev_id = "80010000.ssp", },
 	{ .dev_id = "80034000.ssp", },
 };
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index e18cac9..cadc801 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -139,22 +139,22 @@ static struct clk_lookup xbus_lookups[] __initdata = {
 };
 
 static struct clk_lookup ssp0_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.0", },
+	{ .dev_id = "imx28-mmc.0", },
 	{ .dev_id = "80010000.ssp", },
 };
 
 static struct clk_lookup ssp1_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.1", },
+	{ .dev_id = "imx28-mmc.1", },
 	{ .dev_id = "80012000.ssp", },
 };
 
 static struct clk_lookup ssp2_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.2", },
+	{ .dev_id = "imx28-mmc.2", },
 	{ .dev_id = "80014000.ssp", },
 };
 
 static struct clk_lookup ssp3_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.3", },
+	{ .dev_id = "imx28-mmc.3", },
 	{ .dev_id = "80016000.ssp", },
 };
 
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 13907e4..54bbb8b 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -42,7 +42,6 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/stmp_device.h>
 
-#include <mach/mxs.h>
 #include <mach/mmc.h>
 
 #define DRIVER_NAME	"mxs-mmc"
@@ -50,8 +49,7 @@
 /* card detect polling timeout */
 #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
 
-#define SSP_VERSION_LATEST	4
-#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
+#define ssp_is_old(host)	(host->devid == IMX23_MMC)
 
 /* SSP registers */
 #define HW_SSP_CTRL0				0x000
@@ -123,8 +121,6 @@
 #define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
 #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
 #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
-#define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 0x130)
-#define  BP_SSP_VERSION_MAJOR			(24)
 
 #define BF_SSP(value, field)	(((value) << BP_SSP_##field) & BM_SSP_##field)
 
@@ -139,6 +135,11 @@
 
 #define SSP_PIO_NUM	3
 
+enum mxs_mmc_id {
+	IMX23_MMC,
+	IMX28_MMC,
+};
+
 struct mxs_mmc_host {
 	struct mmc_host			*mmc;
 	struct mmc_request		*mrq;
@@ -158,7 +159,7 @@ struct mxs_mmc_host {
 	enum dma_transfer_direction	slave_dirn;
 	u32				ssp_pio_words[SSP_PIO_NUM];
 
-	unsigned int			version;
+	enum mxs_mmc_id			devid;
 	unsigned char			bus_width;
 	spinlock_t			lock;
 	int				sdio_irq_en;
@@ -678,6 +679,19 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
 	return true;
 }
 
+static struct platform_device_id mxs_mmc_ids[] = {
+	{
+		.name = "imx23-mmc",
+		.driver_data = IMX23_MMC,
+	}, {
+		.name = "imx28-mmc",
+		.driver_data = IMX28_MMC,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
+
 static int mxs_mmc_probe(struct platform_device *pdev)
 {
 	struct mxs_mmc_host *host;
@@ -712,10 +726,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		goto out_mmc_free;
 	}
 
-	/* only major verion does matter */
-	host->version = readl(host->base + HW_SSP_VERSION) >>
-			BP_SSP_VERSION_MAJOR;
-
+	host->devid = pdev->id_entry->driver_data;
 	host->mmc = mmc;
 	host->res = r;
 	host->dma_res = dmares;
@@ -866,6 +877,7 @@ static const struct dev_pm_ops mxs_mmc_pm_ops = {
 static struct platform_driver mxs_mmc_driver = {
 	.probe		= mxs_mmc_probe,
 	.remove		= mxs_mmc_remove,
+	.id_table	= mxs_mmc_ids,
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

The register HW_SSP_VERSION is broken for ssp version detection,
as the address of the register is different between imx23 and imx28.
Let's use platform_device_id to detect the device, so that the use
of cpu_is_xxx can be removed.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/mach-mxs/devices/platform-mxs-mmc.c    |   21 ++++++++-------
 arch/arm/mach-mxs/include/mach/devices-common.h |    1 +
 drivers/clk/mxs/clk-imx23.c                     |    4 +-
 drivers/clk/mxs/clk-imx28.c                     |    8 +++---
 drivers/mmc/host/mxs-mmc.c                      |   32 +++++++++++++++-------
 5 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
index bef9d92..b33c9d0 100644
--- a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
+++ b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
@@ -17,8 +17,9 @@
 #include <mach/mx28.h>
 #include <mach/devices-common.h>
 
-#define mxs_mxs_mmc_data_entry_single(soc, _id, hwid)			\
+#define mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)		\
 	{								\
+		.devid = _devid,					\
 		.id = _id,						\
 		.iobase = soc ## _SSP ## hwid ## _BASE_ADDR,		\
 		.dma = soc ## _DMA_SSP ## hwid,				\
@@ -26,23 +27,23 @@
 		.irq_dma = soc ## _INT_SSP ## hwid ## _DMA,		\
 	}
 
-#define mxs_mxs_mmc_data_entry(soc, _id, hwid)				\
-	[_id] = mxs_mxs_mmc_data_entry_single(soc, _id, hwid)
+#define mxs_mxs_mmc_data_entry(soc, _devid, _id, hwid)			\
+	[_id] = mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)
 
 
 #ifdef CONFIG_SOC_IMX23
 const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
-	mxs_mxs_mmc_data_entry(MX23, 0, 1),
-	mxs_mxs_mmc_data_entry(MX23, 1, 2),
+	mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 0, 1),
+	mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 1, 2),
 };
 #endif
 
 #ifdef CONFIG_SOC_IMX28
 const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
-	mxs_mxs_mmc_data_entry(MX28, 0, 0),
-	mxs_mxs_mmc_data_entry(MX28, 1, 1),
-	mxs_mxs_mmc_data_entry(MX28, 2, 2),
-	mxs_mxs_mmc_data_entry(MX28, 3, 3),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 0, 0),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 1, 1),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 2, 2),
+	mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 3, 3),
 };
 #endif
 
@@ -70,6 +71,6 @@ struct platform_device *__init mxs_add_mxs_mmc(
 		},
 	};
 
-	return mxs_add_platform_device("mxs-mmc", data->id,
+	return mxs_add_platform_device(data->devid, data->id,
 			res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
 }
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index f2e3839..2b37689 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -89,6 +89,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
 /* mmc */
 #include <mach/mmc.h>
 struct mxs_mxs_mmc_data {
+	const char *devid;
 	int id;
 	resource_size_t iobase;
 	resource_size_t dma;
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index 96562f5..f7be225 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -93,8 +93,8 @@ static struct clk_lookup xbus_lookups[] __initdata = {
 };
 
 static struct clk_lookup ssp_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.0", },
-	{ .dev_id = "mxs-mmc.1", },
+	{ .dev_id = "imx23-mmc.0", },
+	{ .dev_id = "imx23-mmc.1", },
 	{ .dev_id = "80010000.ssp", },
 	{ .dev_id = "80034000.ssp", },
 };
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index e18cac9..cadc801 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -139,22 +139,22 @@ static struct clk_lookup xbus_lookups[] __initdata = {
 };
 
 static struct clk_lookup ssp0_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.0", },
+	{ .dev_id = "imx28-mmc.0", },
 	{ .dev_id = "80010000.ssp", },
 };
 
 static struct clk_lookup ssp1_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.1", },
+	{ .dev_id = "imx28-mmc.1", },
 	{ .dev_id = "80012000.ssp", },
 };
 
 static struct clk_lookup ssp2_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.2", },
+	{ .dev_id = "imx28-mmc.2", },
 	{ .dev_id = "80014000.ssp", },
 };
 
 static struct clk_lookup ssp3_lookups[] __initdata = {
-	{ .dev_id = "mxs-mmc.3", },
+	{ .dev_id = "imx28-mmc.3", },
 	{ .dev_id = "80016000.ssp", },
 };
 
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 13907e4..54bbb8b 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -42,7 +42,6 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/stmp_device.h>
 
-#include <mach/mxs.h>
 #include <mach/mmc.h>
 
 #define DRIVER_NAME	"mxs-mmc"
@@ -50,8 +49,7 @@
 /* card detect polling timeout */
 #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
 
-#define SSP_VERSION_LATEST	4
-#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
+#define ssp_is_old(host)	(host->devid == IMX23_MMC)
 
 /* SSP registers */
 #define HW_SSP_CTRL0				0x000
@@ -123,8 +121,6 @@
 #define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
 #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
 #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
-#define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 0x130)
-#define  BP_SSP_VERSION_MAJOR			(24)
 
 #define BF_SSP(value, field)	(((value) << BP_SSP_##field) & BM_SSP_##field)
 
@@ -139,6 +135,11 @@
 
 #define SSP_PIO_NUM	3
 
+enum mxs_mmc_id {
+	IMX23_MMC,
+	IMX28_MMC,
+};
+
 struct mxs_mmc_host {
 	struct mmc_host			*mmc;
 	struct mmc_request		*mrq;
@@ -158,7 +159,7 @@ struct mxs_mmc_host {
 	enum dma_transfer_direction	slave_dirn;
 	u32				ssp_pio_words[SSP_PIO_NUM];
 
-	unsigned int			version;
+	enum mxs_mmc_id			devid;
 	unsigned char			bus_width;
 	spinlock_t			lock;
 	int				sdio_irq_en;
@@ -678,6 +679,19 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
 	return true;
 }
 
+static struct platform_device_id mxs_mmc_ids[] = {
+	{
+		.name = "imx23-mmc",
+		.driver_data = IMX23_MMC,
+	}, {
+		.name = "imx28-mmc",
+		.driver_data = IMX28_MMC,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
+
 static int mxs_mmc_probe(struct platform_device *pdev)
 {
 	struct mxs_mmc_host *host;
@@ -712,10 +726,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		goto out_mmc_free;
 	}
 
-	/* only major verion does matter */
-	host->version = readl(host->base + HW_SSP_VERSION) >>
-			BP_SSP_VERSION_MAJOR;
-
+	host->devid = pdev->id_entry->driver_data;
 	host->mmc = mmc;
 	host->res = r;
 	host->dma_res = dmares;
@@ -866,6 +877,7 @@ static const struct dev_pm_ops mxs_mmc_pm_ops = {
 static struct platform_driver mxs_mmc_driver = {
 	.probe		= mxs_mmc_probe,
 	.remove		= mxs_mmc_remove,
+	.id_table	= mxs_mmc_ids,
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 04/10] mmc: mxs-mmc: move header from mach into linux folder
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

Rename arch/arm/mach-mxs/include/mach/mmc.h to
include/linux/mmc/mxs-mmc.h, so that mxs-mmc driver becomes
<mach/*> inclusion free.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/mach-mxs/include/mach/devices-common.h    |    2 +-
 drivers/mmc/host/mxs-mmc.c                         |    3 +--
 .../mach/mmc.h => include/linux/mmc/mxs-mmc.h      |    7 ++++---
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename arch/arm/mach-mxs/include/mach/mmc.h => include/linux/mmc/mxs-mmc.h (81%)

diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index 2b37689..6fc0601 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -87,7 +87,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
 		const struct mxs_mxs_i2c_data *data);
 
 /* mmc */
-#include <mach/mmc.h>
+#include <linux/mmc/mxs-mmc.h>
 struct mxs_mxs_mmc_data {
 	const char *devid;
 	int id;
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 54bbb8b..c70c7c7 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -41,8 +41,7 @@
 #include <linux/fsl/mxs-dma.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/stmp_device.h>
-
-#include <mach/mmc.h>
+#include <linux/mmc/mxs-mmc.h>
 
 #define DRIVER_NAME	"mxs-mmc"
 
diff --git a/arch/arm/mach-mxs/include/mach/mmc.h b/include/linux/mmc/mxs-mmc.h
similarity index 81%
rename from arch/arm/mach-mxs/include/mach/mmc.h
rename to include/linux/mmc/mxs-mmc.h
index 211547a..7c2ad3a 100644
--- a/arch/arm/mach-mxs/include/mach/mmc.h
+++ b/include/linux/mmc/mxs-mmc.h
@@ -6,8 +6,8 @@
  * published by the Free Software Foundation.
  */
 
-#ifndef __MACH_MXS_MMC_H__
-#define __MACH_MXS_MMC_H__
+#ifndef __LINUX_MMC_MXS_MMC_H__
+#define __LINUX_MMC_MXS_MMC_H__
 
 struct mxs_mmc_platform_data {
 	int wp_gpio;	/* write protect pin */
@@ -15,4 +15,5 @@ struct mxs_mmc_platform_data {
 #define SLOTF_4_BIT_CAPABLE	(1 << 0)
 #define SLOTF_8_BIT_CAPABLE	(1 << 1)
 };
-#endif /* __MACH_MXS_MMC_H__ */
+
+#endif /* __LINUX_MMC_MXS_MMC_H__ */
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 04/10] mmc: mxs-mmc: move header from mach into linux folder
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Rename arch/arm/mach-mxs/include/mach/mmc.h to
include/linux/mmc/mxs-mmc.h, so that mxs-mmc driver becomes
<mach/*> inclusion free.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/mach-mxs/include/mach/devices-common.h    |    2 +-
 drivers/mmc/host/mxs-mmc.c                         |    3 +--
 .../mach/mmc.h => include/linux/mmc/mxs-mmc.h      |    7 ++++---
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename arch/arm/mach-mxs/include/mach/mmc.h => include/linux/mmc/mxs-mmc.h (81%)

diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index 2b37689..6fc0601 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -87,7 +87,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
 		const struct mxs_mxs_i2c_data *data);
 
 /* mmc */
-#include <mach/mmc.h>
+#include <linux/mmc/mxs-mmc.h>
 struct mxs_mxs_mmc_data {
 	const char *devid;
 	int id;
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 54bbb8b..c70c7c7 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -41,8 +41,7 @@
 #include <linux/fsl/mxs-dma.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/stmp_device.h>
-
-#include <mach/mmc.h>
+#include <linux/mmc/mxs-mmc.h>
 
 #define DRIVER_NAME	"mxs-mmc"
 
diff --git a/arch/arm/mach-mxs/include/mach/mmc.h b/include/linux/mmc/mxs-mmc.h
similarity index 81%
rename from arch/arm/mach-mxs/include/mach/mmc.h
rename to include/linux/mmc/mxs-mmc.h
index 211547a..7c2ad3a 100644
--- a/arch/arm/mach-mxs/include/mach/mmc.h
+++ b/include/linux/mmc/mxs-mmc.h
@@ -6,8 +6,8 @@
  * published by the Free Software Foundation.
  */
 
-#ifndef __MACH_MXS_MMC_H__
-#define __MACH_MXS_MMC_H__
+#ifndef __LINUX_MMC_MXS_MMC_H__
+#define __LINUX_MMC_MXS_MMC_H__
 
 struct mxs_mmc_platform_data {
 	int wp_gpio;	/* write protect pin */
@@ -15,4 +15,5 @@ struct mxs_mmc_platform_data {
 #define SLOTF_4_BIT_CAPABLE	(1 << 0)
 #define SLOTF_8_BIT_CAPABLE	(1 << 1)
 };
-#endif /* __MACH_MXS_MMC_H__ */
+
+#endif /* __LINUX_MMC_MXS_MMC_H__ */
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

Use devm_request_and_ioremap and devm_request_irq helpers to clean up
the code a little bit.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   40 +++++++++-------------------------------
 1 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index c70c7c7..1a8ba314 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -146,8 +146,6 @@ struct mxs_mmc_host {
 	struct mmc_data			*data;
 
 	void __iomem			*base;
-	int				irq;
-	struct resource			*res;
 	struct resource			*dma_res;
 	struct clk			*clk;
 	unsigned int			clk_rate;
@@ -695,7 +693,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 {
 	struct mxs_mmc_host *host;
 	struct mmc_host *mmc;
-	struct resource *iores, *dmares, *r;
+	struct resource *iores, *dmares;
 	struct mxs_mmc_platform_data *pdata;
 	struct pinctrl *pinctrl;
 	int ret = 0, irq_err, irq_dma;
@@ -708,28 +706,20 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
 		return -EINVAL;
 
-	r = request_mem_region(iores->start, resource_size(iores), pdev->name);
-	if (!r)
-		return -EBUSY;
-
 	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
-	if (!mmc) {
-		ret = -ENOMEM;
-		goto out_release_mem;
-	}
+	if (!mmc)
+		return -ENOMEM;
 
 	host = mmc_priv(mmc);
-	host->base = ioremap(r->start, resource_size(r));
+	host->base = devm_request_and_ioremap(&pdev->dev, iores);
 	if (!host->base) {
-		ret = -ENOMEM;
+		ret = -EADDRNOTAVAIL;
 		goto out_mmc_free;
 	}
 
 	host->devid = pdev->id_entry->driver_data;
 	host->mmc = mmc;
-	host->res = r;
 	host->dma_res = dmares;
-	host->irq = irq_err;
 	host->sdio_irq_en = 0;
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
@@ -741,7 +731,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	host->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(host->clk)) {
 		ret = PTR_ERR(host->clk);
-		goto out_iounmap;
+		goto out_mmc_free;
 	}
 	clk_prepare_enable(host->clk);
 
@@ -782,7 +772,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mmc);
 
-	ret = request_irq(host->irq, mxs_mmc_irq_handler, 0, DRIVER_NAME, host);
+	ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
+			       DRIVER_NAME, host);
 	if (ret)
 		goto out_free_dma;
 
@@ -790,26 +781,20 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	ret = mmc_add_host(mmc);
 	if (ret)
-		goto out_free_irq;
+		goto out_free_dma;
 
 	dev_info(mmc_dev(host->mmc), "initialized\n");
 
 	return 0;
 
-out_free_irq:
-	free_irq(host->irq, host);
 out_free_dma:
 	if (host->dmach)
 		dma_release_channel(host->dmach);
 out_clk_put:
 	clk_disable_unprepare(host->clk);
 	clk_put(host->clk);
-out_iounmap:
-	iounmap(host->base);
 out_mmc_free:
 	mmc_free_host(mmc);
-out_release_mem:
-	release_mem_region(iores->start, resource_size(iores));
 	return ret;
 }
 
@@ -817,12 +802,9 @@ static int mxs_mmc_remove(struct platform_device *pdev)
 {
 	struct mmc_host *mmc = platform_get_drvdata(pdev);
 	struct mxs_mmc_host *host = mmc_priv(mmc);
-	struct resource *res = host->res;
 
 	mmc_remove_host(mmc);
 
-	free_irq(host->irq, host);
-
 	platform_set_drvdata(pdev, NULL);
 
 	if (host->dmach)
@@ -831,12 +813,8 @@ static int mxs_mmc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(host->clk);
 	clk_put(host->clk);
 
-	iounmap(host->base);
-
 	mmc_free_host(mmc);
 
-	release_mem_region(res->start, resource_size(res));
-
 	return 0;
 }
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Use devm_request_and_ioremap and devm_request_irq helpers to clean up
the code a little bit.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   40 +++++++++-------------------------------
 1 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index c70c7c7..1a8ba314 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -146,8 +146,6 @@ struct mxs_mmc_host {
 	struct mmc_data			*data;
 
 	void __iomem			*base;
-	int				irq;
-	struct resource			*res;
 	struct resource			*dma_res;
 	struct clk			*clk;
 	unsigned int			clk_rate;
@@ -695,7 +693,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 {
 	struct mxs_mmc_host *host;
 	struct mmc_host *mmc;
-	struct resource *iores, *dmares, *r;
+	struct resource *iores, *dmares;
 	struct mxs_mmc_platform_data *pdata;
 	struct pinctrl *pinctrl;
 	int ret = 0, irq_err, irq_dma;
@@ -708,28 +706,20 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
 		return -EINVAL;
 
-	r = request_mem_region(iores->start, resource_size(iores), pdev->name);
-	if (!r)
-		return -EBUSY;
-
 	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
-	if (!mmc) {
-		ret = -ENOMEM;
-		goto out_release_mem;
-	}
+	if (!mmc)
+		return -ENOMEM;
 
 	host = mmc_priv(mmc);
-	host->base = ioremap(r->start, resource_size(r));
+	host->base = devm_request_and_ioremap(&pdev->dev, iores);
 	if (!host->base) {
-		ret = -ENOMEM;
+		ret = -EADDRNOTAVAIL;
 		goto out_mmc_free;
 	}
 
 	host->devid = pdev->id_entry->driver_data;
 	host->mmc = mmc;
-	host->res = r;
 	host->dma_res = dmares;
-	host->irq = irq_err;
 	host->sdio_irq_en = 0;
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
@@ -741,7 +731,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	host->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(host->clk)) {
 		ret = PTR_ERR(host->clk);
-		goto out_iounmap;
+		goto out_mmc_free;
 	}
 	clk_prepare_enable(host->clk);
 
@@ -782,7 +772,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mmc);
 
-	ret = request_irq(host->irq, mxs_mmc_irq_handler, 0, DRIVER_NAME, host);
+	ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
+			       DRIVER_NAME, host);
 	if (ret)
 		goto out_free_dma;
 
@@ -790,26 +781,20 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	ret = mmc_add_host(mmc);
 	if (ret)
-		goto out_free_irq;
+		goto out_free_dma;
 
 	dev_info(mmc_dev(host->mmc), "initialized\n");
 
 	return 0;
 
-out_free_irq:
-	free_irq(host->irq, host);
 out_free_dma:
 	if (host->dmach)
 		dma_release_channel(host->dmach);
 out_clk_put:
 	clk_disable_unprepare(host->clk);
 	clk_put(host->clk);
-out_iounmap:
-	iounmap(host->base);
 out_mmc_free:
 	mmc_free_host(mmc);
-out_release_mem:
-	release_mem_region(iores->start, resource_size(iores));
 	return ret;
 }
 
@@ -817,12 +802,9 @@ static int mxs_mmc_remove(struct platform_device *pdev)
 {
 	struct mmc_host *mmc = platform_get_drvdata(pdev);
 	struct mxs_mmc_host *host = mmc_priv(mmc);
-	struct resource *res = host->res;
 
 	mmc_remove_host(mmc);
 
-	free_irq(host->irq, host);
-
 	platform_set_drvdata(pdev, NULL);
 
 	if (host->dmach)
@@ -831,12 +813,8 @@ static int mxs_mmc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(host->clk);
 	clk_put(host->clk);
 
-	iounmap(host->base);
-
 	mmc_free_host(mmc);
 
-	release_mem_region(res->start, resource_size(res));
-
 	return 0;
 }
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 06/10] mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

It replaces dma_res with dma_channel in struct mxs_mmc_host, so that
the device tree support will be a little easier, since dma channel
can not be retrieved from "struct resource *dma_res".

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 1a8ba314..e905721 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -146,7 +146,7 @@ struct mxs_mmc_host {
 	struct mmc_data			*data;
 
 	void __iomem			*base;
-	struct resource			*dma_res;
+	int				dma_channel;
 	struct clk			*clk;
 	unsigned int			clk_rate;
 
@@ -668,7 +668,7 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
 	if (!mxs_dma_is_apbh(chan))
 		return false;
 
-	if (chan->chan_id != host->dma_res->start)
+	if (chan->chan_id != host->dma_channel)
 		return false;
 
 	chan->private = &host->dma_data;
@@ -719,7 +719,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	host->devid = pdev->id_entry->driver_data;
 	host->mmc = mmc;
-	host->dma_res = dmares;
+	host->dma_channel = dmares->start;
 	host->sdio_irq_en = 0;
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 06/10] mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

It replaces dma_res with dma_channel in struct mxs_mmc_host, so that
the device tree support will be a little easier, since dma channel
can not be retrieved from "struct resource *dma_res".

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 1a8ba314..e905721 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -146,7 +146,7 @@ struct mxs_mmc_host {
 	struct mmc_data			*data;
 
 	void __iomem			*base;
-	struct resource			*dma_res;
+	int				dma_channel;
 	struct clk			*clk;
 	unsigned int			clk_rate;
 
@@ -668,7 +668,7 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
 	if (!mxs_dma_is_apbh(chan))
 		return false;
 
-	if (chan->chan_id != host->dma_res->start)
+	if (chan->chan_id != host->dma_channel)
 		return false;
 
 	chan->private = &host->dma_data;
@@ -719,7 +719,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	host->devid = pdev->id_entry->driver_data;
 	host->mmc = mmc;
-	host->dma_res = dmares;
+	host->dma_channel = dmares->start;
 	host->sdio_irq_en = 0;
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

It has wp_gpio copied in struct mxs_mmc_host from platform_data,
so that the use of platform_data can be limited in probe function,
which will ease the device tree probe.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index e905721..66f792a 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -160,21 +160,17 @@ struct mxs_mmc_host {
 	unsigned char			bus_width;
 	spinlock_t			lock;
 	int				sdio_irq_en;
+	int				wp_gpio;
 };
 
 static int mxs_mmc_get_ro(struct mmc_host *mmc)
 {
 	struct mxs_mmc_host *host = mmc_priv(mmc);
-	struct mxs_mmc_platform_data *pdata =
-		mmc_dev(host->mmc)->platform_data;
 
-	if (!pdata)
-		return -EFAULT;
-
-	if (!gpio_is_valid(pdata->wp_gpio))
+	if (!gpio_is_valid(host->wp_gpio))
 		return -EINVAL;
 
-	return gpio_get_value(pdata->wp_gpio);
+	return gpio_get_value(host->wp_gpio);
 }
 
 static int mxs_mmc_get_cd(struct mmc_host *mmc)
@@ -758,6 +754,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
 		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
 			mmc->caps |= MMC_CAP_4_BIT_DATA;
+		host->wp_gpio = pdata->wp_gpio;
 	}
 
 	mmc->f_min = 400000;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

It has wp_gpio copied in struct mxs_mmc_host from platform_data,
so that the use of platform_data can be limited in probe function,
which will ease the device tree probe.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/mxs-mmc.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index e905721..66f792a 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -160,21 +160,17 @@ struct mxs_mmc_host {
 	unsigned char			bus_width;
 	spinlock_t			lock;
 	int				sdio_irq_en;
+	int				wp_gpio;
 };
 
 static int mxs_mmc_get_ro(struct mmc_host *mmc)
 {
 	struct mxs_mmc_host *host = mmc_priv(mmc);
-	struct mxs_mmc_platform_data *pdata =
-		mmc_dev(host->mmc)->platform_data;
 
-	if (!pdata)
-		return -EFAULT;
-
-	if (!gpio_is_valid(pdata->wp_gpio))
+	if (!gpio_is_valid(host->wp_gpio))
 		return -EINVAL;
 
-	return gpio_get_value(pdata->wp_gpio);
+	return gpio_get_value(host->wp_gpio);
 }
 
 static int mxs_mmc_get_cd(struct mmc_host *mmc)
@@ -758,6 +754,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
 		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
 			mmc->caps |= MMC_CAP_4_BIT_DATA;
+		host->wp_gpio = pdata->wp_gpio;
 	}
 
 	mmc->f_min = 400000;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

It adds device tree probe support for mxs-mmc driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
 drivers/mmc/host/mxs-mmc.c                        |   48 ++++++++++++++++++--
 2 files changed, 69 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt

diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
new file mode 100644
index 0000000..d7c2a40
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
@@ -0,0 +1,26 @@
+* Freescale MXS MMC controller
+
+The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
+to support MMC, SD, and SDIO types of memory cards.
+
+Required properties:
+- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
+  imx23 and imx28.
+- reg: Should contain registers location and length
+- interrupts: Should contain ERROR and DMA interrupts
+- fsl,ssp-dma-channel: APBH DMA channel for the SSP
+- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
+
+Optional properties:
+- wp-gpios: Specify GPIOs for write protection
+
+Examples:
+
+ssp0: ssp@80010000 {
+	compatible = "fsl,imx28-mmc";
+	reg = <0x80010000 2000>;
+	interrupts = <96 82>;
+	fsl,ssp-dma-channel = <0>;
+	fsl,bus-width = <8>;
+	status = "okay";
+};
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 66f792a..c6b56b4 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -23,6 +23,9 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
@@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
 
+static const struct of_device_id mxs_mmc_dt_ids[] = {
+	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
+	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
+
 static int mxs_mmc_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *of_id =
+			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
+	struct device_node *np = pdev->dev.of_node;
 	struct mxs_mmc_host *host;
 	struct mmc_host *mmc;
 	struct resource *iores, *dmares;
@@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	irq_err = platform_get_irq(pdev, 0);
 	irq_dma = platform_get_irq(pdev, 1);
-	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
+	if (!iores || irq_err < 0 || irq_dma < 0)
 		return -EINVAL;
 
 	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
@@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		goto out_mmc_free;
 	}
 
-	host->devid = pdev->id_entry->driver_data;
+	if (np) {
+		host->devid = (enum mxs_mmc_id) of_id->data;
+		/*
+		 * TODO: This is a temporary solution and should be changed
+		 * to use generic DMA binding later when the helplers get in.
+		 */
+		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
+					   &host->dma_channel);
+		if (ret) {
+			dev_err(mmc_dev(host->mmc),
+				"failed to get dma channel\n");
+			goto out_mmc_free;
+		}
+	} else {
+		host->devid = pdev->id_entry->driver_data;
+		host->dma_channel = dmares->start;
+	}
+
 	host->mmc = mmc;
-	host->dma_channel = dmares->start;
 	host->sdio_irq_en = 0;
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
-		goto out_iounmap;
+		goto out_mmc_free;
 	}
 
 	host->clk = clk_get(&pdev->dev, NULL);
@@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
 
 	pdata =	mmc_dev(host->mmc)->platform_data;
-	if (pdata) {
+	if (!pdata) {
+		u32 bus_width = 0;
+		of_property_read_u32(np, "fsl,bus-width", &bus_width);
+		if (bus_width == 4)
+			mmc->caps |= MMC_CAP_4_BIT_DATA;
+		else if (bus_width == 8)
+			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
+		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
+	} else {
 		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
 			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
 		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
@@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
 		.owner	= THIS_MODULE,
 #ifdef CONFIG_PM
 		.pm	= &mxs_mmc_pm_ops,
+		.of_match_table = mxs_mmc_dt_ids,
 #endif
 	},
 };
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

It adds device tree probe support for mxs-mmc driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
 drivers/mmc/host/mxs-mmc.c                        |   48 ++++++++++++++++++--
 2 files changed, 69 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt

diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
new file mode 100644
index 0000000..d7c2a40
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
@@ -0,0 +1,26 @@
+* Freescale MXS MMC controller
+
+The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
+to support MMC, SD, and SDIO types of memory cards.
+
+Required properties:
+- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
+  imx23 and imx28.
+- reg: Should contain registers location and length
+- interrupts: Should contain ERROR and DMA interrupts
+- fsl,ssp-dma-channel: APBH DMA channel for the SSP
+- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
+
+Optional properties:
+- wp-gpios: Specify GPIOs for write protection
+
+Examples:
+
+ssp0: ssp at 80010000 {
+	compatible = "fsl,imx28-mmc";
+	reg = <0x80010000 2000>;
+	interrupts = <96 82>;
+	fsl,ssp-dma-channel = <0>;
+	fsl,bus-width = <8>;
+	status = "okay";
+};
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 66f792a..c6b56b4 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -23,6 +23,9 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
@@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
 
+static const struct of_device_id mxs_mmc_dt_ids[] = {
+	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
+	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
+
 static int mxs_mmc_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *of_id =
+			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
+	struct device_node *np = pdev->dev.of_node;
 	struct mxs_mmc_host *host;
 	struct mmc_host *mmc;
 	struct resource *iores, *dmares;
@@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	irq_err = platform_get_irq(pdev, 0);
 	irq_dma = platform_get_irq(pdev, 1);
-	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
+	if (!iores || irq_err < 0 || irq_dma < 0)
 		return -EINVAL;
 
 	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
@@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		goto out_mmc_free;
 	}
 
-	host->devid = pdev->id_entry->driver_data;
+	if (np) {
+		host->devid = (enum mxs_mmc_id) of_id->data;
+		/*
+		 * TODO: This is a temporary solution and should be changed
+		 * to use generic DMA binding later when the helplers get in.
+		 */
+		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
+					   &host->dma_channel);
+		if (ret) {
+			dev_err(mmc_dev(host->mmc),
+				"failed to get dma channel\n");
+			goto out_mmc_free;
+		}
+	} else {
+		host->devid = pdev->id_entry->driver_data;
+		host->dma_channel = dmares->start;
+	}
+
 	host->mmc = mmc;
-	host->dma_channel = dmares->start;
 	host->sdio_irq_en = 0;
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
-		goto out_iounmap;
+		goto out_mmc_free;
 	}
 
 	host->clk = clk_get(&pdev->dev, NULL);
@@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
 
 	pdata =	mmc_dev(host->mmc)->platform_data;
-	if (pdata) {
+	if (!pdata) {
+		u32 bus_width = 0;
+		of_property_read_u32(np, "fsl,bus-width", &bus_width);
+		if (bus_width == 4)
+			mmc->caps |= MMC_CAP_4_BIT_DATA;
+		else if (bus_width == 8)
+			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
+		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
+	} else {
 		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
 			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
 		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
@@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
 		.owner	= THIS_MODULE,
 #ifdef CONFIG_PM
 		.pm	= &mxs_mmc_pm_ops,
+		.of_match_table = mxs_mmc_dt_ids,
 #endif
 	},
 };
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 09/10] ARM: dts: enable mmc for imx23-evk
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/boot/dts/imx23-evk.dts |   11 +++++++++++
 arch/arm/boot/dts/imx23.dtsi    |   19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx23-evk.dts b/arch/arm/boot/dts/imx23-evk.dts
index 8cad51e..a7408f6 100644
--- a/arch/arm/boot/dts/imx23-evk.dts
+++ b/arch/arm/boot/dts/imx23-evk.dts
@@ -21,6 +21,17 @@
 	};
 
 	apb@80000000 {
+		apbh@80000000 {
+			ssp0: ssp@80010000 {
+				compatible = "fsl,imx23-mmc";
+				pinctrl-names = "default";
+				pinctrl-0 = <&mmc0_8bit_pins_a &mmc0_pins_fixup>;
+				fsl,bus-width = <8>;
+				wp-gpios = <&gpio1 30 0>;
+				status = "okay";
+			};
+		};
+
 		apbx@80040000 {
 			duart: serial@80070000 {
 				pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 36c6057..37069b6 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -69,6 +69,8 @@
 
 			ssp0: ssp@80010000 {
 				reg = <0x80010000 2000>;
+				interrupts = <15 14>;
+				fsl,ssp-dma-channel = <1>;
 				status = "disabled";
 			};
 
@@ -117,6 +119,21 @@
 					fsl,voltage = <1>;
 					fsl,pull-up = <0>;
 				};
+
+				mmc0_8bit_pins_a: mmc0-8bit@0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x2020 0x2030 0x2040
+						0x2050 0x0082 0x0092 0x00a2
+						0x00b2 0x2000 0x2010 0x2060>;
+					fsl,drive-strength = <1>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <1>;
+				};
+
+				mmc0_pins_fixup: mmc0-pins-fixup {
+					fsl,pinmux-ids = <0x2010 0x2060>;
+					fsl,pull-up = <0>;
+				};
 			};
 
 			digctl@8001c000 {
@@ -161,6 +178,8 @@
 
 			ssp1: ssp@80034000 {
 				reg = <0x80034000 2000>;
+				interrupts = <2 20>;
+				fsl,ssp-dma-channel = <2>;
 				status = "disabled";
 			};
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 09/10] ARM: dts: enable mmc for imx23-evk
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/boot/dts/imx23-evk.dts |   11 +++++++++++
 arch/arm/boot/dts/imx23.dtsi    |   19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx23-evk.dts b/arch/arm/boot/dts/imx23-evk.dts
index 8cad51e..a7408f6 100644
--- a/arch/arm/boot/dts/imx23-evk.dts
+++ b/arch/arm/boot/dts/imx23-evk.dts
@@ -21,6 +21,17 @@
 	};
 
 	apb at 80000000 {
+		apbh at 80000000 {
+			ssp0: ssp at 80010000 {
+				compatible = "fsl,imx23-mmc";
+				pinctrl-names = "default";
+				pinctrl-0 = <&mmc0_8bit_pins_a &mmc0_pins_fixup>;
+				fsl,bus-width = <8>;
+				wp-gpios = <&gpio1 30 0>;
+				status = "okay";
+			};
+		};
+
 		apbx at 80040000 {
 			duart: serial at 80070000 {
 				pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 36c6057..37069b6 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -69,6 +69,8 @@
 
 			ssp0: ssp at 80010000 {
 				reg = <0x80010000 2000>;
+				interrupts = <15 14>;
+				fsl,ssp-dma-channel = <1>;
 				status = "disabled";
 			};
 
@@ -117,6 +119,21 @@
 					fsl,voltage = <1>;
 					fsl,pull-up = <0>;
 				};
+
+				mmc0_8bit_pins_a: mmc0-8bit at 0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x2020 0x2030 0x2040
+						0x2050 0x0082 0x0092 0x00a2
+						0x00b2 0x2000 0x2010 0x2060>;
+					fsl,drive-strength = <1>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <1>;
+				};
+
+				mmc0_pins_fixup: mmc0-pins-fixup {
+					fsl,pinmux-ids = <0x2010 0x2060>;
+					fsl,pull-up = <0>;
+				};
 			};
 
 			digctl at 8001c000 {
@@ -161,6 +178,8 @@
 
 			ssp1: ssp at 80034000 {
 				reg = <0x80034000 2000>;
+				interrupts = <2 20>;
+				fsl,ssp-dma-channel = <2>;
 				status = "disabled";
 			};
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 10/10] ARM: dts: enable mmc for imx28-evk
  2012-05-07 14:43 ` Shawn Guo
@ 2012-05-07 14:43   ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Chris Ball, Dong Aisheng, Marek Vasut, Shawn Guo

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/boot/dts/imx28-evk.dts |   19 +++++++++++++++++++
 arch/arm/boot/dts/imx28.dtsi    |   25 +++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx28-evk.dts b/arch/arm/boot/dts/imx28-evk.dts
index 5aee8ed..6ca10f2 100644
--- a/arch/arm/boot/dts/imx28-evk.dts
+++ b/arch/arm/boot/dts/imx28-evk.dts
@@ -21,6 +21,25 @@
 	};
 
 	apb@80000000 {
+		apbh@80000000 {
+			ssp0: ssp@80010000 {
+				compatible = "fsl,imx28-mmc";
+				pinctrl-names = "default";
+				pinctrl-0 = <&mmc0_8bit_pins_a
+					&mmc0_cd_cfg &mmc0_sck_cfg>;
+				fsl,bus-width = <8>;
+				wp-gpios = <&gpio2 12 0>;
+				status = "okay";
+			};
+
+			ssp1: ssp@80012000 {
+				compatible = "fsl,imx28-mmc";
+				fsl,bus-width = <8>;
+				wp-gpios = <&gpio0 28 0>;
+				status = "okay";
+			};
+		};
+
 		apbx@80040000 {
 			duart: serial@80074000 {
 				pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 1abd9b3..8596bdf 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -81,24 +81,28 @@
 			ssp0: ssp@80010000 {
 				reg = <0x80010000 2000>;
 				interrupts = <96 82>;
+				fsl,ssp-dma-channel = <0>;
 				status = "disabled";
 			};
 
 			ssp1: ssp@80012000 {
 				reg = <0x80012000 2000>;
 				interrupts = <97 83>;
+				fsl,ssp-dma-channel = <1>;
 				status = "disabled";
 			};
 
 			ssp2: ssp@80014000 {
 				reg = <0x80014000 2000>;
 				interrupts = <98 84>;
+				fsl,ssp-dma-channel = <2>;
 				status = "disabled";
 			};
 
 			ssp3: ssp@80016000 {
 				reg = <0x80016000 2000>;
 				interrupts = <99 85>;
+				fsl,ssp-dma-channel = <3>;
 				status = "disabled";
 			};
 
@@ -179,6 +183,27 @@
 					fsl,voltage = <1>;
 					fsl,pull-up = <1>;
 				};
+
+				mmc0_8bit_pins_a: mmc0-8bit@0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x2000 0x2010 0x2020
+						0x2030 0x2040 0x2050 0x2060
+						0x2070 0x2080 0x2090 0x20a0>;
+					fsl,drive-strength = <1>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <1>;
+				};
+
+				mmc0_cd_cfg: mmc0-cd-cfg {
+					fsl,pinmux-ids = <0x2090>;
+					fsl,pull-up = <0>;
+				};
+
+				mmc0_sck_cfg: mmc0-sck-cfg {
+					fsl,pinmux-ids = <0x20a0>;
+					fsl,drive-strength = <2>;
+					fsl,pull-up = <0>;
+				};
 			};
 
 			digctl@8001c000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 10/10] ARM: dts: enable mmc for imx28-evk
@ 2012-05-07 14:43   ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/boot/dts/imx28-evk.dts |   19 +++++++++++++++++++
 arch/arm/boot/dts/imx28.dtsi    |   25 +++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx28-evk.dts b/arch/arm/boot/dts/imx28-evk.dts
index 5aee8ed..6ca10f2 100644
--- a/arch/arm/boot/dts/imx28-evk.dts
+++ b/arch/arm/boot/dts/imx28-evk.dts
@@ -21,6 +21,25 @@
 	};
 
 	apb at 80000000 {
+		apbh at 80000000 {
+			ssp0: ssp at 80010000 {
+				compatible = "fsl,imx28-mmc";
+				pinctrl-names = "default";
+				pinctrl-0 = <&mmc0_8bit_pins_a
+					&mmc0_cd_cfg &mmc0_sck_cfg>;
+				fsl,bus-width = <8>;
+				wp-gpios = <&gpio2 12 0>;
+				status = "okay";
+			};
+
+			ssp1: ssp at 80012000 {
+				compatible = "fsl,imx28-mmc";
+				fsl,bus-width = <8>;
+				wp-gpios = <&gpio0 28 0>;
+				status = "okay";
+			};
+		};
+
 		apbx at 80040000 {
 			duart: serial at 80074000 {
 				pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 1abd9b3..8596bdf 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -81,24 +81,28 @@
 			ssp0: ssp at 80010000 {
 				reg = <0x80010000 2000>;
 				interrupts = <96 82>;
+				fsl,ssp-dma-channel = <0>;
 				status = "disabled";
 			};
 
 			ssp1: ssp at 80012000 {
 				reg = <0x80012000 2000>;
 				interrupts = <97 83>;
+				fsl,ssp-dma-channel = <1>;
 				status = "disabled";
 			};
 
 			ssp2: ssp at 80014000 {
 				reg = <0x80014000 2000>;
 				interrupts = <98 84>;
+				fsl,ssp-dma-channel = <2>;
 				status = "disabled";
 			};
 
 			ssp3: ssp at 80016000 {
 				reg = <0x80016000 2000>;
 				interrupts = <99 85>;
+				fsl,ssp-dma-channel = <3>;
 				status = "disabled";
 			};
 
@@ -179,6 +183,27 @@
 					fsl,voltage = <1>;
 					fsl,pull-up = <1>;
 				};
+
+				mmc0_8bit_pins_a: mmc0-8bit at 0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x2000 0x2010 0x2020
+						0x2030 0x2040 0x2050 0x2060
+						0x2070 0x2080 0x2090 0x20a0>;
+					fsl,drive-strength = <1>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <1>;
+				};
+
+				mmc0_cd_cfg: mmc0-cd-cfg {
+					fsl,pinmux-ids = <0x2090>;
+					fsl,pull-up = <0>;
+				};
+
+				mmc0_sck_cfg: mmc0-sck-cfg {
+					fsl,pinmux-ids = <0x20a0>;
+					fsl,drive-strength = <2>;
+					fsl,pull-up = <0>;
+				};
 			};
 
 			digctl at 8001c000 {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH 01/10] mmc: mxs-mmc: use global stmp_device functionality
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:41     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:41 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> Use global stmp_device functionality to reduce mach-dependency.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/mmc/host/mxs-mmc.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index bb03ddd..2ea5361 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -40,9 +40,9 @@
>  #include <linux/module.h>
>  #include <linux/fsl/mxs-dma.h>
>  #include <linux/pinctrl/consumer.h>
> +#include <linux/stmp_device.h>
> 
>  #include <mach/mxs.h>
> -#include <mach/common.h>
>  #include <mach/mmc.h>
> 
>  #define DRIVER_NAME	"mxs-mmc"
> @@ -191,7 +191,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
>  {
>  	u32 ctrl0, ctrl1;
> 
> -	mxs_reset_block(host->base);
> +	stmp_reset_block(host->base);
> 
>  	ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
>  	ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
> @@ -279,7 +279,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void
> *dev_id)
> 
>  	stat = readl(host->base + HW_SSP_CTRL1);
>  	writel(stat & MXS_MMC_IRQ_BITS,
> -	       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
> +	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
> 
>  	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
>  		mmc_signal_sdio_irq(host->mmc);
> @@ -637,18 +637,18 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host
> *mmc, int enable)
> 
>  	if (enable) {
>  		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
> -		       host->base + HW_SSP_CTRL0 + MXS_SET_ADDR);
> +		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + MXS_SET_ADDR);
> +		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
> 
>  		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
>  			mmc_signal_sdio_irq(host->mmc);
> 
>  	} else {
>  		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
> -		       host->base + HW_SSP_CTRL0 + MXS_CLR_ADDR);
> +		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
> +		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
>  	}
> 
>  	spin_unlock_irqrestore(&host->lock, flags);

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 01/10] mmc: mxs-mmc: use global stmp_device functionality
@ 2012-05-07 23:41     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:41 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> Use global stmp_device functionality to reduce mach-dependency.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/mmc/host/mxs-mmc.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index bb03ddd..2ea5361 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -40,9 +40,9 @@
>  #include <linux/module.h>
>  #include <linux/fsl/mxs-dma.h>
>  #include <linux/pinctrl/consumer.h>
> +#include <linux/stmp_device.h>
> 
>  #include <mach/mxs.h>
> -#include <mach/common.h>
>  #include <mach/mmc.h>
> 
>  #define DRIVER_NAME	"mxs-mmc"
> @@ -191,7 +191,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
>  {
>  	u32 ctrl0, ctrl1;
> 
> -	mxs_reset_block(host->base);
> +	stmp_reset_block(host->base);
> 
>  	ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
>  	ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
> @@ -279,7 +279,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void
> *dev_id)
> 
>  	stat = readl(host->base + HW_SSP_CTRL1);
>  	writel(stat & MXS_MMC_IRQ_BITS,
> -	       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
> +	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
> 
>  	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
>  		mmc_signal_sdio_irq(host->mmc);
> @@ -637,18 +637,18 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host
> *mmc, int enable)
> 
>  	if (enable) {
>  		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
> -		       host->base + HW_SSP_CTRL0 + MXS_SET_ADDR);
> +		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + MXS_SET_ADDR);
> +		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
> 
>  		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
>  			mmc_signal_sdio_irq(host->mmc);
> 
>  	} else {
>  		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
> -		       host->base + HW_SSP_CTRL0 + MXS_CLR_ADDR);
> +		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
> +		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
>  	}
> 
>  	spin_unlock_irqrestore(&host->lock, flags);

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:43     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:43 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> Let macro ssp_is_old take host as parameter to make the code easy
> to read.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/mxs-mmc.c |   59
> ++++++++++++++++++++++--------------------- 1 files changed, 30
> insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 2ea5361..13907e4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -51,7 +51,7 @@
>  #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
> 
>  #define SSP_VERSION_LATEST	4
> -#define ssp_is_old()		(host->version < SSP_VERSION_LATEST)
> +#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)

(host)->version ... to make the macro safer.

> 
>  /* SSP registers */
>  #define HW_SSP_CTRL0				0x000
> @@ -86,14 +86,14 @@
>  #define  BM_SSP_BLOCK_SIZE_BLOCK_COUNT		(0xffffff << 4)
>  #define  BP_SSP_BLOCK_SIZE_BLOCK_SIZE		(0)
>  #define  BM_SSP_BLOCK_SIZE_BLOCK_SIZE		(0xf)
> -#define HW_SSP_TIMING				(ssp_is_old() ? 0x050 : 
0x070)
> +#define HW_SSP_TIMING(h)			(ssp_is_old(h) ? 0x050 : 0x070)
>  #define  BP_SSP_TIMING_TIMEOUT			(16)
>  #define  BM_SSP_TIMING_TIMEOUT			(0xffff << 16)
>  #define  BP_SSP_TIMING_CLOCK_DIVIDE		(8)
>  #define  BM_SSP_TIMING_CLOCK_DIVIDE		(0xff << 8)
>  #define  BP_SSP_TIMING_CLOCK_RATE		(0)
>  #define  BM_SSP_TIMING_CLOCK_RATE		(0xff)
> -#define HW_SSP_CTRL1				(ssp_is_old() ? 0x060 : 0x080)
> +#define HW_SSP_CTRL1(h)				(ssp_is_old(h) ? 0x060 : 
0x080)
>  #define  BM_SSP_CTRL1_SDIO_IRQ			(1 << 31)
>  #define  BM_SSP_CTRL1_SDIO_IRQ_EN		(1 << 30)
>  #define  BM_SSP_CTRL1_RESP_ERR_IRQ		(1 << 29)
> @@ -116,11 +116,11 @@
>  #define  BM_SSP_CTRL1_WORD_LENGTH		(0xf << 4)
>  #define  BP_SSP_CTRL1_SSP_MODE			(0)
>  #define  BM_SSP_CTRL1_SSP_MODE			(0xf)
> -#define HW_SSP_SDRESP0				(ssp_is_old() ? 0x080 : 
0x0a0)
> -#define HW_SSP_SDRESP1				(ssp_is_old() ? 0x090 : 
0x0b0)
> -#define HW_SSP_SDRESP2				(ssp_is_old() ? 0x0a0 : 
0x0c0)
> -#define HW_SSP_SDRESP3				(ssp_is_old() ? 0x0b0 : 
0x0d0)
> -#define HW_SSP_STATUS				(ssp_is_old() ? 0x0c0 : 
0x100)
> +#define HW_SSP_SDRESP0(h)			(ssp_is_old(h) ? 0x080 : 0x0a0)
> +#define HW_SSP_SDRESP1(h)			(ssp_is_old(h) ? 0x090 : 0x0b0)
> +#define HW_SSP_SDRESP2(h)			(ssp_is_old(h) ? 0x0a0 : 0x0c0)
> +#define HW_SSP_SDRESP3(h)			(ssp_is_old(h) ? 0x0b0 : 0x0d0)
> +#define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
>  #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
>  #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
>  #define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 
0x130)
> @@ -183,7 +183,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
>  {
>  	struct mxs_mmc_host *host = mmc_priv(mmc);
> 
> -	return !(readl(host->base + HW_SSP_STATUS) &
> +	return !(readl(host->base + HW_SSP_STATUS(host)) &
>  		 BM_SSP_STATUS_CARD_DETECT);
>  }
> 
> @@ -207,7 +207,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
>  	writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
>  	       BF_SSP(2, TIMING_CLOCK_DIVIDE) |
>  	       BF_SSP(0, TIMING_CLOCK_RATE),
> -	       host->base + HW_SSP_TIMING);
> +	       host->base + HW_SSP_TIMING(host));
> 
>  	if (host->sdio_irq_en) {
>  		ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
> @@ -215,7 +215,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
>  	}
> 
>  	writel(ctrl0, host->base + HW_SSP_CTRL0);
> -	writel(ctrl1, host->base + HW_SSP_CTRL1);
> +	writel(ctrl1, host->base + HW_SSP_CTRL1(host));
>  }
> 
>  static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
> @@ -229,12 +229,12 @@ static void mxs_mmc_request_done(struct mxs_mmc_host
> *host)
> 
>  	if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
>  		if (mmc_resp_type(cmd) & MMC_RSP_136) {
> -			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0);
> -			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1);
> -			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2);
> -			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3);
> +			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0(host));
> +			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1(host));
> +			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2(host));
> +			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3(host));
>  		} else {
> -			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0);
> +			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0(host));
>  		}
>  	}
> 
> @@ -277,11 +277,11 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void
> *dev_id)
> 
>  	spin_lock(&host->lock);
> 
> -	stat = readl(host->base + HW_SSP_CTRL1);
> +	stat = readl(host->base + HW_SSP_CTRL1(host));
>  	writel(stat & MXS_MMC_IRQ_BITS,
> -	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
> +	       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
> 
> -	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> +	if ((sta & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))

^ s/sta/stat/ ... did you try compiling this at all ? :-)

>  		mmc_signal_sdio_irq(host->mmc);
> 
>  	spin_unlock(&host->lock);
> @@ -485,7 +485,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
>  		blocks = 1;
> 
>  	/* xfer count, block size and count need to be set differently */
> -	if (ssp_is_old()) {
> +	if (ssp_is_old(host)) {
>  		ctrl0 |= BF_SSP(data_size, CTRL0_XFER_COUNT);
>  		cmd0 |= BF_SSP(log2_blksz, CMD0_BLOCK_SIZE) |
>  			BF_SSP(blocks - 1, CMD0_BLOCK_COUNT);
> @@ -509,10 +509,10 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
> 
>  	/* set the timeout count */
>  	timeout = mxs_ns_to_ssp_ticks(host->clk_rate, data->timeout_ns);
> -	val = readl(host->base + HW_SSP_TIMING);
> +	val = readl(host->base + HW_SSP_TIMING(host));
>  	val &= ~(BM_SSP_TIMING_TIMEOUT);
>  	val |= BF_SSP(timeout, TIMING_TIMEOUT);
> -	writel(val, host->base + HW_SSP_TIMING);
> +	writel(val, host->base + HW_SSP_TIMING(host));
> 
>  	/* pio */
>  	host->ssp_pio_words[0] = ctrl0;
> @@ -598,11 +598,11 @@ static void mxs_mmc_set_clk_rate(struct mxs_mmc_host
> *host, unsigned int rate)
> 
>  	ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
> 
> -	val = readl(host->base + HW_SSP_TIMING);
> +	val = readl(host->base + HW_SSP_TIMING(host));
>  	val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
>  	val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
>  	val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
> -	writel(val, host->base + HW_SSP_TIMING);
> +	writel(val, host->base + HW_SSP_TIMING(host));
> 
>  	host->clk_rate = ssp_sck;
> 
> @@ -639,16 +639,17 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host
> *mmc, int enable) writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
>  		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
> +		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_SET);
> 
> -		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
> +		if (readl(host->base + HW_SSP_STATUS(host)) &
> +				BM_SSP_STATUS_SDIO_IRQ)
>  			mmc_signal_sdio_irq(host->mmc);
> 
>  	} else {
>  		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
>  		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
> +		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
>  	}
> 
>  	spin_unlock_irqrestore(&host->lock, flags);
> @@ -765,8 +766,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 
>  	mmc->max_segs = 52;
>  	mmc->max_blk_size = 1 << 0xf;
> -	mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff;
> -	mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff;
> +	mmc->max_blk_count = (ssp_is_old(host)) ? 0xff : 0xffffff;
> +	mmc->max_req_size = (ssp_is_old(host)) ? 0xffff : 0xffffffff;
>  	mmc->max_seg_size = dma_get_max_seg_size(host->dmach->device->dev);
> 
>  	platform_set_drvdata(pdev, mmc);

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter
@ 2012-05-07 23:43     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:43 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> Let macro ssp_is_old take host as parameter to make the code easy
> to read.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/mxs-mmc.c |   59
> ++++++++++++++++++++++--------------------- 1 files changed, 30
> insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 2ea5361..13907e4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -51,7 +51,7 @@
>  #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
> 
>  #define SSP_VERSION_LATEST	4
> -#define ssp_is_old()		(host->version < SSP_VERSION_LATEST)
> +#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)

(host)->version ... to make the macro safer.

> 
>  /* SSP registers */
>  #define HW_SSP_CTRL0				0x000
> @@ -86,14 +86,14 @@
>  #define  BM_SSP_BLOCK_SIZE_BLOCK_COUNT		(0xffffff << 4)
>  #define  BP_SSP_BLOCK_SIZE_BLOCK_SIZE		(0)
>  #define  BM_SSP_BLOCK_SIZE_BLOCK_SIZE		(0xf)
> -#define HW_SSP_TIMING				(ssp_is_old() ? 0x050 : 
0x070)
> +#define HW_SSP_TIMING(h)			(ssp_is_old(h) ? 0x050 : 0x070)
>  #define  BP_SSP_TIMING_TIMEOUT			(16)
>  #define  BM_SSP_TIMING_TIMEOUT			(0xffff << 16)
>  #define  BP_SSP_TIMING_CLOCK_DIVIDE		(8)
>  #define  BM_SSP_TIMING_CLOCK_DIVIDE		(0xff << 8)
>  #define  BP_SSP_TIMING_CLOCK_RATE		(0)
>  #define  BM_SSP_TIMING_CLOCK_RATE		(0xff)
> -#define HW_SSP_CTRL1				(ssp_is_old() ? 0x060 : 0x080)
> +#define HW_SSP_CTRL1(h)				(ssp_is_old(h) ? 0x060 : 
0x080)
>  #define  BM_SSP_CTRL1_SDIO_IRQ			(1 << 31)
>  #define  BM_SSP_CTRL1_SDIO_IRQ_EN		(1 << 30)
>  #define  BM_SSP_CTRL1_RESP_ERR_IRQ		(1 << 29)
> @@ -116,11 +116,11 @@
>  #define  BM_SSP_CTRL1_WORD_LENGTH		(0xf << 4)
>  #define  BP_SSP_CTRL1_SSP_MODE			(0)
>  #define  BM_SSP_CTRL1_SSP_MODE			(0xf)
> -#define HW_SSP_SDRESP0				(ssp_is_old() ? 0x080 : 
0x0a0)
> -#define HW_SSP_SDRESP1				(ssp_is_old() ? 0x090 : 
0x0b0)
> -#define HW_SSP_SDRESP2				(ssp_is_old() ? 0x0a0 : 
0x0c0)
> -#define HW_SSP_SDRESP3				(ssp_is_old() ? 0x0b0 : 
0x0d0)
> -#define HW_SSP_STATUS				(ssp_is_old() ? 0x0c0 : 
0x100)
> +#define HW_SSP_SDRESP0(h)			(ssp_is_old(h) ? 0x080 : 0x0a0)
> +#define HW_SSP_SDRESP1(h)			(ssp_is_old(h) ? 0x090 : 0x0b0)
> +#define HW_SSP_SDRESP2(h)			(ssp_is_old(h) ? 0x0a0 : 0x0c0)
> +#define HW_SSP_SDRESP3(h)			(ssp_is_old(h) ? 0x0b0 : 0x0d0)
> +#define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
>  #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
>  #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
>  #define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 
0x130)
> @@ -183,7 +183,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
>  {
>  	struct mxs_mmc_host *host = mmc_priv(mmc);
> 
> -	return !(readl(host->base + HW_SSP_STATUS) &
> +	return !(readl(host->base + HW_SSP_STATUS(host)) &
>  		 BM_SSP_STATUS_CARD_DETECT);
>  }
> 
> @@ -207,7 +207,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
>  	writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
>  	       BF_SSP(2, TIMING_CLOCK_DIVIDE) |
>  	       BF_SSP(0, TIMING_CLOCK_RATE),
> -	       host->base + HW_SSP_TIMING);
> +	       host->base + HW_SSP_TIMING(host));
> 
>  	if (host->sdio_irq_en) {
>  		ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
> @@ -215,7 +215,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
>  	}
> 
>  	writel(ctrl0, host->base + HW_SSP_CTRL0);
> -	writel(ctrl1, host->base + HW_SSP_CTRL1);
> +	writel(ctrl1, host->base + HW_SSP_CTRL1(host));
>  }
> 
>  static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
> @@ -229,12 +229,12 @@ static void mxs_mmc_request_done(struct mxs_mmc_host
> *host)
> 
>  	if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
>  		if (mmc_resp_type(cmd) & MMC_RSP_136) {
> -			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0);
> -			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1);
> -			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2);
> -			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3);
> +			cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0(host));
> +			cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1(host));
> +			cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2(host));
> +			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3(host));
>  		} else {
> -			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0);
> +			cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0(host));
>  		}
>  	}
> 
> @@ -277,11 +277,11 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void
> *dev_id)
> 
>  	spin_lock(&host->lock);
> 
> -	stat = readl(host->base + HW_SSP_CTRL1);
> +	stat = readl(host->base + HW_SSP_CTRL1(host));
>  	writel(stat & MXS_MMC_IRQ_BITS,
> -	       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
> +	       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
> 
> -	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> +	if ((sta & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))

^ s/sta/stat/ ... did you try compiling this at all ? :-)

>  		mmc_signal_sdio_irq(host->mmc);
> 
>  	spin_unlock(&host->lock);
> @@ -485,7 +485,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
>  		blocks = 1;
> 
>  	/* xfer count, block size and count need to be set differently */
> -	if (ssp_is_old()) {
> +	if (ssp_is_old(host)) {
>  		ctrl0 |= BF_SSP(data_size, CTRL0_XFER_COUNT);
>  		cmd0 |= BF_SSP(log2_blksz, CMD0_BLOCK_SIZE) |
>  			BF_SSP(blocks - 1, CMD0_BLOCK_COUNT);
> @@ -509,10 +509,10 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
> 
>  	/* set the timeout count */
>  	timeout = mxs_ns_to_ssp_ticks(host->clk_rate, data->timeout_ns);
> -	val = readl(host->base + HW_SSP_TIMING);
> +	val = readl(host->base + HW_SSP_TIMING(host));
>  	val &= ~(BM_SSP_TIMING_TIMEOUT);
>  	val |= BF_SSP(timeout, TIMING_TIMEOUT);
> -	writel(val, host->base + HW_SSP_TIMING);
> +	writel(val, host->base + HW_SSP_TIMING(host));
> 
>  	/* pio */
>  	host->ssp_pio_words[0] = ctrl0;
> @@ -598,11 +598,11 @@ static void mxs_mmc_set_clk_rate(struct mxs_mmc_host
> *host, unsigned int rate)
> 
>  	ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
> 
> -	val = readl(host->base + HW_SSP_TIMING);
> +	val = readl(host->base + HW_SSP_TIMING(host));
>  	val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
>  	val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
>  	val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
> -	writel(val, host->base + HW_SSP_TIMING);
> +	writel(val, host->base + HW_SSP_TIMING(host));
> 
>  	host->clk_rate = ssp_sck;
> 
> @@ -639,16 +639,17 @@ static void mxs_mmc_enable_sdio_irq(struct mmc_host
> *mmc, int enable) writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
>  		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_SET);
> +		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_SET);
> 
> -		if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ)
> +		if (readl(host->base + HW_SSP_STATUS(host)) &
> +				BM_SSP_STATUS_SDIO_IRQ)
>  			mmc_signal_sdio_irq(host->mmc);
> 
>  	} else {
>  		writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK,
>  		       host->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
>  		writel(BM_SSP_CTRL1_SDIO_IRQ_EN,
> -		       host->base + HW_SSP_CTRL1 + STMP_OFFSET_REG_CLR);
> +		       host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
>  	}
> 
>  	spin_unlock_irqrestore(&host->lock, flags);
> @@ -765,8 +766,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 
>  	mmc->max_segs = 52;
>  	mmc->max_blk_size = 1 << 0xf;
> -	mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff;
> -	mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff;
> +	mmc->max_blk_count = (ssp_is_old(host)) ? 0xff : 0xffffff;
> +	mmc->max_req_size = (ssp_is_old(host)) ? 0xffff : 0xffffffff;
>  	mmc->max_seg_size = dma_get_max_seg_size(host->dmach->device->dev);
> 
>  	platform_set_drvdata(pdev, mmc);

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:46     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:46 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> The register HW_SSP_VERSION is broken for ssp version detection,
> as the address of the register is different between imx23 and imx28.
> Let's use platform_device_id to detect the device, so that the use
> of cpu_is_xxx can be removed.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

[...]

> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 13907e4..54bbb8b 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -42,7 +42,6 @@
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/stmp_device.h>
> 
> -#include <mach/mxs.h>
>  #include <mach/mmc.h>
> 
>  #define DRIVER_NAME	"mxs-mmc"
> @@ -50,8 +49,7 @@
>  /* card detect polling timeout */
>  #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
> 
> -#define SSP_VERSION_LATEST	4
> -#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
> +#define ssp_is_old(host)	(host->devid == IMX23_MMC)

(host)->devid ...

> 
>  /* SSP registers */
>  #define HW_SSP_CTRL0				0x000
> @@ -123,8 +121,6 @@
>  #define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
>  #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
>  #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
> -#define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 
0x130)
> -#define  BP_SSP_VERSION_MAJOR			(24)
> 
>  #define BF_SSP(value, field)	(((value) << BP_SSP_##field) &
> BM_SSP_##field)
> 
> @@ -139,6 +135,11 @@
> 
>  #define SSP_PIO_NUM	3
> 
> +enum mxs_mmc_id {
> +	IMX23_MMC,
> +	IMX28_MMC,
> +};
> +
>  struct mxs_mmc_host {
>  	struct mmc_host			*mmc;
>  	struct mmc_request		*mrq;
> @@ -158,7 +159,7 @@ struct mxs_mmc_host {
>  	enum dma_transfer_direction	slave_dirn;
>  	u32				ssp_pio_words[SSP_PIO_NUM];
> 
> -	unsigned int			version;
> +	enum mxs_mmc_id			devid;
>  	unsigned char			bus_width;
>  	spinlock_t			lock;
>  	int				sdio_irq_en;
> @@ -678,6 +679,19 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan,
> void *param) return true;
>  }
> 
> +static struct platform_device_id mxs_mmc_ids[] = {
> +	{
> +		.name = "imx23-mmc",
> +		.driver_data = IMX23_MMC,
> +	}, {
> +		.name = "imx28-mmc",
> +		.driver_data = IMX28_MMC,
> +	}, {
> +		/* sentinel */
> +	}
> +};
> +MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>  	struct mxs_mmc_host *host;
> @@ -712,10 +726,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		goto out_mmc_free;
>  	}
> 
> -	/* only major verion does matter */
> -	host->version = readl(host->base + HW_SSP_VERSION) >>
> -			BP_SSP_VERSION_MAJOR;
> -
> +	host->devid = pdev->id_entry->driver_data;
>  	host->mmc = mmc;
>  	host->res = r;
>  	host->dma_res = dmares;
> @@ -866,6 +877,7 @@ static const struct dev_pm_ops mxs_mmc_pm_ops = {
>  static struct platform_driver mxs_mmc_driver = {
>  	.probe		= mxs_mmc_probe,
>  	.remove		= mxs_mmc_remove,
> +	.id_table	= mxs_mmc_ids,
>  	.driver		= {
>  		.name	= DRIVER_NAME,
>  		.owner	= THIS_MODULE,

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx
@ 2012-05-07 23:46     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:46 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> The register HW_SSP_VERSION is broken for ssp version detection,
> as the address of the register is different between imx23 and imx28.
> Let's use platform_device_id to detect the device, so that the use
> of cpu_is_xxx can be removed.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

[...]

> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 13907e4..54bbb8b 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -42,7 +42,6 @@
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/stmp_device.h>
> 
> -#include <mach/mxs.h>
>  #include <mach/mmc.h>
> 
>  #define DRIVER_NAME	"mxs-mmc"
> @@ -50,8 +49,7 @@
>  /* card detect polling timeout */
>  #define MXS_MMC_DETECT_TIMEOUT			(HZ/2)
> 
> -#define SSP_VERSION_LATEST	4
> -#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
> +#define ssp_is_old(host)	(host->devid == IMX23_MMC)

(host)->devid ...

> 
>  /* SSP registers */
>  #define HW_SSP_CTRL0				0x000
> @@ -123,8 +121,6 @@
>  #define HW_SSP_STATUS(h)			(ssp_is_old(h) ? 0x0c0 : 0x100)
>  #define  BM_SSP_STATUS_CARD_DETECT		(1 << 28)
>  #define  BM_SSP_STATUS_SDIO_IRQ			(1 << 17)
> -#define HW_SSP_VERSION				(cpu_is_mx23() ? 0x110 : 
0x130)
> -#define  BP_SSP_VERSION_MAJOR			(24)
> 
>  #define BF_SSP(value, field)	(((value) << BP_SSP_##field) &
> BM_SSP_##field)
> 
> @@ -139,6 +135,11 @@
> 
>  #define SSP_PIO_NUM	3
> 
> +enum mxs_mmc_id {
> +	IMX23_MMC,
> +	IMX28_MMC,
> +};
> +
>  struct mxs_mmc_host {
>  	struct mmc_host			*mmc;
>  	struct mmc_request		*mrq;
> @@ -158,7 +159,7 @@ struct mxs_mmc_host {
>  	enum dma_transfer_direction	slave_dirn;
>  	u32				ssp_pio_words[SSP_PIO_NUM];
> 
> -	unsigned int			version;
> +	enum mxs_mmc_id			devid;
>  	unsigned char			bus_width;
>  	spinlock_t			lock;
>  	int				sdio_irq_en;
> @@ -678,6 +679,19 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan,
> void *param) return true;
>  }
> 
> +static struct platform_device_id mxs_mmc_ids[] = {
> +	{
> +		.name = "imx23-mmc",
> +		.driver_data = IMX23_MMC,
> +	}, {
> +		.name = "imx28-mmc",
> +		.driver_data = IMX28_MMC,
> +	}, {
> +		/* sentinel */
> +	}
> +};
> +MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>  	struct mxs_mmc_host *host;
> @@ -712,10 +726,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		goto out_mmc_free;
>  	}
> 
> -	/* only major verion does matter */
> -	host->version = readl(host->base + HW_SSP_VERSION) >>
> -			BP_SSP_VERSION_MAJOR;
> -
> +	host->devid = pdev->id_entry->driver_data;
>  	host->mmc = mmc;
>  	host->res = r;
>  	host->dma_res = dmares;
> @@ -866,6 +877,7 @@ static const struct dev_pm_ops mxs_mmc_pm_ops = {
>  static struct platform_driver mxs_mmc_driver = {
>  	.probe		= mxs_mmc_probe,
>  	.remove		= mxs_mmc_remove,
> +	.id_table	= mxs_mmc_ids,
>  	.driver		= {
>  		.name	= DRIVER_NAME,
>  		.owner	= THIS_MODULE,

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 04/10] mmc: mxs-mmc: move header from mach into linux folder
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:47     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:47 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> Rename arch/arm/mach-mxs/include/mach/mmc.h to
> include/linux/mmc/mxs-mmc.h, so that mxs-mmc driver becomes
> <mach/*> inclusion free.

Good :-)

Acked-by: Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  arch/arm/mach-mxs/include/mach/devices-common.h    |    2 +-
>  drivers/mmc/host/mxs-mmc.c                         |    3 +--
>  .../mach/mmc.h => include/linux/mmc/mxs-mmc.h      |    7 ++++---
>  3 files changed, 6 insertions(+), 6 deletions(-)
>  rename arch/arm/mach-mxs/include/mach/mmc.h => include/linux/mmc/mxs-mmc.h
> (81%)
> 
> diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h
> b/arch/arm/mach-mxs/include/mach/devices-common.h index 2b37689..6fc0601
> 100644
> --- a/arch/arm/mach-mxs/include/mach/devices-common.h
> +++ b/arch/arm/mach-mxs/include/mach/devices-common.h
> @@ -87,7 +87,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
>  		const struct mxs_mxs_i2c_data *data);
> 
>  /* mmc */
> -#include <mach/mmc.h>
> +#include <linux/mmc/mxs-mmc.h>
>  struct mxs_mxs_mmc_data {
>  	const char *devid;
>  	int id;
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 54bbb8b..c70c7c7 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -41,8 +41,7 @@
>  #include <linux/fsl/mxs-dma.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/stmp_device.h>
> -
> -#include <mach/mmc.h>
> +#include <linux/mmc/mxs-mmc.h>
> 
>  #define DRIVER_NAME	"mxs-mmc"
> 
> diff --git a/arch/arm/mach-mxs/include/mach/mmc.h
> b/include/linux/mmc/mxs-mmc.h similarity index 81%
> rename from arch/arm/mach-mxs/include/mach/mmc.h
> rename to include/linux/mmc/mxs-mmc.h
> index 211547a..7c2ad3a 100644
> --- a/arch/arm/mach-mxs/include/mach/mmc.h
> +++ b/include/linux/mmc/mxs-mmc.h
> @@ -6,8 +6,8 @@
>   * published by the Free Software Foundation.
>   */
> 
> -#ifndef __MACH_MXS_MMC_H__
> -#define __MACH_MXS_MMC_H__
> +#ifndef __LINUX_MMC_MXS_MMC_H__
> +#define __LINUX_MMC_MXS_MMC_H__
> 
>  struct mxs_mmc_platform_data {
>  	int wp_gpio;	/* write protect pin */
> @@ -15,4 +15,5 @@ struct mxs_mmc_platform_data {
>  #define SLOTF_4_BIT_CAPABLE	(1 << 0)
>  #define SLOTF_8_BIT_CAPABLE	(1 << 1)
>  };
> -#endif /* __MACH_MXS_MMC_H__ */
> +
> +#endif /* __LINUX_MMC_MXS_MMC_H__ */

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 04/10] mmc: mxs-mmc: move header from mach into linux folder
@ 2012-05-07 23:47     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:47 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> Rename arch/arm/mach-mxs/include/mach/mmc.h to
> include/linux/mmc/mxs-mmc.h, so that mxs-mmc driver becomes
> <mach/*> inclusion free.

Good :-)

Acked-by: Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  arch/arm/mach-mxs/include/mach/devices-common.h    |    2 +-
>  drivers/mmc/host/mxs-mmc.c                         |    3 +--
>  .../mach/mmc.h => include/linux/mmc/mxs-mmc.h      |    7 ++++---
>  3 files changed, 6 insertions(+), 6 deletions(-)
>  rename arch/arm/mach-mxs/include/mach/mmc.h => include/linux/mmc/mxs-mmc.h
> (81%)
> 
> diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h
> b/arch/arm/mach-mxs/include/mach/devices-common.h index 2b37689..6fc0601
> 100644
> --- a/arch/arm/mach-mxs/include/mach/devices-common.h
> +++ b/arch/arm/mach-mxs/include/mach/devices-common.h
> @@ -87,7 +87,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
>  		const struct mxs_mxs_i2c_data *data);
> 
>  /* mmc */
> -#include <mach/mmc.h>
> +#include <linux/mmc/mxs-mmc.h>
>  struct mxs_mxs_mmc_data {
>  	const char *devid;
>  	int id;
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 54bbb8b..c70c7c7 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -41,8 +41,7 @@
>  #include <linux/fsl/mxs-dma.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/stmp_device.h>
> -
> -#include <mach/mmc.h>
> +#include <linux/mmc/mxs-mmc.h>
> 
>  #define DRIVER_NAME	"mxs-mmc"
> 
> diff --git a/arch/arm/mach-mxs/include/mach/mmc.h
> b/include/linux/mmc/mxs-mmc.h similarity index 81%
> rename from arch/arm/mach-mxs/include/mach/mmc.h
> rename to include/linux/mmc/mxs-mmc.h
> index 211547a..7c2ad3a 100644
> --- a/arch/arm/mach-mxs/include/mach/mmc.h
> +++ b/include/linux/mmc/mxs-mmc.h
> @@ -6,8 +6,8 @@
>   * published by the Free Software Foundation.
>   */
> 
> -#ifndef __MACH_MXS_MMC_H__
> -#define __MACH_MXS_MMC_H__
> +#ifndef __LINUX_MMC_MXS_MMC_H__
> +#define __LINUX_MMC_MXS_MMC_H__
> 
>  struct mxs_mmc_platform_data {
>  	int wp_gpio;	/* write protect pin */
> @@ -15,4 +15,5 @@ struct mxs_mmc_platform_data {
>  #define SLOTF_4_BIT_CAPABLE	(1 << 0)
>  #define SLOTF_8_BIT_CAPABLE	(1 << 1)
>  };
> -#endif /* __MACH_MXS_MMC_H__ */
> +
> +#endif /* __LINUX_MMC_MXS_MMC_H__ */

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:49     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:49 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> Use devm_request_and_ioremap and devm_request_irq helpers to clean up
> the code a little bit.

Nice :)

btw do we have i2c dt bindings ?

Acked-by: Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/mxs-mmc.c |   40 +++++++++-------------------------------
>  1 files changed, 9 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index c70c7c7..1a8ba314 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -146,8 +146,6 @@ struct mxs_mmc_host {
>  	struct mmc_data			*data;
> 
>  	void __iomem			*base;
> -	int				irq;
> -	struct resource			*res;
>  	struct resource			*dma_res;
>  	struct clk			*clk;
>  	unsigned int			clk_rate;
> @@ -695,7 +693,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>  	struct mxs_mmc_host *host;
>  	struct mmc_host *mmc;
> -	struct resource *iores, *dmares, *r;
> +	struct resource *iores, *dmares;
>  	struct mxs_mmc_platform_data *pdata;
>  	struct pinctrl *pinctrl;
>  	int ret = 0, irq_err, irq_dma;
> @@ -708,28 +706,20 @@ static int mxs_mmc_probe(struct platform_device
> *pdev) if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
>  		return -EINVAL;
> 
> -	r = request_mem_region(iores->start, resource_size(iores), pdev->name);
> -	if (!r)
> -		return -EBUSY;
> -
>  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> -	if (!mmc) {
> -		ret = -ENOMEM;
> -		goto out_release_mem;
> -	}
> +	if (!mmc)
> +		return -ENOMEM;
> 
>  	host = mmc_priv(mmc);
> -	host->base = ioremap(r->start, resource_size(r));
> +	host->base = devm_request_and_ioremap(&pdev->dev, iores);
>  	if (!host->base) {
> -		ret = -ENOMEM;
> +		ret = -EADDRNOTAVAIL;
>  		goto out_mmc_free;
>  	}
> 
>  	host->devid = pdev->id_entry->driver_data;
>  	host->mmc = mmc;
> -	host->res = r;
>  	host->dma_res = dmares;
> -	host->irq = irq_err;
>  	host->sdio_irq_en = 0;
> 
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> @@ -741,7 +731,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	host->clk = clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(host->clk)) {
>  		ret = PTR_ERR(host->clk);
> -		goto out_iounmap;
> +		goto out_mmc_free;
>  	}
>  	clk_prepare_enable(host->clk);
> 
> @@ -782,7 +772,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 
>  	platform_set_drvdata(pdev, mmc);
> 
> -	ret = request_irq(host->irq, mxs_mmc_irq_handler, 0, DRIVER_NAME, host);
> +	ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
> +			       DRIVER_NAME, host);
>  	if (ret)
>  		goto out_free_dma;
> 
> @@ -790,26 +781,20 @@ static int mxs_mmc_probe(struct platform_device
> *pdev)
> 
>  	ret = mmc_add_host(mmc);
>  	if (ret)
> -		goto out_free_irq;
> +		goto out_free_dma;
> 
>  	dev_info(mmc_dev(host->mmc), "initialized\n");
> 
>  	return 0;
> 
> -out_free_irq:
> -	free_irq(host->irq, host);
>  out_free_dma:
>  	if (host->dmach)
>  		dma_release_channel(host->dmach);
>  out_clk_put:
>  	clk_disable_unprepare(host->clk);
>  	clk_put(host->clk);
> -out_iounmap:
> -	iounmap(host->base);
>  out_mmc_free:
>  	mmc_free_host(mmc);
> -out_release_mem:
> -	release_mem_region(iores->start, resource_size(iores));
>  	return ret;
>  }
> 
> @@ -817,12 +802,9 @@ static int mxs_mmc_remove(struct platform_device
> *pdev) {
>  	struct mmc_host *mmc = platform_get_drvdata(pdev);
>  	struct mxs_mmc_host *host = mmc_priv(mmc);
> -	struct resource *res = host->res;
> 
>  	mmc_remove_host(mmc);
> 
> -	free_irq(host->irq, host);
> -
>  	platform_set_drvdata(pdev, NULL);
> 
>  	if (host->dmach)
> @@ -831,12 +813,8 @@ static int mxs_mmc_remove(struct platform_device
> *pdev) clk_disable_unprepare(host->clk);
>  	clk_put(host->clk);
> 
> -	iounmap(host->base);
> -
>  	mmc_free_host(mmc);
> 
> -	release_mem_region(res->start, resource_size(res));
> -
>  	return 0;
>  }

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler
@ 2012-05-07 23:49     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:49 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> Use devm_request_and_ioremap and devm_request_irq helpers to clean up
> the code a little bit.

Nice :)

btw do we have i2c dt bindings ?

Acked-by: Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/mxs-mmc.c |   40 +++++++++-------------------------------
>  1 files changed, 9 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index c70c7c7..1a8ba314 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -146,8 +146,6 @@ struct mxs_mmc_host {
>  	struct mmc_data			*data;
> 
>  	void __iomem			*base;
> -	int				irq;
> -	struct resource			*res;
>  	struct resource			*dma_res;
>  	struct clk			*clk;
>  	unsigned int			clk_rate;
> @@ -695,7 +693,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>  	struct mxs_mmc_host *host;
>  	struct mmc_host *mmc;
> -	struct resource *iores, *dmares, *r;
> +	struct resource *iores, *dmares;
>  	struct mxs_mmc_platform_data *pdata;
>  	struct pinctrl *pinctrl;
>  	int ret = 0, irq_err, irq_dma;
> @@ -708,28 +706,20 @@ static int mxs_mmc_probe(struct platform_device
> *pdev) if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
>  		return -EINVAL;
> 
> -	r = request_mem_region(iores->start, resource_size(iores), pdev->name);
> -	if (!r)
> -		return -EBUSY;
> -
>  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> -	if (!mmc) {
> -		ret = -ENOMEM;
> -		goto out_release_mem;
> -	}
> +	if (!mmc)
> +		return -ENOMEM;
> 
>  	host = mmc_priv(mmc);
> -	host->base = ioremap(r->start, resource_size(r));
> +	host->base = devm_request_and_ioremap(&pdev->dev, iores);
>  	if (!host->base) {
> -		ret = -ENOMEM;
> +		ret = -EADDRNOTAVAIL;
>  		goto out_mmc_free;
>  	}
> 
>  	host->devid = pdev->id_entry->driver_data;
>  	host->mmc = mmc;
> -	host->res = r;
>  	host->dma_res = dmares;
> -	host->irq = irq_err;
>  	host->sdio_irq_en = 0;
> 
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> @@ -741,7 +731,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	host->clk = clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(host->clk)) {
>  		ret = PTR_ERR(host->clk);
> -		goto out_iounmap;
> +		goto out_mmc_free;
>  	}
>  	clk_prepare_enable(host->clk);
> 
> @@ -782,7 +772,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 
>  	platform_set_drvdata(pdev, mmc);
> 
> -	ret = request_irq(host->irq, mxs_mmc_irq_handler, 0, DRIVER_NAME, host);
> +	ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
> +			       DRIVER_NAME, host);
>  	if (ret)
>  		goto out_free_dma;
> 
> @@ -790,26 +781,20 @@ static int mxs_mmc_probe(struct platform_device
> *pdev)
> 
>  	ret = mmc_add_host(mmc);
>  	if (ret)
> -		goto out_free_irq;
> +		goto out_free_dma;
> 
>  	dev_info(mmc_dev(host->mmc), "initialized\n");
> 
>  	return 0;
> 
> -out_free_irq:
> -	free_irq(host->irq, host);
>  out_free_dma:
>  	if (host->dmach)
>  		dma_release_channel(host->dmach);
>  out_clk_put:
>  	clk_disable_unprepare(host->clk);
>  	clk_put(host->clk);
> -out_iounmap:
> -	iounmap(host->base);
>  out_mmc_free:
>  	mmc_free_host(mmc);
> -out_release_mem:
> -	release_mem_region(iores->start, resource_size(iores));
>  	return ret;
>  }
> 
> @@ -817,12 +802,9 @@ static int mxs_mmc_remove(struct platform_device
> *pdev) {
>  	struct mmc_host *mmc = platform_get_drvdata(pdev);
>  	struct mxs_mmc_host *host = mmc_priv(mmc);
> -	struct resource *res = host->res;
> 
>  	mmc_remove_host(mmc);
> 
> -	free_irq(host->irq, host);
> -
>  	platform_set_drvdata(pdev, NULL);
> 
>  	if (host->dmach)
> @@ -831,12 +813,8 @@ static int mxs_mmc_remove(struct platform_device
> *pdev) clk_disable_unprepare(host->clk);
>  	clk_put(host->clk);
> 
> -	iounmap(host->base);
> -
>  	mmc_free_host(mmc);
> 
> -	release_mem_region(res->start, resource_size(res));
> -
>  	return 0;
>  }

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 06/10] mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:51     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:51 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> It replaces dma_res with dma_channel in struct mxs_mmc_host, so that
> the device tree support will be a little easier, since dma channel
> can not be retrieved from "struct resource *dma_res".
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/mmc/host/mxs-mmc.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 1a8ba314..e905721 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -146,7 +146,7 @@ struct mxs_mmc_host {
>  	struct mmc_data			*data;
> 
>  	void __iomem			*base;
> -	struct resource			*dma_res;
> +	int				dma_channel;
>  	struct clk			*clk;
>  	unsigned int			clk_rate;
> 
> @@ -668,7 +668,7 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan,
> void *param) if (!mxs_dma_is_apbh(chan))
>  		return false;
> 
> -	if (chan->chan_id != host->dma_res->start)
> +	if (chan->chan_id != host->dma_channel)
>  		return false;
> 
>  	chan->private = &host->dma_data;
> @@ -719,7 +719,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 
>  	host->devid = pdev->id_entry->driver_data;
>  	host->mmc = mmc;
> -	host->dma_res = dmares;
> +	host->dma_channel = dmares->start;
>  	host->sdio_irq_en = 0;
> 
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 06/10] mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host
@ 2012-05-07 23:51     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:51 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> It replaces dma_res with dma_channel in struct mxs_mmc_host, so that
> the device tree support will be a little easier, since dma channel
> can not be retrieved from "struct resource *dma_res".
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/mmc/host/mxs-mmc.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 1a8ba314..e905721 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -146,7 +146,7 @@ struct mxs_mmc_host {
>  	struct mmc_data			*data;
> 
>  	void __iomem			*base;
> -	struct resource			*dma_res;
> +	int				dma_channel;
>  	struct clk			*clk;
>  	unsigned int			clk_rate;
> 
> @@ -668,7 +668,7 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan,
> void *param) if (!mxs_dma_is_apbh(chan))
>  		return false;
> 
> -	if (chan->chan_id != host->dma_res->start)
> +	if (chan->chan_id != host->dma_channel)
>  		return false;
> 
>  	chan->private = &host->dma_data;
> @@ -719,7 +719,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> 
>  	host->devid = pdev->id_entry->driver_data;
>  	host->mmc = mmc;
> -	host->dma_res = dmares;
> +	host->dma_channel = dmares->start;
>  	host->sdio_irq_en = 0;
> 
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:53     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:53 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> It has wp_gpio copied in struct mxs_mmc_host from platform_data,

Copy wp_gpio into struct ...

> so that the use of platform_data can be limited in probe function,
> which will ease the device tree probe.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Otherwise
Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/mmc/host/mxs-mmc.c |   11 ++++-------
>  1 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index e905721..66f792a 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -160,21 +160,17 @@ struct mxs_mmc_host {
>  	unsigned char			bus_width;
>  	spinlock_t			lock;
>  	int				sdio_irq_en;
> +	int				wp_gpio;
>  };
> 
>  static int mxs_mmc_get_ro(struct mmc_host *mmc)
>  {
>  	struct mxs_mmc_host *host = mmc_priv(mmc);
> -	struct mxs_mmc_platform_data *pdata =
> -		mmc_dev(host->mmc)->platform_data;
> 
> -	if (!pdata)
> -		return -EFAULT;
> -
> -	if (!gpio_is_valid(pdata->wp_gpio))
> +	if (!gpio_is_valid(host->wp_gpio))
>  		return -EINVAL;
> 
> -	return gpio_get_value(pdata->wp_gpio);
> +	return gpio_get_value(host->wp_gpio);
>  }
> 
>  static int mxs_mmc_get_cd(struct mmc_host *mmc)
> @@ -758,6 +754,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
>  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA;
> +		host->wp_gpio = pdata->wp_gpio;
>  	}
> 
>  	mmc->f_min = 400000;

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
@ 2012-05-07 23:53     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:53 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> It has wp_gpio copied in struct mxs_mmc_host from platform_data,

Copy wp_gpio into struct ...

> so that the use of platform_data can be limited in probe function,
> which will ease the device tree probe.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Otherwise
Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/mmc/host/mxs-mmc.c |   11 ++++-------
>  1 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index e905721..66f792a 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -160,21 +160,17 @@ struct mxs_mmc_host {
>  	unsigned char			bus_width;
>  	spinlock_t			lock;
>  	int				sdio_irq_en;
> +	int				wp_gpio;
>  };
> 
>  static int mxs_mmc_get_ro(struct mmc_host *mmc)
>  {
>  	struct mxs_mmc_host *host = mmc_priv(mmc);
> -	struct mxs_mmc_platform_data *pdata =
> -		mmc_dev(host->mmc)->platform_data;
> 
> -	if (!pdata)
> -		return -EFAULT;
> -
> -	if (!gpio_is_valid(pdata->wp_gpio))
> +	if (!gpio_is_valid(host->wp_gpio))
>  		return -EINVAL;
> 
> -	return gpio_get_value(pdata->wp_gpio);
> +	return gpio_get_value(host->wp_gpio);
>  }
> 
>  static int mxs_mmc_get_cd(struct mmc_host *mmc)
> @@ -758,6 +754,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
>  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA;
> +		host->wp_gpio = pdata->wp_gpio;
>  	}
> 
>  	mmc->f_min = 400000;

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-07 23:58     ` Marek Vasut
  -1 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:58 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

Dear Shawn Guo,

> It adds device tree probe support for mxs-mmc driver.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
>  drivers/mmc/host/mxs-mmc.c                        |   48
> ++++++++++++++++++-- 2 files changed, 69 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt new file mode 100644
> index 0000000..d7c2a40
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> @@ -0,0 +1,26 @@
> +* Freescale MXS MMC controller
> +
> +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC
> controller +to support MMC, SD, and SDIO types of memory cards.
> +
> +Required properties:
> +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
> +  imx23 and imx28.
> +- reg: Should contain registers location and length
> +- interrupts: Should contain ERROR and DMA interrupts
> +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
> +
> +Optional properties:
> +- wp-gpios: Specify GPIOs for write protection

You can have multiple wp-gpio per port? :-)

> +
> +Examples:
> +
> +ssp0: ssp@80010000 {
> +	compatible = "fsl,imx28-mmc";
> +	reg = <0x80010000 2000>;
> +	interrupts = <96 82>;
> +	fsl,ssp-dma-channel = <0>;
> +	fsl,bus-width = <8>;
> +	status = "okay";
> +};
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 66f792a..c6b56b4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -23,6 +23,9 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/ioport.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
>  #include <linux/interrupt.h>
> @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
> 
> +static const struct of_device_id mxs_mmc_dt_ids[] = {
> +	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> +	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
> +	const struct of_device_id *of_id =
> +			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> +	struct device_node *np = pdev->dev.of_node;
>  	struct mxs_mmc_host *host;
>  	struct mmc_host *mmc;
>  	struct resource *iores, *dmares;
> @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
>  	irq_err = platform_get_irq(pdev, 0);
>  	irq_dma = platform_get_irq(pdev, 1);
> -	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
> +	if (!iores || irq_err < 0 || irq_dma < 0)
>  		return -EINVAL;
> 
>  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device
> *pdev) goto out_mmc_free;
>  	}
> 
> -	host->devid = pdev->id_entry->driver_data;
> +	if (np) {
> +		host->devid = (enum mxs_mmc_id) of_id->data;
> +		/*
> +		 * TODO: This is a temporary solution and should be changed
> +		 * to use generic DMA binding later when the helplers get in.
> +		 */
> +		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> +					   &host->dma_channel);
> +		if (ret) {
> +			dev_err(mmc_dev(host->mmc),
> +				"failed to get dma channel\n");
> +			goto out_mmc_free;
> +		}
> +	} else {
> +		host->devid = pdev->id_entry->driver_data;
> +		host->dma_channel = dmares->start;
> +	}
> +
>  	host->mmc = mmc;
> -	host->dma_channel = dmares->start;
>  	host->sdio_irq_en = 0;
> 
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> -		goto out_iounmap;
> +		goto out_mmc_free;
>  	}
> 
>  	host->clk = clk_get(&pdev->dev, NULL);
> @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
> 
>  	pdata =	mmc_dev(host->mmc)->platform_data;
> -	if (pdata) {
> +	if (!pdata) {
> +		u32 bus_width = 0;
> +		of_property_read_u32(np, "fsl,bus-width", &bus_width);
> +		if (bus_width == 4)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA;
> +		else if (bus_width == 8)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> +		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> +	} else {
>  		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
>  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
>  		.owner	= THIS_MODULE,
>  #ifdef CONFIG_PM
>  		.pm	= &mxs_mmc_pm_ops,
> +		.of_match_table = mxs_mmc_dt_ids,
>  #endif
>  	},
>  };

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-07 23:58     ` Marek Vasut
  0 siblings, 0 replies; 58+ messages in thread
From: Marek Vasut @ 2012-05-07 23:58 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> It adds device tree probe support for mxs-mmc driver.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
>  drivers/mmc/host/mxs-mmc.c                        |   48
> ++++++++++++++++++-- 2 files changed, 69 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> 
> diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt new file mode 100644
> index 0000000..d7c2a40
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> @@ -0,0 +1,26 @@
> +* Freescale MXS MMC controller
> +
> +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC
> controller +to support MMC, SD, and SDIO types of memory cards.
> +
> +Required properties:
> +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
> +  imx23 and imx28.
> +- reg: Should contain registers location and length
> +- interrupts: Should contain ERROR and DMA interrupts
> +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
> +
> +Optional properties:
> +- wp-gpios: Specify GPIOs for write protection

You can have multiple wp-gpio per port? :-)

> +
> +Examples:
> +
> +ssp0: ssp at 80010000 {
> +	compatible = "fsl,imx28-mmc";
> +	reg = <0x80010000 2000>;
> +	interrupts = <96 82>;
> +	fsl,ssp-dma-channel = <0>;
> +	fsl,bus-width = <8>;
> +	status = "okay";
> +};
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 66f792a..c6b56b4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -23,6 +23,9 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/ioport.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
>  #include <linux/interrupt.h>
> @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
> 
> +static const struct of_device_id mxs_mmc_dt_ids[] = {
> +	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> +	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
> +	const struct of_device_id *of_id =
> +			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> +	struct device_node *np = pdev->dev.of_node;
>  	struct mxs_mmc_host *host;
>  	struct mmc_host *mmc;
>  	struct resource *iores, *dmares;
> @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
>  	irq_err = platform_get_irq(pdev, 0);
>  	irq_dma = platform_get_irq(pdev, 1);
> -	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
> +	if (!iores || irq_err < 0 || irq_dma < 0)
>  		return -EINVAL;
> 
>  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device
> *pdev) goto out_mmc_free;
>  	}
> 
> -	host->devid = pdev->id_entry->driver_data;
> +	if (np) {
> +		host->devid = (enum mxs_mmc_id) of_id->data;
> +		/*
> +		 * TODO: This is a temporary solution and should be changed
> +		 * to use generic DMA binding later when the helplers get in.
> +		 */
> +		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> +					   &host->dma_channel);
> +		if (ret) {
> +			dev_err(mmc_dev(host->mmc),
> +				"failed to get dma channel\n");
> +			goto out_mmc_free;
> +		}
> +	} else {
> +		host->devid = pdev->id_entry->driver_data;
> +		host->dma_channel = dmares->start;
> +	}
> +
>  	host->mmc = mmc;
> -	host->dma_channel = dmares->start;
>  	host->sdio_irq_en = 0;
> 
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> -		goto out_iounmap;
> +		goto out_mmc_free;
>  	}
> 
>  	host->clk = clk_get(&pdev->dev, NULL);
> @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
> 
>  	pdata =	mmc_dev(host->mmc)->platform_data;
> -	if (pdata) {
> +	if (!pdata) {
> +		u32 bus_width = 0;
> +		of_property_read_u32(np, "fsl,bus-width", &bus_width);
> +		if (bus_width == 4)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA;
> +		else if (bus_width == 8)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> +		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> +	} else {
>  		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
>  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
>  		.owner	= THIS_MODULE,
>  #ifdef CONFIG_PM
>  		.pm	= &mxs_mmc_pm_ops,
> +		.of_match_table = mxs_mmc_dt_ids,
>  #endif
>  	},
>  };

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter
  2012-05-07 23:43     ` Marek Vasut
@ 2012-05-08 14:32       ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:32 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

On Tue, May 08, 2012 at 01:43:49AM +0200, Marek Vasut wrote:
> >  #define SSP_VERSION_LATEST	4
> > -#define ssp_is_old()		(host->version < SSP_VERSION_LATEST)
> > +#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
> 
> (host)->version ... to make the macro safer.
> 
Sounds good.

> > -	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> > +	if ((sta & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> 
> ^ s/sta/stat/ ... did you try compiling this at all ? :-)
> 
This is an error introduced by a last minute rebase.  Thanks for
catching it.  Fixed.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter
@ 2012-05-08 14:32       ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 08, 2012 at 01:43:49AM +0200, Marek Vasut wrote:
> >  #define SSP_VERSION_LATEST	4
> > -#define ssp_is_old()		(host->version < SSP_VERSION_LATEST)
> > +#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
> 
> (host)->version ... to make the macro safer.
> 
Sounds good.

> > -	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> > +	if ((sta & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> 
> ^ s/sta/stat/ ... did you try compiling this at all ? :-)
> 
This is an error introduced by a last minute rebase.  Thanks for
catching it.  Fixed.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx
  2012-05-07 23:46     ` Marek Vasut
@ 2012-05-08 14:35       ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:35 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

On Tue, May 08, 2012 at 01:46:44AM +0200, Marek Vasut wrote:
> > -#define SSP_VERSION_LATEST	4
> > -#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
> > +#define ssp_is_old(host)	(host->devid == IMX23_MMC)
> 
> (host)->devid ...
> 
Fixed, as well as dma_is_apbh and apbh_is_old.  Thanks.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx
@ 2012-05-08 14:35       ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 08, 2012 at 01:46:44AM +0200, Marek Vasut wrote:
> > -#define SSP_VERSION_LATEST	4
> > -#define ssp_is_old(host)	(host->version < SSP_VERSION_LATEST)
> > +#define ssp_is_old(host)	(host->devid == IMX23_MMC)
> 
> (host)->devid ...
> 
Fixed, as well as dma_is_apbh and apbh_is_old.  Thanks.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler
  2012-05-07 23:49     ` Marek Vasut
@ 2012-05-08 14:38       ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:38 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

On Tue, May 08, 2012 at 01:49:58AM +0200, Marek Vasut wrote:
> btw do we have i2c dt bindings ?
> 
I'm working on it.

> Acked-by: Marek Vasut <marex@denx.de>

Thanks.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler
@ 2012-05-08 14:38       ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 08, 2012 at 01:49:58AM +0200, Marek Vasut wrote:
> btw do we have i2c dt bindings ?
> 
I'm working on it.

> Acked-by: Marek Vasut <marex@denx.de>

Thanks.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
  2012-05-07 23:53     ` Marek Vasut
@ 2012-05-08 14:40       ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:40 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

On Tue, May 08, 2012 at 01:53:44AM +0200, Marek Vasut wrote:
> Dear Shawn Guo,
> 
> > It has wp_gpio copied in struct mxs_mmc_host from platform_data,
> 
> Copy wp_gpio into struct ...
> 
Updated.

> > so that the use of platform_data can be limited in probe function,
> > which will ease the device tree probe.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> 
> Otherwise
> Acked-by: Marek Vasut <marex@denx.de>
> 
Thanks.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host
@ 2012-05-08 14:40       ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 08, 2012 at 01:53:44AM +0200, Marek Vasut wrote:
> Dear Shawn Guo,
> 
> > It has wp_gpio copied in struct mxs_mmc_host from platform_data,
> 
> Copy wp_gpio into struct ...
> 
Updated.

> > so that the use of platform_data can be limited in probe function,
> > which will ease the device tree probe.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> 
> Otherwise
> Acked-by: Marek Vasut <marex@denx.de>
> 
Thanks.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-07 23:58     ` Marek Vasut
@ 2012-05-08 14:43       ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:43 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-mmc, linux-arm-kernel, Chris Ball, Dong Aisheng

On Tue, May 08, 2012 at 01:58:07AM +0200, Marek Vasut wrote:
> > +Optional properties:
> > +- wp-gpios: Specify GPIOs for write protection
> 
> You can have multiple wp-gpio per port? :-)
> 
This is a naming idiom documented in
Documentation/devicetree/bindings/gpio/gpio.txt

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-08 14:43       ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-08 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 08, 2012 at 01:58:07AM +0200, Marek Vasut wrote:
> > +Optional properties:
> > +- wp-gpios: Specify GPIOs for write protection
> 
> You can have multiple wp-gpio per port? :-)
> 
This is a naming idiom documented in
Documentation/devicetree/bindings/gpio/gpio.txt

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-07 14:43   ` Shawn Guo
@ 2012-05-12 14:44     ` Chris Ball
  -1 siblings, 0 replies; 58+ messages in thread
From: Chris Ball @ 2012-05-12 14:44 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, linux-arm-kernel, Dong Aisheng, Marek Vasut

Hi Shawn, just minor language changes,

On Mon, May 07 2012, Shawn Guo wrote:
> It adds device tree probe support for mxs-mmc driver.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
>  drivers/mmc/host/mxs-mmc.c                        |   48 ++++++++++++++++++--
>  2 files changed, 69 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>
> diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> new file mode 100644
> index 0000000..d7c2a40
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> @@ -0,0 +1,26 @@
> +* Freescale MXS MMC controller
> +
> +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
> +to support MMC, SD, and SDIO types of memory cards.
> +
> +Required properties:
> +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
> +  imx23 and imx28.
> +- reg: Should contain registers location and length
> +- interrupts: Should contain ERROR and DMA interrupts
> +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>

Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html

> +
> +Optional properties:
> +- wp-gpios: Specify GPIOs for write protection
> +
> +Examples:
> +
> +ssp0: ssp@80010000 {
> +	compatible = "fsl,imx28-mmc";
> +	reg = <0x80010000 2000>;
> +	interrupts = <96 82>;
> +	fsl,ssp-dma-channel = <0>;
> +	fsl,bus-width = <8>;
> +	status = "okay";
> +};

You list a "status" property but it isn't mentioned in the required or
optional properties section, or used in the code.  What's it for?

> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 66f792a..c6b56b4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -23,6 +23,9 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/ioport.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
>  #include <linux/interrupt.h>
> @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
>  
> +static const struct of_device_id mxs_mmc_dt_ids[] = {
> +	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> +	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
> +	const struct of_device_id *of_id =
> +			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> +	struct device_node *np = pdev->dev.of_node;
>  	struct mxs_mmc_host *host;
>  	struct mmc_host *mmc;
>  	struct resource *iores, *dmares;
> @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
>  	irq_err = platform_get_irq(pdev, 0);
>  	irq_dma = platform_get_irq(pdev, 1);
> -	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
> +	if (!iores || irq_err < 0 || irq_dma < 0)
>  		return -EINVAL;
>  
>  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		goto out_mmc_free;
>  	}
>  
> -	host->devid = pdev->id_entry->driver_data;
> +	if (np) {
> +		host->devid = (enum mxs_mmc_id) of_id->data;
> +		/*
> +		 * TODO: This is a temporary solution and should be changed
> +		 * to use generic DMA binding later when the helplers get in.

"helpers"

> +		 */
> +		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> +					   &host->dma_channel);
> +		if (ret) {
> +			dev_err(mmc_dev(host->mmc),
> +				"failed to get dma channel\n");
> +			goto out_mmc_free;
> +		}
> +	} else {
> +		host->devid = pdev->id_entry->driver_data;
> +		host->dma_channel = dmares->start;
> +	}
> +
>  	host->mmc = mmc;
> -	host->dma_channel = dmares->start;
>  	host->sdio_irq_en = 0;
>  
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> -		goto out_iounmap;
> +		goto out_mmc_free;
>  	}
>  
>  	host->clk = clk_get(&pdev->dev, NULL);
> @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
>  
>  	pdata =	mmc_dev(host->mmc)->platform_data;
> -	if (pdata) {
> +	if (!pdata) {
> +		u32 bus_width = 0;
> +		of_property_read_u32(np, "fsl,bus-width", &bus_width);
> +		if (bus_width == 4)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA;
> +		else if (bus_width == 8)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> +		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> +	} else {
>  		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
>  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
>  		.owner	= THIS_MODULE,
>  #ifdef CONFIG_PM
>  		.pm	= &mxs_mmc_pm_ops,
> +		.of_match_table = mxs_mmc_dt_ids,
>  #endif
>  	},
>  };

Rest looks fine, thanks.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-12 14:44     ` Chris Ball
  0 siblings, 0 replies; 58+ messages in thread
From: Chris Ball @ 2012-05-12 14:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shawn, just minor language changes,

On Mon, May 07 2012, Shawn Guo wrote:
> It adds device tree probe support for mxs-mmc driver.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
>  drivers/mmc/host/mxs-mmc.c                        |   48 ++++++++++++++++++--
>  2 files changed, 69 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>
> diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> new file mode 100644
> index 0000000..d7c2a40
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> @@ -0,0 +1,26 @@
> +* Freescale MXS MMC controller
> +
> +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
> +to support MMC, SD, and SDIO types of memory cards.
> +
> +Required properties:
> +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
> +  imx23 and imx28.
> +- reg: Should contain registers location and length
> +- interrupts: Should contain ERROR and DMA interrupts
> +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>

Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html

> +
> +Optional properties:
> +- wp-gpios: Specify GPIOs for write protection
> +
> +Examples:
> +
> +ssp0: ssp at 80010000 {
> +	compatible = "fsl,imx28-mmc";
> +	reg = <0x80010000 2000>;
> +	interrupts = <96 82>;
> +	fsl,ssp-dma-channel = <0>;
> +	fsl,bus-width = <8>;
> +	status = "okay";
> +};

You list a "status" property but it isn't mentioned in the required or
optional properties section, or used in the code.  What's it for?

> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 66f792a..c6b56b4 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -23,6 +23,9 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/ioport.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
>  #include <linux/interrupt.h>
> @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
>  
> +static const struct of_device_id mxs_mmc_dt_ids[] = {
> +	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> +	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
> +	const struct of_device_id *of_id =
> +			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> +	struct device_node *np = pdev->dev.of_node;
>  	struct mxs_mmc_host *host;
>  	struct mmc_host *mmc;
>  	struct resource *iores, *dmares;
> @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
>  	irq_err = platform_get_irq(pdev, 0);
>  	irq_dma = platform_get_irq(pdev, 1);
> -	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
> +	if (!iores || irq_err < 0 || irq_dma < 0)
>  		return -EINVAL;
>  
>  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		goto out_mmc_free;
>  	}
>  
> -	host->devid = pdev->id_entry->driver_data;
> +	if (np) {
> +		host->devid = (enum mxs_mmc_id) of_id->data;
> +		/*
> +		 * TODO: This is a temporary solution and should be changed
> +		 * to use generic DMA binding later when the helplers get in.

"helpers"

> +		 */
> +		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> +					   &host->dma_channel);
> +		if (ret) {
> +			dev_err(mmc_dev(host->mmc),
> +				"failed to get dma channel\n");
> +			goto out_mmc_free;
> +		}
> +	} else {
> +		host->devid = pdev->id_entry->driver_data;
> +		host->dma_channel = dmares->start;
> +	}
> +
>  	host->mmc = mmc;
> -	host->dma_channel = dmares->start;
>  	host->sdio_irq_en = 0;
>  
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> -		goto out_iounmap;
> +		goto out_mmc_free;
>  	}
>  
>  	host->clk = clk_get(&pdev->dev, NULL);
> @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
>  
>  	pdata =	mmc_dev(host->mmc)->platform_data;
> -	if (pdata) {
> +	if (!pdata) {
> +		u32 bus_width = 0;
> +		of_property_read_u32(np, "fsl,bus-width", &bus_width);
> +		if (bus_width == 4)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA;
> +		else if (bus_width == 8)
> +			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> +		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> +	} else {
>  		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
>  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
>  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
>  		.owner	= THIS_MODULE,
>  #ifdef CONFIG_PM
>  		.pm	= &mxs_mmc_pm_ops,
> +		.of_match_table = mxs_mmc_dt_ids,
>  #endif
>  	},
>  };

Rest looks fine, thanks.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-12 14:44     ` Chris Ball
@ 2012-05-13  0:03       ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-13  0:03 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, linux-arm-kernel, Dong Aisheng, Marek Vasut

On Sat, May 12, 2012 at 10:44:42AM -0400, Chris Ball wrote:
> Hi Shawn, just minor language changes,
> 
> On Mon, May 07 2012, Shawn Guo wrote:
> > It adds device tree probe support for mxs-mmc driver.
> >
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >  Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
> >  drivers/mmc/host/mxs-mmc.c                        |   48 ++++++++++++++++++--
> >  2 files changed, 69 insertions(+), 5 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> >
> > diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> > new file mode 100644
> > index 0000000..d7c2a40
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> > @@ -0,0 +1,26 @@
> > +* Freescale MXS MMC controller
> > +
> > +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
> > +to support MMC, SD, and SDIO types of memory cards.
> > +
> > +Required properties:
> > +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
> > +  imx23 and imx28.
> > +- reg: Should contain registers location and length
> > +- interrupts: Should contain ERROR and DMA interrupts
> > +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> > +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
> 
> Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html
> 
Yes, I've been keeping my eyes on the discussion.  Before that generic
bindings get landed, the vendor prefix can be treated as a marker that
this is something should use generic binding.

> > +
> > +Optional properties:
> > +- wp-gpios: Specify GPIOs for write protection
> > +
> > +Examples:
> > +
> > +ssp0: ssp@80010000 {
> > +	compatible = "fsl,imx28-mmc";
> > +	reg = <0x80010000 2000>;
> > +	interrupts = <96 82>;
> > +	fsl,ssp-dma-channel = <0>;
> > +	fsl,bus-width = <8>;
> > +	status = "okay";
> > +};
> 
> You list a "status" property but it isn't mentioned in the required or
> optional properties section, or used in the code.  What's it for?
> 
This is something part of DT core, and does not really belong to mxs-mmc
bindings, so remove it from the example.

> > diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> > index 66f792a..c6b56b4 100644
> > --- a/drivers/mmc/host/mxs-mmc.c
> > +++ b/drivers/mmc/host/mxs-mmc.c
> > @@ -23,6 +23,9 @@
> >  #include <linux/kernel.h>
> >  #include <linux/init.h>
> >  #include <linux/ioport.h>
> > +#include <linux/of.h>
> > +#include <linux/of_device.h>
> > +#include <linux/of_gpio.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/delay.h>
> >  #include <linux/interrupt.h>
> > @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
> >  };
> >  MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
> >  
> > +static const struct of_device_id mxs_mmc_dt_ids[] = {
> > +	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> > +	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> > +
> >  static int mxs_mmc_probe(struct platform_device *pdev)
> >  {
> > +	const struct of_device_id *of_id =
> > +			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> > +	struct device_node *np = pdev->dev.of_node;
> >  	struct mxs_mmc_host *host;
> >  	struct mmc_host *mmc;
> >  	struct resource *iores, *dmares;
> > @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >  	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
> >  	irq_err = platform_get_irq(pdev, 0);
> >  	irq_dma = platform_get_irq(pdev, 1);
> > -	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
> > +	if (!iores || irq_err < 0 || irq_dma < 0)
> >  		return -EINVAL;
> >  
> >  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> > @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >  		goto out_mmc_free;
> >  	}
> >  
> > -	host->devid = pdev->id_entry->driver_data;
> > +	if (np) {
> > +		host->devid = (enum mxs_mmc_id) of_id->data;
> > +		/*
> > +		 * TODO: This is a temporary solution and should be changed
> > +		 * to use generic DMA binding later when the helplers get in.
> 
> "helpers"
> 
Fixed.  Thanks for the catch.

> > +		 */
> > +		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> > +					   &host->dma_channel);
> > +		if (ret) {
> > +			dev_err(mmc_dev(host->mmc),
> > +				"failed to get dma channel\n");
> > +			goto out_mmc_free;
> > +		}
> > +	} else {
> > +		host->devid = pdev->id_entry->driver_data;
> > +		host->dma_channel = dmares->start;
> > +	}
> > +
> >  	host->mmc = mmc;
> > -	host->dma_channel = dmares->start;
> >  	host->sdio_irq_en = 0;
> >  
> >  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> >  	if (IS_ERR(pinctrl)) {
> >  		ret = PTR_ERR(pinctrl);
> > -		goto out_iounmap;
> > +		goto out_mmc_free;
> >  	}
> >  
> >  	host->clk = clk_get(&pdev->dev, NULL);
> > @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >  		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
> >  
> >  	pdata =	mmc_dev(host->mmc)->platform_data;
> > -	if (pdata) {
> > +	if (!pdata) {
> > +		u32 bus_width = 0;
> > +		of_property_read_u32(np, "fsl,bus-width", &bus_width);
> > +		if (bus_width == 4)
> > +			mmc->caps |= MMC_CAP_4_BIT_DATA;
> > +		else if (bus_width == 8)
> > +			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> > +		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> > +	} else {
> >  		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
> >  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> >  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> > @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
> >  		.owner	= THIS_MODULE,
> >  #ifdef CONFIG_PM
> >  		.pm	= &mxs_mmc_pm_ops,
> > +		.of_match_table = mxs_mmc_dt_ids,
> >  #endif
> >  	},
> >  };
> 
> Rest looks fine, thanks.
> 
Thanks, Chris.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-13  0:03       ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-13  0:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, May 12, 2012 at 10:44:42AM -0400, Chris Ball wrote:
> Hi Shawn, just minor language changes,
> 
> On Mon, May 07 2012, Shawn Guo wrote:
> > It adds device tree probe support for mxs-mmc driver.
> >
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >  Documentation/devicetree/bindings/mmc/mxs-mmc.txt |   26 +++++++++++
> >  drivers/mmc/host/mxs-mmc.c                        |   48 ++++++++++++++++++--
> >  2 files changed, 69 insertions(+), 5 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> >
> > diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> > new file mode 100644
> > index 0000000..d7c2a40
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
> > @@ -0,0 +1,26 @@
> > +* Freescale MXS MMC controller
> > +
> > +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
> > +to support MMC, SD, and SDIO types of memory cards.
> > +
> > +Required properties:
> > +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
> > +  imx23 and imx28.
> > +- reg: Should contain registers location and length
> > +- interrupts: Should contain ERROR and DMA interrupts
> > +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
> > +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
> 
> Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html
> 
Yes, I've been keeping my eyes on the discussion.  Before that generic
bindings get landed, the vendor prefix can be treated as a marker that
this is something should use generic binding.

> > +
> > +Optional properties:
> > +- wp-gpios: Specify GPIOs for write protection
> > +
> > +Examples:
> > +
> > +ssp0: ssp at 80010000 {
> > +	compatible = "fsl,imx28-mmc";
> > +	reg = <0x80010000 2000>;
> > +	interrupts = <96 82>;
> > +	fsl,ssp-dma-channel = <0>;
> > +	fsl,bus-width = <8>;
> > +	status = "okay";
> > +};
> 
> You list a "status" property but it isn't mentioned in the required or
> optional properties section, or used in the code.  What's it for?
> 
This is something part of DT core, and does not really belong to mxs-mmc
bindings, so remove it from the example.

> > diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> > index 66f792a..c6b56b4 100644
> > --- a/drivers/mmc/host/mxs-mmc.c
> > +++ b/drivers/mmc/host/mxs-mmc.c
> > @@ -23,6 +23,9 @@
> >  #include <linux/kernel.h>
> >  #include <linux/init.h>
> >  #include <linux/ioport.h>
> > +#include <linux/of.h>
> > +#include <linux/of_device.h>
> > +#include <linux/of_gpio.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/delay.h>
> >  #include <linux/interrupt.h>
> > @@ -685,8 +688,18 @@ static struct platform_device_id mxs_mmc_ids[] = {
> >  };
> >  MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
> >  
> > +static const struct of_device_id mxs_mmc_dt_ids[] = {
> > +	{ .compatible = "fsl,imx23-mmc", .data = (void *) IMX23_MMC, },
> > +	{ .compatible = "fsl,imx28-mmc", .data = (void *) IMX28_MMC, },
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> > +
> >  static int mxs_mmc_probe(struct platform_device *pdev)
> >  {
> > +	const struct of_device_id *of_id =
> > +			of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> > +	struct device_node *np = pdev->dev.of_node;
> >  	struct mxs_mmc_host *host;
> >  	struct mmc_host *mmc;
> >  	struct resource *iores, *dmares;
> > @@ -699,7 +712,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >  	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
> >  	irq_err = platform_get_irq(pdev, 0);
> >  	irq_dma = platform_get_irq(pdev, 1);
> > -	if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
> > +	if (!iores || irq_err < 0 || irq_dma < 0)
> >  		return -EINVAL;
> >  
> >  	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
> > @@ -713,15 +726,31 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >  		goto out_mmc_free;
> >  	}
> >  
> > -	host->devid = pdev->id_entry->driver_data;
> > +	if (np) {
> > +		host->devid = (enum mxs_mmc_id) of_id->data;
> > +		/*
> > +		 * TODO: This is a temporary solution and should be changed
> > +		 * to use generic DMA binding later when the helplers get in.
> 
> "helpers"
> 
Fixed.  Thanks for the catch.

> > +		 */
> > +		ret = of_property_read_u32(np, "fsl,ssp-dma-channel",
> > +					   &host->dma_channel);
> > +		if (ret) {
> > +			dev_err(mmc_dev(host->mmc),
> > +				"failed to get dma channel\n");
> > +			goto out_mmc_free;
> > +		}
> > +	} else {
> > +		host->devid = pdev->id_entry->driver_data;
> > +		host->dma_channel = dmares->start;
> > +	}
> > +
> >  	host->mmc = mmc;
> > -	host->dma_channel = dmares->start;
> >  	host->sdio_irq_en = 0;
> >  
> >  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> >  	if (IS_ERR(pinctrl)) {
> >  		ret = PTR_ERR(pinctrl);
> > -		goto out_iounmap;
> > +		goto out_mmc_free;
> >  	}
> >  
> >  	host->clk = clk_get(&pdev->dev, NULL);
> > @@ -749,7 +778,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >  		    MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
> >  
> >  	pdata =	mmc_dev(host->mmc)->platform_data;
> > -	if (pdata) {
> > +	if (!pdata) {
> > +		u32 bus_width = 0;
> > +		of_property_read_u32(np, "fsl,bus-width", &bus_width);
> > +		if (bus_width == 4)
> > +			mmc->caps |= MMC_CAP_4_BIT_DATA;
> > +		else if (bus_width == 8)
> > +			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> > +		host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> > +	} else {
> >  		if (pdata->flags & SLOTF_8_BIT_CAPABLE)
> >  			mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
> >  		if (pdata->flags & SLOTF_4_BIT_CAPABLE)
> > @@ -857,6 +894,7 @@ static struct platform_driver mxs_mmc_driver = {
> >  		.owner	= THIS_MODULE,
> >  #ifdef CONFIG_PM
> >  		.pm	= &mxs_mmc_pm_ops,
> > +		.of_match_table = mxs_mmc_dt_ids,
> >  #endif
> >  	},
> >  };
> 
> Rest looks fine, thanks.
> 
Thanks, Chris.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-13  0:03       ` Shawn Guo
@ 2012-05-13  0:11         ` Chris Ball
  -1 siblings, 0 replies; 58+ messages in thread
From: Chris Ball @ 2012-05-13  0:11 UTC (permalink / raw)
  To: Shawn Guo
  Cc: linux-mmc, linux-arm-kernel, Dong Aisheng, Marek Vasut, Arnd Bergmann

Hi, adding Arnd,

On Sat, May 12 2012, Shawn Guo wrote:
>> > diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>> > new file mode 100644
>> > index 0000000..d7c2a40
>> > --- /dev/null
>> > +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>> > @@ -0,0 +1,26 @@
>> > +* Freescale MXS MMC controller
>> > +
>> > +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
>> > +to support MMC, SD, and SDIO types of memory cards.
>> > +
>> > +Required properties:
>> > +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
>> > +  imx23 and imx28.
>> > +- reg: Should contain registers location and length
>> > +- interrupts: Should contain ERROR and DMA interrupts
>> > +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
>> > +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
>> 
>> Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
>> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html
>> 
> Yes, I've been keeping my eyes on the discussion.  Before that generic
> bindings get landed, the vendor prefix can be treated as a marker that
> this is something should use generic binding.

Sorry, I don't understand this explanation.  As soon as Arnd's patch
lands (possibly even for 3.5), we will be making sure that all of the
bindings are consistently using "bus-width" with no prefix -- that's
what Arnd's patch does to the existing .dts files.  Why introduce an
inconsistent binding now that we have to change later, instead of
getting it right straight away?

I'd like bindings going into mainline to be as correct as possible from
the moment that they're merged into mainline, because they describe an
API with the kernel.  The fact that we have some bindings currently in
the tree that we'll have to change to use the consistent naming scheme
Arnd proposes is regrettable, not intentional, so we shouldn't be
planning on doing more of it.  Does that make sense?

I'll take a look at merging Arnd's bindings patch and fixing up the
review comments on it now; it sounds like we really need to get it
merged and adopted very soon.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-13  0:11         ` Chris Ball
  0 siblings, 0 replies; 58+ messages in thread
From: Chris Ball @ 2012-05-13  0:11 UTC (permalink / raw)
  To: linux-arm-kernel

Hi, adding Arnd,

On Sat, May 12 2012, Shawn Guo wrote:
>> > diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>> > new file mode 100644
>> > index 0000000..d7c2a40
>> > --- /dev/null
>> > +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>> > @@ -0,0 +1,26 @@
>> > +* Freescale MXS MMC controller
>> > +
>> > +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
>> > +to support MMC, SD, and SDIO types of memory cards.
>> > +
>> > +Required properties:
>> > +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
>> > +  imx23 and imx28.
>> > +- reg: Should contain registers location and length
>> > +- interrupts: Should contain ERROR and DMA interrupts
>> > +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
>> > +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
>> 
>> Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
>> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html
>> 
> Yes, I've been keeping my eyes on the discussion.  Before that generic
> bindings get landed, the vendor prefix can be treated as a marker that
> this is something should use generic binding.

Sorry, I don't understand this explanation.  As soon as Arnd's patch
lands (possibly even for 3.5), we will be making sure that all of the
bindings are consistently using "bus-width" with no prefix -- that's
what Arnd's patch does to the existing .dts files.  Why introduce an
inconsistent binding now that we have to change later, instead of
getting it right straight away?

I'd like bindings going into mainline to be as correct as possible from
the moment that they're merged into mainline, because they describe an
API with the kernel.  The fact that we have some bindings currently in
the tree that we'll have to change to use the consistent naming scheme
Arnd proposes is regrettable, not intentional, so we shouldn't be
planning on doing more of it.  Does that make sense?

I'll take a look at merging Arnd's bindings patch and fixing up the
review comments on it now; it sounds like we really need to get it
merged and adopted very soon.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-13  0:11         ` Chris Ball
@ 2012-05-13  0:21           ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-13  0:21 UTC (permalink / raw)
  To: Chris Ball
  Cc: linux-mmc, linux-arm-kernel, Dong Aisheng, Marek Vasut, Arnd Bergmann

On 13 May 2012 08:11, Chris Ball <cjb@laptop.org> wrote:
> Hi, adding Arnd,
>
> On Sat, May 12 2012, Shawn Guo wrote:
>>> > diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>>> > new file mode 100644
>>> > index 0000000..d7c2a40
>>> > --- /dev/null
>>> > +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>>> > @@ -0,0 +1,26 @@
>>> > +* Freescale MXS MMC controller
>>> > +
>>> > +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
>>> > +to support MMC, SD, and SDIO types of memory cards.
>>> > +
>>> > +Required properties:
>>> > +- compatible: Should be "fsl,<chip>-mmc".  The supported chips include
>>> > +  imx23 and imx28.
>>> > +- reg: Should contain registers location and length
>>> > +- interrupts: Should contain ERROR and DMA interrupts
>>> > +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
>>> > +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
>>>
>>> Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
>>> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html
>>>
>> Yes, I've been keeping my eyes on the discussion.  Before that generic
>> bindings get landed, the vendor prefix can be treated as a marker that
>> this is something should use generic binding.
>
> Sorry, I don't understand this explanation.  As soon as Arnd's patch
> lands (possibly even for 3.5), we will be making sure that all of the
> bindings are consistently using "bus-width" with no prefix -- that's
> what Arnd's patch does to the existing .dts files.  Why introduce an
> inconsistent binding now that we have to change later, instead of
> getting it right straight away?
>
> I'd like bindings going into mainline to be as correct as possible from
> the moment that they're merged into mainline, because they describe an
> API with the kernel.  The fact that we have some bindings currently in
> the tree that we'll have to change to use the consistent naming scheme
> Arnd proposes is regrettable, not intentional, so we shouldn't be
> planning on doing more of it.  Does that make sense?
>
> I'll take a look at merging Arnd's bindings patch and fixing up the
> review comments on it now; it sounds like we really need to get it
> merged and adopted very soon.
>
In that case, ok, I will remove the prefix right away.

Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-13  0:21           ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-13  0:21 UTC (permalink / raw)
  To: linux-arm-kernel

On 13 May 2012 08:11, Chris Ball <cjb@laptop.org> wrote:
> Hi, adding Arnd,
>
> On Sat, May 12 2012, Shawn Guo wrote:
>>> > diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>>> > new file mode 100644
>>> > index 0000000..d7c2a40
>>> > --- /dev/null
>>> > +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt
>>> > @@ -0,0 +1,26 @@
>>> > +* Freescale MXS MMC controller
>>> > +
>>> > +The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
>>> > +to support MMC, SD, and SDIO types of memory cards.
>>> > +
>>> > +Required properties:
>>> > +- compatible: Should be "fsl,<chip>-mmc". ?The supported chips include
>>> > + ?imx23 and imx28.
>>> > +- reg: Should contain registers location and length
>>> > +- interrupts: Should contain ERROR and DMA interrupts
>>> > +- fsl,ssp-dma-channel: APBH DMA channel for the SSP
>>> > +- fsl,bus-width: Number of data lines, can be <1>, <4>, or <8>
>>>
>>> Please don't use a prefix on "bus-width" -- see Arnd's proposed bindings:
>>> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/091993.html
>>>
>> Yes, I've been keeping my eyes on the discussion. ?Before that generic
>> bindings get landed, the vendor prefix can be treated as a marker that
>> this is something should use generic binding.
>
> Sorry, I don't understand this explanation. ?As soon as Arnd's patch
> lands (possibly even for 3.5), we will be making sure that all of the
> bindings are consistently using "bus-width" with no prefix -- that's
> what Arnd's patch does to the existing .dts files. ?Why introduce an
> inconsistent binding now that we have to change later, instead of
> getting it right straight away?
>
> I'd like bindings going into mainline to be as correct as possible from
> the moment that they're merged into mainline, because they describe an
> API with the kernel. ?The fact that we have some bindings currently in
> the tree that we'll have to change to use the consistent naming scheme
> Arnd proposes is regrettable, not intentional, so we shouldn't be
> planning on doing more of it. ?Does that make sense?
>
> I'll take a look at merging Arnd's bindings patch and fixing up the
> review comments on it now; it sounds like we really need to get it
> merged and adopted very soon.
>
In that case, ok, I will remove the prefix right away.

Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/10] mmc: mxs-mmc: add device tree support
  2012-05-13  0:21           ` Shawn Guo
@ 2012-05-13  0:29             ` Shawn Guo
  -1 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-13  0:29 UTC (permalink / raw)
  To: Chris Ball
  Cc: linux-mmc, linux-arm-kernel, Dong Aisheng, Marek Vasut, Arnd Bergmann

On Sun, May 13, 2012 at 08:21:23AM +0800, Shawn Guo wrote:
> In that case, ok, I will remove the prefix right away.
> 
Done.  Branch updated.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/10] mmc: mxs-mmc: add device tree support
@ 2012-05-13  0:29             ` Shawn Guo
  0 siblings, 0 replies; 58+ messages in thread
From: Shawn Guo @ 2012-05-13  0:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, May 13, 2012 at 08:21:23AM +0800, Shawn Guo wrote:
> In that case, ok, I will remove the prefix right away.
> 
Done.  Branch updated.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2012-05-13  0:29 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07 14:43 [PATCH 00/10] Add device tree support for mxs-mmc Shawn Guo
2012-05-07 14:43 ` Shawn Guo
2012-05-07 14:43 ` [PATCH 01/10] mmc: mxs-mmc: use global stmp_device functionality Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:41   ` Marek Vasut
2012-05-07 23:41     ` Marek Vasut
2012-05-07 14:43 ` [PATCH 02/10] mmc: mxs-mmc: let ssp_is_old take host as parameter Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:43   ` Marek Vasut
2012-05-07 23:43     ` Marek Vasut
2012-05-08 14:32     ` Shawn Guo
2012-05-08 14:32       ` Shawn Guo
2012-05-07 14:43 ` [PATCH 03/10] mmc: mxs-mmc: get rid of the use of cpu_is_xxx Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:46   ` Marek Vasut
2012-05-07 23:46     ` Marek Vasut
2012-05-08 14:35     ` Shawn Guo
2012-05-08 14:35       ` Shawn Guo
2012-05-07 14:43 ` [PATCH 04/10] mmc: mxs-mmc: move header from mach into linux folder Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:47   ` Marek Vasut
2012-05-07 23:47     ` Marek Vasut
2012-05-07 14:43 ` [PATCH 05/10] mmc: mxs-mmc: use devm_* helper to make cleanup simpler Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:49   ` Marek Vasut
2012-05-07 23:49     ` Marek Vasut
2012-05-08 14:38     ` Shawn Guo
2012-05-08 14:38       ` Shawn Guo
2012-05-07 14:43 ` [PATCH 06/10] mmc: mxs-mmc: have dma_channel than dma_res in mxs_mmc_host Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:51   ` Marek Vasut
2012-05-07 23:51     ` Marek Vasut
2012-05-07 14:43 ` [PATCH 07/10] mmc: mxs-mmc: copy wp_gpio in struct mxs_mmc_host Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:53   ` Marek Vasut
2012-05-07 23:53     ` Marek Vasut
2012-05-08 14:40     ` Shawn Guo
2012-05-08 14:40       ` Shawn Guo
2012-05-07 14:43 ` [PATCH 08/10] mmc: mxs-mmc: add device tree support Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 23:58   ` Marek Vasut
2012-05-07 23:58     ` Marek Vasut
2012-05-08 14:43     ` Shawn Guo
2012-05-08 14:43       ` Shawn Guo
2012-05-12 14:44   ` Chris Ball
2012-05-12 14:44     ` Chris Ball
2012-05-13  0:03     ` Shawn Guo
2012-05-13  0:03       ` Shawn Guo
2012-05-13  0:11       ` Chris Ball
2012-05-13  0:11         ` Chris Ball
2012-05-13  0:21         ` Shawn Guo
2012-05-13  0:21           ` Shawn Guo
2012-05-13  0:29           ` Shawn Guo
2012-05-13  0:29             ` Shawn Guo
2012-05-07 14:43 ` [PATCH 09/10] ARM: dts: enable mmc for imx23-evk Shawn Guo
2012-05-07 14:43   ` Shawn Guo
2012-05-07 14:43 ` [PATCH 10/10] ARM: dts: enable mmc for imx28-evk Shawn Guo
2012-05-07 14:43   ` Shawn Guo

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.