Article View: linux.kernel.netdev
Article #108[RFC PATCH v2 1/7] net: stmmac: dwmac-meson8b: let the controller apply the RGMII delays
From: Lucas Tanure
Date: Wed, 07 Oct 2026 08:26
Date: Wed, 07 Oct 2026 08:26
108 lines
10754 bytes
10754 bytes
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;
+ }
+
if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
dev_err(dwmac->dev,
--
2.56.0
Technical Details
Message-ID:
<20261007082627.63807-2-tanure@linux.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342249-linux-kernel-netdev=dewy.ruReferences:
<20261007082627.63807-1-tanure@linux.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342249-linux-kernel-netdev=dewy.ru
From: tanure@linux.com (Lucas Tanure)
Newsgroups: linux.kernel.netdev
Subject: [RFC PATCH v2 1/7] net: stmmac: dwmac-meson8b: let the controller apply the RGMII delays
Date: Wed, 7 Oct 2026 09:26:21 +0100
Organization: Usenet Network
Message-ID: <20261007082627.63807-2-tanure@linux.com>
References: <20261007082627.63807-1-tanure@linux.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="608311"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:f034/tbQFSLVV+5AkQHJpViUo+4= sha256:8rR8jzkinQnbm2uM7zcqWPReasY85nBznpR7baWv2Q4=
sha1:YOtN16TephmjkwDjyTkHqz26YsM= sha256:uRZoaIeoj9NGAso73Pg63dlD0wkPoNYb1gpnJdBc+cQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id A1C7710F10E; Wed, 7 Oct 2026 11:28:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.651
X-Spam-Status: No, score=-0.651 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id O4YUhYAPzIwK;
Wed, 7 Oct 2026 11:28:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-342249-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id B550910F108; Wed, 7 Oct 2026 11:28:53 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sea.lore.kernel.org (Postfix) with ESMTP id 0DE0A2AF56; Wed, 7 Oct 2026 08:26:35 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 96E6E44AB73;
Wed, 7 Oct 2026 08:26:33 +0000 (UTC)
X-Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC2CA43E4B0
for <netdev@vger.kernel.org>; Wed, 7 Oct 2026 08:26:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791361593; cv=none; b=qNOstNDh9Klb44ZQKe1HnYWUSMz9nWeE8H5oZ77sJIXULffYCxdMJtfq+XVMm4s/EQV+uJ7YAFaJjLHbDv+6vDkVjvRJED7ldI/fz6g4hqfmftdkPOnlZ1mKvdPoGnnlPaKKTK+L+FQo9IWUeM1ORBVn+F4wYx21mgeKYUAVXD8=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791361593; c=relaxed/simple;
bh=vpIj2UvLb9aw8rcNInqkcoO/0+5t9pSXrN9HKJ6PL/s=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version; b=ESUf+p3jJSkyl8BA0vVp2AKfo7m4lgp5BLrAEjAXPD7A9JQblGHrGXPEzj3fPm+avBQ/q0RVUP6S5fpbPXWT6Nt1foGeJldz1SvWNJJvlFfS8U77AbYjRzc1gTVVMMUckhoNYUu15AtahQNdAyGIKMvda97ofKlkSp2OPS9not0=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.50
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-48afcd7ba9bso890255f8f.3
for <netdev@vger.kernel.org>; Wed, 07 Oct 2026 01:26:31 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791361590; x=1791966390;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=qQePSOktcZsNwbFN9JzDoxNSE7kDsX9flymDNSHZKFQ=;
b=JwwgyrLdL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TP id ffacd0b85a97d-48c7289c820mr3137268f8f.47.1791361589960;
Wed, 07 Oct 2026 01:26:29 -0700 (PDT)
X-Received: from threads.localdomain ([84.70.176.222])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48c71d3b502sm4251370f8f.52.2026.10.07.01.26.29
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 07 Oct 2026 01:26:29 -0700 (PDT)
X-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
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261007082627.63807-1-tanure@linux.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>