From: Lei Wen Date: Sat, 8 Oct 2011 04:14:57 +0000 (+0000) Subject: mmc: sdhci: add timeout for data transfer X-Git-Tag: v2011.12-rc1~333^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a004abde88e509443a45cc309f310db128cec5f2;p=u-boot mmc: sdhci: add timeout for data transfer Signed-off-by: Lei Wen --- diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 31c738e9af..77a9e708d0 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -81,8 +81,9 @@ static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data) static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, unsigned int start_addr) { - unsigned int stat, rdy, mask, block = 0; + unsigned int stat, rdy, mask, timeout, block = 0; + timeout = 10000; rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL; mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE; do { @@ -108,6 +109,12 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS); } #endif + if (timeout-- > 0) + udelay(10); + else { + printf("Transfer data timeout\n"); + return -1; + } } while (!(stat & SDHCI_INT_DATA_END)); return 0; }