Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1193357ybg; Tue, 2 Jun 2020 03:52:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb57lzRDJNkHkG+YMVmWlqoFJZBFQOOj9okcRh9jTAO0Xxux3kSgYaVFfXOBnM5+IQla75 X-Received: by 2002:a05:6402:1a48:: with SMTP id bf8mr26468315edb.133.1591095152257; Tue, 02 Jun 2020 03:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591095152; cv=none; d=google.com; s=arc-20160816; b=LIqavntAI13WHfE/XKLmoLI6CPHmUOeAO1Pw3vRFAlyP3hmtMx137XtGWbGVRSzQw0 VbDTsjR/8kTShb4ns/MoLBpB0xTESJFzTfA20eS6UVBE35kKE4ChbuhAVWEf/Q5dHSM2 E8RvLD+yXCZK0XfNPJjm/wC2Mk+deUAao5ky4gFZmt3UpJzogcbr6Snzo/FOZdIKiGbQ Ye4t1OooezP0GqE9y4F4GJ74MswzP5pd4MG7zGsTo5TkCP84BHKVu6KZQ6BmGbFvos04 /T7/pwiw/JVt8W4MLls1zVqRa1HtDvtX97UpOd6g8207snKA41XwcaV4xE2DXPx+p0rh TdXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=yEWV89sH7GhkGwXnh3f0+FyvuHm5cUh1s4CNEpM1YpA=; b=G2mRJyfPWqnTHbnoSFcS6zx4XLiy1Im+rdl56lwXeFdMfny6K0Tsp4BIUB3tgzB/Zd W9Lw/xTA7sriE8cwOddBfNyu3v7NyD9Xqybccit+4fWUMoT+koiLv84dZ4i4ShaCPE95 txcLdsHqae7+uDd6ZUM4v1c/MOU17p5GG0Dc2gry4uJdPBpXa5uL/wy1putfeJJT7BAB 7Tp+dvgyyPZuEvIsy7SUfU4E3ZaSweu1UmTD8/D5RZwPtGvA4C94PfIxl1C39Acl45Ql rtwSzo1kU3iiwJD5R0MFhekoEb6EjP7khHnNzXokAq+pr1vQXQtRbGHiHvTOVt2xXZRl eh6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si1258096edq.605.2020.06.02.03.52.09; Tue, 02 Jun 2020 03:52:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726848AbgFBKu1 (ORCPT + 99 others); Tue, 2 Jun 2020 06:50:27 -0400 Received: from alexa-out-blr-02.qualcomm.com ([103.229.18.198]:57579 "EHLO alexa-out-blr-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726606AbgFBKu0 (ORCPT ); Tue, 2 Jun 2020 06:50:26 -0400 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by alexa-out-blr-02.qualcomm.com with ESMTP/TLS/AES256-SHA; 02 Jun 2020 16:20:20 +0530 Received: from vbadigan-linux.qualcomm.com ([10.206.24.109]) by ironmsg01-blr.qualcomm.com with ESMTP; 02 Jun 2020 16:20:13 +0530 Received: by vbadigan-linux.qualcomm.com (Postfix, from userid 76677) id 210404BF9; Tue, 2 Jun 2020 16:20:13 +0530 (IST) From: Veerabhadrarao Badiganti 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 , Veerabhadrarao Badiganti Subject: [PATCH V3 2/3] mmc: sdhci: Allow platform controlled voltage switching Date: Tue, 2 Jun 2020 16:17:55 +0530 Message-Id: <1591094883-11674-3-git-send-email-vbadigan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1591094883-11674-1-git-send-email-vbadigan@codeaurora.org> References: <1589541535-8523-1-git-send-email-vbadigan@codeaurora.org> <1591094883-11674-1-git-send-email-vbadigan@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vijay Viswanath 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 Signed-off-by: Veerabhadrarao Badiganti Acked-by: Adrian Hunter --- 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