linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support
@ 2013-01-21 11:02 Shawn Guo
  2013-01-21 11:02 ` [PATCH 1/6] mmc: sdhci-esdhc-imx: separate transfer mode from command write for usdhc Shawn Guo
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo

The series makes Auto CMD23 work for imx6q usdhc and then adds 8bit
mmc support.

Sascha Hauer (2):
  mmc: sdhci: rename platform_8bit_width to platform_bus_width
  mmc: sdhci-esdhc-imx: support 8bit mode

Shawn Guo (4):
  mmc: sdhci-esdhc-imx: separate transfer mode from command write for
    usdhc
  mmc: sdhci-esdhc-imx: manually reset MIX_CTRL for usdhc
  mmc: sdhci-esdhc-imx: Auto CMD23 support for usdhc
  mmc: dt: bus-width can be an optional property

 Documentation/devicetree/bindings/mmc/mmc.txt |    5 +-
 drivers/mmc/host/sdhci-esdhc-imx.c            |   98 +++++++++++++++++++++----
 drivers/mmc/host/sdhci-pci.c                  |    4 +-
 drivers/mmc/host/sdhci-pxav2.c                |    2 +-
 drivers/mmc/host/sdhci-s3c.c                  |    8 +-
 drivers/mmc/host/sdhci-tegra.c                |    4 +-
 drivers/mmc/host/sdhci.c                      |    8 +-
 drivers/mmc/host/sdhci.h                      |    2 +-
 include/linux/platform_data/mmc-esdhc-imx.h   |    1 +
 9 files changed, 101 insertions(+), 31 deletions(-)

-- 
1.7.9.5



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

* [PATCH 1/6] mmc: sdhci-esdhc-imx: separate transfer mode from command write for usdhc
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
@ 2013-01-21 11:02 ` Shawn Guo
  2013-01-21 11:02 ` [PATCH 2/6] mmc: sdhci-esdhc-imx: manually reset MIX_CTRL " Shawn Guo
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo

The combining of SDHCI_TRANSFER_MODE and SDHCI_COMMAND writes is only
required for esdhc, but not necessarily for usdhc.  Different from
esdhc where the bits for transfer mode and command are all in the same
register CMD_XFR_TYP, usdhc has a newly introduced register MIX_CTRL
to hold transfer mode bits.  So it makes more sense to separate transfer
mode from command write for usdhc.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 370c052..48832c5 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -239,10 +239,6 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 
 	switch (reg) {
 	case SDHCI_TRANSFER_MODE:
-		/*
-		 * Postpone this write, we must do it together with a
-		 * command write that is down below.
-		 */
 		if ((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
 				&& (host->cmd->opcode == SD_IO_RW_EXTENDED)
 				&& (host->cmd->data->blocks > 1)
@@ -252,7 +248,18 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 			v |= ESDHC_VENDOR_SPEC_SDIO_QUIRK;
 			writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
 		}
-		imx_data->scratchpad = val;
+
+		if (is_imx6q_usdhc(imx_data)) {
+			u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
+			m = val | (m & 0xffff0000);
+			writel(m, host->ioaddr + ESDHC_MIX_CTRL);
+		} else {
+			/*
+			 * Postpone this write, we must do it together with a
+			 * command write that is down below.
+			 */
+			imx_data->scratchpad = val;
+		}
 		return;
 	case SDHCI_COMMAND:
 		if ((host->cmd->opcode == MMC_STOP_TRANSMISSION ||
@@ -260,16 +267,12 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 	            (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
 			val |= SDHCI_CMD_ABORTCMD;
 
-		if (is_imx6q_usdhc(imx_data)) {
-			u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
-			m = imx_data->scratchpad | (m & 0xffff0000);
-			writel(m, host->ioaddr + ESDHC_MIX_CTRL);
+		if (is_imx6q_usdhc(imx_data))
 			writel(val << 16,
 			       host->ioaddr + SDHCI_TRANSFER_MODE);
-		} else {
+		else
 			writel(val << 16 | imx_data->scratchpad,
 			       host->ioaddr + SDHCI_TRANSFER_MODE);
-		}
 		return;
 	case SDHCI_BLOCK_SIZE:
 		val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
-- 
1.7.9.5



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

* [PATCH 2/6] mmc: sdhci-esdhc-imx: manually reset MIX_CTRL for usdhc
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
  2013-01-21 11:02 ` [PATCH 1/6] mmc: sdhci-esdhc-imx: separate transfer mode from command write for usdhc Shawn Guo
@ 2013-01-21 11:02 ` Shawn Guo
  2013-01-21 11:02 ` [PATCH 3/6] mmc: sdhci-esdhc-imx: Auto CMD23 support " Shawn Guo
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo

It's another violation to SDHC spec that software reset on usdhc
does not reset MIX_CTRL register.  Have to do it manually, otherwise
the preserving of the register bits (e.g. AC23EN) may cause mmc card
fail to be initialized.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 48832c5..968a70f 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -318,8 +318,15 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 	 * circuit relies on.  To work around it, we turn the clocks on back
 	 * to keep card detection circuit functional.
 	 */
-	if ((reg == SDHCI_SOFTWARE_RESET) && (val & 1))
+	if ((reg == SDHCI_SOFTWARE_RESET) && (val & 1)) {
 		esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL);
+		/*
+		 * The reset on usdhc fails to clear MIX_CTRL register.
+		 * Do it manually here.
+		 */
+		if (is_imx6q_usdhc(imx_data))
+			writel(0, host->ioaddr + ESDHC_MIX_CTRL);
+	}
 }
 
 static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
-- 
1.7.9.5



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

* [PATCH 3/6] mmc: sdhci-esdhc-imx: Auto CMD23 support for usdhc
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
  2013-01-21 11:02 ` [PATCH 1/6] mmc: sdhci-esdhc-imx: separate transfer mode from command write for usdhc Shawn Guo
  2013-01-21 11:02 ` [PATCH 2/6] mmc: sdhci-esdhc-imx: manually reset MIX_CTRL " Shawn Guo
@ 2013-01-21 11:02 ` Shawn Guo
  2013-01-21 11:02 ` [PATCH 4/6] mmc: sdhci: rename platform_8bit_width to platform_bus_width Shawn Guo
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo

SDHCI core will try to use Auto CMD23 for mmc card.  Currently, we will
see the following message with mmc card on usdhc due to the lacking of
Auto CMD23 support in the driver.

$ mmc0: new high speed MMC card at address 0001
mmcblk1: mmc0:0001 MMC02G 1.87 GiB
mmcblk1: error -84 transferring data, sector 0, nr 8, cmd response 0x900, card status 0xb00
mmcblk1: retrying using single block read
 mmcblk1:

Enable Auto CMD23 support for usdhc so that mmc card can work in
multiple block mode.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 968a70f..24daaf4 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -36,6 +36,9 @@
 #define  ESDHC_VENDOR_SPEC_SDIO_QUIRK	(1 << 1)
 #define ESDHC_WTMK_LVL			0x44
 #define ESDHC_MIX_CTRL			0x48
+#define  ESDHC_MIX_CTRL_AC23EN		(1 << 7)
+/* Bits 3 and 6 are not SDHCI standard definitions */
+#define  ESDHC_MIX_CTRL_SDHCI_MASK	0xb7
 
 /*
  * There is an INT DMA ERR mis-match between eSDHC and STD SDHC SPEC:
@@ -251,7 +254,12 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 
 		if (is_imx6q_usdhc(imx_data)) {
 			u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
-			m = val | (m & 0xffff0000);
+			/* Swap AC23 bit */
+			if (val & SDHCI_TRNS_AUTO_CMD23) {
+				val &= ~SDHCI_TRNS_AUTO_CMD23;
+				val |= ESDHC_MIX_CTRL_AC23EN;
+			}
+			m = val | (m & ~ESDHC_MIX_CTRL_SDHCI_MASK);
 			writel(m, host->ioaddr + ESDHC_MIX_CTRL);
 		} else {
 			/*
-- 
1.7.9.5



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

* [PATCH 4/6] mmc: sdhci: rename platform_8bit_width to platform_bus_width
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
                   ` (2 preceding siblings ...)
  2013-01-21 11:02 ` [PATCH 3/6] mmc: sdhci-esdhc-imx: Auto CMD23 support " Shawn Guo
@ 2013-01-21 11:02 ` Shawn Guo
  2013-01-21 11:02 ` [PATCH 5/6] mmc: sdhci-esdhc-imx: support 8bit mode Shawn Guo
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo

From: Sascha Hauer <s.hauer@pengutronix.de>

The 8bit in the function name is misleading. When set, it will be
used to set the bus width, regardless of whether 8bit or another
bus width is requested, so change the function name to
platform_bus_width.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-pci.c   |    4 ++--
 drivers/mmc/host/sdhci-pxav2.c |    2 +-
 drivers/mmc/host/sdhci-s3c.c   |    8 ++++----
 drivers/mmc/host/sdhci-tegra.c |    4 ++--
 drivers/mmc/host/sdhci.c       |    8 ++++----
 drivers/mmc/host/sdhci.h       |    2 +-
 6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index c7dd0cb..c7ccf30 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -935,7 +935,7 @@ static int sdhci_pci_enable_dma(struct sdhci_host *host)
 	return 0;
 }
 
-static int sdhci_pci_8bit_width(struct sdhci_host *host, int width)
+static int sdhci_pci_bus_width(struct sdhci_host *host, int width)
 {
 	u8 ctrl;
 
@@ -977,7 +977,7 @@ static void sdhci_pci_hw_reset(struct sdhci_host *host)
 
 static struct sdhci_ops sdhci_pci_ops = {
 	.enable_dma	= sdhci_pci_enable_dma,
-	.platform_8bit_width	= sdhci_pci_8bit_width,
+	.platform_bus_width	= sdhci_pci_bus_width,
 	.hw_reset		= sdhci_pci_hw_reset,
 };
 
diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c
index ac854aa..7e57565 100644
--- a/drivers/mmc/host/sdhci-pxav2.c
+++ b/drivers/mmc/host/sdhci-pxav2.c
@@ -121,7 +121,7 @@ static u32 pxav2_get_max_clock(struct sdhci_host *host)
 static struct sdhci_ops pxav2_sdhci_ops = {
 	.get_max_clock = pxav2_get_max_clock,
 	.platform_reset_exit = pxav2_set_private_registers,
-	.platform_8bit_width = pxav2_mmc_set_width,
+	.platform_bus_width = pxav2_mmc_set_width,
 };
 
 #ifdef CONFIG_OF
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 82a8de1..b16dae0 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -332,14 +332,14 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
 }
 
 /**
- * sdhci_s3c_platform_8bit_width - support 8bit buswidth
+ * sdhci_s3c_platform_bus_width - support 8bit buswidth
  * @host: The SDHCI host being queried
  * @width: MMC_BUS_WIDTH_ macro for the bus width being requested
  *
  * We have 8-bit width support but is not a v3 controller.
- * So we add platform_8bit_width() and support 8bit width.
+ * So we add platform_bus_width() and support 8bit width.
  */
-static int sdhci_s3c_platform_8bit_width(struct sdhci_host *host, int width)
+static int sdhci_s3c_platform_bus_width(struct sdhci_host *host, int width)
 {
 	u8 ctrl;
 
@@ -369,7 +369,7 @@ static struct sdhci_ops sdhci_s3c_ops = {
 	.get_max_clock		= sdhci_s3c_get_max_clk,
 	.set_clock		= sdhci_s3c_set_clock,
 	.get_min_clock		= sdhci_s3c_get_min_clock,
-	.platform_8bit_width	= sdhci_s3c_platform_8bit_width,
+	.platform_bus_width	= sdhci_s3c_platform_bus_width,
 };
 
 static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 3695b2e..5a600a5 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -143,7 +143,7 @@ static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
 	}
 }
 
