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
6 From: Romain Izard <romain.izard.pro@gmail.com>
8 commit 2ce0c7b65505e0d915e99389cced45b478dc935d upstream.
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
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
18 Implement a custom 'set_power' function for this specific hardware, that
19 configures the voltage in the register in all cases.
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>
27 drivers/mmc/host/sdhci-of-at91.c | 19 +++++++++++++++++++
28 1 file changed, 19 insertions(+)
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);
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.
41 +static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
44 + if (!IS_ERR(host->mmc->supply.vmmc)) {
45 + struct mmc_host *mmc = host->mmc;
47 + spin_unlock_irq(&host->lock);
48 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
49 + spin_lock_irq(&host->lock);
51 + sdhci_set_power_noreg(host, mode, vdd);
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,
58 .set_uhs_signaling = sdhci_set_uhs_signaling,
59 + .set_power = sdhci_at91_set_power,
62 static const struct sdhci_pltfm_data soc_data_sama5d2 = {