Skip to contentSkip to conversation

fsl_esdhc fixes

PATCH New Kumar Gala 2 participants 9 messages Dec 15, 2010 – Dec 16, 2010 MMC, SD and SDIO

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

cover fsl_esdhc fixes

These are some various fsl_esdhc fixes that we've had around for some time to get SDHC/MMC working on various boards.

- k

author
#1 lore raw

PATCH 1/3 fsl_esdhc: Use mmc_set_clock to set initial speed

From: Jerry Huang <[email protected]>

After booting the u-boot, and first using some SD card (such as Sandisk 2G SD card), because the field 'clock' of struct mmc is zero, this will cause the read transfer is always active and SDHC DATA line is always active, therefore, driver can't handle the next command.

Therefore, we use mmc_set_clock to setup both the data structure and HW to the initial clock speed of 400000Hz.

---
 drivers/mmc/fsl_esdhc.c |    2 +-
 include/mmc.h           |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/fsl_esdhc.c +1 -1
index 57cd4ee..73d5cd3 100644
@@ -398,7 +398,7 @@ static int esdhc_init(struct mmc *mmc)
 	esdhc_write32(&regs->sysctl, SYSCTL_HCKEN | SYSCTL_IPGEN);
 
 	/* Set the initial clock speed */
-	set_sysctl(mmc, 400000);
+	mmc_set_clock(mmc, 400000);
 
 	/* Disable the BRR and BWR bits in IRQSTAT */
 	esdhc_clrbits32(&regs->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR);
include/mmc.h +1 -0
index 9f94f42..cc4aa36 100644
@@ -280,6 +280,7 @@ int mmc_register(struct mmc *mmc);
 int mmc_initialize(bd_t *bis);
 int mmc_init(struct mmc *mmc);
 int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
+void mmc_set_clock(struct mmc *mmc, uint clock);
 struct mmc *find_mmc_device(int dev_num);
 int mmc_set_dev(int dev_num);
 void print_mmc_devices(char separator);
Signature · 1 line
1.7.2.3
author
#2 lore raw

PATCH 2/3 fsl_esdhc: Fix max clock frequency

From: Jerry Huang <[email protected]>

The max clock of MMC is 52MHz

---
 drivers/mmc/fsl_esdhc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/fsl_esdhc.c +1 -1
index 73d5cd3..7bab2f6 100644
@@ -477,7 +477,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 		mmc->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
 	mmc->f_min = 400000;
-	mmc->f_max = MIN(gd->sdhc_clk, 50000000);
+	mmc->f_max = MIN(gd->sdhc_clk, 52000000);
 
 	mmc_register(mmc);
 
Signature · 1 line
1.7.2.3
author
#3 lore raw

PATCH 3/3 fsl_esdhc: Fix the voltage validation process

From: Li Yang <[email protected]>

The current code use all the voltage range support by the host controller to do the validation. This will cause problem when the host supports Low Voltage Range. Change the validation voltage to be based on board setup.

---
 drivers/mmc/fsl_esdhc.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
drivers/mmc/fsl_esdhc.c +15 -5
index 7bab2f6..40b136c 100644
@@ -444,7 +444,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 {
 	struct fsl_esdhc *regs;
 	struct mmc *mmc;
-	u32 caps;
+	u32 caps, voltage_caps;
 
 	if (!cfg)
 		return -1;
@@ -462,14 +462,24 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 	mmc->set_ios = esdhc_set_ios;
 	mmc->init = esdhc_init;
 
+	voltage_caps = 0;
 	caps = regs->hostcapblt;
-
 	if (caps & ESDHC_HOSTCAPBLT_VS18)
-		mmc->voltages |= MMC_VDD_165_195;
+		voltage_caps |= MMC_VDD_165_195;
 	if (caps & ESDHC_HOSTCAPBLT_VS30)
-		mmc->voltages |= MMC_VDD_29_30 | MMC_VDD_30_31;
+		voltage_caps |= MMC_VDD_29_30 | MMC_VDD_30_31;
 	if (caps & ESDHC_HOSTCAPBLT_VS33)
-		mmc->voltages |= MMC_VDD_32_33 | MMC_VDD_33_34;
+		voltage_caps |= MMC_VDD_32_33 | MMC_VDD_33_34;
+
+#ifdef CONFIG_SYS_SD_VOLTAGE
+	mmc->voltages = CONFIG_SYS_SD_VOLTAGE;
+#else
+	mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
+#endif
+	if ((mmc->voltages & voltage_caps) == 0) {
+		printf("voltage not supported by controller\n");
+		return -1;
+	}
 
 	mmc->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
 
Signature · 1 line
1.7.2.3
#4 lore raw

PATCH 3/3 fsl_esdhc: Fix the voltage validation process

Quoted 9 lines · Kumar Gala

From: Li Yang <[email protected]>

The current code use all the voltage range support by the host controller to do the validation. This will cause problem when the host supports Low Voltage Range. Change the validation voltage to be based on board setup.

---

Regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#5 lore raw

PATCH 2/3 fsl_esdhc: Fix max clock frequency

In reply to Kumar Gala
Quoted 6 lines · Kumar Gala

From: Jerry Huang <[email protected]>

The max clock of MMC is 52MHz

---

It runs successfully on i.MX51.

Regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#6 lore raw

PATCH 1/3 fsl_esdhc: Use mmc_set_clock to set initial speed

In reply to Kumar Gala
Quoted 7 lines · Kumar Gala

From: Jerry Huang <[email protected]>

After booting the u-boot, and first using some SD card (such as Sandisk 2G SD card), because the field 'clock' of struct mmc is zero, this will cause the read transfer is always active and SDHC DATA line is always active, therefore, driver can't handle the next command.

Quoted 6 lines

Therefore, we use mmc_set_clock to setup both the data structure and HW to the initial clock speed of 400000Hz.

---

Tested on i.MX51, too.

Regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
author
#7 lore raw

cover fsl_esdhc fixes

In reply to Kumar Gala
Quoted 2 lines · Kumar Gala

These are some various fsl_esdhc fixes that we've had around for some time to get SDHC/MMC working on various boards.

Stefano,

Can you take a look at what if any impact these have on the imx side.

thanks

- k

#8 lore raw

cover fsl_esdhc fixes

Quoted 10 lines · Kumar Gala
Quoted 2 lines · Kumar Gala

These are some various fsl_esdhc fixes that we've had around for some time to get SDHC/MMC working on various boards.

Stefano,

Can you take a look at what if any impact these have on the imx side.

Hi Kumar,

I have tested successfully your patches on a i.MX51 target. I will send now my tested-by.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================