-static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width)
+static int tegra_sdhci_buswidth(struct sdhci_host *host, int bus_width)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_tegra *tegra_host = pltfm_host->priv;
@@ -170,7 +170,7 @@ static struct sdhci_ops tegra_sdhci_ops = {
 	.read_l     = tegra_sdhci_readl,
 	.read_w     = tegra_sdhci_readw,
 	.write_l    = tegra_sdhci_writel,
-	.platform_8bit_width = tegra_sdhci_8bit,
+	.platform_bus_width = tegra_sdhci_buswidth,
 	.platform_reset_exit = tegra_sdhci_reset_exit,
 };
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 336ab06..3bb9b88 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1395,11 +1395,11 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
 	/*
 	 * If your platform has 8-bit width support but is not a v3 controller,
 	 * or if it requires special setup code, you should implement that in
-	 * platform_8bit_width().
+	 * platform_bus_width().
 	 */
-	if (host->ops->platform_8bit_width)
-		host->ops->platform_8bit_width(host, ios->bus_width);
-	else {
+	if (host->ops->platform_bus_width) {
+		host->ops->platform_bus_width(host, ios->bus_width);
+	} else {
 		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
 		if (ios->bus_width == MMC_BUS_WIDTH_8) {
 			ctrl &= ~SDHCI_CTRL_4BITBUS;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index a6d69b7..c8d11b9 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -269,7 +269,7 @@ struct sdhci_ops {
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
 	unsigned int	(*get_timeout_clock)(struct sdhci_host *host);
-	int		(*platform_8bit_width)(struct sdhci_host *host,
+	int		(*platform_bus_width)(struct sdhci_host *host,
 					       int width);
 	void (*platform_send_init_74_clocks)(struct sdhci_host *host,
 					     u8 power_mode);
-- 
1.7.9.5



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

* [PATCH 5/6] mmc: sdhci-esdhc-imx: support 8bit mode
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
                   ` (3 preceding siblings ...)
  2013-01-21 11:02 ` [PATCH 4/6] mmc: sdhci: rename platform_8bit_width to platform_bus_width Shawn Guo
@ 2013-01-21 11:02 ` Shawn Guo
  2013-01-21 11:02 ` [PATCH 6/6] mmc: dt: bus-width can be an optional property Shawn Guo
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo

From: Sascha Hauer <s.hauer@pengutronix.de>

The i.MX esdhc has a nonstandard bit layout for the SDHCI_HOST_CONTROL
register. To support 8bit bus width on i.MX populate the platform_bus_width
callback. This is tested on an i.MX25, but should according to the datasheets
work on the other i.MX using this hardware aswell. The i.MX6, while having
a SDHCI_SPEC_300 controller, still uses the same nonstandard register layout.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c          |   56 ++++++++++++++++++++++++++-
 include/linux/platform_data/mmc-esdhc-imx.h |    1 +
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 24daaf4..f7ee5e6 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -41,6 +41,13 @@
 #define  ESDHC_MIX_CTRL_SDHCI_MASK	0xb7
 
 /*
+ * Our interpretation of the SDHCI_HOST_CONTROL register
+ */
+#define ESDHC_CTRL_4BITBUS		(0x1 << 1)
+#define ESDHC_CTRL_8BITBUS		(0x2 << 1)
+#define ESDHC_CTRL_BUSWIDTH_MASK	(0x3 << 1)
+
+/*
  * There is an INT DMA ERR mis-match between eSDHC and STD SDHC SPEC:
  * Bit25 is used in STD SPEC, and is reserved in fsl eSDHC design,
  * but bit28 is used as the INT DMA ERR in fsl eSDHC design.
@@ -294,6 +301,7 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct pltfm_imx_data *imx_data = pltfm_host->priv;
 	u32 new_val;
+	u32 mask;
 
 	switch (reg) {
 	case SDHCI_POWER_CONTROL:
@@ -304,7 +312,7 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 		return;
 	case SDHCI_HOST_CONTROL:
 		/* FSL messed up here, so we need to manually compose it. */
-		new_val = val & (SDHCI_CTRL_LED | SDHCI_CTRL_4BITBUS);
+		new_val = val & SDHCI_CTRL_LED;
 		/* ensure the endianness */
 		new_val |= ESDHC_HOST_CONTROL_LE;
 		/* bits 8&9 are reserved on mx25 */
@@ -313,7 +321,13 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 			new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
 		}
 
-		esdhc_clrset_le(host, 0xffff, new_val, reg);
+		/*
+		 * Do not touch buswidth bits here. This is done in
+		 * esdhc_pltfm_bus_width.
+		 */
+		mask = 0xffff & ~ESDHC_CTRL_BUSWIDTH_MASK;
+
+		esdhc_clrset_le(host, mask, new_val, reg);
 		return;
 	}
 	esdhc_clrset_le(host, 0xff, val, reg);
@@ -370,6 +384,28 @@ static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
 	return -ENOSYS;
 }
 
+static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
+{
+	u32 ctrl;
+
+	switch (width) {
+	case MMC_BUS_WIDTH_8:
+		ctrl = ESDHC_CTRL_8BITBUS;
+		break;
+	case MMC_BUS_WIDTH_4:
+		ctrl = ESDHC_CTRL_4BITBUS;
+		break;
+	default:
+		ctrl = 0;
+		break;
+	}
+
+	esdhc_clrset_le(host, ESDHC_CTRL_BUSWIDTH_MASK, ctrl,
+			SDHCI_HOST_CONTROL);
+
+	return 0;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = esdhc_readl_le,
 	.read_w = esdhc_readw_le,
@@ -380,6 +416,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 	.get_max_clock = esdhc_pltfm_get_max_clock,
 	.get_min_clock = esdhc_pltfm_get_min_clock,
 	.get_ro = esdhc_pltfm_get_ro,
+	.platform_bus_width = esdhc_pltfm_bus_width,
 };
 
 static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
@@ -417,6 +454,8 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 	if (gpio_is_valid(boarddata->wp_gpio))
 		boarddata->wp_type = ESDHC_WP_GPIO;
 
+	of_property_read_u32(np, "bus-width", &boarddata->max_bus_width);
+
 	return 0;
 }
 #else
@@ -548,6 +587,19 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		break;
 	}
 
