mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] more mci related stuff
@ 2012-02-09 13:39 Sascha Hauer
  2012-02-09 13:39 ` [PATCH 1/5] Add a timeout polling loop convenience wrapper Sascha Hauer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-02-09 13:39 UTC (permalink / raw)
  To: barebox

The following is needed to make my board work with 8bit eMMC properly.
Well, mostly properly as I didn't manage to get the eMMC work in DDR
mode.

Sascha Hauer (5):
      Add a timeout polling loop convenience wrapper
      mci i.MX esdhc: use timeout loops
      mci: Add a complete list of EXT_CSD_* fields from the kernel
      mci: Fix 8 bit mmc cards
      mci i.MX esdhc: make 8bit modes platform dependent

 arch/arm/mach-imx/include/mach/esdhc.h |    2 +
 drivers/mci/imx-esdhc.c                |   33 ++++++--
 drivers/mci/mci-core.c                 |  133 +++++++++++++++++++++++++------
 include/clock.h                        |   19 +++++
 include/mci.h                          |   51 +++++++++++-
 5 files changed, 199 insertions(+), 39 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/5] Add a timeout polling loop convenience wrapper
  2012-02-09 13:39 [PATCH] more mci related stuff Sascha Hauer
@ 2012-02-09 13:39 ` Sascha Hauer
  2012-02-09 13:39 ` [PATCH 2/5] mci i.MX esdhc: use timeout loops Sascha Hauer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-02-09 13:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/clock.h |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/clock.h b/include/clock.h
index af5b939..123f874 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -40,4 +40,23 @@ void mdelay(unsigned long msecs);
 #define MSECOND ((uint64_t)(1000 * 1000))
 #define USECOND ((uint64_t)(1000))
 
+/*
+ * Convenience wrapper to implement a typical polling loop with
+ * timeout. returns 0 if the condition became true within the
+ * timeout or -ETIMEDOUT otherwise
+ */
+#define wait_on_timeout(timeout, condition) \
+({								\
+	int __ret = 0;						\
+	uint64_t __to_start = get_time_ns();			\
+								\
+	while (!(condition)) {					\
+		if (is_timeout(__to_start, (timeout))) {	\
+			__ret = -ETIMEDOUT;			\
+			break;					\
+		}						\
+	}							\
+	__ret;							\
+})
+
 #endif /* CLOCK_H */
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/5] mci i.MX esdhc: use timeout loops
  2012-02-09 13:39 [PATCH] more mci related stuff Sascha Hauer
  2012-02-09 13:39 ` [PATCH 1/5] Add a timeout polling loop convenience wrapper Sascha Hauer
@ 2012-02-09 13:39 ` Sascha Hauer
  2012-02-09 13:39 ` [PATCH 3/5] mci: Add a complete list of EXT_CSD_* fields from the kernel Sascha Hauer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-02-09 13:39 UTC (permalink / raw)
  To: barebox

Too often I have waited to get a reaction from this driver
when something goes wrong. Use timeout loops instead of
inifinite polling loops.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/imx-esdhc.c |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 2123a8b..d36d211 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -238,6 +238,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	u32	irqstat;
 	struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
 	struct fsl_esdhc *regs = host->regs;
+	int ret;
 
 	esdhc_write32(&regs->irqstat, -1);
 
@@ -268,8 +269,12 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	esdhc_write32(&regs->xfertyp, xfertyp);
 
 	/* Wait for the command to complete */
-	while (!(esdhc_read32(&regs->irqstat) & IRQSTAT_CC))
-		;
+	ret = wait_on_timeout(100 * MSECOND,
+			esdhc_read32(&regs->irqstat) & IRQSTAT_CC);
+	if (ret) {
+		dev_err(host->dev, "timeout 1\n");
+		return -ETIMEDOUT;
+	}
 
 	irqstat = esdhc_read32(&regs->irqstat);
 	esdhc_write32(&regs->irqstat, irqstat);
@@ -321,12 +326,20 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	esdhc_write32(&regs->irqstat, -1);
 
 	/* Wait for the bus to be idle */
-	while ((esdhc_read32(&regs->prsstat) & PRSSTAT_CICHB) ||
-			(esdhc_read32(&regs->prsstat) & PRSSTAT_CIDHB))
-		;
+	ret = wait_on_timeout(100 * MSECOND,
+			!(esdhc_read32(&regs->prsstat) &
+				(PRSSTAT_CICHB | PRSSTAT_CIDHB)));
+	if (ret) {
+		dev_err(host->dev, "timeout 2\n");
+		return -ETIMEDOUT;
+	}
 
