Skip to contentSkip to conversation

mmc: sdhci: Improve external VDD regulator support

PATCH Applied Tim Kryger 2 participants 2 messages Jun 25, 2014

Subsystems (2)
lore
Share & tools
lore

Tim Kryger

author
#0 lore raw

PATCH 1/1 mmc: sdhci: Improve external VDD regulator support

A standard compliant SDHCI can itself supply VDD at 1.8, 3.0, or 3.3v. Several vendors ignore this and instead rely upon external regulators to supply VDD. While the external regulators typically can supply one of the standard SDHCI voltage levels, there is no real reason for this to be a hard requirement.

This patch alters the SDHCI driver such that external VDD regulators that provide voltages other than the three mentioned above may be used so long as they can supply a voltage that meets the needs of the card.

In the case that an external VDD regulator is provided, it is reasonable to ignore the voltage capabilities of the host controller and allow the external regulator to set the OCR mask. Additionally, there is no need to convert a VDD voltage request into one of the standard SDHCI voltage levels or program it in the host controller's power control register.

---

This change corrects a regression observed on Exynos platforms that was triggered by "mmc: sdhci: Use mmc core regulator infrastucture"

https://www.mail-archive.com/[email protected]/msg27101.html

 drivers/mmc/host/sdhci.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +9 -7
index c23a872..07a2426 100644
@@ -1226,6 +1226,13 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
 	struct mmc_host *mmc = host->mmc;
 	u8 pwr = 0;
 
+	if (!IS_ERR(mmc->supply.vmmc)) {
+		spin_unlock_irq(&host->lock);
+		mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
+		spin_lock_irq(&host->lock);
+		return;
+	}
+
 	if (mode != MMC_POWER_OFF) {
 		switch (1 << vdd) {
 		case MMC_VDD_165_195:
@@ -1284,12 +1291,6 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
 		if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER)
 			mdelay(10);
 	}
-
-	if (!IS_ERR(mmc->supply.vmmc)) {
-		spin_unlock_irq(&host->lock);
-		mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
-		spin_lock_irq(&host->lock);
-	}
 }
 
 /*****************************************************************************\
@@ -3092,8 +3093,9 @@ int sdhci_add_host(struct sdhci_host *host)
 				   SDHCI_MAX_CURRENT_MULTIPLIER;
 	}
 
+	/* If OCR set by external regulators, use it instead */
 	if (mmc->ocr_avail)
-		ocr_avail &= mmc->ocr_avail;
+		ocr_avail = mmc->ocr_avail;
 
 	if (host->ocr_mask)
 		ocr_avail &= host->ocr_mask;
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 10 lines · Tim Kryger

A standard compliant SDHCI can itself supply VDD at 1.8, 3.0, or 3.3v. Several vendors ignore this and instead rely upon external regulators to supply VDD. While the external regulators typically can supply one of the standard SDHCI voltage levels, there is no real reason for this to be a hard requirement.

This patch alters the SDHCI driver such that external VDD regulators that provide voltages other than the three mentioned above may be used so long as they can supply a voltage that meets the needs of the card.

Quoted 8 lines

In the case that an external VDD regulator is provided, it is reasonable to ignore the voltage capabilities of the host controller and allow the external regulator to set the OCR mask. Additionally, there is no need to convert a VDD voltage request into one of the standard SDHCI voltage levels or program it in the host controller's power control register.

Thanks! Applied for next.

Kind regards
Uffe

Quoted 58 lines

---

This change corrects a regression observed on Exynos platforms that was triggered by "mmc: sdhci: Use mmc core regulator infrastucture"

https://www.mail-archive.com/[email protected]/msg27101.html

 drivers/mmc/host/sdhci.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +7 -0
index c23a872..07a2426 100644
@@ -1226,6 +1226,13 @@ static void sdhci_set_power(struct sdhci_host *host,
 unsigned char mode,
 	struct mmc_host *mmc = host->mmc;
 	u8 pwr = 0;
 
+	if (!IS_ERR(mmc->supply.vmmc)) {
+		spin_unlock_irq(&host->lock);
+		mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
+		spin_lock_irq(&host->lock);
+		return;
+	}
+
 	if (mode != MMC_POWER_OFF) {
 		switch (1 << vdd) {
drivers/mmc/host/sdhci.c +0 -6
 		case MMC_VDD_165_195:
@@ -1284,12 +1291,6 @@ static void sdhci_set_power(struct sdhci_host *host,
 unsigned char mode,
 		if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER)
 			mdelay(10);
 	}
-
-	if (!IS_ERR(mmc->supply.vmmc)) {
-		spin_unlock_irq(&host->lock);
-		mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
-		spin_lock_irq(&host->lock);
-	}
 }
 

/*****************************************************************************\

drivers/mmc/host/sdhci.c +2 -2
@@ -3092,8 +3093,9 @@ int sdhci_add_host(struct sdhci_host *host)
 				   SDHCI_MAX_CURRENT_MULTIPLIER;
 	}
 
+	/* If OCR set by external regulators, use it instead */
 	if (mmc->ocr_avail)
-		ocr_avail &= mmc->ocr_avail;
+		ocr_avail = mmc->ocr_avail;
 
 	if (host->ocr_mask)
 		ocr_avail &= host->ocr_mask;
--

1.7.9.5