+	switch (boarddata->max_bus_width) {
+	case 8:
+		host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA;
+		break;
+	case 4:
+		host->mmc->caps |= MMC_CAP_4_BIT_DATA;
+		break;
+	case 1:
+	default:
+		host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
+		break;
+	}
+
 	err = sdhci_add_host(host);
 	if (err)
 		goto disable_clk;
diff --git a/include/linux/platform_data/mmc-esdhc-imx.h b/include/linux/platform_data/mmc-esdhc-imx.h
index aaf9748..b4a0521 100644
--- a/include/linux/platform_data/mmc-esdhc-imx.h
+++ b/include/linux/platform_data/mmc-esdhc-imx.h
@@ -39,5 +39,6 @@ struct esdhc_platform_data {
 	unsigned int cd_gpio;
 	enum wp_types wp_type;
 	enum cd_types cd_type;
+	int max_bus_width;
 };
 #endif /* __ASM_ARCH_IMX_ESDHC_H */
-- 
1.7.9.5



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

* [PATCH 6/6] mmc: dt: bus-width can be an optional property
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
                   ` (4 preceding siblings ...)
  2013-01-21 11:02 ` [PATCH 5/6] mmc: sdhci-esdhc-imx: support 8bit mode Shawn Guo
@ 2013-01-21 11:02 ` Shawn Guo
  2013-02-08 23:02   ` Grant Likely
  2013-01-25  6:47 ` [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Dirk Behme
  2013-01-28 21:50 ` Chris Ball
  7 siblings, 1 reply; 10+ messages in thread
