1 From c03a6b0585e7c469c199d349405b3967bcf18672 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Mon, 22 Jan 2018 12:17:27 +0000
4 Subject: [PATCH 166/454] mmc: bcm2835-sdhost: Support underclocking
6 Support underclocking of the SD bus in two ways:
7 1. using the max-frequency DT property (which currently has no DT
9 2. using the exiting sd_overclock parameter.
11 The two methods differ slightly - in the former the MMC subsystem is
12 aware of the underclocking, while in the latter it isn't - but the
13 end results should be the same.
15 See: https://github.com/raspberrypi/linux/issues/2350
17 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
19 drivers/mmc/host/bcm2835-sdhost.c | 6 +++---
20 1 file changed, 3 insertions(+), 3 deletions(-)
22 --- a/drivers/mmc/host/bcm2835-sdhost.c
23 +++ b/drivers/mmc/host/bcm2835-sdhost.c
24 @@ -1519,8 +1519,7 @@ void bcm2835_sdhost_set_clock(struct bcm
26 pr_info("%s: set_clock(%d)\n", mmc_hostname(host->mmc), clock);
28 - if ((host->overclock_50 > 50) &&
30 + if (host->overclock_50 && (clock == 50*MHZ))
31 clock = host->overclock_50 * MHZ + (MHZ - 1);
33 /* The SDCDIV register has 11 bits, and holds (div - 2).
34 @@ -1894,7 +1893,8 @@ int bcm2835_sdhost_add_host(struct bcm28
38 - mmc->f_max = host->max_clk;
39 + if (!mmc->f_max || mmc->f_max > host->max_clk)
40 + mmc->f_max = host->max_clk;
41 mmc->f_min = host->max_clk / SDCDIV_MAX_CDIV;
43 mmc->max_busy_timeout = (~(unsigned int)0)/(mmc->f_max/1000);