mmc: bcm2835-mmc: Support underclocking
authorPhil Elwell <phil@raspberrypi.org>
Mon, 22 Jan 2018 12:22:01 +0000 (12:22 +0000)
committerRaspbian kernel package updater <root@raspbian.org>
Sat, 31 Mar 2018 14:57:29 +0000 (15:57 +0100)
Support underclocking of the SD bus using the max-frequency DT property
(which currently has no DT parameter). The sd_overclock parameter
already provides another way to achieve the same thing which should be
equivalent in end result, but it is a bug not to support max-frequency
as well.

See: https://github.com/raspberrypi/linux/issues/2350

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
drivers/mmc/host/bcm2835-mmc.c

index c4a5e992c6fb4a40b933239350ed4bfc8fb40155..b7f5fd96ecb6c59395022e868726f890ad3cd927 100644 (file)
@@ -1310,8 +1310,8 @@ static int bcm2835_mmc_add_host(struct bcm2835_host *host)
 
        host->clk_mul = 0;
 
-       mmc->f_max = host->max_clk;
-       mmc->f_max = host->max_clk;
+       if (!mmc->f_max || mmc->f_max > host->max_clk)
+               mmc->f_max = host->max_clk;
        mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
 
        /* SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK */