Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2725309pxk; Tue, 15 Sep 2020 00:01:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS3t3T5bME+u064mlTg4THY8r4oGcP31+MirI+/Wg08nOfcF680dZiKyt6gUMIE+d5oZGz X-Received: by 2002:a50:ed8d:: with SMTP id h13mr20320546edr.50.1600153269062; Tue, 15 Sep 2020 00:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600153269; cv=none; d=google.com; s=arc-20160816; b=v8fnHFFjXNlWxbUpoppiN/YavOOa6cn8Q4JhVOf3ogj9EvG/P5Gp+6kV4YCOWiBjyG C0Z5RvcX361xR8LoOQEWqBH6eVIcZA/Q7iqrzt2bxizTnUZXbdUgVLkOS5psKHELEnRB WcAGLfqqLau/p4sY2QHLvVsAnlv3SjDdB81ZUe1UVj0rVBnL6nCdFFhMyHlRFuj9ZViR Wz+LpvGAvpOi0fghlXpPUN+7Ob1BlivNPxS76xo5uYqwVzrkXeI4PomvYWsFYi5HAMlY oU/2hmNl+sTjfdW8qm4e3cw1ePaKkKppPqEBElSgg+3C2wxLl739MkHAWLOj6EV1QpAj TgzQ== 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=RM0TRqzdIYCRaUY20HBu5jkowpibtAwtQdq920OxMMs=; b=yQnCVUk0zm96akVfCWNbfA2uxcs6B82plxTHjtJ3vQER86QSQZkJgGvPbMOeRcIChy 4CoOH3fKFF19QW2Agy2InPge3hcN24KINXhYwY/UKfewcwP/g9aqyDsRWCFkeAW4pbpN lVYhijjasqjYoshMK+fBVzTq51/q3+Pe+Sa4mHu3LAoWmOKjuhvnhPprd8/onBRwn61S HaMH7/1yxNBXqg8PnjZCCeuDvVPKt93hNJrpS23+tZ3lZNnHxAj6brw8Cp84D/TOyBEB 4GqJnjLT4NrMCB7AN35WeY+uA/IahOrxLt9dHhJTA9EPQpNEu7BGpqYRlwHIgWU0adrT W1ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qR9Ll7o2; 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 ha18si8446997ejb.543.2020.09.15.00.00.45; Tue, 15 Sep 2020 00:01:09 -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=qR9Ll7o2; 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 S1726186AbgIOG7P (ORCPT + 99 others); Tue, 15 Sep 2020 02:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbgIOG7M (ORCPT ); Tue, 15 Sep 2020 02:59:12 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B2DEC061788 for ; Mon, 14 Sep 2020 23:59:12 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id gf14so1234996pjb.5 for ; Mon, 14 Sep 2020 23:59:12 -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=RM0TRqzdIYCRaUY20HBu5jkowpibtAwtQdq920OxMMs=; b=qR9Ll7o2RG84QZEO0G0K6fbhcvZiZVgrOUGDc66w1LqUYkulRaX0ftd6SwoYkdtURI U0yTWO9e2+ndVVAFUm/pafo49RX/HI78yjPbVO/H4jVp02YO9nKLTAAiQHFGP2n9GtO0 z1eQYNT19GwkhQMcKKDxkMd3NpSu7mX9V7zb1Kke032s23emHHPJW97oU2xIrHxoo+jp j7SPIF9asXQbjBWQot6TNWd4mi5xSWJJqljHpXWk7EJDJf1b95vFmyNAZOV32svQDlLV uU1p0bQ8tFCRIXUxebamqfogTjKKgDNKf29V5GcMKN3UVDmBgUlw7YQB1W5pHw9pVT6v QTKQ== 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=RM0TRqzdIYCRaUY20HBu5jkowpibtAwtQdq920OxMMs=; b=o/C83bMr0reEvLN8XlwrzWFRLtmMs8sWGb8+G6ZVhCnveapKQB5m+7OOh15WYMEvNm ViQsRNQXekeJsASx5heo7RklHEidCPrZSDzplouUsPz0n7hKGMav5z8fg+cBTg2Ai8ud 1t0PrxIJr3/P1/gJCW49cQSCLbDJxCWQT+EGDsDhv8f45IoT41deVWjIdSwkGgH/OJPQ xS5Ibe1HHuovn71dB+/x1dsoL+lpWXxACee/eOTt0WqusZilvxKS8y1G/fm2WSRNYOma TF7yY87DcLLOEFH4i5wn1NAMr1nBKu+D97BjNFwHINpi56omtimmSfuOYJJAqX+Gn8JY 2Yng== X-Gm-Message-State: AOAM5317tTYyscyL77PBZ3JxjcU6XaQHW+c/b624RXPsao3zo6LIevYM t0KSiIYHuL/41YxI0ExCKp+rww== X-Received: by 2002:a17:902:d714:b029:d0:cbe1:e7a2 with SMTP id w20-20020a170902d714b02900d0cbe1e7a2mr17469495ply.19.1600153151832; Mon, 14 Sep 2020 23:59:11 -0700 (PDT) Received: from laputa (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id o20sm11034207pgh.63.2020.09.14.23.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 23:59:11 -0700 (PDT) Date: Tue, 15 Sep 2020 15:59:02 +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 11/21] mmc: sdhci: UHS-II support, export host operations to core Message-ID: <20200915065902.GE2860208@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: <20200710111044.29509-1-benchuanggli@gmail.com> <5f3dc200-b9ef-a678-25b7-3bff3a529703@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5f3dc200-b9ef-a678-25b7-3bff3a529703@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 21, 2020 at 05:05:44PM +0300, Adrian Hunter wrote: > On 10/07/20 2:10 pm, Ben Chuang wrote: > > From: AKASHI Takahiro > > > > Export sdhci-specific UHS-II operations to core. > > > > Signed-off-by: Ben Chuang > > Signed-off-by: AKASHI Takahiro > > --- > > drivers/mmc/host/sdhci.c | 70 ++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 70 insertions(+) > > > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > > index c2f6923d296c..aaf41954511a 100644 > > --- a/drivers/mmc/host/sdhci.c > > +++ b/drivers/mmc/host/sdhci.c > > @@ -2977,6 +2977,70 @@ static void sdhci_card_event(struct mmc_host *mmc) > > spin_unlock_irqrestore(&host->lock, flags); > > } > > > > +#if IS_ENABLED(CONFIG_MMC_SDHCI_UHS2) > > +static int sdhci_uhs2_detect_init(struct mmc_host *mmc) > > +{ > > + struct sdhci_host *host = mmc_priv(mmc); > > + int ret; > > + > > + if (sdhci_uhs2_ops.do_detect_init) > > + ret = sdhci_uhs2_ops.do_detect_init(host); > > + else > > + return 0; > > + > > + return ret; > > +} > > + > > +static int sdhci_uhs2_set_reg(struct mmc_host *mmc, enum uhs2_act act) > > +{ > > + struct sdhci_host *host = mmc_priv(mmc); > > + int ret; > > + > > + if (sdhci_uhs2_ops.do_set_reg) > > + ret = sdhci_uhs2_ops.do_set_reg(host, act); > > + else > > + ret = 0; > > + > > + return ret; > > +} > > + > > +static void sdhci_uhs2_disable_clk(struct mmc_host *mmc) > > +{ > > + struct sdhci_host *host = mmc_priv(mmc); > > + u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); > > + > > + clk &= ~SDHCI_CLOCK_CARD_EN; > > + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); > > +} > > + > > +static void sdhci_uhs2_enable_clk(struct mmc_host *mmc) > > +{ > > + struct sdhci_host *host = mmc_priv(mmc); > > + u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); > > + ktime_t timeout; > > + > > + clk |= SDHCI_CLOCK_CARD_EN; > > + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); > > + > > + /* Wait max 20 ms */ > > + timeout = ktime_add_ms(ktime_get(), 20); > > + while (1) { > > + bool timedout = ktime_after(ktime_get(), timeout); > > + > > + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); > > + if (clk & SDHCI_CLOCK_INT_STABLE) > > + break; > > + if (timedout) { > > + pr_err("%s: Internal clock never stabilised.\n", > > + mmc_hostname(host->mmc)); > > + sdhci_dumpregs(host); > > + return; > > + } > > + udelay(10); > > + } > > +} > > +#endif /* CONFIG_MMC_SDHCI_UHS2 */ > > Please put all uhs2 functions in sdhci-uhs2.c and call them through sdhci_ops. Okay although the logic itself in sdhci_uhs2_[enable|disable]_clk() doesn't seem to be UHS-II specific. -Takahiro Akashi > > > + > > static const struct mmc_host_ops sdhci_ops = { > > .request = sdhci_request, > > .post_req = sdhci_post_req, > > @@ -2992,6 +3056,12 @@ static const struct mmc_host_ops sdhci_ops = { > > .execute_tuning = sdhci_execute_tuning, > > .card_event = sdhci_card_event, > > .card_busy = sdhci_card_busy, > > +#if IS_ENABLED(CONFIG_MMC_SDHCI_UHS2) > > + .uhs2_detect_init = sdhci_uhs2_detect_init, > > + .uhs2_set_reg = sdhci_uhs2_set_reg, > > + .uhs2_disable_clk = sdhci_uhs2_disable_clk, > > + .uhs2_enable_clk = sdhci_uhs2_enable_clk, > > +#endif /* CONFIG_MMC_SDHCI_UHS2 */ > > }; > > > > /*****************************************************************************\ > > >