Skip to content

Commit 2a187d0

Browse files
osctobestorulf
authored andcommitted
mmc: sdhci: fix minimum clock rate for v3 controller
For SDHCIv3+ with programmable clock mode, minimal clock frequency is still base clock / max(divider). Minimal programmable clock frequency is always greater than minimal divided clock frequency. Without this patch, SDHCI uses out-of-spec initial frequency when multiplier is big enough: mmc1: mmc_rescan_try_freq: trying to init card at 468750 Hz [for 480 MHz source clock divided by 1024] The code in sdhci_calc_clk() already chooses a correct SDCLK clock mode. Fixes: c3ed387 ("mmc: sdhci: add support for programmable clock mode") Cc: <[email protected]> # 4f6aa32: mmc: tegra: Only advertise UHS modes if IO regulator is present Cc: <[email protected]> Signed-off-by: Michał Mirosław <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/ffb489519a446caffe7a0a05c4b9372bd52397bb.1579082031.git.mirq-linux@rere.qmqm.pl Signed-off-by: Ulf Hansson <[email protected]>
1 parent f571389 commit 2a187d0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3913,11 +3913,13 @@ int sdhci_setup_host(struct sdhci_host *host)
39133913
if (host->ops->get_min_clock)
39143914
mmc->f_min = host->ops->get_min_clock(host);
39153915
else if (host->version >= SDHCI_SPEC_300) {
3916-
if (host->clk_mul) {
3917-
mmc->f_min = (host->max_clk * host->clk_mul) / 1024;
3916+
if (host->clk_mul)
39183917
max_clk = host->max_clk * host->clk_mul;
3919-
} else
3920-
mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
3918+
/*
3919+
* Divided Clock Mode minimum clock rate is always less than
3920+
* Programmable Clock Mode minimum clock rate.
3921+
*/
3922+
mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
39213923
} else
39223924
mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
39233925

0 commit comments

Comments
 (0)