Skip to content

Commit 0fcb031

Browse files
Vijay ViswanathUlf Hansson
authored andcommitted
mmc: sdhci: Allow platform controlled voltage switching
If vendor platform drivers are controlling whole logic of voltage switching, then sdhci driver no need control vqmmc regulator. So skip enabling/disable vqmmc from SDHC driver. Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/1592919288-1020-2-git-send-email-vbadigan@codeaurora.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent b343a09 commit 0fcb031

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎drivers/mmc/host/sdhci.c‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,6 +4105,7 @@ int sdhci_setup_host(struct sdhci_host *host)
41054105
unsigned int override_timeout_clk;
41064106
u32 max_clk;
41074107
int ret;
4108+
bool enable_vqmmc = false;
41084109

41094110
WARN_ON(host == NULL);
41104111
if (host == NULL)
@@ -4118,9 +4119,12 @@ int sdhci_setup_host(struct sdhci_host *host)
41184119
* the host can take the appropriate action if regulators are not
41194120
* available.
41204121
*/
4121-
ret = mmc_regulator_get_supply(mmc);
4122-
if (ret)
4123-
return ret;
4122+
if (!mmc->supply.vqmmc) {
4123+
ret = mmc_regulator_get_supply(mmc);
4124+
if (ret)
4125+
return ret;
4126+
enable_vqmmc = true;
4127+
}
41244128

41254129
DBG("Version: 0x%08x | Present: 0x%08x\n",
41264130
sdhci_readw(host, SDHCI_HOST_VERSION),
@@ -4377,7 +4381,15 @@ int sdhci_setup_host(struct sdhci_host *host)
43774381
mmc->caps |= MMC_CAP_NEEDS_POLL;
43784382

43794383
if (!IS_ERR(mmc->supply.vqmmc)) {
4380-
ret = regulator_enable(mmc->supply.vqmmc);
4384+
if (enable_vqmmc) {
4385+
ret = regulator_enable(mmc->supply.vqmmc);
4386+
if (ret) {
4387+
pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
4388+
mmc_hostname(mmc), ret);
4389+
mmc->supply.vqmmc = ERR_PTR(-EINVAL);
4390+
}
4391+
host->sdhci_core_to_disable_vqmmc = !ret;
4392+
}
43814393

43824394
/* If vqmmc provides no 1.8V signalling, then there's no UHS */
43834395
if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 1700000,
@@ -4390,12 +4402,6 @@ int sdhci_setup_host(struct sdhci_host *host)
43904402
if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 2700000,
43914403
3600000))
43924404
host->flags &= ~SDHCI_SIGNALING_330;
4393-
4394-
if (ret) {
4395-
pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
4396-
mmc_hostname(mmc), ret);
4397-
mmc->supply.vqmmc = ERR_PTR(-EINVAL);
4398-
}
43994405
}
44004406

44014407
if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
@@ -4626,7 +4632,7 @@ int sdhci_setup_host(struct sdhci_host *host)
46264632
return 0;
46274633

46284634
unreg:
4629-
if (!IS_ERR(mmc->supply.vqmmc))
4635+
if (host->sdhci_core_to_disable_vqmmc)
46304636
regulator_disable(mmc->supply.vqmmc);
46314637
undma:
46324638
if (host->align_buffer)
@@ -4644,7 +4650,7 @@ void sdhci_cleanup_host(struct sdhci_host *host)
46444650
{
46454651
struct mmc_host *mmc = host->mmc;
46464652

4647-
if (!IS_ERR(mmc->supply.vqmmc))
4653+
if (host->sdhci_core_to_disable_vqmmc)
46484654
regulator_disable(mmc->supply.vqmmc);
46494655

46504656
if (host->align_buffer)
@@ -4787,7 +4793,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
47874793

47884794
destroy_workqueue(host->complete_wq);
47894795

4790-
if (!IS_ERR(mmc->supply.vqmmc))
4796+
if (host->sdhci_core_to_disable_vqmmc)
47914797
regulator_disable(mmc->supply.vqmmc);
47924798

47934799
if (host->align_buffer)

‎drivers/mmc/host/sdhci.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ struct sdhci_host {
567567
u32 caps1; /* CAPABILITY_1 */
568568
bool read_caps; /* Capability flags have been read */
569569

570+
bool sdhci_core_to_disable_vqmmc; /* sdhci core can disable vqmmc */
570571
unsigned int ocr_avail_sdio; /* OCR bit masks */
571572
unsigned int ocr_avail_sd;
572573
unsigned int ocr_avail_mmc;

0 commit comments

Comments
 (0)