Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp705711imm; Wed, 25 Jul 2018 04:56:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdsswMJ/kMPe7MxndZBi8UmyIG2VUu6d1GLRHq1roXTJDfg3nZM/gWW1GqPqkNSU/mP8EgY X-Received: by 2002:a17:902:8210:: with SMTP id x16-v6mr20751100pln.307.1532519811989; Wed, 25 Jul 2018 04:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532519811; cv=none; d=google.com; s=arc-20160816; b=ZSNDrMydehABG6FaZVQkyucLhIYjDsOv6vKv3TBrMr31PibEfadL+sRh0wHCPBu0ya XwInSh2JiLSsJ+9YIlQgZbIb2E3DWQGRgxJ1TERnq3MevL35hxIjw937HYWgH+shq9B0 KCIIMv4njtfKN0P1Z5/Y2LxVzEX/BX/D0xPQMbupgNv0dLmyVdlINLJHiLGO+JCkb6/h gZTu1XKstbKzF1+pnmiIYLb2GLOVW+VgwF87z3fSNjaEKK/DgSlV/AQY/h58lWxzeeke cY8mE+Un3/YKiv2I1+iimJvuhhmSuRpMCpPLNfKdQiw7WK0oMV+q76iDQegHDgHbHaMr pYzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=OzzFGrnoI7Sgm4AOl0W++rrhIuY2PckwF/7aUXhmDpM=; b=dF3IgWb0AczY1dUzZd5+ZzY6f2xyIcEn4hTe/ejD3H33UyvwfUC8Yqar3FcGvBJUAj iE51OSp95Nl5uNzochBZvQ2RV8AVd+gpisOGCqGV/GkbgOsPsKTIxeZrJgDg5SP04+Yp I1hM2/dGcKCSYqi/+Wd2ozU2U9X6OdM1b40uQ9i2brA4dZcAw7alUEFDZcrGco0L8nzR jWB606fu4MvXys/lknz9RnnnbxMnA5itzuLdr+GA41CsyPoy0rgbmjEXhgag1wbGtIoU 9nKP2x+tc+CgYiVG/BNToGYkn706jPgBqCUCdIRLvB62JH+ZpN/d5QEJ8a/ybeLjehvf icug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u123-v6si14335075pgb.414.2018.07.25.04.56.36; Wed, 25 Jul 2018 04:56:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbeGYNHI (ORCPT + 99 others); Wed, 25 Jul 2018 09:07:08 -0400 Received: from mga03.intel.com ([134.134.136.65]:12651 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728390AbeGYNHI (ORCPT ); Wed, 25 Jul 2018 09:07:08 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 04:55:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="57760364" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by fmsmga008.fm.intel.com with ESMTP; 25 Jul 2018 04:55:38 -0700 Subject: Re: [PATCH V1 1/3] mmc: sdhci: Allow platform controlled voltage switching To: Vijay Viswanath , 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 References: <1532083566-43215-1-git-send-email-vviswana@codeaurora.org> <1532083566-43215-2-git-send-email-vviswana@codeaurora.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <33e12e51-4b96-032f-845f-7910d654018c@intel.com> Date: Wed, 25 Jul 2018 14:53:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: <1532083566-43215-2-git-send-email-vviswana@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > 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) >