Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2717980imm; Fri, 20 Jul 2018 03:48:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeWjXcODhF87ggLWvcRYJZ5Jl49nawmkCOy/9hZ+OOSahIRaB9j60YwPgqHkJfxskcjg5Sl X-Received: by 2002:a17:902:aa8f:: with SMTP id d15-v6mr1651666plr.64.1532083684515; Fri, 20 Jul 2018 03:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532083684; cv=none; d=google.com; s=arc-20160816; b=srGalPVEj7qC/vawW5prhLTxiawX57dS4AtAtcjHqnOlUQ0xwLQywpwi3VUPklYPpf lNy8ciQ4dmZxv93q09439dLhxSo7p8joBFUpHQDcLyzuM8vFXnnxzm7/cHlp5N53mhAU 7Xqu2q/2CcfmkH44jiVaRQY5jOZOk/mvdkSBN4hY25xQMpyrahDmdCdYFMar0+42SEXI KetFxVuz30Sg+7pg/GYIh1pU+XyKRRniFEwjwQ2VdINDcWh34FNL4DEviZpdarIDORzY bx9iPR0aHX1YtHo5QMpIDJ98VcB/KsDzspARtMn/4L4WTtSG18SIBtf3K2wBrwsUdHJ+ gqDg== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=ODPRCSv1Xn0Xdfo5ou4chR2QPO1vMF4XBwwyXbYeGlk=; b=zt2v4qQ6WQrf30tkk+mMVc+XEIrBHfRf04F04ZG1xjTmHRHsUyfI8sk5lqAioJ0ZIA 8r9ZPMO6bbDrkgGlpwTMXTt8xPKYN6nHzGRjmAPnEUUiM/N7Hhx3RMVpdnE+fliOXRAX p9IeYfgwM6ZWXcHqmY02Ihc3T+PxdM/Auy/dFMbjn4XQFqxjBPFACqz/pWmMXb2YrsNr +DaRG6k1iN87teiFsutvnQB8GSAHbwFdmXU85U0aQ6JymuWpzSMYzBAfU8h8YsK32RRg zqb+tisODS2DhcQdjpj4PfKIzyTYeFAoTGHUCSTqhZh/piO6CHxtH1O6z1b+doghuARj aDQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=PFCq8P2U; dkim=pass header.i=@codeaurora.org header.s=default header.b=PFCq8P2U; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si1750462pgx.310.2018.07.20.03.47.50; Fri, 20 Jul 2018 03:48:04 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=PFCq8P2U; dkim=pass header.i=@codeaurora.org header.s=default header.b=PFCq8P2U; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729816AbeGTLeK (ORCPT + 99 others); Fri, 20 Jul 2018 07:34:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49646 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727233AbeGTLeJ (ORCPT ); Fri, 20 Jul 2018 07:34:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 91C5C60452; Fri, 20 Jul 2018 10:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532083589; bh=i0dHwrywsGlepkwBzxXQ5WOwcSMGz2tAahBjD6is1so=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PFCq8P2UGXc+isa0lIuf7EDVawEqdaSKGwZ9GKvtCFrlxmsYt07m8SSnTwka51mbB bIpV8mjsNDL9o32Il6z92g8VapW+mkka6CGHD9J6qVXMLBJoRjBB5/Pb+b0MnXM2Su sp4f7s7Vuhl2aKglychKcDoTRUnmLoRrESjTFSMM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from hydcbspbld03.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vviswana@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4DB96606AC; Fri, 20 Jul 2018 10:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532083589; bh=i0dHwrywsGlepkwBzxXQ5WOwcSMGz2tAahBjD6is1so=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PFCq8P2UGXc+isa0lIuf7EDVawEqdaSKGwZ9GKvtCFrlxmsYt07m8SSnTwka51mbB bIpV8mjsNDL9o32Il6z92g8VapW+mkka6CGHD9J6qVXMLBJoRjBB5/Pb+b0MnXM2Su sp4f7s7Vuhl2aKglychKcDoTRUnmLoRrESjTFSMM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4DB96606AC Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vviswana@codeaurora.org From: Vijay Viswanath To: adrian.hunter@intel.com, 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, vviswana@codeaurora.org, bjorn.andersson@linaro.org, riteshh@codeaurora.org, vbadigan@codeaurora.org, evgreen@chromium.org, dianders@google.com, sayalil@codeaurora.org Subject: [PATCH V1 1/3] mmc: sdhci: Allow platform controlled voltage switching Date: Fri, 20 Jul 2018 16:16:04 +0530 Message-Id: <1532083566-43215-2-git-send-email-vviswana@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532083566-43215-1-git-send-email-vviswana@codeaurora.org> References: <1532083566-43215-1-git-send-email-vviswana@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; @@ -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); + 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) 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)) 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)) regulator_disable(mmc->supply.vqmmc); if (host->align_buffer) -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.