brcm2708: add kernel 4.14 support
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.14 / 950-0166-mmc-bcm2835-sdhost-Support-underclocking.patch
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
5
6 Support underclocking of the SD bus in two ways:
7 1. using the max-frequency DT property (which currently has no DT
8 parameter), and
9 2. using the exiting sd_overclock parameter.
10
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.
14
15 See: https://github.com/raspberrypi/linux/issues/2350
16
17 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
18 ---
19 drivers/mmc/host/bcm2835-sdhost.c | 6 +++---
20 1 file changed, 3 insertions(+), 3 deletions(-)
21
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
25 if (host->debug)
26 pr_info("%s: set_clock(%d)\n", mmc_hostname(host->mmc), clock);
27
28 - if ((host->overclock_50 > 50) &&
29 - (clock == 50*MHZ))
30 + if (host->overclock_50 && (clock == 50*MHZ))
31 clock = host->overclock_50 * MHZ + (MHZ - 1);
32
33 /* The SDCDIV register has 11 bits, and holds (div - 2).
34 @@ -1894,7 +1893,8 @@ int bcm2835_sdhost_add_host(struct bcm28
35
36 mmc = host->mmc;
37
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;
42
43 mmc->max_busy_timeout = (~(unsigned int)0)/(mmc->f_max/1000);