From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Lucas Tanure <tanure@linux.com>,
xianwei.zhao@amlogic.com, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/7] net: stmmac: dwmac-meson8b: let the controller apply the RGMII delays
Date: Wed, 7 Oct 2026 11:35:11 +0200 [thread overview]
Message-ID: <517a0416-3c48-4b38-865c-5c0b7e5bd143@bootlin.com> (raw)
In-Reply-To: <20261007082627.63807-2-tanure@linux.com>
Hi Lucas,
On 10/7/26 10:26, Lucas Tanure wrote:
> RGMII needs a delay on each of its two clocks. A board can get it from
> the length of its tracks, from the PHY, or from the controller.
> "rgmii-id" in the device tree says the delay is added inside the chips
> but not which chip adds it, and the generic tx-internal-delay-ps and
> rx-internal-delay-ps properties name the controller.
>
> This driver ignored those properties. In the "-id" modes it switched
> its own delays off and left the whole job to the PHY, so a board that
> asks the controller for one of them does not get it, and a board whose
> PHY cannot supply that delay has no usable link at all.
>
> Boards not using those properties behave as before.
>
> Assisted-by: LLM
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 46 ++++++++++++++++++-
> 1 file changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> index e4d5c41294f4..d73dfd0ac167 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> @@ -92,6 +92,8 @@ struct meson8b_dwmac {
> struct clk *rgmii_tx_clk;
> u32 tx_delay_ns;
> u32 rx_delay_ps;
> + bool mac_tx_delay;
> + bool mac_rx_delay;
> struct clk *timing_adj_clk;
> };
>
> @@ -299,6 +301,22 @@ static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
> delay_config = rx_adj_config;
> break;
> case PHY_INTERFACE_MODE_RGMII_ID:
> + /*
> + * "rgmii-id" only says the delays are internal, not which
> + * side applies them. The *-internal-delay-ps properties say
> + * it is this controller, so leave ours switched on.
> + */
> + if (dwmac->mac_tx_delay || dwmac->mac_rx_delay) {
> + delay_config = 0;
> + if (dwmac->mac_tx_delay)
> + delay_config |= tx_dly_config;
> + if (dwmac->mac_rx_delay)
> + delay_config |= rx_adj_config;
> + else
> + cfg_rxclk_dly = 0;
> + break;
> + }
> + fallthrough;
> case PHY_INTERFACE_MODE_RMII:
> delay_config = 0;
> cfg_rxclk_dly = 0;
> @@ -384,6 +402,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> struct plat_stmmacenet_data *plat_dat;
> struct stmmac_resources stmmac_res;
> struct meson8b_dwmac *dwmac;
> + u32 tx_delay_ps;
> int ret;
>
> ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> @@ -409,9 +428,13 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> dwmac->dev = &pdev->dev;
> dwmac->phy_mode = plat_dat->phy_interface;
>
> + /* the generic property is preferred over the vendor one */
> + if (!of_property_read_u32(pdev->dev.of_node, "tx-internal-delay-ps",
> + &tx_delay_ps))
> + dwmac->tx_delay_ns = tx_delay_ps / 1000;
> /* use 2ns as fallback since this value was previously hardcoded */
> - if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
> - &dwmac->tx_delay_ns))
> + else if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
> + &dwmac->tx_delay_ns))
> dwmac->tx_delay_ns = 2;
>
> /* RX delay defaults to 0ps since this is what many boards use */
> @@ -424,6 +447,25 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> dwmac->rx_delay_ps *= 1000;
> }
>
> + /*
> + * Each property names one clock this controller delays itself. The
> + * PHY must be asked for whatever is left, or the two would delay the
> + * same clock and push it past the window.
> + */
> + dwmac->mac_tx_delay = of_property_present(pdev->dev.of_node,
> + "tx-internal-delay-ps");
> + dwmac->mac_rx_delay = of_property_present(pdev->dev.of_node,
> + "rx-internal-delay-ps");
> +
> + if (dwmac->phy_mode == PHY_INTERFACE_MODE_RGMII_ID) {
> + if (dwmac->mac_tx_delay && dwmac->mac_rx_delay)
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII;
> + else if (dwmac->mac_tx_delay)
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII_RXID;
> + else if (dwmac->mac_rx_delay)
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII_TXID;
> + }
There's a helper for that :
phy_fix_phy_mode_for_mac_delays(), passed as parameters the mode, and wether the mac
inserts TX/RX delays, and it returns what you should hand out to the PHY :)
> +
> if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
> if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
> dev_err(dwmac->dev,
This looks better, thanks for this :)
Maxime
text:
Return-Path: <netdev+bounces-342286-maxime.chevallier=bootlin.com@vger.kernel.org>
Delivered-To: maxime.chevallier@bootlin.com
Received: from mail.galae.net ([172.22.1.253])
by 9e7fea892943 with LMTP
id gCS8EoUVxmqzXwwAtaWaaQ
(envelope-from <netdev+bounces-342286-maxime.chevallier=bootlin.com@vger.kernel.org>)
for <maxime.chevallier@bootlin.com>; Wed, 07 Oct 2026 11:48:53 +0200
X-Original-To: maxime.chevallier@bootlin.com
Received: from smtpin-01.galae.net (smtpin-01.galae.net [51.159.2.148])
(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 mail.galae.net (Postcow) with ESMTPS id D4A4611D500F1
for <maxime.chevallier@bootlin.com>; Wed, 7 Oct 2026 11:48:52 +0200 (CEST)
Authentication-Results: mail.galae.net;
dkim=pass header.d=bootlin.com header.s=dkim header.b="F6vLO8/J";
arc=pass ("subspace.kernel.org:s=arc-20240116:i=1");
dmarc=pass (policy=reject) header.from=bootlin.com;
spf=pass (mail.galae.net: domain of "netdev+bounces-342286-maxime.chevallier=bootlin.com@vger.kernel.org" designates 172.234.253.10 as permitted sender) smtp.mailfrom="netdev+bounces-342286-maxime.chevallier=bootlin.com@vger.kernel.org"
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com;
s=dkim; t=1791366533;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:list-id:
list-unsubscribe:list-subscribe:dkim-signature;
bh=xQN3wQkVGd6JZIsxjTwgNRXi/qvLUOwJEvsQFsaSMuc=;
b=Qi6pce3VtYmTMb1Ew1UlNg9GwFxewjzDvcBgA6A6zaktaGT7lCXj5jhqjpT1R2Ilsfwv0Y
OQlrGc1i05r3RnxM3gyBfDwpqADD3N63DoWnitF8hQxKv6u0GGDZ//KgmKks/r0q7GbEA7
ifC3xuxbXqeGr58Kj7CrAiYiajgSb8i6rJoFQbUespcEZTVGOP0Gt6c+TKC4ryI675+slf
WFuTbc6/VkKMws+IKwUly81oufSb6RE2Blf4+ACVM278PGGoClgkZGyM2RcdhQMbZyH/b7
PLyxbH4NKFms3laoRWYWKzSgGxn0DKtzZv95P48YQrlnaxohc/ctxZCevf8lCg==
ARC-Authentication-Results: i=2;
mail.galae.net;
dkim=pass header.d=bootlin.com header.s=dkim header.b="F6vLO8/J";
arc=pass ("subspace.kernel.org:s=arc-20240116:i=1");
dmarc=pass (policy=reject) header.from=bootlin.com;
spf=pass (mail.galae.net: domain of "netdev+bounces-342286-maxime.chevallier=bootlin.com@vger.kernel.org" designates 172.234.253.10 as permitted sender) smtp.mailfrom="netdev+bounces-342286-maxime.chevallier=bootlin.com@vger.kernel.org"
ARC-Seal: i=2; s=dkim; d=bootlin.com; t=1791366533; a=rsa-sha256; cv=pass;
b=xWuimLhKlpaFMWkt2/Xr2UAD+5VCOeeOi/l924ahktq6WdC9XLcwTak4JbPDbW50jQTH+z
0Qlk3OOn9lq+YsLYHad64g6Xo+wu3B1DBPXIKlU+XAf/fQZLXL50AL+Z5AxwxjaoHGYcYL
zsUJFI+IpwrKk/dSCTj3m3eHQhb0Ney20tGchcBKXkX4MG4VEl2Fm5YDmrIqNvG0MFbSxp
HWKP4p8ECn/udbScNnXAnB1S7fpNrnUkupTzW8DRFF0Z9igjpyi5VJm7tY+GY1fEVDUIy3
J9BouEY42W5v4olMRLhFo7nIzcthtch429NIJbWXo/pxnIjHTvyWJEE9re960w==
Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by smtpin-01.galae.net (Postfix) with ESMTPS id 493643429DF
for <maxime.chevallier@bootlin.com>; Wed, 7 Oct 2026 09:48:52 +0000 (UTC)
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sea.lore.kernel.org (Postfix) with ESMTP id 26DD9456E0
for <maxime.chevallier@bootlin.com>; Wed, 7 Oct 2026 09:36:30 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C7EED47D45B;
Wed, 7 Oct 2026 09:35:41 +0000 (UTC)
X-Original-To: netdev@vger.kernel.org
Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84C02388369
for <netdev@vger.kernel.org>; Wed, 7 Oct 2026 09:35:27 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791365739; cv=none; b=h8PcMp5x/Fr/7hPhQ4dxsO1S7x33aa+qTZcdUnAZrixphIrgtiL9adJaCOF+gZfXzTLCkxGUPkaTpIwO/iaQQffJ7UnadVXqmxr6ajsPik4xueFznUW+XGwH01fCPO8mr6/Hia+F/KM6gZi2t/DXMECf3GtYg4nNZ3yrDXAeh2w=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791365739; c=relaxed/simple;
bh=HZ4Yai8hHKkjGNwF1DyF5ppHLfujuiudOKsOWhFEiMA=;
h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:
In-Reply-To:Content-Type; b=TPOvKSIPlj2Eq5eRFZ06xfenPpaEgaSamE+rGTEJt2oDqBapSyOdsCype5fctrgscFPh5WyZlQMwRXTbjH1zX5OFEJHzLlwcSmsYXLBdIpEYpFzMfLemCzSMuPixg1cAJ5+hFswUgHr+HMlVCTfygXK5Y2Fitr9Eqpn7zgbDlcs=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=F6vLO8/J; arc=none smtp.client-ip=185.246.84.56
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com
Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233])
by smtpout-02.galae.net (Postfix) with ESMTPS id 10CCD1A1152;
Wed, 7 Oct 2026 09:35:20 +0000 (UTC)
Received: from mail.galae.net (mail.galae.net [212.83.136.155])
by smtpout-01.galae.net (Postfix) with ESMTPS id D0BCE6074B;
Wed, 7 Oct 2026 09:35:19 +0000 (UTC)
Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9C9EC11D5006E;
Wed, 7 Oct 2026 11:35:12 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim;
t=1791365718; h=from:subject:date:message-id:to:cc:mime-version:content-type:
content-transfer-encoding:content-language:in-reply-to:references;
bh=xQN3wQkVGd6JZIsxjTwgNRXi/qvLUOwJEvsQFsaSMuc=;
b=F6vLO8/Jrxzbe/6VTfHp1fxHL49UWZ7bUNvCBV6S3aWj9qw4/Y+NYCnR+wXXtMVF21vtN8
6HO18hsdYrmSr3IcUe2mcYmZiNvV8UMqDzr+mA6xQj+34muF/6X8kXoalbJzvztH26FNBa
K5+OZbd3o0t/hlIz1fWptevr9i2LwGhB7MyPt4CWYzBcKhrRfHzLvkEgXBp/jTbEPTQObp
7oAGJRThN3DBQLRGYmhO2A1fjO10mSyM258NnQc7qDy09Vmq/uYJdtwgPHdNMHIZeMHZRC
JINJJrljNLVaiKtvTHsTbReOHINo7BhmDfAKbGYWXUNz9HNrGtFmjQExvdZfCQ==
Message-ID: <517a0416-3c48-4b38-865c-5c0b7e5bd143@bootlin.com>
Date: Wed, 7 Oct 2026 11:35:11 +0200
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [RFC PATCH v2 1/7] net: stmmac: dwmac-meson8b: let the controller
apply the RGMII delays
To: Lucas Tanure <tanure@linux.com>, xianwei.zhao@amlogic.com,
Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller"
<davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>, Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org,
linux-kernel@vger.kernel.org
References: <20261007082627.63807-1-tanure@linux.com>
<20261007082627.63807-2-tanure@linux.com>
Content-Language: en-US
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
In-Reply-To: <20261007082627.63807-2-tanure@linux.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Last-TLS-Session-Version: TLSv1.3
X-Last-TLS-Session-Version: TLSv1.3
X-Spamd-Result: default: False [-3.17 / 30.00];
SUSPICIOUS_RECIPS(1.50)[];
IP_REPUTATION_HAM(-1.41)[asn: 63949(-0.40), country: SG(-0.01), ip: 172.234.253.10(-1.00)];
BAYES_HAM(-1.09)[81.68%];
ARC_ALLOW(-1.00)[subspace.kernel.org:s=arc-20240116:i=1];
DMARC_POLICY_ALLOW(-0.50)[bootlin.com,reject];
R_DKIM_ALLOW(-0.20)[bootlin.com:s=dkim];
R_SPF_ALLOW(-0.20)[+ip4:172.234.253.10:c];
MAILLIST(-0.15)[generic];
MIME_GOOD(-0.10)[text/plain];
HAS_LIST_UNSUB(-0.01)[];
MX_GOOD(-0.01)[];
RECEIVED_HELO_LOCALHOST(0.00)[];
URIBL_BLOCKED(0.00)[bootlin.com:mid,bootlin.com:dkim,linux.com:email,sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns];
RCVD_TLS_LAST(0.00)[];
RCPT_MAILCOW_DOMAIN(0.00)[bootlin.com];
MAILCOW_DOMAIN_HEADER_FROM(0.00)[bootlin.com];
RCPT_COUNT_TWELVE(0.00)[21];
TO_DN_SOME(0.00)[];
FREEMAIL_TO(0.00)[linux.com,amlogic.com,lunn.ch,davemloft.net,kernel.org,redhat.com,linaro.org,baylibre.com,googlemail.com,gmail.com,foss.st.com];
MIME_TRACE(0.00)[0:+];
BCC(0.00)[];
FORGED_SENDER_MAILLIST(0.00)[];
TAGGED_FROM(0.00)[bounces-342286-maxime.chevallier=bootlin.com];
RBL_SENDERSCORE_REPUT_BLOCKED(0.00)[172.234.253.10:from];
DKIM_TRACE(0.00)[bootlin.com:+];
DNSWL_BLOCKED(0.00)[185.246.84.56:received,100.90.174.1:received,172.234.253.10:from,212.83.139.233:received,212.83.136.155:received];
NEURAL_HAM(-0.00)[-1.000];
PRECEDENCE_BULK(0.00)[];
FROM_HAS_DN(0.00)[];
FROM_NEQ_ENVFROM(0.00)[maxime.chevallier@bootlin.com,netdev@vger.kernel.org];
ARC_SIGNED(0.00)[bootlin.com:s=dkim:i=2];
MID_RHS_MATCH_FROM(0.00)[];
TAGGED_RCPT(0.00)[netdev,dt];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
DWL_DNSWL_BLOCKED(0.00)[bootlin.com:dkim];
ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG];
RCVD_VIA_SMTP_AUTH(0.00)[];
EXTERNAL_RELAY_AUTHENTICATED(0.00)[];
RCVD_COUNT_SEVEN(0.00)[7]
X-Rspamd-Queue-Id: D4A4611D500F1
Hi Lucas,
On 10/7/26 10:26, Lucas Tanure wrote:
> RGMII needs a delay on each of its two clocks. A board can get it from
> the length of its tracks, from the PHY, or from the controller.
> "rgmii-id" in the device tree says the delay is added inside the chips
> but not which chip adds it, and the generic tx-internal-delay-ps and
> rx-internal-delay-ps properties name the controller.
>
> This driver ignored those properties. In the "-id" modes it switched
> its own delays off and left the whole job to the PHY, so a board that
> asks the controller for one of them does not get it, and a board whose
> PHY cannot supply that delay has no usable link at all.
>
> Boards not using those properties behave as before.
>
> Assisted-by: LLM
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 46 ++++++++++++++++++-
> 1 file changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> index e4d5c41294f4..d73dfd0ac167 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> @@ -92,6 +92,8 @@ struct meson8b_dwmac {
> struct clk *rgmii_tx_clk;
> u32 tx_delay_ns;
> u32 rx_delay_ps;
> + bool mac_tx_delay;
> + bool mac_rx_delay;
> struct clk *timing_adj_clk;
> };
>
> @@ -299,6 +301,22 @@ static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
> delay_config = rx_adj_config;
> break;
> case PHY_INTERFACE_MODE_RGMII_ID:
> + /*
> + * "rgmii-id" only says the delays are internal, not which
> + * side applies them. The *-internal-delay-ps properties say
> + * it is this controller, so leave ours switched on.
> + */
> + if (dwmac->mac_tx_delay || dwmac->mac_rx_delay) {
> + delay_config = 0;
> + if (dwmac->mac_tx_delay)
> + delay_config |= tx_dly_config;
> + if (dwmac->mac_rx_delay)
> + delay_config |= rx_adj_config;
> + else
> + cfg_rxclk_dly = 0;
> + break;
> + }
> + fallthrough;
> case PHY_INTERFACE_MODE_RMII:
> delay_config = 0;
> cfg_rxclk_dly = 0;
> @@ -384,6 +402,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> struct plat_stmmacenet_data *plat_dat;
> struct stmmac_resources stmmac_res;
> struct meson8b_dwmac *dwmac;
> + u32 tx_delay_ps;
> int ret;
>
> ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> @@ -409,9 +428,13 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> dwmac->dev = &pdev->dev;
> dwmac->phy_mode = plat_dat->phy_interface;
>
> + /* the generic property is preferred over the vendor one */
> + if (!of_property_read_u32(pdev->dev.of_node, "tx-internal-delay-ps",
> + &tx_delay_ps))
> + dwmac->tx_delay_ns = tx_delay_ps / 1000;
> /* use 2ns as fallback since this value was previously hardcoded */
> - if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
> - &dwmac->tx_delay_ns))
> + else if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
> + &dwmac->tx_delay_ns))
> dwmac->tx_delay_ns = 2;
>
> /* RX delay defaults to 0ps since this is what many boards use */
> @@ -424,6 +447,25 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> dwmac->rx_delay_ps *= 1000;
> }
>
> + /*
> + * Each property names one clock this controller delays itself. The
> + * PHY must be asked for whatever is left, or the two would delay the
> + * same clock and push it past the window.
> + */
> + dwmac->mac_tx_delay = of_property_present(pdev->dev.of_node,
> + "tx-internal-delay-ps");
> + dwmac->mac_rx_delay = of_property_present(pdev->dev.of_node,
> + "rx-internal-delay-ps");
> +
> + if (dwmac->phy_mode == PHY_INTERFACE_MODE_RGMII_ID) {
> + if (dwmac->mac_tx_delay && dwmac->mac_rx_delay)
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII;
> + else if (dwmac->mac_tx_delay)
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII_RXID;
> + else if (dwmac->mac_rx_delay)
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII_TXID;
> + }
There's a helper for that :
phy_fix_phy_mode_for_mac_delays(), passed as parameters the mode, and wether the mac
inserts TX/RX delays, and it returns what you should hand out to the PHY :)
> +
> if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
> if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
> dev_err(dwmac->dev,
This looks better, thanks for this :)
Maxime
next prev parent reply other threads:[~2026-10-13 17:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 8:26 [RFC PATCH v2 0/7] Add ethernet support for the Amlogic T7 Lucas Tanure
2026-10-07 8:26 ` [RFC PATCH v2 1/7] net: stmmac: dwmac-meson8b: let the controller apply the RGMII delays Lucas Tanure
2026-10-07 9:35 ` Maxime Chevallier [this message]
2026-10-07 12:58 ` Andrew Lunn
2026-10-07 8:26 ` [RFC PATCH v2 2/7] dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations Lucas Tanure
2026-10-07 8:26 ` [RFC PATCH v2 3/7] dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac Lucas Tanure
2026-10-07 9:51 ` Conor Dooley
2026-10-07 10:34 ` Lucas Tanure
2026-10-07 12:59 ` Conor Dooley
2026-10-07 12:35 ` Neil Armstrong
2026-10-07 13:07 ` Andrew Lunn
2026-10-07 13:06 ` Andrew Lunn
2026-10-07 8:26 ` [RFC PATCH v2 4/7] net: stmmac: dwmac-meson8b: add support for the Amlogic T7 Lucas Tanure
2026-10-07 9:36 ` Maxime Chevallier
2026-10-07 8:26 ` [RFC PATCH v2 5/7] arm64: dts: amlogic: t7: add the ethernet pinctrl nodes Lucas Tanure
2026-10-07 8:26 ` [RFC PATCH v2 6/7] arm64: dts: amlogic: t7: add the ethernet controller Lucas Tanure
2026-10-07 13:12 ` Andrew Lunn
2026-10-07 13:34 ` Maxime Chevallier
2026-10-09 5:52 ` Lucas Tanure
2026-10-07 8:26 ` [RFC PATCH v2 7/7] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port Lucas Tanure
2026-10-07 13:01 ` [RFC PATCH v2 0/7] Add ethernet support for the Amlogic T7 Andrew Lunn
2026-10-09 5:59 ` Lucas Tanure
2026-10-09 12:13 ` Andrew Lunn
2026-10-09 20:52 ` Lucas Tanure
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=517a0416-3c48-4b38-865c-5c0b7e5bd143@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=tanure@linux.com \
--cc=xianwei.zhao@amlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®