All of lore.kernel.org
 help / color / mirror / Atom feed
From: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
To: adrian.hunter@intel.com, ulf.hansson@linaro.org,
	bjorn.andersson@linaro.org, robh+dt@kernel.org
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	Vijay Viswanath <vviswana@codeaurora.org>,
	Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
Subject: [PATCH V3 2/3] mmc: sdhci: Allow platform controlled voltage switching
Date: Tue,  2 Jun 2020 16:17:55 +0530	[thread overview]
Message-ID: <1591094883-11674-3-git-send-email-vbadigan@codeaurora.org> (raw)
In-Reply-To: <1591094883-11674-1-git-send-email-vbadigan@codeaurora.org>

From: Vijay Viswanath <vviswana@codeaurora.org>

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>
---
 drivers/mmc/host/sdhci.c | 32 +++++++++++++++++++-------------
 drivers/mmc/host/sdhci.h |  1 +
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 37b1158c1c0c..e6275c2202b0 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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)
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0008bbd27127..0770c036e2ff 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -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;
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


  parent reply	other threads:[~2020-06-02 10:50 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 11:18 [PATCH V1 0/3] Internal voltage control for qcom SDHC Veerabhadrarao Badiganti
2020-05-15 11:18 ` [PATCH V1 1/3] dt-bindings: mmc: Supply max load for mmc supplies Veerabhadrarao Badiganti
2020-05-15 11:18 ` [PATCH V1 2/3] mmc: sdhci-msm: Use internal voltage control Veerabhadrarao Badiganti
2020-05-18 19:57   ` Bjorn Andersson
2020-05-19  3:11     ` Bjorn Andersson
2020-05-20 11:16     ` Veerabhadrarao Badiganti
2020-05-21 18:21       ` Bjorn Andersson
2020-05-15 11:18 ` [PATCH V1 3/3] mmc: sdhci: Allow platform controlled voltage switching Veerabhadrarao Badiganti
2020-05-19  6:06   ` Adrian Hunter
2020-05-20 11:19     ` Veerabhadrarao Badiganti
2020-05-21 15:23 ` [PATCH V2 0/3] Internal voltage control for qcom SDHC Veerabhadrarao Badiganti
2020-05-21 15:23   ` [PATCH V2 1/3] dt-bindings: mmc: Supply max load for mmc supplies Veerabhadrarao Badiganti
2020-05-28 23:23     ` Rob Herring
2020-05-21 15:23   ` [PATCH V2 2/3] mmc: sdhci-msm: Use internal voltage control Veerabhadrarao Badiganti
2020-05-21 19:07     ` Bjorn Andersson
2020-05-22 13:27       ` Veerabhadrarao Badiganti
2020-05-22 17:04         ` Bjorn Andersson
2020-05-28  7:13           ` Veerabhadrarao Badiganti
2020-05-21 15:23   ` [PATCH V2 3/3] mmc: sdhci: Allow platform controlled voltage switching Veerabhadrarao Badiganti
2020-05-25  5:42     ` Adrian Hunter
2020-06-02 10:47 ` [PATCH V3 0/3] Internal voltage control for qcom SDHC Veerabhadrarao Badiganti
2020-06-02 10:47   ` [PATCH V3 1/3] dt-bindings: mmc: Supply max load for mmc supplies Veerabhadrarao Badiganti
2020-06-09 23:02     ` Rob Herring
2020-06-10 10:00       ` Mark Brown
2020-06-02 10:47   ` Veerabhadrarao Badiganti [this message]
2020-06-02 10:47   ` [PATCH V3 3/3] mmc: sdhci-msm: Use internal voltage control Veerabhadrarao Badiganti
2020-06-09  3:34     ` Veerabhadrarao Badiganti
2020-06-16 15:36 ` [PATCH V4 0/2] Internal voltage control for qcom SDHC Veerabhadrarao Badiganti
2020-06-16 15:36   ` [PATCH V4 1/2] mmc: sdhci: Allow platform controlled voltage switching Veerabhadrarao Badiganti
2020-06-16 15:36   ` [PATCH V4 2/2] mmc: sdhci-msm: Use internal voltage control Veerabhadrarao Badiganti
2020-06-17  9:34     ` Ulf Hansson
2020-06-17 12:45       ` Veerabhadrarao Badiganti
2020-06-17 14:16         ` Ulf Hansson
2020-06-18  6:30           ` Veerabhadrarao Badiganti
2020-06-23 13:34 ` [PATCH V5 0/3] Internal voltage control for qcom SDHC Veerabhadrarao Badiganti
2020-06-23 13:34   ` [PATCH V5 1/3] mmc: sdhci: Allow platform controlled voltage switching Veerabhadrarao Badiganti
2020-06-23 13:34   ` [PATCH V5 2/3] mmc: core: Set default power mode in mmc_alloc_host Veerabhadrarao Badiganti
2020-06-23 13:34   ` [PATCH V5 3/3] mmc: sdhci-msm: Use internal voltage control Veerabhadrarao Badiganti
2020-07-06 14:49   ` [PATCH V5 0/3] Internal voltage control for qcom SDHC Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1591094883-11674-3-git-send-email-vbadigan@codeaurora.org \
    --to=vbadigan@codeaurora.org \
    --cc=adrian.hunter@intel.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vviswana@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.