Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp287509rdb; Tue, 31 Oct 2023 07:34:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIB1B5vhESh/5cXkYOeIHOENRUjFUmh5nLSDnOAYSYlFnBDZwknt9kgNrvvjdH8YxGgWSW X-Received: by 2002:a17:902:f149:b0:1cc:337e:bd6d with SMTP id d9-20020a170902f14900b001cc337ebd6dmr7346807plb.68.1698762842075; Tue, 31 Oct 2023 07:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698762842; cv=none; d=google.com; s=arc-20160816; b=CCF3NCI0/R1Sud3Qgj+1POiHaLfZWwr/0gQD6IHkf9JlITXHwNAgONl4kX4HTq9w9B Xc1Yj+GF8zhoEJ30+b3KUqvAu9HsD7V8roEPKZl292vKt2hTEL5Ou8sK8+8Qs0lobLMP uA4rEktaHppmZq0hL2CQaB2TxtrsKMqDsCbfmGSHvOgg9TooR1jDh+1fF0A/OCOTDgv4 D78s/vflBq4PH/uHuZxQz99a4aFpOM7GccMfz15zE5/2ZcB4ZAjB54z24OK76fV7SRGj +4JuA3LOMm2+1CnkQ/9beJUua+Az1S73c96P6hNmliKioD6/YziK8z2MDP6jqz4as9GI PpvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:mime-version :references:in-reply-to:from:dkim-signature; bh=COgus/3ZSuwT+db+ge/hLLqZedK9bhS7aDmQpcwmeRs=; fh=L3sAS9rIAPetJrE918VRFcCQQAY8UAZiZXaHWXOVg+s=; b=mEyN5qY/ylo9Ughna+25WXaUuofk/mxLG4hI98H8c6KWjjHQc9aAxszWtyPJKRwEI/ NbFmUg5Ay0vV2X12/TK+DRp/XFMQkpgx2DKvuOXra7H0e5puYgKprzts6lpPOVQhM2Dc YMpUM3edcLumZzB/qH9+v2zrcV3uG3GuVoDdHgW8PE3ytFm8eY2ENjSmhoujBKIQpSi3 2Jij/y1JIhJyPugxsDfsnlax72KIIFypYlj/qbfCOTM+Ol9cVE+dxQgkZd2xRWCc3bEO PB1IF52SbWwKGYKTCaiRdvJ6pgzSPhqNB2t9WrNOqtW439ICVF9r0gaEeE6j9c7ScoxI Oh6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=pKRxZ27g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h2-20020a170902f54200b001cc4fbe9281si1072213plf.582.2023.10.31.07.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=pKRxZ27g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E58E6801D489; Tue, 31 Oct 2023 07:34:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344314AbjJaOeA (ORCPT + 99 others); Tue, 31 Oct 2023 10:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344241AbjJaOd7 (ORCPT ); Tue, 31 Oct 2023 10:33:59 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F79ED for ; Tue, 31 Oct 2023 07:33:57 -0700 (PDT) Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8A45740945 for ; Tue, 31 Oct 2023 14:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698762834; bh=COgus/3ZSuwT+db+ge/hLLqZedK9bhS7aDmQpcwmeRs=; h=From:In-Reply-To:References:Mime-Version:Date:Message-ID:Subject: To:Cc:Content-Type; b=pKRxZ27g12d3CP7xd6GzxzNtCroWm+aae+LdfT2U0ihVagT1f4aJiY1oEp7fMssce m4uWhxgtXGFWp0Yupeln1XmvGtpem/CGS37nNvNc46JXc/WgkynCZEtincrTbMCFF7 uqnMHWDrtrbF3Yzoxe7bpqv5pbfIeVkp56exvn0gOvqNRBsYuWz1iKsyCiviLou0NE /VifAcQ5WrAFR/zFYNtZ/vImPQAHx7ZqGB0zw/dIBkI92ujQWCCoeFijDpwOPHCTPN Qzm1LMGWNbDVc10Q7qchFVNHRKpaoKhwXKab5VwfeJcycqOGCW54OWU9Yo199Vd1l4 KvT016xtXy7gQ== Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-66d24cdf232so73629426d6.1 for ; Tue, 31 Oct 2023 07:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698762831; x=1699367631; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=COgus/3ZSuwT+db+ge/hLLqZedK9bhS7aDmQpcwmeRs=; b=wXi5evO7ZLZVj2pgbRgZWG3ng3e/Iss3kefklCItH3/gZ1KxgdauzqxANsmne8NRUx AYVEyABJtTM8hF3+f4w6EIb5LgbJkQ6rhFvw3Anc2U5vQFQdJDP1AmyWpRAels7noeDR cGnX15bMnTiCmGUl0Q2YDpgl6LjJND0dpbmhB4b39bJutqnhtBsq+pp0EUnZnqAzuON3 w81EhpGmfrdh0TwKSSARU60GFWN0yX29sYZXk5hwb8ZCeeOHHGgHthTA99m6RnInIvSt yXVCOz2ZrKjDeKps/rw2Qz3rVFlKPo4GtvokoalcJeHvGs4XkkLv1lS/hTb3pb9b+QB8 4SMw== X-Gm-Message-State: AOJu0YyrIkdMNMPmbMrAjN3Pij7y8QY+9MmS6dDw7xe1BXXjIQWKFDZ3 uP/aTciVwLg9vezHx7x0O3lvenhaQ+Y5kYOyxF62uOET1SXbeKP8/U/xGs54wyfaItSbyYz27MR yrOPQpvojd83zEtFu5/Dsa3n2aaoBWIWMBSzTcoLmzaysNGZ2RWtGV5jftQ== X-Received: by 2002:a05:6214:29c7:b0:671:9c02:cba9 with SMTP id gh7-20020a05621429c700b006719c02cba9mr8520626qvb.51.1698762831404; Tue, 31 Oct 2023 07:33:51 -0700 (PDT) X-Received: by 2002:a05:6214:29c7:b0:671:9c02:cba9 with SMTP id gh7-20020a05621429c700b006719c02cba9mr8520611qvb.51.1698762831069; Tue, 31 Oct 2023 07:33:51 -0700 (PDT) Received: from 348282803490 named unknown by gmailapi.google.com with HTTPREST; Tue, 31 Oct 2023 07:33:50 -0700 From: Emil Renner Berthing In-Reply-To: <20231029042712.520010-6-cristian.ciocaltea@collabora.com> References: <20231029042712.520010-1-cristian.ciocaltea@collabora.com> <20231029042712.520010-6-cristian.ciocaltea@collabora.com> Mime-Version: 1.0 Date: Tue, 31 Oct 2023 07:33:50 -0700 Message-ID: Subject: Re: [PATCH v2 05/12] net: stmmac: dwmac-starfive: Add support for JH7100 SoC To: Cristian Ciocaltea , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Emil Renner Berthing , Samin Guo , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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]); Tue, 31 Oct 2023 07:34:01 -0700 (PDT) Cristian Ciocaltea wrote: > Add a missing quirk to enable support for the StarFive JH7100 SoC. > > Additionally, for greater flexibility in operation, allow using the > rgmii-rxid and rgmii-txid phy modes. > > Co-developed-by: Emil Renner Berthing > Signed-off-by: Emil Renner Berthing > Signed-off-by: Cristian Ciocaltea Hi Cristian, Thanks for working on this! This driver has code to update the phy clock for different line speeds. I don't think that will work without the CLK_SET_RATE_PARENT flag added to the clock in [1] which in turn depends on [2]. [1]: https://github.com/esmil/linux/commit/b200c3054b58a49ba25af67aff82d9045e3c3666 [2]: https://github.com/esmil/linux/commit/dce189542c16bf0eb8533d96c0305cb59d149dae Two more comments below.. > --- > drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 ++-- > .../ethernet/stmicro/stmmac/dwmac-starfive.c | 32 ++++++++++++++++--- > 2 files changed, 31 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig > index a2b9e289aa36..c3c2c8360047 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig > +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig > @@ -165,9 +165,9 @@ config DWMAC_STARFIVE > help > Support for ethernet controllers on StarFive RISC-V SoCs > > - This selects the StarFive platform specific glue layer support for > - the stmmac device driver. This driver is used for StarFive JH7110 > - ethernet controller. > + This selects the StarFive platform specific glue layer support > + for the stmmac device driver. This driver is used for the > + StarFive JH7100 and JH7110 ethernet controllers. > > config DWMAC_STI > tristate "STi GMAC support" > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > index 5d630affb4d1..88c431edcea0 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > @@ -15,13 +15,20 @@ > > #include "stmmac_platform.h" > > -#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 > -#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 > -#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U > +#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 > +#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 > +#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U > + > +#define JH7100_SYSMAIN_REGISTER49_DLYCHAIN 0xc8 > + > +struct starfive_dwmac_data { > + unsigned int gtxclk_dlychain; > +}; > > struct starfive_dwmac { > struct device *dev; > struct clk *clk_tx; > + const struct starfive_dwmac_data *data; > }; > > static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) > @@ -67,6 +74,8 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) > > case PHY_INTERFACE_MODE_RGMII: > case PHY_INTERFACE_MODE_RGMII_ID: > + case PHY_INTERFACE_MODE_RGMII_RXID: > + case PHY_INTERFACE_MODE_RGMII_TXID: > mode = STARFIVE_DWMAC_PHY_INFT_RGMII; > break; > > @@ -89,6 +98,14 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) > if (err) > return dev_err_probe(dwmac->dev, err, "error setting phy mode\n"); > > + if (dwmac->data) { I think you want something like this so future quirks don't need to touch this code: if (dwmac->data && dwmac->data->gtxclk_dlychain) > + err = regmap_write(regmap, JH7100_SYSMAIN_REGISTER49_DLYCHAIN, > + dwmac->data->gtxclk_dlychain); > + if (err) > + return dev_err_probe(dwmac->dev, err, > + "error selecting gtxclk delay chain\n"); > + } > + > return 0; > } > > @@ -114,6 +131,8 @@ static int starfive_dwmac_probe(struct platform_device *pdev) > if (!dwmac) > return -ENOMEM; > > + dwmac->data = device_get_match_data(&pdev->dev); > + > dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx"); > if (IS_ERR(dwmac->clk_tx)) > return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx), > @@ -144,8 +163,13 @@ static int starfive_dwmac_probe(struct platform_device *pdev) > return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); > } > > +static const struct starfive_dwmac_data jh7100_data = { > + .gtxclk_dlychain = 4 Please add a , at the end of this line. I know it's unlikely that we need to add more properties, but it's still good practice to do. This way such patches won't need to touch this line. > +}; > + > static const struct of_device_id starfive_dwmac_match[] = { > - { .compatible = "starfive,jh7110-dwmac" }, > + { .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data }, > + { .compatible = "starfive,jh7110-dwmac" }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, starfive_dwmac_match); > -- > 2.42.0 >