]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mmc: sdhci: Allow platform controlled voltage switching
authorVijay Viswanath <vviswana@codeaurora.org>
Tue, 23 Jun 2020 13:34:46 +0000 (19:04 +0530)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 13 Jul 2020 10:18:24 +0000 (12:18 +0200)
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>
drivers/mmc/host/sdhci.c
drivers/mmc/host/sdhci.h

index 37b1158c1c0c9427d272b45a24c4049de5ff702e..e6275c2202b0d2287f4a496ee3cbcc71ab1a4881 100644 (file)
@@ -4105,6 +4105,7 @@ int sdhci_setup_host(struct sdhci_host *host)
        unsigned int override_timeout_clk;
        u32 max_clk;
        int ret;
+       bool enable_vqmmc = false;
 
        WARN_ON(host == NULL);
        if (host == NULL)
@@ -4118,9 +4119,12 @@ int sdhci_setup_host(struct sdhci_host *host)
         * the host can take the appropriate action if regulators are not
         * available.
         */
-       ret = mmc_regulator_get_supply(mmc);
-       if (ret)
-               return ret;
+       if (!mmc->supply.vqmmc) {
+               ret = mmc_regulator_get_supply(mmc);
+               if (ret)
+                       return ret;
+               enable_vqmmc  = true;
+       }
 
        DBG("Version:   0x%08x | Present:  0x%08x\n",
            sdhci_readw(host, SDHCI_HOST_VERSION),
@@ -4377,7 +4381,15 @@ int sdhci_setup_host(struct sdhci_host *host)
                mmc->caps |= MMC_CAP_NEEDS_POLL;
 
        if (!IS_ERR(mmc->supply.vqmmc)) {
-               ret = regulator_enable(mmc->supply.vqmmc);
+               if (enable_vqmmc) {
+                       ret = regulator_enable(mmc->supply.vqmmc);
+                       if (ret) {
+                               pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
+                                       mmc_hostname(mmc), ret);
+                               mmc->supply.vqmmc = ERR_PTR(-EINVAL);
+                       }
+                       host->sdhci_core_to_disable_vqmmc = !ret;
+               }
 
                /* If vqmmc provides no 1.8V signalling, then there's no UHS */
                if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 1700000,
@@ -4390,12 +4402,6 @@ int sdhci_setup_host(struct sdhci_host *host)
                if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 2700000,
                                                    3600000))
                        host->flags &= ~SDHCI_SIGNALING_330;
-
-               if (ret) {
-                       pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
-                               mmc_hostname(mmc), ret);
-                       mmc->supply.vqmmc = ERR_PTR(-EINVAL);
-               }
        }
 
        if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
@@ -4626,7 +4632,7 @@ int sdhci_setup_host(struct sdhci_host *host)
        return 0;
 
 unreg:
-       if (!IS_ERR(mmc->supply.vqmmc))
+       if (host->sdhci_core_to_disable_vqmmc)
                regulator_disable(mmc->supply.vqmmc);
 undma:
        if (host->align_buffer)
@@ -4644,7 +4650,7 @@ void sdhci_cleanup_host(struct sdhci_host *host)
 {
        struct mmc_host *mmc = host->mmc;
 
-       if (!IS_ERR(mmc->supply.vqmmc))
+       if (host->sdhci_core_to_disable_vqmmc)
                regulator_disable(mmc->supply.vqmmc);
 
        if (host->align_buffer)
@@ -4787,7 +4793,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 
        destroy_workqueue(host->complete_wq);
 
-       if (!IS_ERR(mmc->supply.vqmmc))
+       if (host->sdhci_core_to_disable_vqmmc)
                regulator_disable(mmc->supply.vqmmc);
 
        if (host->align_buffer)
index 0008bbd27127336b233b96f8591d253b8268d619..0770c036e2ff5d75dbfbd757cd5bc3876e8ce1c0 100644 (file)
@@ -567,6 +567,7 @@ struct sdhci_host {
        u32 caps1;              /* CAPABILITY_1 */
        bool read_caps;         /* Capability flags have been read */
 
+       bool sdhci_core_to_disable_vqmmc;  /* sdhci core can disable vqmmc */
        unsigned int            ocr_avail_sdio; /* OCR bit masks */
        unsigned int            ocr_avail_sd;
        unsigned int            ocr_avail_mmc;