From: Shawn Guo @ 2013-01-21 11:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: Sascha Hauer, Chris Ball, Shawn Guo, devicetree-discuss

None of mmc drivers implements bus-width as a required device tree
property.  Instead, some drivers like atmel-mci, dw_mmc, sdhci-s3c
implement it as an optional one, and will force bus width to be 1
when the property is absent.  Let's change the common binding to
reflect what the drivers are usually doing.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: devicetree-discuss@lists.ozlabs.org
---
 Documentation/devicetree/bindings/mmc/mmc.txt |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
index a591c67..cef217d 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -6,9 +6,6 @@ Interpreted by the OF core:
 - reg: Registers location and length.
 - interrupts: Interrupts used by the MMC controller.
 
-Required properties:
-- bus-width: Number of data lines, can be <1>, <4>, or <8>
-
 Card detection:
 If no property below is supplied, standard SDHCI card detect is used.
 Only one of the properties in this section should be supplied:
@@ -17,6 +14,8 @@ Only one of the properties in this section should be supplied:
   - non-removable: non-removable slot (like eMMC); assume always present.
 
 Optional properties:
+- bus-width: Number of data lines, can be <1>, <4>, or <8>.  The default
+  will be <1> if the property is absent.
 - wp-gpios: Specify GPIOs for write protection, see gpio binding
 - cd-inverted: when present, polarity on the cd gpio line is inverted
 - wp-inverted: when present, polarity on the wp gpio line is inverted
-- 
1.7.9.5



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

