From patchwork Mon Feb 12 06:01:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Viswanath X-Patchwork-Id: 10211847 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 39752602CB for ; Mon, 12 Feb 2018 06:02:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C9D28917 for ; Mon, 12 Feb 2018 06:02:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D66728B4A; Mon, 12 Feb 2018 06:02:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21D128917 for ; Mon, 12 Feb 2018 06:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932861AbeBLGBj (ORCPT ); Mon, 12 Feb 2018 01:01:39 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35804 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932416AbeBLGBh (ORCPT ); Mon, 12 Feb 2018 01:01:37 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4418F60F76; Mon, 12 Feb 2018 06:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518415297; bh=ch2jMZJSwujLiyQRyvmtAyMROd1c6hpQy+orkwFC85g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FEBc8e71qIqaE5KzgcuFkUlXaq65VxJIgRo4VyUQf5kJmYPy2LOs3bpxHhCSPt4VA wdTjKTbdclHd2ruhlyJSlizPrcoMyysHx12CzEvX2s9aWNEsTBrRkrYynv/RiIUlM9 l6bGju3yZdAgyj9wPproC/OAIahaq3YKMXmtNtKY= 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 D971C60F6D; Mon, 12 Feb 2018 06:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518415296; bh=ch2jMZJSwujLiyQRyvmtAyMROd1c6hpQy+orkwFC85g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IDwZNsn1XowyoE0OnVUAM0NlKVxgI/oA3Q7Zla9E8nKuQcFmD7JBFcmY31FySFw5O M7TpVAFwInYlHj0YrtoLg8KFFuZGM3qznFrA1hVsjsNdG8UjwJZ+12XIKooRkUkPNB +7apjV1I5bJb1QMmy6PhCgurMx/crtkCcsUFcrS4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D971C60F6D 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 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, asutoshd@codeaurora.org, stummala@codeaurora.org, venkatg@codeaurora.org, pramod.gurav@linaro.org, jeremymc@redhat.com, vviswana@codeaurora.org Subject: [PATCH V2 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages Date: Mon, 12 Feb 2018 11:31:17 +0530 Message-Id: <1518415278-59062-2-git-send-email-vviswana@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1518415278-59062-1-git-send-email-vviswana@codeaurora.org> References: <1518415278-59062-1-git-send-email-vviswana@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During probe check whether the vdd-io regulator of sdhc platform device can support 1.8V and 3V and store this information as a capability of platform device. Signed-off-by: Vijay Viswanath --- drivers/mmc/host/sdhci-msm.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index c283291..5c23e92 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -23,6 +23,7 @@ #include #include "sdhci-pltfm.h" +#include #define CORE_MCI_VERSION 0x50 #define CORE_VERSION_MAJOR_SHIFT 28 @@ -81,6 +82,9 @@ #define CORE_HC_SELECT_IN_HS400 (6 << 19) #define CORE_HC_SELECT_IN_MASK (7 << 19) +#define CORE_3_0V_SUPPORT (1 << 25) +#define CORE_1_8V_SUPPORT (1 << 26) + #define CORE_CSR_CDC_CTLR_CFG0 0x130 #define CORE_SW_TRIG_FULL_CALIB BIT(16) #define CORE_HW_AUTOCAL_ENA BIT(17) @@ -148,6 +152,7 @@ struct sdhci_msm_host { u32 curr_io_level; wait_queue_head_t pwr_irq_wait; bool pwr_irq_flag; + u32 caps_0; }; static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host, @@ -1313,6 +1318,35 @@ static void sdhci_msm_writeb(struct sdhci_host *host, u8 val, int reg) sdhci_msm_check_power_status(host, req_type); } +static int sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host) +{ + struct mmc_host *mmc = msm_host->mmc; + struct regulator *supply = mmc->supply.vqmmc; + int i, count; + u32 caps = 0, vdd_uV; + + if (!IS_ERR(mmc->supply.vqmmc)) { + count = regulator_count_voltages(supply); + if (count < 0) + return count; + for (i = 0; i < count; i++) { + vdd_uV = regulator_list_voltage(supply, i); + if (vdd_uV <= 0) + continue; + if (vdd_uV > 2700000) + caps |= CORE_3_0V_SUPPORT; + if (vdd_uV < 1950000) + caps |= CORE_1_8V_SUPPORT; + } + } + msm_host->caps_0 |= caps; + pr_debug("%s: %s: supported caps: 0x%08x\n", mmc_hostname(mmc), + __func__, caps); + + return 0; +} + + static const struct of_device_id sdhci_msm_dt_match[] = { { .compatible = "qcom,sdhci-msm-v4" }, {}, @@ -1530,6 +1564,10 @@ static int sdhci_msm_probe(struct platform_device *pdev) ret = sdhci_add_host(host); if (ret) goto pm_runtime_disable; + ret = sdhci_msm_set_regulator_caps(msm_host); + if (ret) + dev_err(&pdev->dev, "%s: Failed to set regulator caps: %d\n", + __func__, ret); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev);