Skip to content

Commit 5222161

Browse files
Tim Krygerstorulf
authored andcommitted
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. Signed-off-by: Tim Kryger <tim.kryger@gmail.com> Tested-by: Sachin Kamat <spk.linux@gmail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 87a0f46 commit 5222161

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,13 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
12261226
struct mmc_host *mmc = host->mmc;
12271227
u8 pwr = 0;
12281228

1229+
if (!IS_ERR(mmc->supply.vmmc)) {
1230+
spin_unlock_irq(&host->lock);
1231+
mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
1232+
spin_lock_irq(&host->lock);
1233+
return;
1234+
}
1235+
12291236
if (mode != MMC_POWER_OFF) {
12301237
switch (1 << vdd) {
12311238
case MMC_VDD_165_195:
@@ -1284,12 +1291,6 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
12841291
if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER)
12851292
mdelay(10);
12861293
}
1287-
1288-
if (!IS_ERR(mmc->supply.vmmc)) {
1289-
spin_unlock_irq(&host->lock);
1290-
mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
1291-
spin_lock_irq(&host->lock);
1292-
}
12931294
}
12941295

12951296
/*****************************************************************************\
@@ -3092,8 +3093,9 @@ int sdhci_add_host(struct sdhci_host *host)
30923093
SDHCI_MAX_CURRENT_MULTIPLIER;
30933094
}
30943095

3096+
/* If OCR set by external regulators, use it instead */
30953097
if (mmc->ocr_avail)
3096-
ocr_avail &= mmc->ocr_avail;
3098+
ocr_avail = mmc->ocr_avail;
30973099

30983100
if (host->ocr_mask)
30993101
ocr_avail &= host->ocr_mask;

0 commit comments

Comments
 (0)