* Re: [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
                   ` (5 preceding siblings ...)
  2013-01-21 11:02 ` [PATCH 6/6] mmc: dt: bus-width can be an optional property Shawn Guo
@ 2013-01-25  6:47 ` Dirk Behme
  2013-01-28 21:50 ` Chris Ball
  7 siblings, 0 replies; 10+ messages in thread
From: Dirk Behme @ 2013-01-25  6:47 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc@vger.kernel.org, Sascha Hauer, Chris Ball

On 21.01.2013 12:02, Shawn Guo wrote:
> The series makes Auto CMD23 work for imx6q usdhc and then adds 8bit
> mmc support.
> 
> Sascha Hauer (2):
>   mmc: sdhci: rename platform_8bit_width to platform_bus_width
>   mmc: sdhci-esdhc-imx: support 8bit mode
> 
> Shawn Guo (4):
>   mmc: sdhci-esdhc-imx: separate transfer mode from command write for
>     usdhc
>   mmc: sdhci-esdhc-imx: manually reset MIX_CTRL for usdhc
>   mmc: sdhci-esdhc-imx: Auto CMD23 support for usdhc
>   mmc: dt: bus-width can be an optional property
> 
>  Documentation/devicetree/bindings/mmc/mmc.txt |    5 +-
>  drivers/mmc/host/sdhci-esdhc-imx.c            |   98 +++++++++++++++++++++----
>  drivers/mmc/host/sdhci-pci.c                  |    4 +-
>  drivers/mmc/host/sdhci-pxav2.c                |    2 +-
>  drivers/mmc/host/sdhci-s3c.c                  |    8 +-
>  drivers/mmc/host/sdhci-tegra.c                |    4 +-
>  drivers/mmc/host/sdhci.c                      |    8 +-
>  drivers/mmc/host/sdhci.h                      |    2 +-
>  include/linux/platform_data/mmc-esdhc-imx.h   |    1 +
>  9 files changed, 101 insertions(+), 31 deletions(-)

Whole series:

Tested-by: Dirk Behme <dirk.behme@de.bosch.com>

Tested on i.MX6.

Thanks

Dirk

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

* Re: [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support
  2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
                   ` (6 preceding siblings ...)
  2013-01-25  6:47 ` [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Dirk Behme
@ 2013-01-28 21:50 ` Chris Ball
  7 siblings, 0 replies; 10+ messages in thread
From: Chris Ball @ 2013-01-28 21:50 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, Sascha Hauer

Hi Shawn,

On Mon, Jan 21 2013, Shawn Guo wrote:
> The series makes Auto CMD23 work for imx6q usdhc and then adds 8bit
> mmc support.

Thanks, the whole set is pushed to mmc-next for 3.9.

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

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

* Re: [PATCH 6/6] mmc: dt: bus-width can be an optional property
  2013-01-21 11:02 ` [PATCH 6/6] mmc: dt: bus-width can be an optional property Shawn Guo
@ 2013-02-08 23:02   ` Grant Likely
  0 siblings, 0 replies; 10+ messages in thread
From: Grant Likely @ 2013-02-08 23:02 UTC (permalink / raw)
  To: Shawn Guo, linux-mmc; +Cc: Sascha Hauer, Chris Ball, devicetree-discuss

On Mon, 21 Jan 2013 19:02:29 +0800, Shawn Guo <shawn.guo@linaro.org> wrote:
> None of mmc drivers implements bus-width as a required device tree
> property.  Instead, some drivers like atmel-mci, dw_mmc, sdhci-s3c
> implement it as an optional one, and will force bus width to be 1
> when the property is absent.  Let's change the common binding to
> reflect what the drivers are usually doing.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: devicetree-discuss@lists.ozlabs.org

Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  Documentation/devicetree/bindings/mmc/mmc.txt |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
> index a591c67..cef217d 100644
> --- a/Documentation/devicetree/bindings/mmc/mmc.txt
> +++ b/Documentation/devicetree/bindings/mmc/mmc.txt
> @@ -6,9 +6,6 @@ Interpreted by the OF core:
>  - reg: Registers location and length.
>  - interrupts: Interrupts used by the MMC controller.
>  
> -Required properties:
> -- bus-width: Number of data lines, can be <1>, <4>, or <8>
> -
>  Card detection:
>  If no property below is supplied, standard SDHCI card detect is used.
>  Only one of the properties in this section should be supplied:
> @@ -17,6 +14,8 @@ Only one of the properties in this section should be supplied:
>    - non-removable: non-removable slot (like eMMC); assume always present.
>  
>  Optional properties:
> +- bus-width: Number of data lines, can be <1>, <4>, or <8>.  The default
> +  will be <1> if the property is absent.
>  - wp-gpios: Specify GPIOs for write protection, see gpio binding
>  - cd-inverted: when present, polarity on the cd gpio line is inverted
>  - wp-inverted: when present, polarity on the wp gpio line is inverted
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

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

end of thread, other threads:[~2013-02-08 23:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-21 11:02 [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Shawn Guo
2013-01-21 11:02 ` [PATCH 1/6] mmc: sdhci-esdhc-imx: separate transfer mode from command write for usdhc Shawn Guo
2013-01-21 11:02 ` [PATCH 2/6] mmc: sdhci-esdhc-imx: manually reset MIX_CTRL " Shawn Guo
2013-01-21 11:02 ` [PATCH 3/6] mmc: sdhci-esdhc-imx: Auto CMD23 support " Shawn Guo
2013-01-21 11:02 ` [PATCH 4/6] mmc: sdhci: rename platform_8bit_width to platform_bus_width Shawn Guo
2013-01-21 11:02 ` [PATCH 5/6] mmc: sdhci-esdhc-imx: support 8bit mode Shawn Guo
2013-01-21 11:02 ` [PATCH 6/6] mmc: dt: bus-width can be an optional property Shawn Guo
2013-02-08 23:02   ` Grant Likely
2013-01-25  6:47 ` [PATCH 0/6] sdhci-esdhc-imx: 8bit mmc support Dirk Behme
2013-01-28 21:50 ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).