Received: by 10.223.185.116 with SMTP id b49csp1856888wrg; Sun, 11 Feb 2018 23:16:34 -0800 (PST) X-Google-Smtp-Source: AH8x226Ro/xn9U3ZCdwQky7X1rlHoeLJJOC7JY7FAyUeO7wQgAcy1+LPhJnZMF/Lx30i6VZF/7yj X-Received: by 2002:a17:902:5793:: with SMTP id l19-v6mr9499437pli.56.1518419794416; Sun, 11 Feb 2018 23:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518419794; cv=none; d=google.com; s=arc-20160816; b=U4q53+i3X3hJtmmnxA5YLC6Q8a42yjP1gIHH+q1gJRiF6surb4luwsb3AfOO3UB18H cUKf0pdKwS3d0Zm45la5gS5heRoiG7q3s9T6UKnI4+loVYGlUd2UpcF9GDsIZxdn0DUt L7XucZKUY1A3tW3QveBdHF8mvaboJzcXlspWGNjxrl5AY/1seEq2YnaPTJmSIMgRHNpb OYtGyjJQj0LmOyoQYqkzKsnqmkhIWuwfXpEIUYNPOQZrLgBqb0ZX8ri2mmdhRGTYVH43 odUf1St5WhfFou7LNPsofxrnzkvKJJ0wRlOXZ1Iey3SSKAc+m9OEaGR0KXB+CQ3DYKC4 mjoQ== 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=DSiOW6JEIN/dU0mrXHuUxHEKqlDj8eSblRcf64GIzsk=; b=vd86yQ7r2siM7gCg0OvQKUEzJSr32Y+wIEqPzPtq1baFkMBgkNQd86ocoGlZCyPLRi qymuYjDMjQ9741Kvj5cBogvk0LIDF9QRN/ye2aCZwguDzy00Xrtcf1q3BKhPKRTrvbu8 8SbIMrTNDhvdSu1eC8A6Kph9u1AkEemNIfLuF2/idN0s8a/snKlvya5ZoC29X+LC88+e L5VYZ+t5WP8iurjmMJFUAHM0PuFNby2/Bjv/im7qMK0G9HBVrj6nKEsGe/1yScOz1hVN 4MIb7eFeBKHDzi/P0Le8ZztK5fpJ+ZPdKyH+xbQIvgF2zZA0tfrss8u7lTiiAMMr+PBb HU4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=FEBc8e71; dkim=pass header.i=@codeaurora.org header.s=default header.b=IDwZNsn1; 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 f5si1615132pgv.163.2018.02.11.23.16.19; Sun, 11 Feb 2018 23:16:34 -0800 (PST) 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=FEBc8e71; dkim=pass header.i=@codeaurora.org header.s=default header.b=IDwZNsn1; 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 S932875AbeBLGBk (ORCPT + 99 others); Mon, 12 Feb 2018 01:01:40 -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= 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 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 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.