aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryangbo lu <yangbo.lu@nxp.com>2017-04-25 22:45:49 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2017-04-28 06:35:27 -0400
commite145ac451eb68b51e0ede4c131bd5a539fb675b6 (patch)
tree034830c2ecd85c51ce7f2609937396190ceef159
parenta04b9b47ae587e088439495f31ca740d92191a75 (diff)
mmc: sdhci-of-esdhc: poll ESDHC_CLOCK_STABLE bit with udelay
The loop to poll ESDHC_CLOCK_STABLE bit with mdelay would waste time because the time to stabilize is much less than 1 ms. This patch is to use udelay instead to avoid time wasting. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/sdhci-of-esdhc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 7518360c03d2..77dfc5915ddc 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -445,7 +445,7 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
445 struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 445 struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
446 int pre_div = 1; 446 int pre_div = 1;
447 int div = 1; 447 int div = 1;
448 u32 timeout; 448 ktime_t timeout;
449 u32 temp; 449 u32 temp;
450 450
451 host->mmc->actual_clock = 0; 451 host->mmc->actual_clock = 0;
@@ -489,15 +489,14 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
489 sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL); 489 sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
490 490
491 /* Wait max 20 ms */ 491 /* Wait max 20 ms */
492 timeout = 20; 492 timeout = ktime_add_ms(ktime_get(), 20);
493 while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) { 493 while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
494 if (timeout == 0) { 494 if (ktime_after(ktime_get(), timeout)) {
495 pr_err("%s: Internal clock never stabilised.\n", 495 pr_err("%s: Internal clock never stabilised.\n",
496 mmc_hostname(host->mmc)); 496 mmc_hostname(host->mmc));
497 return; 497 return;
498 } 498 }
499 timeout--; 499 udelay(10);
500 mdelay(1);
501 } 500 }
502 501
503 temp |= ESDHC_CLOCK_SDCLKEN; 502 temp |= ESDHC_CLOCK_SDCLKEN;