From: Adrian Hunter <adrian.hunter@intel.com>
To: Vijay Viswanath <vviswana@codeaurora.org>,
ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
shawn.lin@rock-chips.com, linux-arm-msm@vger.kernel.org,
georgi.djakov@linaro.org, devicetree@vger.kernel.org,
asutoshd@codeaurora.org, stummala@codeaurora.org,
venkatg@codeaurora.org, jeremymc@redhat.com,
bjorn.andersson@linaro.org, riteshh@codeaurora.org,
vbadigan@codeaurora.org, evgreen@chromium.org,
dianders@google.com, sayalil@codeaurora.org
Subject: Re: [PATCH V1 1/3] mmc: sdhci: Allow platform controlled voltage switching
Date: Wed, 25 Jul 2018 14:53:59 +0300 [thread overview]
Message-ID: <33e12e51-4b96-032f-845f-7910d654018c@intel.com> (raw)
In-Reply-To: <1532083566-43215-2-git-send-email-vviswana@codeaurora.org>
On 20/07/18 13:46, Vijay Viswanath wrote:
> Some controllers can have internal mechanism to inform the SW that it
> is ready for voltage switching. For such controllers, changing voltage
> before the HW is ready can result in various issues.
>
> During setup/cleanup of host, check whether regulator enable/disable
> was already done by platform driver.
>
> Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org>
> ---
> drivers/mmc/host/sdhci.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 1c828e0..494a1e2 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3472,6 +3472,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)
> @@ -3485,7 +3486,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 (!mmc->supply.vmmc) {
> + ret = mmc_regulator_get_supply(mmc);
> + enable_vqmmc = true;
> + } else {
> + ret = 0;
> + }
> if (ret)
> return ret;
Why not
if (!mmc->supply.vmmc) {
ret = mmc_regulator_get_supply(mmc);
if (ret)
return ret;
enable_vqmmc = true;
}
>
> @@ -3736,7 +3742,10 @@ int sdhci_setup_host(struct sdhci_host *host)
>
> /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */
> if (!IS_ERR(mmc->supply.vqmmc)) {
> - ret = regulator_enable(mmc->supply.vqmmc);
> + if (enable_vqmmc)
> + ret = regulator_enable(mmc->supply.vqmmc);
Please introduce host->vqmmc_enabled = !ret;
> + else
> + ret = 0;
> if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 1700000,
> 1950000))
> host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |
> @@ -3984,7 +3993,7 @@ int sdhci_setup_host(struct sdhci_host *host)
> return 0;
>
> unreg:
> - if (!IS_ERR(mmc->supply.vqmmc))
> + if (!IS_ERR(mmc->supply.vqmmc) && enable_vqmmc)
And just make this
if (host->vqmmc_enabled)
> regulator_disable(mmc->supply.vqmmc);
> undma:
> if (host->align_buffer)
> @@ -4002,7 +4011,8 @@ void sdhci_cleanup_host(struct sdhci_host *host)
> {
> struct mmc_host *mmc = host->mmc;
>
> - if (!IS_ERR(mmc->supply.vqmmc))
> + if (!IS_ERR(mmc->supply.vqmmc) &&
> + (regulator_is_enabled(mmc->supply.vqmmc) > 0))
if (host->vqmmc_enabled)
> regulator_disable(mmc->supply.vqmmc);
>
> if (host->align_buffer)
> @@ -4135,7 +4145,8 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
>
> tasklet_kill(&host->finish_tasklet);
>
> - if (!IS_ERR(mmc->supply.vqmmc))
> + if (!IS_ERR(mmc->supply.vqmmc) &&
> + (regulator_is_enabled(mmc->supply.vqmmc) > 0))
if (host->vqmmc_enabled)
> regulator_disable(mmc->supply.vqmmc);
>
> if (host->align_buffer)
>
next prev parent reply other threads:[~2018-07-25 11:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-20 10:46 [PATCH V1 0/3] Internal voltage control for platform drivers Vijay Viswanath
2018-07-20 10:46 ` [PATCH V1 1/3] mmc: sdhci: Allow platform controlled voltage switching Vijay Viswanath
2018-07-25 11:53 ` Adrian Hunter [this message]
2018-07-25 12:23 ` Vijay Viswanath
2018-07-25 12:37 ` Adrian Hunter
2018-07-20 10:46 ` [PATCH V1 2/3] Documentation: sdhci-msm: Add entries for passing load values Vijay Viswanath
2018-07-25 17:55 ` Rob Herring
2018-07-20 10:46 ` [PATCH V1 3/3] mmc: sdhci-msm: Use internal voltage control Vijay Viswanath
2018-07-25 14:04 ` Adrian Hunter
2018-09-18 11:35 ` Veerabhadrarao Badiganti
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=33e12e51-4b96-032f-845f-7910d654018c@intel.com \
--to=adrian.hunter@intel.com \
--cc=asutoshd@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@google.com \
--cc=evgreen@chromium.org \
--cc=georgi.djakov@linaro.org \
--cc=jeremymc@redhat.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=riteshh@codeaurora.org \
--cc=robh+dt@kernel.org \
--cc=sayalil@codeaurora.org \
--cc=shawn.lin@rock-chips.com \
--cc=stummala@codeaurora.org \
--cc=ulf.hansson@linaro.org \
--cc=vbadigan@codeaurora.org \
--cc=venkatg@codeaurora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome