Commit 4b01681c authored by Mark Brown's avatar Mark Brown Committed by Chris Ball

mmc: sdhci: Fix SDHCI_QUIRK_TIMEOUT_USES_SDCLK

Commit 373e6a (mmc: sdhci: R1B command handling + MMC_CAP_ERASE) moved the
handling of SDHCI_QUIRK_TIMEOUT_USES_SDCLK from sdhci_calc_timeout() to
sdhci_add_host(). This causes division by zero errors on at least the S3C
SDHCI controller as the quirk implementation needs host->clock set to work
but host->clock has not been set when sdhci_add_host() is called.

Fix this by backing out that portion of the change, the clock may vary at
runtime anyway. It does occur to me that we may want to move the quirk to
where we set the clock but this seems more invasive and I'm concerned
about undesirable side effects.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Andrei Warkentin <andreiw@motorola.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 24f5b53b
...@@ -616,6 +616,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) ...@@ -616,6 +616,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
target_timeout = data->timeout_ns / 1000 + target_timeout = data->timeout_ns / 1000 +
data->timeout_clks / host->clock; data->timeout_clks / host->clock;
if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
host->timeout_clk = host->clock / 1000;
/* /*
* Figure out needed cycles. * Figure out needed cycles.
* We do this in steps in order to fit inside a 32 bit int. * We do this in steps in order to fit inside a 32 bit int.
...@@ -626,6 +629,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) ...@@ -626,6 +629,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
* => * =>
* (1) / (2) > 2^6 * (1) / (2) > 2^6
*/ */
BUG_ON(!host->timeout_clk);
count = 0; count = 0;
current_timeout = (1 << 13) * 1000 / host->timeout_clk; current_timeout = (1 << 13) * 1000 / host->timeout_clk;
while (current_timeout < target_timeout) { while (current_timeout < target_timeout) {
...@@ -1901,9 +1905,6 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -1901,9 +1905,6 @@ int sdhci_add_host(struct sdhci_host *host)
if (caps & SDHCI_TIMEOUT_CLK_UNIT) if (caps & SDHCI_TIMEOUT_CLK_UNIT)
host->timeout_clk *= 1000; host->timeout_clk *= 1000;
if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
host->timeout_clk = host->clock / 1000;
/* /*
* Set host parameters. * Set host parameters.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment