Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1922700pxk; Sun, 13 Sep 2020 22:46:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeCOUYOF1MW2TS+civLqQcYJiIwG2wMF58QHJgcU5A+E7pu03y8k8PpD/emrChIE21OKV9 X-Received: by 2002:a17:906:4c58:: with SMTP id d24mr13507274ejw.108.1600062410881; Sun, 13 Sep 2020 22:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600062410; cv=none; d=google.com; s=arc-20160816; b=1FHEOn8OD6TKFTjJuUAl1tRsRXhhp7Kw+0ssKgBgZVsTalbBYYvj04K1mPGz2RlMWv QqNcFntV2TQqXlGE5We/hxjMRGgpWU0TVNm6fNh2Ebi5A/fQxJ8qZsW6Xk3pg1+SbF7J GUXgt/mJYq7esZzOmMK+hNXLLjEazd+PRE9zvvyZcPTm8UQnivpswwurzi42rE5vECsj 6zh89gEoQ/cf/xMP/X1N0Wf+pE1u0OvFU2Ve8juklHnjt31Meo3rVqLCIlDA2EjV2rvq zG9Ebz+C38x3kSIv15DIy+DhMmLomuTJOltt/mUaXHeQLTMiAXjlYgM9LRh6io/m6zCV drfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=glNkNRmAU7RgWAdV6/8XgRfmftYWgIcuHxeSjWhpb4E=; b=ravJqy2y9na5Yq5I3C4JUJnheklONuev4YOe/T4PvVEm+wKCVa4/WgkyHOtQzBBWwu SlIEyDD2cs5K1asrHBMGnuhbIXZimOupYz/hv7q1ahHV69Zkol7TegoHsqb3tcyQa9ob sghNm+0z0N98HT5wgRTQGOwjQ61QCc1OqAEhIdVtwK3U3hdOREIGJSnIRQlU3nODc/R/ vV80+lqbpSw0Z6xFvT+TcoOAyi7tg4/NOaMwHbqs7KD//9J+GAUx7m+05fuXGZM8cDWO QyfzBpD9TAYb5uzy76zeG55Rqf/PPo9nyndZwA5hGHFSB4Aa7GM5UdjQSba1qc+/BJyB cDYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+UxwzwJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si6928748ejg.582.2020.09.13.22.46.28; Sun, 13 Sep 2020 22:46:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+UxwzwJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgINFpd (ORCPT + 99 others); Mon, 14 Sep 2020 01:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726003AbgINFp1 (ORCPT ); Mon, 14 Sep 2020 01:45:27 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A1FAC06174A for ; Sun, 13 Sep 2020 22:45:43 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u13so10655795pgh.1 for ; Sun, 13 Sep 2020 22:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=glNkNRmAU7RgWAdV6/8XgRfmftYWgIcuHxeSjWhpb4E=; b=f+UxwzwJdNkNO/6FibwIffKu3/WUBpoItsoZOlKwJS4ClrjUc7OGQF7rLPhEigPZrD P/LSX8+T0lA3hfpw5AJkM2NzUkVtMTw+9eXZGTFkXle3dbuefjzuP2u56A2i+hXb7OBS W2PuJ5VHlKpm+lL6TEhMU+GNl78UdYZrwSXR8X1NodmFpXwcR/hAvQXErMxPamXpnQ+i e7LrcwOCXlaxCD1NmKZo+P4elpUvLPpQTXFZiTwOJ/D5o5fBSR7sqcLYsXMvIbF2Srpm nw8JyadTJoQswyU5VQR/8+t87+W975kkrMDZWJ6d4f/8/ytcVgIc4TVionvfw8J8K8rP sCog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=glNkNRmAU7RgWAdV6/8XgRfmftYWgIcuHxeSjWhpb4E=; b=hIi20FwxrDWbA4D7vdzqor1A1bqmvpdRQPU9G7f6DZ7CHZemU6KAO2go9QQfvhFBy9 Nz11JEGeOoHIyxOYal+SCOcV10J2h23wT1Ie3JrzP5jYPry49591gCktUynV56wpTlN+ PLnuZwrvYoyRlRG0GcnNBha1G0ZWEklw8X6JYGyF93LsYrJ+q1rcDTeYMRTbZsPthcYp gRnLQPbVCOXup0qOQDt2xeRmnfP3rF/ybkiPRDQmZWkv+iBeShkEZxkCWI+3iZm/cA05 M103N6PzfVVUGaGJ70hA8yII1IMYER/Nww0lCJ6lzPET9sQ+oOeul4hS9GLB/a5lnvKr a2Vg== X-Gm-Message-State: AOAM532d+bzn94UakAayPjzvdzLkLUJlPxNBaflWqka/JnzuwlKIkgnB +AseyJnhlOHQ6ln6gw8yha2xqw== X-Received: by 2002:aa7:8aca:0:b029:13e:d13d:a13e with SMTP id b10-20020aa78aca0000b029013ed13da13emr12165811pfd.38.1600062342826; Sun, 13 Sep 2020 22:45:42 -0700 (PDT) Received: from laputa (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id y13sm7342708pgs.53.2020.09.13.22.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:45:42 -0700 (PDT) Date: Mon, 14 Sep 2020 14:45:37 +0900 From: AKASHI Takahiro To: Adrian Hunter Cc: Ben Chuang , ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, ben.chuang@genesyslogic.com.tw, greg.tu@genesyslogic.com.tw Subject: Re: [RFC PATCH V3 15/21] mmc: sdhci: UHS-II support, modify set_power() to handle vdd2 Message-ID: <20200914054537.GA2738017@laputa> Mail-Followup-To: AKASHI Takahiro , Adrian Hunter , Ben Chuang , ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, ben.chuang@genesyslogic.com.tw, greg.tu@genesyslogic.com.tw References: <20200710111140.29725-1-benchuanggli@gmail.com> <97c43596-a18f-4c7a-c226-5209772d91d1@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <97c43596-a18f-4c7a-c226-5209772d91d1@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adrian, On Fri, Aug 21, 2020 at 05:11:18PM +0300, Adrian Hunter wrote: > On 10/07/20 2:11 pm, Ben Chuang wrote: > > From: AKASHI Takahiro > > > > VDD2 is used for powering UHS-II interface. > > Modify sdhci_set_power_and_bus_voltage(), sdhci_set_power_noreg() > > and sdhci_set_power_noreg() to handle VDD2. > > vdd2 is always 1.8 V and I suspect there may never be support for anything > else, so we should start with 1.8 V only. What do you mean here? You don't want to add an extra argument, vdd2, to sdhci_set_power(). Correct? > Also can we create uhs2_set_power_reg() and uhs2_set_power_noreg() and use > the existing ->set_power() callback Again what do you expect here? Do you want to see any platform-specific mmc driver who supports UHS-II to implement its own call back like: void sdhci_foo_set_power(struct sdhci_host *host, unsigned char mode, unsigned short vdd) { sdhci_set_power(host, mode,vdd); /* in case that sdhci_uhs2 module is not inserted */ if (!(mmc->caps & MMC_CAP_UHS2)) return; /* vdd2 specific operation */ if (IS_ERR_OR_NULL(host->mmc->supply.vmmc2)) sdhci_uhs2_set_power_noreg(host, mode); else sdhci_uhs2_set_power_reg(host, mode); /* maybe more platform-specific initialization */ } struct sdhci_ops sdhci_foo_ops = { .set_power = sdhci_foo_set_power, ... } Is this what you mean? (I'm not quite sure yet that sdhci_ush2_set_power_noreg() can be split off from sdhci_set_power_noreg().) -Takahiro Akashi } > > > > Signed-off-by: Ben Chuang > > Signed-off-by: AKASHI Takahiro > > --- > > drivers/mmc/host/sdhci-omap.c | 2 +- > > drivers/mmc/host/sdhci-pci-core.c | 4 +-- > > drivers/mmc/host/sdhci-pxav3.c | 4 +-- > > drivers/mmc/host/sdhci-xenon.c | 4 +-- > > drivers/mmc/host/sdhci.c | 42 ++++++++++++++++++++++++------- > > drivers/mmc/host/sdhci.h | 9 +++---- > > 6 files changed, 43 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c > > index 1ec74c2d5c17..1926585debe5 100644 > > --- a/drivers/mmc/host/sdhci-omap.c > > +++ b/drivers/mmc/host/sdhci-omap.c > > @@ -678,7 +678,7 @@ static void sdhci_omap_set_clock(struct sdhci_host *host, unsigned int clock) > > } > > > > static void sdhci_omap_set_power(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > struct mmc_host *mmc = host->mmc; > > > > diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c > > index bb6802448b2f..40f5a24a8982 100644 > > --- a/drivers/mmc/host/sdhci-pci-core.c > > +++ b/drivers/mmc/host/sdhci-pci-core.c > > @@ -629,12 +629,12 @@ static int bxt_get_cd(struct mmc_host *mmc) > > #define SDHCI_INTEL_PWR_TIMEOUT_UDELAY 100 > > > > static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > int cntr; > > u8 reg; > > > > - sdhci_set_power(host, mode, vdd); > > + sdhci_set_power(host, mode, vdd, -1); > > > > if (mode == MMC_POWER_OFF) > > return; > > diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c > > index e55037ceda73..457e9425339a 100644 > > --- a/drivers/mmc/host/sdhci-pxav3.c > > +++ b/drivers/mmc/host/sdhci-pxav3.c > > @@ -298,12 +298,12 @@ static void pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs) > > } > > > > static void pxav3_set_power(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > struct mmc_host *mmc = host->mmc; > > u8 pwr = host->pwr; > > > > - sdhci_set_power_noreg(host, mode, vdd); > > + sdhci_set_power_noreg(host, mode, vdd, -1); > > > > if (host->pwr == pwr) > > return; > > diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c > > index 4703cd540c7f..2b0ebb91895a 100644 > > --- a/drivers/mmc/host/sdhci-xenon.c > > +++ b/drivers/mmc/host/sdhci-xenon.c > > @@ -214,12 +214,12 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host, > > } > > > > static void xenon_set_power(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > struct mmc_host *mmc = host->mmc; > > u8 pwr = host->pwr; > > > > - sdhci_set_power_noreg(host, mode, vdd); > > + sdhci_set_power_noreg(host, mode, vdd, -1); > > > > if (host->pwr == pwr) > > return; > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > > index d38d734ec83f..ca3d4a506e01 100644 > > --- a/drivers/mmc/host/sdhci.c > > +++ b/drivers/mmc/host/sdhci.c > > @@ -2089,12 +2089,15 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) > > EXPORT_SYMBOL_GPL(sdhci_set_clock); > > > > static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > struct mmc_host *mmc = host->mmc; > > > > mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); > > > > + if (mmc->caps & MMC_CAP_UHS2 && !IS_ERR(mmc->supply.vmmc2)) > > + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc2, vdd2); > > + > > if (mode != MMC_POWER_OFF) > > sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL); > > else > > @@ -2102,7 +2105,7 @@ static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode, > > } > > > > void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > u8 pwr = 0; > > > > @@ -2133,6 +2136,20 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, > > } > > } > > > > + if (mode != MMC_POWER_OFF) { > > + if (vdd2 != (unsigned short)-1) { > > + switch (1 << vdd2) { > > + case MMC_VDD2_165_195: > > + pwr |= SDHCI_VDD2_POWER_180; > > + break; > > + default: > > + WARN(1, "%s: Invalid vdd2 %#x\n", > > + mmc_hostname(host->mmc), vdd2); > > + break; > > + } > > + } > > + } > > + > > if (host->pwr == pwr) > > return; > > > > @@ -2159,7 +2176,13 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, > > sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); > > > > pwr |= SDHCI_POWER_ON; > > + if (vdd2 != (unsigned short)-1) > > + pwr |= SDHCI_VDD2_POWER_ON; > > + > > + sdhci_writeb(host, pwr & 0xf, SDHCI_POWER_CONTROL); > > + mdelay(5); > > sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); > > + mdelay(5); > > > > if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON) > > sdhci_runtime_pm_bus_on(host); > > @@ -2175,12 +2198,12 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, > > EXPORT_SYMBOL_GPL(sdhci_set_power_noreg); > > > > void sdhci_set_power(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, unsigned short vdd2) > > { > > if (IS_ERR(host->mmc->supply.vmmc)) > > - sdhci_set_power_noreg(host, mode, vdd); > > + sdhci_set_power_noreg(host, mode, vdd, vdd2); > > else > > - sdhci_set_power_reg(host, mode, vdd); > > + sdhci_set_power_reg(host, mode, vdd, vdd2); > > } > > EXPORT_SYMBOL_GPL(sdhci_set_power); > > > > @@ -2192,14 +2215,15 @@ EXPORT_SYMBOL_GPL(sdhci_set_power); > > */ > > void sdhci_set_power_and_bus_voltage(struct sdhci_host *host, > > unsigned char mode, > > - unsigned short vdd) > > + unsigned short vdd, > > + unsigned short vdd2) > > { > > if (!IS_ERR(host->mmc->supply.vmmc)) { > > struct mmc_host *mmc = host->mmc; > > > > mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); > > } > > - sdhci_set_power_noreg(host, mode, vdd); > > + sdhci_set_power_noreg(host, mode, vdd, -1); > > } > > EXPORT_SYMBOL_GPL(sdhci_set_power_and_bus_voltage); > > > > @@ -2377,9 +2401,9 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > > } > > > > if (host->ops->set_power) > > - host->ops->set_power(host, ios->power_mode, ios->vdd); > > + host->ops->set_power(host, ios->power_mode, ios->vdd, -1); > > else > > - sdhci_set_power(host, ios->power_mode, ios->vdd); > > + sdhci_set_power(host, ios->power_mode, ios->vdd, -1); > > > > /* 4.0 host support */ > > if (host->version >= SDHCI_SPEC_400) { > > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > > index ecf55394ea46..f6732f33f29f 100644 > > --- a/drivers/mmc/host/sdhci.h > > +++ b/drivers/mmc/host/sdhci.h > > @@ -689,7 +689,7 @@ struct sdhci_ops { > > > > void (*set_clock)(struct sdhci_host *host, unsigned int clock); > > void (*set_power)(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd); > > + unsigned short vdd, unsigned short vdd2); > > > > u32 (*irq)(struct sdhci_host *host, u32 intmask); > > > > @@ -852,13 +852,10 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, > > unsigned int *actual_clock); > > void sdhci_set_clock(struct sdhci_host *host, unsigned int clock); > > void sdhci_enable_clk(struct sdhci_host *host, u16 clk); > > -void sdhci_set_power(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd); > > void sdhci_set_power_and_bus_voltage(struct sdhci_host *host, > > unsigned char mode, > > - unsigned short vdd); > > -void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, > > - unsigned short vdd); > > + unsigned short vdd, > > + unsigned short vdd2); > > void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq); > > int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq); > > void sdhci_set_bus_width(struct sdhci_host *host, int width); > > >