-	while (esdhc_read32(&regs->prsstat) & PRSSTAT_DLA)
-		;
+	ret = wait_on_timeout(100 * MSECOND,
+			!(esdhc_read32(&regs->prsstat) & PRSSTAT_DLA));
+	if (ret) {
+		dev_err(host->dev, "timeout 3\n");
+		return -ETIMEDOUT;
+	}
 
 	return 0;
 }
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/5] mci: Add a complete list of EXT_CSD_* fields from the kernel
  2012-02-09 13:39 [PATCH] more mci related stuff Sascha Hauer
  2012-02-09 13:39 ` [PATCH 1/5] Add a timeout polling loop convenience wrapper Sascha Hauer
  2012-02-09 13:39 ` [PATCH 2/5] mci i.MX esdhc: use timeout loops Sascha Hauer
@ 2012-02-09 13:39 ` Sascha Hauer
  2012-02-09 13:39 ` [PATCH 4/5] mci: Fix 8 bit mmc cards Sascha Hauer
  2012-02-09 13:39 ` [PATCH 5/5] mci i.MX esdhc: make 8bit modes platform dependent Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-02-09 13:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c |    2 +-
 include/mci.h          |   50 +++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index c6e8669..2377fef 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -427,7 +427,7 @@ static int mmc_change_freq(struct mci *mci)
 	}
 
 	/* No high-speed support */
-	if (!ext_csd[185])
+	if (!ext_csd[EXT_CSD_HS_TIMING])
 		return 0;
 
 	/* High Speed is set, there are two types: 52MHz and 26MHz */
diff --git a/include/mci.h b/include/mci.h
index d8a88da..7e3b459 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -140,11 +140,51 @@
  * EXT_CSD fields
  */
 
-#define EXT_CSD_BUS_WIDTH	183	/* R/W */
-#define EXT_CSD_HS_TIMING	185	/* R/W */
-#define EXT_CSD_CARD_TYPE	196	/* RO */
-#define EXT_CSD_REV		192	/* RO */
-#define EXT_CSD_SEC_CNT		212	/* RO, 4 bytes */
+#define EXT_CSD_FLUSH_CACHE		32      /* W */
+#define EXT_CSD_CACHE_CTRL		33      /* R/W */
+#define EXT_CSD_POWER_OFF_NOTIFICATION	34	/* R/W */
+#define EXT_CSD_GP_SIZE_MULT		143	/* R/W */
+#define EXT_CSD_PARTITION_ATTRIBUTE	156	/* R/W */
+#define EXT_CSD_PARTITION_SUPPORT	160	/* RO */
+#define EXT_CSD_HPI_MGMT		161	/* R/W */
+#define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
+#define EXT_CSD_SANITIZE_START		165     /* W */
+#define EXT_CSD_WR_REL_PARAM		166	/* RO */
+#define EXT_CSD_BOOT_WP			173	/* R/W */
+#define EXT_CSD_ERASE_GROUP_DEF		175	/* R/W */
+#define EXT_CSD_PART_CONFIG		179	/* R/W */
+#define EXT_CSD_ERASED_MEM_CONT		181	/* RO */
+#define EXT_CSD_BUS_WIDTH		183	/* R/W */
+#define EXT_CSD_HS_TIMING		185	/* R/W */
+#define EXT_CSD_POWER_CLASS		187	/* R/W */
+#define EXT_CSD_REV			192	/* RO */
+#define EXT_CSD_STRUCTURE		194	/* RO */
+#define EXT_CSD_CARD_TYPE		196	/* RO */
+#define EXT_CSD_OUT_OF_INTERRUPT_TIME	198	/* RO */
+#define EXT_CSD_PART_SWITCH_TIME        199     /* RO */
+#define EXT_CSD_PWR_CL_52_195		200	/* RO */
+#define EXT_CSD_PWR_CL_26_195		201	/* RO */
+#define EXT_CSD_PWR_CL_52_360		202	/* RO */
+#define EXT_CSD_PWR_CL_26_360		203	/* RO */
+#define EXT_CSD_SEC_CNT			212	/* RO, 4 bytes */
+#define EXT_CSD_S_A_TIMEOUT		217	/* RO */
+#define EXT_CSD_REL_WR_SEC_C		222	/* RO */
+#define EXT_CSD_HC_WP_GRP_SIZE		221	/* RO */
+#define EXT_CSD_ERASE_TIMEOUT_MULT	223	/* RO */
+#define EXT_CSD_HC_ERASE_GRP_SIZE	224	/* RO */
+#define EXT_CSD_BOOT_MULT		226	/* RO */
+#define EXT_CSD_SEC_TRIM_MULT		229	/* RO */
+#define EXT_CSD_SEC_ERASE_MULT		230	/* RO */
+#define EXT_CSD_SEC_FEATURE_SUPPORT	231	/* RO */
+#define EXT_CSD_TRIM_MULT		232	/* RO */
+#define EXT_CSD_PWR_CL_200_195		236	/* RO */
+#define EXT_CSD_PWR_CL_200_360		237	/* RO */
+#define EXT_CSD_PWR_CL_DDR_52_195	238	/* RO */
+#define EXT_CSD_PWR_CL_DDR_52_360	239	/* RO */
+#define EXT_CSD_POWER_OFF_LONG_TIME	247	/* RO */
+#define EXT_CSD_GENERIC_CMD6_TIME	248	/* RO */
+#define EXT_CSD_CACHE_SIZE		249	/* RO, 4 bytes */
+#define EXT_CSD_HPI_FEATURES		503	/* RO */
 
 /*
  * EXT_CSD field definitions
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/5] mci: Fix 8 bit mmc cards
  2012-02-09 13:39 [PATCH] more mci related stuff Sascha Hauer
                   ` (2 preceding siblings ...)
  2012-02-09 13:39 ` [PATCH 3/5] mci: Add a complete list of EXT_CSD_* fields from the kernel Sascha Hauer
@ 2012-02-09 13:39 ` Sascha Hauer
  2012-02-09 13:39 ` [PATCH 5/5] mci i.MX esdhc: make 8bit modes platform dependent Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-02-09 13:39 UTC (permalink / raw)
  To: barebox

Currently we test the cards capabilities for being 8bit capable.
This does not work since noone ever sets this bit. Unfortunately
there is no bit to test 8bit capability, so we introduce a patch
from the kernel which puts the mmc card into 8bit mode and tests
whether it can succesfully read the ext_csd in this mode.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c |  133 ++++++++++++++++++++++++++++++++++++++---------
 include/mci.h          |    1 +
 2 files changed, 108 insertions(+), 26 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 2377fef..0bf4449 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -391,10 +391,10 @@ static int mci_switch(struct mci *mci, unsigned set, unsigned index,
  */
 static int mmc_change_freq(struct mci *mci)
 {
-	char *ext_csd = sector_buf;
 	char cardtype;
 	int err;
 
+	mci->ext_csd = xmalloc(512);
 	mci->card_caps = 0;
 
 	/* Only version 4 supports high-speed */
@@ -403,13 +403,13 @@ static int mmc_change_freq(struct mci *mci)
 
 	mci->card_caps |= MMC_MODE_4BIT;
 
-	err = mci_send_ext_csd(mci, ext_csd);
+	err = mci_send_ext_csd(mci, mci->ext_csd);
 	if (err) {
 		dev_dbg(mci->mci_dev, "Preparing for frequency setup failed: %d\n", err);
 		return err;
 	}
 
-	cardtype = ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK;
+	cardtype = mci->ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK;
 
 	err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1);
 
@@ -419,7 +419,7 @@ static int mmc_change_freq(struct mci *mci)
 	}
 
 	/* Now check to see that it worked */
-	err = mci_send_ext_csd(mci, ext_csd);
+	err = mci_send_ext_csd(mci, mci->ext_csd);
 
 	if (err) {
 		dev_dbg(mci->mci_dev, "Verifying frequency change failed: %d\n", err);
@@ -427,7 +427,7 @@ static int mmc_change_freq(struct mci *mci)
 	}
 
 	/* No high-speed support */
-	if (!ext_csd[EXT_CSD_HS_TIMING])
+	if (!mci->ext_csd[EXT_CSD_HS_TIMING])
 		return 0;
 
 	/* High Speed is set, there are two types: 52MHz and 26MHz */
@@ -767,6 +767,67 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci)
 	dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)mci->capacity >> 20);
 }
 
+static int mmc_compare_ext_csds(struct mci *mci, unsigned bus_width)
+{
+	u8 *bw_ext_csd;
+	int err;
+
+	if (bus_width == MMC_BUS_WIDTH_1)
+		return 0;
+
+	bw_ext_csd = xmalloc(512);
+	err = mci_send_ext_csd(mci, bw_ext_csd);
+	if (err) {
+		dev_info(mci->mci_dev, "mci_send_ext_csd failed with %d\n", err);
+		if (bus_width != MMC_BUS_WIDTH_1)
+			err = -EINVAL;
+		goto out;
+	}
+
+	if (bus_width == MMC_BUS_WIDTH_1)
+		goto out;
+	/* only compare read only fields */
+	err = (mci->ext_csd[EXT_CSD_PARTITION_SUPPORT] ==
+			bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) &&
+		(mci->ext_csd[EXT_CSD_ERASED_MEM_CONT] ==
+			bw_ext_csd[EXT_CSD_ERASED_MEM_CONT]) &&
+		(mci->ext_csd[EXT_CSD_REV] ==
+			bw_ext_csd[EXT_CSD_REV]) &&
+		(mci->ext_csd[EXT_CSD_STRUCTURE] ==
+			bw_ext_csd[EXT_CSD_STRUCTURE]) &&
+		(mci->ext_csd[EXT_CSD_CARD_TYPE] ==
+			bw_ext_csd[EXT_CSD_CARD_TYPE]) &&
+		(mci->ext_csd[EXT_CSD_S_A_TIMEOUT] ==
+			bw_ext_csd[EXT_CSD_S_A_TIMEOUT]) &&
+		(mci->ext_csd[EXT_CSD_HC_WP_GRP_SIZE] ==
+			bw_ext_csd[EXT_CSD_HC_WP_GRP_SIZE]) &&
+		(mci->ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT] ==
+			bw_ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT]) &&
+		(mci->ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] ==
+			bw_ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]) &&
+		(mci->ext_csd[EXT_CSD_SEC_TRIM_MULT] ==
+			bw_ext_csd[EXT_CSD_SEC_TRIM_MULT]) &&
+		(mci->ext_csd[EXT_CSD_SEC_ERASE_MULT] ==
+			bw_ext_csd[EXT_CSD_SEC_ERASE_MULT]) &&
+		(mci->ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT] ==
+			bw_ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT]) &&
+		(mci->ext_csd[EXT_CSD_TRIM_MULT] ==
+			bw_ext_csd[EXT_CSD_TRIM_MULT]) &&
+		(mci->ext_csd[EXT_CSD_SEC_CNT + 0] ==
+			bw_ext_csd[EXT_CSD_SEC_CNT + 0]) &&
+		(mci->ext_csd[EXT_CSD_SEC_CNT + 1] ==
+			bw_ext_csd[EXT_CSD_SEC_CNT + 1]) &&
+		(mci->ext_csd[EXT_CSD_SEC_CNT + 2] ==
+			bw_ext_csd[EXT_CSD_SEC_CNT + 2]) &&
+		(mci->ext_csd[EXT_CSD_SEC_CNT + 3] ==
+			bw_ext_csd[EXT_CSD_SEC_CNT + 3]) ?
+				0 : -EINVAL;
+
+out:
+	free(bw_ext_csd);
+	return err;
+}
+
 static int mci_startup_sd(struct mci *mci)
 {
 	struct mci_cmd cmd;
@@ -802,29 +863,18 @@ static int mci_startup_sd(struct mci *mci)
 
 static int mci_startup_mmc(struct mci *mci)
 {
+	struct mci_host *host = mci->host;
 	int err;
+	int idx = 0;
+	static unsigned ext_csd_bits[] = {
+		EXT_CSD_BUS_WIDTH_4,
+		EXT_CSD_BUS_WIDTH_8,
+	};
+	static unsigned bus_widths[] = {
+		MMC_BUS_WIDTH_4,
+		MMC_BUS_WIDTH_8,
+	};
 
-	if (mci->card_caps & MMC_MODE_4BIT) {
-		dev_dbg(mci->mci_dev, "Set MMC bus width to 4 bit\n");
-		/* Set the card to use 4 bit*/
-		err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL,
-				EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
-		if (err) {
-			dev_dbg(mci->mci_dev, "Changing MMC bus width failed: %d\n", err);
-			return err;
-		}
-		mci_set_bus_width(mci, MMC_BUS_WIDTH_4);
-	} else if (mci->card_caps & MMC_MODE_8BIT) {
-		dev_dbg(mci->mci_dev, "Set MMC bus width to 8 bit\n");
-		/* Set the card to use 8 bit*/
-		err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL,
-				EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_8);
-		if (err) {
-			dev_dbg(mci->mci_dev, "Changing MMC bus width failed: %d\n", err);
-			return err;
-		}
-		mci_set_bus_width(mci, MMC_BUS_WIDTH_8);
-	}
 	/* if possible, speed up the transfer */
 	if (mci->card_caps & MMC_MODE_HS) {
 		if (mci->card_caps & MMC_MODE_HS_52MHz)
@@ -834,6 +884,37 @@ static int mci_startup_mmc(struct mci *mci)
 	} else
 		mci_set_clock(mci, 20000000);
 
+	/*
+	 * Unlike SD, MMC cards dont have a configuration register to notify
+	 * supported bus width. So bus test command should be run to identify
+	 * the supported bus width or compare the ext csd values of current
+	 * bus width and ext csd values of 1 bit mode read earlier.
+	 */
+	if (host->host_caps & MMC_MODE_8BIT)
+		idx = 1;
+
+	for (; idx >= 0; idx--) {
+
+		/*
+		 * Host is capable of 8bit transfer, then switch
+		 * the device to work in 8bit transfer mode. If the
+		 * mmc switch command returns error then switch to
+		 * 4bit transfer mode. On success set the corresponding
+		 * bus width on the host.
+		 */
+		err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL,
+				 EXT_CSD_BUS_WIDTH,
+				 ext_csd_bits[idx]);
+		if (err)
+			continue;
+
+		mci_set_bus_width(mci, bus_widths[idx]);
+
+		err = mmc_compare_ext_csds(mci, bus_widths[idx]);
+		if (!err)
+			break;
+	}
+
 	return 0;
 }
 
diff --git a/include/mci.h b/include/mci.h
index 7e3b459..97036c3 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -326,6 +326,7 @@ struct mci {
 	unsigned write_bl_len;
 	uint64_t capacity;	/**< Card's data capacity in bytes */
 	int ready_for_use;	/** true if already probed */
+	char *ext_csd;
 };
 
 int mci_register(struct mci_host*);
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/5] mci i.MX esdhc: make 8bit modes platform dependent
  2012-02-09 13:39 [PATCH] more mci related stuff Sascha Hauer
                   ` (3 preceding siblings ...)
  2012-02-09 13:39 ` [PATCH 4/5] mci: Fix 8 bit mmc cards Sascha Hauer
@ 2012-02-09 13:39 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-02-09 13:39 UTC (permalink / raw)
  To: barebox

Whether the controller works in 8bit mode is not only dependent
on the controller but also on the board having wired up 8 data
lines, so put a capabilities field in platform data.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/include/mach/esdhc.h |    2 ++
 drivers/mci/imx-esdhc.c                |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/esdhc.h b/arch/arm/mach-imx/include/mach/esdhc.h
index aaf9748..b4c1aa9 100644
--- a/arch/arm/mach-imx/include/mach/esdhc.h
+++ b/arch/arm/mach-imx/include/mach/esdhc.h
@@ -32,6 +32,7 @@ enum cd_types {
  * @cd_gpio:	gpio for card_detect interrupt
  * @wp_type:	type of write_protect method (see wp_types enum above)
  * @cd_type:	type of card_detect method (see cd_types enum above)
+ * @caps:	supported bus width capabilities (MMC_MODE_4BIT | MMC_MODE_8BIT)
  */
 
 struct esdhc_platform_data {
@@ -39,5 +40,6 @@ struct esdhc_platform_data {
 	unsigned int cd_gpio;
 	enum wp_types wp_type;
 	enum cd_types cd_type;
+	unsigned caps;
 };
 #endif /* __ASM_ARCH_IMX_ESDHC_H */
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index d36d211..c6f2d5c 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -511,6 +511,7 @@ static int fsl_esdhc_probe(struct device_d *dev)
 	struct mci_host *mci;
 	u32 caps;
 	int ret;
+	struct esdhc_platform_data *pdata = dev->platform_data;
 
 	host = xzalloc(sizeof(*host));
 	mci = &host->mci;
@@ -534,7 +535,10 @@ static int fsl_esdhc_probe(struct device_d *dev)
 	if (caps & ESDHC_HOSTCAPBLT_VS33)
 		mci->voltages |= MMC_VDD_32_33 | MMC_VDD_33_34;
 
-	mci->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
+	if (pdata && pdata->caps)
+		mci->host_caps = pdata->caps;
+	else
+		mci->host_caps = MMC_MODE_4BIT;
 
 	if (caps & ESDHC_HOSTCAPBLT_HSS)
 		mci->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-02-09 13:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 13:39 [PATCH] more mci related stuff Sascha Hauer
2012-02-09 13:39 ` [PATCH 1/5] Add a timeout polling loop convenience wrapper Sascha Hauer
2012-02-09 13:39 ` [PATCH 2/5] mci i.MX esdhc: use timeout loops Sascha Hauer
2012-02-09 13:39 ` [PATCH 3/5] mci: Add a complete list of EXT_CSD_* fields from the kernel Sascha Hauer
2012-02-09 13:39 ` [PATCH 4/5] mci: Fix 8 bit mmc cards Sascha Hauer
2012-02-09 13:39 ` [PATCH 5/5] mci i.MX esdhc: make 8bit modes platform dependent Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox