Skip to content

Commit 20a0c37

Browse files
yuanjieyang-qualcommstorulf
authored andcommitted
mmc: sdhci-msm: Correctly set the load for the regulator
Qualcomm regulator supports two power supply modes: HPM and LPM. Currently, the sdhci-msm.c driver does not set the load to adjust the current for eMMC and SD. If the regulator dont't set correct load in LPM state, it will lead to the inability to properly initialize eMMC and SD. Set the correct regulator current for eMMC and SD to ensure that the device can work normally even when the regulator is in LPM. Signed-off-by: Yuanjie Yang <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 1931cd7 commit 20a0c37

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

drivers/mmc/host/sdhci-msm.c

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,18 @@
134134
/* Timeout value to avoid infinite waiting for pwr_irq */
135135
#define MSM_PWR_IRQ_TIMEOUT_MS 5000
136136

137+
/* Max load for eMMC Vdd supply */
138+
#define MMC_VMMC_MAX_LOAD_UA 570000
139+
137140
/* Max load for eMMC Vdd-io supply */
138141
#define MMC_VQMMC_MAX_LOAD_UA 325000
139142

143+
/* Max load for SD Vdd supply */
144+
#define SD_VMMC_MAX_LOAD_UA 800000
145+
146+
/* Max load for SD Vdd-io supply */
147+
#define SD_VQMMC_MAX_LOAD_UA 22000
148+
140149
#define msm_host_readl(msm_host, host, offset) \
141150
msm_host->var_ops->msm_readl_relaxed(host, offset)
142151

@@ -1403,11 +1412,48 @@ static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
14031412
return ret;
14041413
}
14051414

1406-
static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
1415+
static void msm_config_vmmc_regulator(struct mmc_host *mmc, bool hpm)
1416+
{
1417+
int load;
1418+
1419+
if (!hpm)
1420+
load = 0;
1421+
else if (!mmc->card)
1422+
load = max(MMC_VMMC_MAX_LOAD_UA, SD_VMMC_MAX_LOAD_UA);
1423+
else if (mmc_card_mmc(mmc->card))
1424+
load = MMC_VMMC_MAX_LOAD_UA;
1425+
else if (mmc_card_sd(mmc->card))
1426+
load = SD_VMMC_MAX_LOAD_UA;
1427+
else
1428+
return;
1429+
1430+
regulator_set_load(mmc->supply.vmmc, load);
1431+
}
1432+
1433+
static void msm_config_vqmmc_regulator(struct mmc_host *mmc, bool hpm)
1434+
{
1435+
int load;
1436+
1437+
if (!hpm)
1438+
load = 0;
1439+
else if (!mmc->card)
1440+
load = max(MMC_VQMMC_MAX_LOAD_UA, SD_VQMMC_MAX_LOAD_UA);
1441+
else if (mmc_card_sd(mmc->card))
1442+
load = SD_VQMMC_MAX_LOAD_UA;
1443+
else
1444+
return;
1445+
1446+
regulator_set_load(mmc->supply.vqmmc, load);
1447+
}
1448+
1449+
static int sdhci_msm_set_vmmc(struct sdhci_msm_host *msm_host,
1450+
struct mmc_host *mmc, bool hpm)
14071451
{
14081452
if (IS_ERR(mmc->supply.vmmc))
14091453
return 0;
14101454

1455+
msm_config_vmmc_regulator(mmc, hpm);
1456+
14111457
return mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, mmc->ios.vdd);
14121458
}
14131459

@@ -1420,6 +1466,8 @@ static int msm_toggle_vqmmc(struct sdhci_msm_host *msm_host,
14201466
if (msm_host->vqmmc_enabled == level)
14211467
return 0;
14221468

1469+
msm_config_vqmmc_regulator(mmc, level);
1470+
14231471
if (level) {
14241472
/* Set the IO voltage regulator to default voltage level */
14251473
if (msm_host->caps_0 & CORE_3_0V_SUPPORT)
@@ -1642,7 +1690,8 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
16421690
}
16431691

16441692
if (pwr_state) {
1645-
ret = sdhci_msm_set_vmmc(mmc);
1693+
ret = sdhci_msm_set_vmmc(msm_host, mmc,
1694+
pwr_state & REQ_BUS_ON);
16461695
if (!ret)
16471696
ret = sdhci_msm_set_vqmmc(msm_host, mmc,
16481697
pwr_state & REQ_BUS_ON);

0 commit comments

Comments
 (0)