From 475546fe8e34bdbb2fe23e292adb312aa6c6f788 Mon Sep 17 00:00:00 2001 From: Aisheng Dong Date: Wed, 27 Aug 2014 15:26:32 +0800 Subject: mmc: sdhci: move timeout_clk dynamically calculation code into common code The timeout_clk calculation code for SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK case is common and could be moved into common sdhci_do_set_ios, then platform code which is not using sdhci_set_clock does not need to write the same code again. Signed-off-by: Dong Aisheng Signed-off-by: Ulf Hansson (cherry picked from commit 03d6f5ffc5c469e66bfe0a7d8120d29d4c3c07c9) Conflicts: drivers/mmc/host/sdhci.c --- drivers/mmc/host/sdhci.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 29980ba4e58..0af163737e4 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1225,18 +1225,8 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) } clock_set: - if (real_div) { + if (real_div) host->mmc->actual_clock = (host->max_clk * clk_mul) / real_div; - if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) { - host->timeout_clk = host->mmc->actual_clock / 1000; - host->mmc->max_busy_timeout = - host->ops->get_max_timeout_count ? - host->ops->get_max_timeout_count(host) : - 1 << 27; - host->mmc->max_busy_timeout /= host->timeout_clk; - } - } - clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT; clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN) << SDHCI_DIVIDER_HI_SHIFT; @@ -1471,6 +1461,18 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) sdhci_set_clock(host, ios->clock); + if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK && + host->clock) { + host->timeout_clk = host->mmc->actual_clock ? + host->mmc->actual_clock / 1000 : + host->clock / 1000; + host->mmc->max_busy_timeout = + host->ops->get_max_timeout_count ? + host->ops->get_max_timeout_count(host) : + 1 << 27; + host->mmc->max_busy_timeout /= host->timeout_clk; + } + if (ios->power_mode == MMC_POWER_OFF) vdd_bit = sdhci_set_power(host, -1); else -- cgit v1.2.3