Skip to contentSkip to conversation

drivers/mmc/fsl_esdhc.c: increase timeout

PATCH New Frans Meulenbroeks 1 participant 2 messages Jul 31, 2010 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drivers/mmc/fsl_esdhc.c: increase timeout

some boards have problems reading from flash because the timeout is too strict. e.g. mpc8536ds had problems reading 2gb sandisk sd cl2 cards as well as 4gb transcend cl6 sdhc cards
The odd thing was that a sector that sometimes could be read would not be read the next time. And the cards operate smoothly from within linux. Definitely an indication that the timeout is too strict.
After increasing the timeout both cards worked like a charm.

As a somewhat too large timeout does not hurt (as it is normally not reached anyway) I've reduced the timeout by changing the subtracted value from 13 to 11. Seems to work fine with me (but we could consider forgetting about tuning the value and always write 14 << 16 in the timeout register (the max timeout value). Rmember that this timeout is only used up in case of an error, so it does not delay the normal operation.

---

BTW: it might be that this patch crept in at this commit:
http://git.denx.de/?p=u-boot.git;a=commitdiff;h=c67bee1460a0da89ef08cbc28375171acc9a4227

This one introduced a -1 in the calculation:
- timeout = __ilog2(mmc->tran_speed/10);
+ timeout = fls(mmc->tran_speed/10) - 1;

 drivers/mmc/fsl_esdhc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/fsl_esdhc.c +1 -1
index a368fe6..f982a69 100644
@@ -208,7 +208,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 
 	/* Calculate the timeout period for data transactions */
 	timeout = fls(mmc->tran_speed/10) - 1;
-	timeout -= 13;
+	timeout -= 11;
 
 	if (timeout > 14)
 		timeout = 14;
Signature · 1 line
1.6.4.2
#1 lore raw

PATCH 2/2 drivers/mmc/fsl_esdhc.c: reordered tests

As DATA_ERROR includes the value IRQSTAT_DTOE, a timeout error would yield the first error return instead of TIMEOUT. By swapping the test TIMEOUTs are reported as such

An alternate solution would be to remove the IRQSTAT_DTOE from the DATA_ERROR define but as that one might be less desired I've opted for the simplest solution

---
 drivers/mmc/fsl_esdhc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/fsl_esdhc.c +3 -3
index f982a69..4d04920 100644
@@ -305,11 +305,11 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 		do {
 			irqstat = esdhc_read32(&regs->irqstat);
 
-			if (irqstat & DATA_ERR)
-				return COMM_ERR;
-
 			if (irqstat & IRQSTAT_DTOE)
 				return TIMEOUT;
+
+			if (irqstat & DATA_ERR)
+				return COMM_ERR;
 		} while (!(irqstat & IRQSTAT_TC) &&
 				(esdhc_read32(&regs->prsstat) & PRSSTAT_DLA));
 #endif
Signature · 1 line
1.6.4.2