From: Philip Rakity <[email protected]>

If we are using a regulator the SD Host Controller and the
regulator should agree about the voltages supported.  Use
the common subset that is supported.

Signed-off-by: Philip Rakity <[email protected]>
---
 drivers/mmc/host/sdhci.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 248f68b..78be427 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2894,6 +2894,21 @@ int sdhci_add_host(struct sdhci_host *host)
         * register is set. The actual current value is 4 times the register
         * value.
         */
+       if (host->vmmc) {
+               ret = regulator_is_supported_voltage(host->vmmc, 3300000,
+                       3300000);
+               if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_330)))
+                       caps[0] &= ~SDHCI_CAN_VDD_330;
+               ret = regulator_is_supported_voltage(host->vmmc, 3000000,
+                       3000000);
+               if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_300)))
+                       caps[0] &= ~SDHCI_CAN_VDD_300;
+               ret = regulator_is_supported_voltage(host->vmmc, 1800000,
+                       1800000);
+               if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_180)))
+                       caps[0] &= ~SDHCI_CAN_VDD_180;
+       }
+
        max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT);
        if (!max_current_caps && host->vmmc) {
                u32 curr = regulator_get_current_limit(host->vmmc);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to