Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp424291rdb; Fri, 17 Nov 2023 02:52:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEotC0G6OA0LjQ4cBNUytEBiJfDouF710wbr+NeG64RK9v3u1mvJUPPDFTVqfvtK6BufbYc X-Received: by 2002:a17:903:264d:b0:1cc:7af4:d12c with SMTP id je13-20020a170903264d00b001cc7af4d12cmr11525279plb.62.1700218347083; Fri, 17 Nov 2023 02:52:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700218347; cv=none; d=google.com; s=arc-20160816; b=A7Ol4DOOzNC6G54K8EUwABTydqatK50sB++FJJF11iQlwW1q93EWrdQt3elgn3SOwA igeUxzLTKvtY5JQ0GBg7/oo+IAhIwdNfkTszbUkdWYAqq8kdpGd2GlolTulsBmzn5zUZ yFgjWj9SoTsM8ESImx/JNxD8LEmu8xQ2Wy8w9GO9uvHjchIz9uOVImOyqRQo+Cc1aK0A s0P3uoBiU/Xbdx99pqG377svV8MLMhjhOJZNE9rWh4pFoEgeH75P6hvzBYu0nXd/ltUu aLwf0Dymt+sCWKkoKRqGUKHt0bebOws1a9YLk3ajnuflaRC3IL4deVeaFvHbsGRDq872 BWtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Dvd1r0uV7IB9mFxXPza1NzbwXVBeZL/6VUSeoirYaIk=; fh=E9dRX3P9+1ACoiVN3TLqgt71N7WLrYiSbf3DtPzMktQ=; b=ge4iQZjMJrV5YR3u9H7Xs8pjmOodMSjW8jin3dfg0pXFwI9VTicFa9ycpm1M6khx4P tbWYpTKrpqv/zmEU58bYOY1UTGkO+hlFbFQj6MXr7ToOakT/L2Nnupc6+BGDf54CGkc7 OzITmlLF1DT2LnyBLWHt4QPdHtjcRXKUc0laGh4QsNlXVAoM7mSeXP7zhZRHUUISBt/O FtbuaSVDB4igxkh9lVFSjyHansvQzfzEDMffY/m0s+LwNoNKiumAK0KVixM0Gw+M88eh tjxtr0YwsicZ6M1RimO2eXrIF+r5jNvOZgcIWw9yKnVfuId8oyFz41NXXqav2jI1JupY f0Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gnnMQihO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c11-20020a170902aa4b00b001ce160421d4si1542750plr.179.2023.11.17.02.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:52:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gnnMQihO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C79A28061386; Fri, 17 Nov 2023 02:51:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345981AbjKQKur (ORCPT + 99 others); Fri, 17 Nov 2023 05:50:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbjKQKu3 (ORCPT ); Fri, 17 Nov 2023 05:50:29 -0500 Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A44D52; Fri, 17 Nov 2023 02:50:24 -0800 (PST) Received: by mail-vs1-xe32.google.com with SMTP id ada2fe7eead31-45db31f9156so730936137.1; Fri, 17 Nov 2023 02:50:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700218223; x=1700823023; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Dvd1r0uV7IB9mFxXPza1NzbwXVBeZL/6VUSeoirYaIk=; b=gnnMQihO8Uu6RklknqauW+mICG4ONA3DAe82I2Q9ZAtJxuvqCWJWugAvGrSqPWw/c2 YZQPmSgUVO5uDGCgvdgEIxReUUmQVK6h+2fbZvXGGEYl0P/k/aqcBLDMmR8Gr2DBzuFA 0bVToEygPxJEjCe0Q3dNPIC4M2t1Rf0J9GJUbnyBS5D6pjDWYRrjIgrUyIssK/G0n97P RoezD8rubBv7kFl9z6I6V+4FM+vrAMO8ynz7kag4o7tO9lwBJiFJn8wIxm6eYSjycrrP qb6pEXPtz4NPzososxHSuBpLLEz5SnOme0r3pB/WiTWynMm8qFAQFVT+YlKoYlVfaaNm 4syg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700218223; x=1700823023; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dvd1r0uV7IB9mFxXPza1NzbwXVBeZL/6VUSeoirYaIk=; b=mpanbMnx6qSqf0rUMuUkbxzKF1Sa0Q8icAeH11QwBNrdUmtm17JbW6q1V7yN0qaZgF 11tOB9BfTNozh9O3pzPmw2fgYeXyG8jXhDeTPbWWkO2ZGrpjuNQCGiSZL5D1BKsFzpWE YD8L1RRcRW2j96BzhXVEWg9TN3gP8rcODpl1zXXLVCm1ppN2f/n0dEgCdigX+m21lgpq 2pFwy726zLFkjb/DNm7ZPClhXbOeiJuy6x5lSl2/eJH7epc46Vms3Fc+C7T0WsLao0MS +CrsMJOntoUxbuCaY3YidlQ0xHIA9me1DwIOsZVez+Jgl1rPJuH90FazzP5fBO0nIUgg WdBA== X-Gm-Message-State: AOJu0Yz2iFfSTt+U6STJUljx82H/iBm20LdkIYiNS0iVr8o8XK8wY7ii lDT0wzNyFnayL1679o+WoygV6NRGSExbuYOcWGU= X-Received: by 2002:a05:6102:4b14:b0:45e:3da0:6a31 with SMTP id ia20-20020a0561024b1400b0045e3da06a31mr24769944vsb.13.1700218223454; Fri, 17 Nov 2023 02:50:23 -0800 (PST) MIME-Version: 1.0 References: <20230915094351.11120-1-victorshihgli@gmail.com> <20230915094351.11120-18-victorshihgli@gmail.com> In-Reply-To: From: Victor Shih Date: Fri, 17 Nov 2023 18:50:11 +0800 Message-ID: Subject: Re: [PATCH V12 17/23] mmc: sdhci-uhs2: add uhs2_control() to initialise the interface To: Ulf Hansson Cc: adrian.hunter@intel.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, benchuanggli@gmail.com, HL.Liu@genesyslogic.com.tw, Greg.tu@genesyslogic.com.tw, takahiro.akashi@linaro.org, dlunev@chromium.org, Ben Chuang , Victor Shih Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 02:51:05 -0800 (PST) On Tue, Oct 3, 2023 at 7:20=E2=80=AFPM Ulf Hansson = wrote: > > On Fri, 15 Sept 2023 at 11:44, Victor Shih wrot= e: > > > > From: Victor Shih > > > > This is a sdhci version of mmc's uhs2_set_reg operation. > > UHS-II interface (related registers) will be initialised here. > > Please clarify this. It's not entirely easy to understand what goes on > by reading the commit message above. > > Again, the similar comments as I provided for patch15 applies to > $subject patch too. > Hi, Ulf I will merge patch#15, patch#16 and patch#17 into one patch(patch#15) for version 13. Thanks, Victor Shih > > > > Signed-off-by: Ben Chuang > > Signed-off-by: AKASHI Takahiro > > Signed-off-by: Victor Shih > > Acked-by: Adrian Hunter > > --- > > > > Updates in V8: > > - Reorder the definitions and lose the parentheses in > > sdhci_uhs2_set_config(). > > - read_poll_timeout() to instead of read_poll_timeout_atomic() > > in sdhci_uhs2_check_dormant(). > > > > Updates in V7: > > - Remove unnecessary function. > > > > Updates in V6: > > - Remove unnecessary function. > > - Remove unnecessary parameter when call the DBG(). > > - Cancel export state of some functions. > > > > --- > > > > drivers/mmc/host/sdhci-uhs2.c | 88 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 88 insertions(+) > > > > diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs= 2.c > > index af1b0c5e48fd..09b86fec9f7b 100644 > > --- a/drivers/mmc/host/sdhci-uhs2.c > > +++ b/drivers/mmc/host/sdhci-uhs2.c > > @@ -278,6 +278,48 @@ static void __sdhci_uhs2_set_ios(struct mmc_host *= mmc, struct mmc_ios *ios) > > sdhci_set_clock(host, host->clock); > > } > > > > +static void sdhci_uhs2_set_config(struct sdhci_host *host) > > +{ > > + u32 value; > > + u16 sdhci_uhs2_set_ptr =3D sdhci_readw(host, SDHCI_UHS2_SETTING= S_PTR); > > + u16 sdhci_uhs2_gen_set_reg =3D sdhci_uhs2_set_ptr; > > + u16 sdhci_uhs2_phy_set_reg =3D sdhci_uhs2_set_ptr + 4; > > + u16 sdhci_uhs2_tran_set_reg =3D sdhci_uhs2_set_ptr + 8; > > + u16 sdhci_uhs2_tran_set_1_reg =3D sdhci_uhs2_set_ptr + 12; > > + > > + /* Set Gen Settings */ > > + value =3D FIELD_PREP(SDHCI_UHS2_GEN_SETTINGS_N_LANES_MASK, host= ->mmc->uhs2_caps.n_lanes_set); > > + sdhci_writel(host, value, sdhci_uhs2_gen_set_reg); > > + > > + /* Set PHY Settings */ > > + value =3D FIELD_PREP(SDHCI_UHS2_PHY_N_LSS_DIR_MASK, host->mmc->= uhs2_caps.n_lss_dir_set) | > > + FIELD_PREP(SDHCI_UHS2_PHY_N_LSS_SYN_MASK, host->mmc->uh= s2_caps.n_lss_sync_set); > > + if (host->mmc->ios.timing =3D=3D MMC_TIMING_UHS2_SPEED_B || > > + host->mmc->ios.timing =3D=3D MMC_TIMING_UHS2_SPEED_B_HD) > > + value |=3D SDHCI_UHS2_PHY_SET_SPEED_B; > > + sdhci_writel(host, value, sdhci_uhs2_phy_set_reg); > > + > > + /* Set LINK-TRAN Settings */ > > + value =3D FIELD_PREP(SDHCI_UHS2_TRAN_RETRY_CNT_MASK, host->mmc-= >uhs2_caps.max_retry_set) | > > + FIELD_PREP(SDHCI_UHS2_TRAN_N_FCU_MASK, host->mmc->uhs2_= caps.n_fcu_set); > > + sdhci_writel(host, value, sdhci_uhs2_tran_set_reg); > > + sdhci_writel(host, host->mmc->uhs2_caps.n_data_gap_set, sdhci_u= hs2_tran_set_1_reg); > > +} > > + > > +static int sdhci_uhs2_check_dormant(struct sdhci_host *host) > > +{ > > + int timeout =3D 100000; /* 100ms */ > > Define. > Hi, Ulf I will update this in version 13. Thanks, Victor Shih > > + u32 val; > > + > > + if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_IN_DO= RMANT_STATE), > > + 100, timeout, true, host, SDHCI_PRESENT_S= TATE)) { > > + pr_warn("%s: UHS2 IN_DORMANT fail in 100ms.\n", mmc_hos= tname(host->mmc)); > > + sdhci_dumpregs(host); > > + return -EIO; > > + } > > + return 0; > > +} > > + > > /*********************************************************************= ********\ > > * = * > > * MMC callbacks = * > > @@ -359,6 +401,51 @@ static int sdhci_uhs2_enable_clk(struct mmc_host *= mmc) > > return 0; > > } > > > > +static int sdhci_uhs2_do_detect_init(struct mmc_host *mmc); > > Please re-order the code so this declaration isn't needed. And make it > part of the patch that introduced the function, not in the $subject > patch. > Hi, Ulf I will update this in version 13. Thanks, Victor Shih > > + > > +static int sdhci_uhs2_control(struct mmc_host *mmc, enum sd_uhs2_opera= tion op) > > +{ > > + struct sdhci_host *host =3D mmc_priv(mmc); > > + struct mmc_ios *ios =3D &mmc->ios; > > + int err =3D 0; > > + > > + DBG("Begin uhs2 control, act %d.\n", op); > > + > > + switch (op) { > > + case UHS2_PHY_INIT: > > + err =3D sdhci_uhs2_do_detect_init(mmc); > > + break; > > + case UHS2_SET_CONFIG: > > + sdhci_uhs2_set_config(host); > > + break; > > + case UHS2_ENABLE_INT: > > + sdhci_uhs2_clear_set_irqs(host, 0, SDHCI_INT_CARD_INT); > > + break; > > + case UHS2_DISABLE_INT: > > + sdhci_uhs2_clear_set_irqs(host, SDHCI_INT_CARD_INT, 0); > > + break; > > + case UHS2_CHECK_DORMANT: > > + err =3D sdhci_uhs2_check_dormant(host); > > + break; > > + case UHS2_DISABLE_CLK: > > + err =3D sdhci_uhs2_disable_clk(mmc); > > + break; > > + case UHS2_ENABLE_CLK: > > + err =3D sdhci_uhs2_enable_clk(mmc); > > + break; > > + case UHS2_SET_IOS: > > + err =3D sdhci_uhs2_set_ios(mmc, ios); > > + break; > > + default: > > + pr_err("%s: input sd uhs2 operation %d is wrong!\n", > > + mmc_hostname(host->mmc), op); > > + err =3D -EIO; > > + break; > > + } > > + > > + return err; > > +} > > + > > /*********************************************************************= ********\ > > * = * > > * Driver init/exit = * > > @@ -481,6 +568,7 @@ static int sdhci_uhs2_host_ops_init(struct sdhci_ho= st *host) > > { > > host->mmc_host_ops.start_signal_voltage_switch =3D > > sdhci_uhs2_start_signal_voltage_switch; > > + host->mmc_host_ops.uhs2_control =3D sdhci_uhs2_control; > > > > return 0; > > } > > Kind regards > Uffe