Received: by 10.223.185.116 with SMTP id b49csp301620wrg; Fri, 2 Mar 2018 19:43:49 -0800 (PST) X-Google-Smtp-Source: AG47ELsTwSD+BxhZdW5Vb4KETGNH9yziM9hSesxMCAWj6UEU80e0zQ9hskT2vK2WzIheJ6PAwTOL X-Received: by 10.98.56.131 with SMTP id f125mr7789168pfa.190.1520048629043; Fri, 02 Mar 2018 19:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520048629; cv=none; d=google.com; s=arc-20160816; b=n8CJbn7K8Ar5zjRCrlq20xNffbQHsep5J5VnFPO11zdcak2K3BVQgZsKQun1xeXh7i /cy+GlmmIT/lkFDcnYTnYRA9nPz97tdTn77oyY3JHIVAkCntv/0zaXaHGhBaeGjDN4b7 DeuIm8m1RGqRFC02Ig8iUe8M5pIwqyvGk4G96+FFbuTzPDGuxFOZ+Q1nguQu0irlor83 cwY/F6hPi7ztOf09QNWtqtyhVlPykIuIl0w2FBuqZ8praMLTorKCh1ySBOZ+2N0V+HUl SQz+be32Tthr+I23C0scLhedclqSqRtp0jThJslYOxIEdIEaoFeHVKZSBkGp4Csa+Myx V9zA== 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=14HM4Slvl1DwxbZ5AkOaIXCdZov3WhIDeLsZOjplMtY=; b=XFp4ptnPK9qG8LKsa65UxXis431yJFnLlVrbDSRsVqTEEh0dplVYVELlaRaU0kRwnp mq1GwDmTJ43YLAOAa/dLqptzyxpe87suTCzjbrim+vjPajM7RgnTajyjAG5oUEzwh6bA YMOwUyVxglaRc7ByDzRVmGM230jyFm0FI/QE7v8xn0snMez0JMwCuxZZf0mxaUBUYtrV Zut9jbUtCbgiU+e5O+fCRtTRzrw6Dmsq2+DZlTCw6irnjudKoDpPeF63T9yvW4JahaW6 8Lbft0hsBxNughDdCFSy6zrXFDBJ97b9kpvGeniNNM3PbJqdZiq8xagK5B6YdsuPtPCE ioKQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si4934909pgq.379.2018.03.02.19.43.34; Fri, 02 Mar 2018 19:43:48 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934205AbeCBXI2 (ORCPT + 99 others); Fri, 2 Mar 2018 18:08:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51394 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932885AbeCBXI0 (ORCPT ); Fri, 2 Mar 2018 18:08:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA8A3A7E5; Fri, 2 Mar 2018 23:08:25 +0000 (UTC) Received: from ovpn-116-42.phx2.redhat.com (ovpn-116-42.phx2.redhat.com [10.3.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AD555D9C5; Fri, 2 Mar 2018 23:08:22 +0000 (UTC) Subject: Re: [PATCH V2 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages To: Doug Anderson , Vijay Viswanath Cc: Adrian Hunter , Ulf Hansson , linux-mmc@vger.kernel.org, LKML , Shawn Lin , 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, evgreen@chromium.org References: <1518415278-59062-1-git-send-email-vviswana@codeaurora.org> <1518415278-59062-2-git-send-email-vviswana@codeaurora.org> From: Jeremy McNicoll Organization: Red Hat Message-ID: <19cc8cdf-3c75-5bde-08b2-34c4f4a2d5fa@redhat.com> Date: Fri, 2 Mar 2018 15:08:21 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 02 Mar 2018 23:08:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-03-02 10:23 AM, Doug Anderson wrote: > Hi, > > On Sun, Feb 11, 2018 at 10:01 PM, Vijay Viswanath > wrote: >> 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 > > This is a strange sort order for this include file. Why is it after > the local 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) >> + > > Is there something magical about 25 and 26? This is a new caps field, > so I'd have expected 0 and 1. > > >> #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; >> + } > > Shouldn't you be using regulator_is_supported_voltage() rather than > open coding? Also: I've never personally worked on a device where it > was used, but there is definitely a concept floating about of a > voltage level of 1.2V. Maybe should copy the ranges from > mmc_regulator_set_vqmmc()? > > > Also: seems like you should have some way to deal with "caps" ending > up w/ no bits set. IIRC you can have a regulator that can be enabled > / disabled but doesn't list a voltage, so if someone messed up their > device tree you could end up in this case. Should you print a > warning? ...or treat it as if we support "3.0V"? ...or ? I guess it > depends on how do you want patch #2 to behave in that case. Both, initialize it to sane value and print something. This way at least you have a good chance of booting and not hard hanging and you are given a reasonable message indicating what needs to be fixed. -jeremy > > >> + } > > How should things behave if vqmmc is an error? In that case is it > important to not set "CORE_IO_PAD_PWR_SWITCH_EN" in patch set #2? > ...or should you set "CORE_IO_PAD_PWR_SWITCH_EN" but then make sure > you don't set "CORE_IO_PAD_PWR_SWITCH"? > > >> + 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); > > Why do you need __func__ here? You're already using dev_err(), that > gives an idea of where we are. > > >> >> 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. >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html