diff options
| author | Venkat Gopalakrishnan <venkatg@codeaurora.org> | 2015-01-23 12:58:00 -0800 |
|---|---|---|
| committer | Subhash Jadavani <subhashj@codeaurora.org> | 2016-05-31 15:26:08 -0700 |
| commit | 8b70321d56d4c4ca94b6a165ea22d45387d47c61 (patch) | |
| tree | b8072e9fe7c2dfe9e33d64677016b3c71c115a6e | |
| parent | 8379862de2736e96861ff2fadbd1e21e335df1b0 (diff) | |
mmc: sdhci: Fix unclocked access during MMC_POWER_UP
During MMC_POWER_UP the clocks are turned off when enabling power
to the card. Make sure the controller clocks are enabled for
normal register access.
Change-Id: Iad6fc4dfc6e44d0a609b66432b0985d589c3e5b9
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
| -rw-r--r-- | drivers/mmc/host/sdhci.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index e9d6472d7ccf..3b167c6939ff 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1719,6 +1719,27 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) !(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN)) sdhci_enable_preset_value(host, false); + spin_lock_irqsave(&host->lock, flags); + if (ios->clock || ios->clock != host->clock) { + spin_unlock_irqrestore(&host->lock, flags); + host->ops->set_clock(host, ios->clock); + spin_lock_irqsave(&host->lock, flags); + host->clock = 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; + } + } + spin_unlock_irqrestore(&host->lock, flags); + /* * The controller clocks may be off during power-up and we may end up * enabling card clock before giving power to the card. Hence, during @@ -1739,23 +1760,9 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) } spin_lock_irqsave(&host->lock, flags); - if (!ios->clock || ios->clock != host->clock) { + if (!host->clock) { spin_unlock_irqrestore(&host->lock, flags); - host->ops->set_clock(host, ios->clock); - spin_lock_irqsave(&host->lock, flags); - host->clock = 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; - } + return; } spin_unlock_irqrestore(&host->lock, flags); |
