Received: by 10.223.185.116 with SMTP id b49csp32763wrg; Fri, 2 Mar 2018 13:04:41 -0800 (PST) X-Google-Smtp-Source: AG47ELtxIX0bGSwLiAleAGIYRwWaEfgG5yEBb9uyrG706g81lCBW/+AkWbi3xl3uJLzQe9zPrPiF X-Received: by 2002:a17:902:309:: with SMTP id 9-v6mr6304865pld.63.1520024681025; Fri, 02 Mar 2018 13:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520024680; cv=none; d=google.com; s=arc-20160816; b=kUKvjUgqTV+nwdW7VDozF1Utdv2cJXVgdUfhAZTSo1cv1nku0M9PTWuKVyeHQroE7L wu99SU3t/klFA0oFDBGWfGf+OwiuhvWMTIyjDXIzJERu7X35aQm/9qePZrSbm+qfSSUh AipuuGnt/qFlozgZw0QMSCmGC9xsTJoNA9SfHgLlnxLexak2bc/z3Ah/wIazUHPtrcjY 3ZnUsFTOzp6Diioiu7I+IjrjhEx0i3CkxsKpz/wVx5+oiRipfFk33jzqjmXVv3OZyT3m 9rjoXxitva4UB0xW9j6t0Oxx6nHIntdFVXCyS2rS9Y/IU0HtMo+mjqW67jopNXZa/JYw FMUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=DNOQVhg2lSiRg79HeFNUJWVA5DukBWP5jBt2RW4fZWA=; b=mI7y8RIN7JY/0HDNQ9MJhanhQH944r4GkcNOgIrKoUIdaQkKzN+LRoTehTiP9PBHk2 aStm/bgW950Gng6qsPwQVQTVJzsgJSbf0EJFPLZTm4+MOr+usNJyQX0gs5fO247Y9pVg 032QOKeChJps3lfXRYmD4CZ/ykxZVIWWAd2is5RxEw+UNHNgv5bQyRLwsI4MqnQZKodn snhnDApqqBBLFnVP9HttU8X2+orUDdEX0h/QT57/Oc6TFcB2UyMTfO4Dq8uvM+U3N/No eOutahe7Yp+MmsCrkEUQ6HvTrCMbYZOrEJRkHLsc82aHN81/C6l9bO/Qy1U4HQpza6CR YI+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=WrRIeMx9; dkim=fail header.i=@chromium.org header.s=google header.b=SCik18E8; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si5492775pfi.35.2018.03.02.13.04.27; Fri, 02 Mar 2018 13:04:40 -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=fail header.i=@google.com header.s=20161025 header.b=WrRIeMx9; dkim=fail header.i=@chromium.org header.s=google header.b=SCik18E8; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947249AbeCBSXp (ORCPT + 99 others); Fri, 2 Mar 2018 13:23:45 -0500 Received: from mail-ua0-f195.google.com ([209.85.217.195]:42463 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1947238AbeCBSXk (ORCPT ); Fri, 2 Mar 2018 13:23:40 -0500 Received: by mail-ua0-f195.google.com with SMTP id b23so6617186uak.9 for ; Fri, 02 Mar 2018 10:23:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=DNOQVhg2lSiRg79HeFNUJWVA5DukBWP5jBt2RW4fZWA=; b=WrRIeMx9IesbNSn0qIvrQbGIRE6+xkGraNdOnKNJfRppl836hy4aHPKu7/NWJOE1qM 42H0Qb0bZRg98HwHnOwnYdo0ogbD5LwvvdpekuVxRr5SI6erj1d+K4D/lKA0wfeO0w8J /a3vTOCCWCeHutNlLEuZaPLQRGpSJ6MeVCklACkiBp4AXavRMm8FDyMeEUmoh2KrdRo/ ruoA7c2eRyHf3CE791mRsSZbBrJlYRXWSGG4dD7P7LolQb3RmWIzgMjzNtbv4UNVq7FU byh2hpCh1IZobpg6ndSzTt3UwFl5TR/SMfn4ie8WmRBPYkHDg38C3PIgfidzNQMOlaRO 53+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=DNOQVhg2lSiRg79HeFNUJWVA5DukBWP5jBt2RW4fZWA=; b=SCik18E8f1tx/8hpT8565VkEgRLh+lilc+TwjQQ2VAHtKJt54T6zZfmYlntFBDHJcb 8qX7TMO1KYk88K/iiNt0alJlE6dPLjRVRq11A47/SXziJYN8oKwO1p7e8UwHU3VW8bGJ qS/gXfpVFckikOZDkYjZugOSrJUPDS8xd4IrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=DNOQVhg2lSiRg79HeFNUJWVA5DukBWP5jBt2RW4fZWA=; b=FAkOUF36qbm1xqQQ9iIy0fzgnUaWdjNGOh86i7Q014eenX2zFSpJdty5q9C5XRUBNr OICn57eEjcPsGPyPgucIBlct97UVQcxuLHuPcYz5la2zpzRPhGpIMi6UhNoTIw+53nnS mBzOxpNBeJwD5DCMdKB0yw9mo1VZctJt9CYE8MyWNJ4pMEX9HFN6KHuPBTSig3z1EgwN 4yo6X+2czZOUV62FKWLYz3RSw1nFtcCDF10YegwWpwRpgFmbH5hqSPlzDrfTtMSxjKtA AIHzEnCWtL4oEaoX2ip6+tCTkmTyNqi5LwLLnOX0qeY0qntqs2wui9iZ/WTzsYK22I4b N54w== X-Gm-Message-State: APf1xPAeyN2EV3s81kQmHihfchwP1TQ9Zv5wH4m20O4ScxEPiGKzaBf5 Yi+GhzYCiw0eosoycAdFojdUMuPkq+q2E17Qq9bWTA== X-Received: by 10.159.56.74 with SMTP id q10mr4607331uad.53.1520015018928; Fri, 02 Mar 2018 10:23:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.151.1 with HTTP; Fri, 2 Mar 2018 10:23:37 -0800 (PST) In-Reply-To: <1518415278-59062-2-git-send-email-vviswana@codeaurora.org> References: <1518415278-59062-1-git-send-email-vviswana@codeaurora.org> <1518415278-59062-2-git-send-email-vviswana@codeaurora.org> From: Doug Anderson Date: Fri, 2 Mar 2018 10:23:37 -0800 X-Google-Sender-Auth: ebd14wOPFmJ_PpWFhN2Q0VZqfGs Message-ID: Subject: Re: [PATCH V2 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages To: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + } 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