]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.10.7/mmc-sdhci-of-at91-support-external-regulators.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.10.7 / mmc-sdhci-of-at91-support-external-regulators.patch
1 From 2ce0c7b65505e0d915e99389cced45b478dc935d Mon Sep 17 00:00:00 2001
2 From: Romain Izard <romain.izard.pro@gmail.com>
3 Date: Thu, 9 Mar 2017 16:18:20 +0100
4 Subject: mmc: sdhci-of-at91: Support external regulators
5
6 From: Romain Izard <romain.izard.pro@gmail.com>
7
8 commit 2ce0c7b65505e0d915e99389cced45b478dc935d upstream.
9
10 The SDHCI controller in the SAMA5D2 chip requires a valid voltage set
11 in the power control register, otherwise commands will fail with a
12 timeout error.
13
14 When using the regulator framework to specify the regulator used by the
15 mmc device, the voltage is not configured, and it is not possible to use
16 the connected device.
17
18 Implement a custom 'set_power' function for this specific hardware, that
19 configures the voltage in the register in all cases.
20
21 Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
22 Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
23 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 drivers/mmc/host/sdhci-of-at91.c | 19 +++++++++++++++++++
28 1 file changed, 19 insertions(+)
29
30 --- a/drivers/mmc/host/sdhci-of-at91.c
31 +++ b/drivers/mmc/host/sdhci-of-at91.c
32 @@ -85,11 +85,30 @@ static void sdhci_at91_set_clock(struct
33 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
34 }
35
36 +/*
37 + * In this specific implementation of the SDHCI controller, the power register
38 + * needs to have a valid voltage set even when the power supply is managed by
39 + * an external regulator.
40 + */
41 +static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
42 + unsigned short vdd)
43 +{
44 + if (!IS_ERR(host->mmc->supply.vmmc)) {
45 + struct mmc_host *mmc = host->mmc;
46 +
47 + spin_unlock_irq(&host->lock);
48 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
49 + spin_lock_irq(&host->lock);
50 + }
51 + sdhci_set_power_noreg(host, mode, vdd);
52 +}
53 +
54 static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
55 .set_clock = sdhci_at91_set_clock,
56 .set_bus_width = sdhci_set_bus_width,
57 .reset = sdhci_reset,
58 .set_uhs_signaling = sdhci_set_uhs_signaling,
59 + .set_power = sdhci_at91_set_power,
60 };
61
62 static const struct sdhci_pltfm_data soc_data_sama5d2 = {