Skip to contentSkip to conversation

Add ethernet support for the Amlogic T7

PATCH Superseded Lucas Tanure 5 participants 28 messages Oct 10 – Oct 22

Subsystems (6)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add ethernet support for the Amlogic T7

The T7 pairs a Synopsys gigabit MAC with the same glue registers the G12A has, but nothing described it. This adds the binding, the driver support and the device tree nodes, and enables the port on the Khadas VIM4.

Two clocks set the T7 apart from the G12A. The controller reaches DRAM through a pipeline stage with a gate of its own, sys_ampipe_eth; nothing else claims it, so clk_disable_unused switches it off and transfers stop. The glue registers sit in a block gated by sys_ethphy, so far owned only by the MDIO multiplexer, which probes after the controller has programmed them. Every write to PRG_ETH0/1 was lost and the port ran on the bootloader's values; v2 passed my tests only because a debug knob rewrote the register later. The T7 node now owns that clock as "pclk", which the stmmac core enables before any glue code runs.

The RGMII delays stay as in v2: phy-mode describes the board, so the VIM4 is rgmii-id, and the controller adds the transmit delay because the RTL8211F transmit delay does not work on this board. A sweep of the controller's receive delay against the CRC counter puts the PHY receive delay where it should be, about 2.2ns, while the transmit side never gave a clean link. As Andrew asked, this logic now lives in a T7-only path, so no other board changes behaviour.

Patch 8 is generic: a table in the informative section of ethernet-controller.yaml showing who adds each delay for every phy-mode and property combination. It is independent of the rest and can be taken separately.

Tested on next-20261002 with "clk: meson: t7: keep the memory fabric clocks running" (clk-meson-next) on top: 933/935Mbit/s with iperf3, 5s each way, no CRC error in 432k frames, nothing written by hand.

Overlaps with Xianwei Zhao's "[PATCH v2 0/3] t7: add some nodes for Amlogc t7.", which defines amlogic,t7-dwmac with the axg fallback and three clocks. I will drop or rebase whatever overlaps once we agree.

Changes since v2:
- the controller-side delays are applied on a T7-only path instead of changing every Amlogic board (Andrew); the PHY mode left over comes from phy_fix_phy_mode_for_mac_delays() (Maxime)
- tx-internal-delay-ps is checked against the four values the hardware has, in the binding and in the driver, instead of being truncated (Sashiko)
- amlogic,tx-delay-ns and amlogic,rx-delay-ns are not valid for the T7 (Neil, Andrew)
- the on-chip PHY no longer carries max-speed, phylib reads what the chip reports (Andrew); same for the RTL8211F on the VIM4
- the PHY interrupt line, GPIOH_6, is described on the VIM4 (Sashiko)
- new: the T7 node owns sys_ethphy as "pclk", see above
- new patch 8: the delay ownership table in ethernet-controller.yaml
- no longer RFC
- Conor's Acked-by dropped from patch 2 and Neil's Reviewed-by from patch 6, as both patches changed. Patches 1, 3 and 5 only moved in the series, so their tags stay.

Changes since v1:
- new patch 1: honour tx-internal-delay-ps and rx-internal-delay-ps in the rgmii-*id modes, and pass the PHY whatever delay is left over
- vim4: phy-mode rgmii -> rgmii-id, and amlogic,tx-delay-ns plus rx-internal-delay-ps replaced by tx-internal-delay-ps = <2000>. Neil's Reviewed-by dropped from this one, the change is not cosmetic

Lucas Tanure (8):
dt-bindings: net: amlogic,meson-dwmac: list the compatible
combinations
dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac
net: stmmac: dwmac-meson8b: add support for the Amlogic T7
net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way
arm64: dts: amlogic: t7: add the ethernet pinctrl nodes
arm64: dts: amlogic: t7: add the ethernet controller
arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
dt-bindings: net: ethernet-controller: tabulate who adds the RGMII
delays

 .../bindings/net/amlogic,meson-dwmac.yaml     |  86 ++++++++++---
 .../bindings/net/ethernet-controller.yaml     |  18 +++
 .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts |  20 +++
 arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi   |  88 +++++++++++++
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   | 120 ++++++++++++++----
 5 files changed, 291 insertions(+), 41 deletions(-)
Signature · 1 line
2.56.0
#1 lore raw

PATCH v3 1/8 dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations

The compatible property only checks that the first entry is an Amlogic name and that "snps,dwmac" or "snps,dwmac-3.70a" appears somewhere in the list. It cannot express which fallbacks each SoC takes, so a SoC built on a different Synopsys core cannot be added without loosening the check for every other one.

List the combinations the device trees actually use: Meson6 and Meson8m2 fall back to "snps,dwmac" alone, the others also name the 3.70a core. The example used a two-entry form no device tree has, so give it the Meson GXBB combination.

---
 .../bindings/net/amlogic,meson-dwmac.yaml     | 30 +++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -15
index 5c91716d1f21..90ef79161ab1 100644
@@ -129,20 +129,20 @@ allOf:
 
 properties:
   compatible:
-    additionalItems: true
-    maxItems: 3
-    items:
-      - enum:
-          - amlogic,meson6-dwmac
-          - amlogic,meson8b-dwmac
-          - amlogic,meson8m2-dwmac
-          - amlogic,meson-gxbb-dwmac
-          - amlogic,meson-axg-dwmac
-          - amlogic,meson-g12a-dwmac
-    contains:
-      enum:
-        - snps,dwmac-3.70a
-        - snps,dwmac
+    oneOf:
+      - items:
+          - enum:
+              - amlogic,meson8b-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+          - const: snps,dwmac-3.70a
+          - const: snps,dwmac
+      - items:
+          - enum:
+              - amlogic,meson6-dwmac
+              - amlogic,meson8m2-dwmac
+          - const: snps,dwmac
 
   reg:
     items:
@@ -172,7 +172,7 @@ unevaluatedProperties: false
 examples:
   - |
     ethmac: ethernet@c9410000 {
-        compatible = "amlogic,meson-gxbb-dwmac", "snps,dwmac";
+        compatible = "amlogic,meson-gxbb-dwmac", "snps,dwmac-3.70a", "snps,dwmac";
         reg = <0xc9410000 0x10000>, <0xc8834540 0x8>;
         interrupts = <8>;
         interrupt-names = "macirq";
Signature · 1 line
2.56.0
#2 lore raw

Re: [PATCH v3 1/8] dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations

Hi Lucas and Conor,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 144

Quoted 11 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +11 -0
+          - enum:
+              - amlogic,meson8b-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+          - const: snps,dwmac-3.70a
+          - const: snps,dwmac
+      - items:
+          - enum:
+              - amlogic,meson6-dwmac
+              - amlogic,meson8m2-dwmac

Meson8m2 dwmac reports: User ID: 0x10, Synopsys ID: 0x37 In case it helps I can submit a patch to change the Meson8m2 .dtsi to use "amlogic,meson8m2-dwmac", "snps,dwmac-3.70a", "snps,dwmac" - then we could move it here too.
That leaves only Meson6 with a single fallback compatible. I don't have any Meson6 boards, so it'll have to stay that way.

Best regards,
Martin

#3 lore raw

Re: [PATCH v3 1/8] dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations

Quoted 16 lines · Martin Blumenstingl

Hi Lucas and Conor,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 144

Quoted 11 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +11 -0
+          - enum:
+              - amlogic,meson8b-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+          - const: snps,dwmac-3.70a
+          - const: snps,dwmac
+      - items:
+          - enum:
+              - amlogic,meson6-dwmac
+              - amlogic,meson8m2-dwmac
Quoted 6 lines

Meson8m2 dwmac reports: User ID: 0x10, Synopsys ID: 0x37 In case it helps I can submit a patch to change the Meson8m2 .dtsi to use "amlogic,meson8m2-dwmac", "snps,dwmac-3.70a", "snps,dwmac" - then we could move it here too.
That leaves only Meson6 with a single fallback compatible. I don't have any Meson6 boards, so it'll have to stay that way.

Hi,

Fine by me. But I think it is best to wait for this series to be merged. Lucas

Quoted 4 lines

Best regards,
Martin

#4 lore raw

Re: [PATCH v3 1/8] dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations

Quoted 24 lines · Lucas Tanure
Quoted 16 lines · Martin Blumenstingl

Hi Lucas and Conor,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 144

Quoted 11 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +11 -0
+          - enum:
+              - amlogic,meson8b-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+          - const: snps,dwmac-3.70a
+          - const: snps,dwmac
+      - items:
+          - enum:
+              - amlogic,meson6-dwmac
+              - amlogic,meson8m2-dwmac
Quoted 6 lines

Meson8m2 dwmac reports: User ID: 0x10, Synopsys ID: 0x37 In case it helps I can submit a patch to change the Meson8m2 .dtsi to use "amlogic,meson8m2-dwmac", "snps,dwmac-3.70a", "snps,dwmac" - then we could move it here too.
That leaves only Meson6 with a single fallback compatible. I don't have any Meson6 boards, so it'll have to stay that way.

Quoted 3 lines

Hi,

Fine by me. But I think it is best to wait for this series to be merged.

In the second sentence, you're referring to the dts patch I assume? IMO, you should submit a new version of this with the 8m2 moved to the other enum and Martin can submit the dts patch now, since the current binding permits using dwmac-3.70a, no need to wait for this to be merged.

#5 lore raw

Re: [PATCH v3 1/8] dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations

Quoted 27 lines · Conor Dooley
Quoted 26 lines · Lucas Tanure
Quoted 16 lines · Martin Blumenstingl

Hi Lucas and Conor,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 144

Quoted 11 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +11 -0
+          - enum:
+              - amlogic,meson8b-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+          - const: snps,dwmac-3.70a
+          - const: snps,dwmac
+      - items:
+          - enum:
+              - amlogic,meson6-dwmac
+              - amlogic,meson8m2-dwmac
Quoted 6 lines

Meson8m2 dwmac reports: User ID: 0x10, Synopsys ID: 0x37 In case it helps I can submit a patch to change the Meson8m2 .dtsi to use "amlogic,meson8m2-dwmac", "snps,dwmac-3.70a", "snps,dwmac" - then we could move it here too.
That leaves only Meson6 with a single fallback compatible. I don't have any Meson6 boards, so it'll have to stay that way.

Hi,

Quoted 7 lines
Quoted 1 line

Fine by me. But I think it is best to wait for this series to be merged.

In the second sentence, you're referring to the dts patch I assume? IMO, you should submit a new version of this with the 8m2 moved to the other enum and Martin can submit the dts patch now, since the current binding permits using dwmac-3.70a, no need to wait for this to be merged.

Ok, I will move.
I will sent v4 with your Acked-by, since this is the change
you asked for. Tell me if you want it dropped instead and review the new patch instead.

#6 lore raw

PATCH v3 2/8 dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac

In reply to Lucas Tanure

The T7 has the same ethernet glue as the G12A, but needs two clocks of its own. The controller reaches memory through a pipeline stage with a gate of its own; nothing else claims it, so it is switched off as unused and the port can no longer finish a transfer. The glue registers sit in a block clocked together with the MDIO multiplexer, which only probes after the controller has programmed them: with the clock still off those writes are lost, and the port keeps whatever delays the bootloader left behind.

So the T7 gets its own clock list, without the timing adjustment clock it never uses. The delays follow ethernet-controller.yaml, so the vendor properties are not valid here.

Assisted-by LLM
---
 .../bindings/net/amlogic,meson-dwmac.yaml     | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +56 -0
index 90ef79161ab1..2353dd9181ed 100644
@@ -23,6 +23,7 @@ select:
           - amlogic,meson-gxbb-dwmac
           - amlogic,meson-axg-dwmac
           - amlogic,meson-g12a-dwmac
+          - amlogic,t7-dwmac
   required:
     - compatible
 
@@ -57,6 +58,56 @@ allOf:
             - const: clkin1
             - const: timing-adjustment
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,t7-dwmac
+    then:
+      properties:
+        clocks:
+          items:
+            - description: GMAC main clock
+            - description: First parent clock of the internal mux
+            - description: Second parent clock of the internal mux
+            - description:
+                clock of the pipeline stage inserted in the bus path between
+                the controller and the DRAM. Without it, the controller cannot
+                complete DMA transfers.
+            - description:
+                clock of the register block holding PRG_ETH0 and PRG_ETH1.
+                Without it, the block reads as zero and ignores writes.
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The TX delay is a quarter of the RGMII clock period per step,
+        # which is 2ns at 1Gbit/s.
+        tx-internal-delay-ps:
+          enum: [0, 2000, 4000, 6000]
+          default: 0
+
+        rx-internal-delay-ps:
+          default: 0
+
+  # Delay definitions for Meson8b and newer
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - amlogic,meson8b-dwmac
+              - amlogic,meson8m2-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+    then:
+      properties:
         amlogic,tx-delay-ns:
           enum: [0, 2, 4, 6]
           default: 2
@@ -106,6 +157,7 @@ allOf:
           contains:
             enum:
               - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
     then:
       properties:
         rx-internal-delay-ps:
@@ -143,6 +195,10 @@ properties:
               - amlogic,meson6-dwmac
               - amlogic,meson8m2-dwmac
           - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac
 
   reg:
     items:
Signature · 1 line
2.56.0
#7 lore raw

Re: [PATCH v3 2/8] dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac

Hi Lucas,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 93

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+        # The TX delay is a quarter of the RGMII clock period per step,
+        # which is 2ns at 1Gbit/s.
+        tx-internal-delay-ps:
+          enum: [0, 2000, 4000, 6000]
+          default: 0

Is 0 a valid value? Let's say we have:

    phy-mode = "rgmii-id";
    tx-internal-delay-ps = <0>
    rx-internal-delay-ps = <0>;

According to patch 8 this means: MAC is responsible for adding the delays - but it doesn't add any delays.
I'm not sure if this patch (removing 0 from the enum) or patch 8 need updating.

Best regards,
Martin

#8 lore raw

Re: [PATCH v3 2/8] dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac

Quoted 10 lines · Martin Blumenstingl

Hi Lucas,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 93

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+        # The TX delay is a quarter of the RGMII clock period per step,
+        # which is 2ns at 1Gbit/s.
+        tx-internal-delay-ps:
+          enum: [0, 2000, 4000, 6000]
+          default: 0
Quoted 7 lines

Is 0 a valid value? Let's say we have:

    phy-mode = "rgmii-id";
    tx-internal-delay-ps = <0>
    rx-internal-delay-ps = <0>;

According to patch 8 this means: MAC is responsible for adding the delays - but it doesn't add any delays.
I'm not sure if this patch (removing 0 from the enum) or patch 8 need updating.

Yes, you are right. I will remove 0 as a valid value in v4.

Thanks
Lucas

Quoted 4 lines

Best regards,
Martin

#9 lore raw

PATCH v3 3/8 net: stmmac: dwmac-meson8b: add support for the Amlogic T7

In reply to Lucas Tanure

The glue registers on the T7 are laid out exactly as the G12A ones, RX delay field included, so the T7 can reuse the G12A settings.

What it does not share is how the controller reaches memory. That path runs through a pipeline stage with a gate of its own, and no other device has any use for that gate. Nothing claims it, so it is switched off as unused and a transfer that has started can never finish.

Without that gate the controller cannot do DMA at all, so it is required rather than optional: a clear probe failure beats an undiagnosable hang later.

---
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +19 -0
index e4d5c41294f4..450f7b4b29a6 100644
@@ -81,6 +81,7 @@ struct meson8b_dwmac;
 struct meson8b_dwmac_data {
 	int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
 	bool has_prg_eth1_rgmii_rx_delay;
+	bool has_pipeline_clk;
 };
 
 struct meson8b_dwmac {
@@ -384,6 +385,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;
+	struct clk *pipeline_clk;
 	int ret;
 
 	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
@@ -443,6 +445,13 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 	if (IS_ERR(dwmac->timing_adj_clk))
 		return PTR_ERR(dwmac->timing_adj_clk);
 
+	if (dwmac->data->has_pipeline_clk) {
+		pipeline_clk = devm_clk_get_enabled(dwmac->dev, "pipeline");
+		if (IS_ERR(pipeline_clk))
+			return dev_err_probe(dwmac->dev, PTR_ERR(pipeline_clk),
+					     "missing pipeline clock\n");
+	}
+
 	ret = meson8b_init_rgmii_delays(dwmac);
 	if (ret)
 		return ret;
@@ -479,6 +488,12 @@ static const struct meson8b_dwmac_data meson_g12a_dwmac_data = {
 	.has_prg_eth1_rgmii_rx_delay = true,
 };
 
+static const struct meson8b_dwmac_data meson_t7_dwmac_data = {
+	.set_phy_mode = meson_axg_set_phy_mode,
+	.has_prg_eth1_rgmii_rx_delay = true,
+	.has_pipeline_clk = true,
+};
+
 static const struct of_device_id meson8b_dwmac_match[] = {
 	{
 		.compatible = "amlogic,meson8b-dwmac",
@@ -500,6 +515,10 @@ static const struct of_device_id meson8b_dwmac_match[] = {
 		.compatible = "amlogic,meson-g12a-dwmac",
 		.data = &meson_g12a_dwmac_data,
 	},
+	{
+		.compatible = "amlogic,t7-dwmac",
+		.data = &meson_t7_dwmac_data,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, meson8b_dwmac_match);
Signature · 1 line
2.56.0
reviewer Reviewed-by on v3 3/8
#10 lore raw

Re: [PATCH v3 3/8] net: stmmac: dwmac-meson8b: add support for the Amlogic T7

Quoted 9 lines · Lucas Tanure

The glue registers on the T7 are laid out exactly as the G12A ones, RX delay field included, so the T7 can reuse the G12A settings.

What it does not share is how the controller reaches memory. That path runs through a pipeline stage with a gate of its own, and no other device has any use for that gate. Nothing claims it, so it is switched off as unused and a transfer that has started can never finish.

Quoted 8 lines

Without that gate the controller cannot do DMA at all, so it is required rather than optional: a clear probe failure beats an undiagnosable hang later.

#11 lore raw

PATCH v3 4/8 net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way

In reply to Lucas Tanure

RGMII needs a delay on each of its two clocks. phy-mode says whether the board provides them with longer traces, and the generic tx-internal-delay-ps and rx-internal-delay-ps properties say this controller provides them. Whatever is left is the PHY's job.

The existing code reads phy-mode as naming the chip that adds the delay, which is the opposite, and it ignores both properties. Changing it would change every board already relying on it, so the T7 gets a path of its own and the rest stays as it is.

Assisted-by LLM
---
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   | 103 +++++++++++++-----
 1 file changed, 76 insertions(+), 27 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +76 -27
index 450f7b4b29a6..1861a0d45b2d 100644
@@ -82,6 +82,7 @@ struct meson8b_dwmac_data {
 	int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
 	bool has_prg_eth1_rgmii_rx_delay;
 	bool has_pipeline_clk;
+	bool mac_applies_dt_delays;
 };
 
 struct meson8b_dwmac {
@@ -272,6 +273,49 @@ static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac,
 					meson8b_clk_disable_unprepare, clk);
 }
 
+static int meson_dwmac_init_dt_delays(struct meson8b_dwmac *dwmac,
+				      struct plat_stmmacenet_data *plat_dat)
+{
+	struct device_node *np = dwmac->dev->of_node;
+	u32 tx_delay_ps = 0, rx_delay_ps = 0;
+	phy_interface_t phy_mode;
+	bool mac_tx, mac_rx;
+
+	mac_tx = !of_property_read_u32(np, "tx-internal-delay-ps", &tx_delay_ps);
+	mac_rx = !of_property_read_u32(np, "rx-internal-delay-ps", &rx_delay_ps);
+
+	/* one step is a quarter of the RGMII clock period, 2ns at 1Gbit/s */
+	if (tx_delay_ps > 6000 || tx_delay_ps % 2000)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "The RGMII TX delay must be 0, 2000, 4000 or 6000ps\n");
+
+	/* the RX delay line moves in 200ps steps and reaches 3000ps */
+	if (rx_delay_ps > 3000 || rx_delay_ps % 200)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "The RGMII RX delay range is 0..3000ps in 200ps steps\n");
+
+	phy_mode = phy_fix_phy_mode_for_mac_delays(dwmac->phy_mode, mac_tx,
+						   mac_rx);
+	if (phy_mode == PHY_INTERFACE_MODE_NA)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "Cannot provide the delays %s asks for\n",
+				     phy_modes(dwmac->phy_mode));
+
+	plat_dat->phy_interface = phy_mode;
+
+	meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TXDLY_MASK |
+				PRG_ETH0_ADJ_ENABLE | PRG_ETH0_ADJ_SETUP |
+				PRG_ETH0_ADJ_DELAY | PRG_ETH0_ADJ_SKEW,
+				FIELD_PREP(PRG_ETH0_TXDLY_MASK,
+					   tx_delay_ps / 2000));
+
+	meson8b_dwmac_mask_bits(dwmac, PRG_ETH1, PRG_ETH1_CFG_RXCLK_DLY,
+				FIELD_PREP(PRG_ETH1_CFG_RXCLK_DLY,
+					   rx_delay_ps / 200));
+
+	return 0;
+}
+
 static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
 {
 	u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
@@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 	dwmac->dev = &pdev->dev;
 	dwmac->phy_mode = plat_dat->phy_interface;
 
-	/* 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))
-		dwmac->tx_delay_ns = 2;
-
-	/* RX delay defaults to 0ps since this is what many boards use */
-	if (of_property_read_u32(pdev->dev.of_node, "rx-internal-delay-ps",
-				 &dwmac->rx_delay_ps)) {
-		if (!of_property_read_u32(pdev->dev.of_node,
-					  "amlogic,rx-delay-ns",
-					  &dwmac->rx_delay_ps))
-			/* convert ns to ps */
-			dwmac->rx_delay_ps *= 1000;
-	}
-
-	if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
-		if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
-			dev_err(dwmac->dev,
-				"The RGMII RX delay range is 0..3000ps in 200ps steps");
-			return -EINVAL;
+	if (!dwmac->data->mac_applies_dt_delays) {
+		/* 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))
+			dwmac->tx_delay_ns = 2;
+
+		/* RX delay defaults to 0ps since this is what many boards use */
+		if (of_property_read_u32(pdev->dev.of_node, "rx-internal-delay-ps",
+					 &dwmac->rx_delay_ps)) {
+			if (!of_property_read_u32(pdev->dev.of_node,
+						  "amlogic,rx-delay-ns",
+						  &dwmac->rx_delay_ps))
+				/* convert ns to ps */
+				dwmac->rx_delay_ps *= 1000;
 		}
-	} else {
-		if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) {
-			dev_err(dwmac->dev,
-				"The only allowed RGMII RX delays values are: 0ps, 2000ps");
-			return -EINVAL;
+
+		if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
+			if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
+				dev_err(dwmac->dev,
+					"The RGMII RX delay range is 0..3000ps in 200ps steps");
+				return -EINVAL;
+			}
+		} else {
+			if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) {
+				dev_err(dwmac->dev,
+					"The only allowed RGMII RX delays values are: 0ps, 2000ps");
+				return -EINVAL;
+			}
 		}
 	}
 
@@ -452,7 +498,10 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 					     "missing pipeline clock\n");
 	}
 
-	ret = meson8b_init_rgmii_delays(dwmac);
+	if (dwmac->data->mac_applies_dt_delays)
+		ret = meson_dwmac_init_dt_delays(dwmac, plat_dat);
+	else
+		ret = meson8b_init_rgmii_delays(dwmac);
 	if (ret)
 		return ret;
 
@@ -490,8 +539,8 @@ static const struct meson8b_dwmac_data meson_g12a_dwmac_data = {
 
 static const struct meson8b_dwmac_data meson_t7_dwmac_data = {
 	.set_phy_mode = meson_axg_set_phy_mode,
-	.has_prg_eth1_rgmii_rx_delay = true,
 	.has_pipeline_clk = true,
+	.mac_applies_dt_delays = true,
 };
 
 static const struct of_device_id meson8b_dwmac_match[] = {
Signature · 1 line
2.56.0
#12 lore raw

Re: [PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way

Hi Lucas,

$subject caught my eye because I didn't understand why there's a "T7 way" for adding RGMII delays since we should be following a standard. Patch 8/8 in this series documents the standard. Can you please find a more suitable $subject for this patch?

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_dwmac_probe(struct platform_device *pdev) · line 417

Quoted 11 lines

static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)

 {
        u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +0 -4
@@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
        dwmac->dev = &pdev->dev;
        dwmac->phy_mode = plat_dat->phy_interface;
 
-       /* 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))
-               dwmac->tx_delay_ns = 2;

The 2ns default value in case "amlogic,tx-delay-ns" is absent hasn't been necessary since commit 093d23db4fff ("ARM64: dts: amlogic: add the ethernet TX delay configuration").
That commit is part of v4.12. So boards using RGMII and a .dtb without that property haven't been updated in more than 9 years.

[...]

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_dwmac_probe(struct platform_device *pdev) · line 504

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +4 -1
-       ret = meson8b_init_rgmii_delays(dwmac);
+       if (dwmac->data->mac_applies_dt_delays)
+               ret = meson_dwmac_init_dt_delays(dwmac, plat_dat);
+       else
+               ret = meson8b_init_rgmii_delays(dwmac);

From the discussion in v2 I couldn't understand the overall way forward. I get that new compatible strings should not rely on old, incorrect behavior. But what's the path forward for the other SoCs?

[...]

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static const struct meson8b_dwmac_data meson_g12a_dwmac_data = { · line 543

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +1 -1
 static const struct meson8b_dwmac_data meson_t7_dwmac_data = {
        .set_phy_mode = meson_axg_set_phy_mode,
-       .has_prg_eth1_rgmii_rx_delay = true,
        .has_pipeline_clk = true,
+       .mac_applies_dt_delays = true,

This should be a callback function pointer (apply_delays or similar, to match set_phy_mode) unless there's a way to make older SoCs also follow the "correct" RGMII delay specification.

Best regards,
Martin

#13 lore raw

Re: [PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way

Quoted 6 lines · Martin Blumenstingl

Hi Lucas,

$subject caught my eye because I didn't understand why there's a "T7 way" for adding RGMII delays since we should be following a standard. Patch 8/8 in this series documents the standard. Can you please find a more suitable $subject for this patch?

Ok.

Quoted 10 lines · Lucas Tanure

[...]

Quoted 7 lines
  static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
  {
         u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +0 -0
@@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
         dwmac->dev = &pdev->dev;
         dwmac->phy_mode = plat_dat->phy_interface;
 
Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_dwmac_probe(struct platform_device *pdev) · line 417

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +0 -4
-       /* 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))
-               dwmac->tx_delay_ns = 2;

The 2ns default value in case "amlogic,tx-delay-ns" is absent hasn't been necessary since commit 093d23db4fff ("ARM64: dts: amlogic: add the ethernet TX delay configuration").
That commit is part of v4.12. So boards using RGMII and a .dtb without that property haven't been updated in more than 9 years.

Ok, so for v4 the code is moved probe into the function only the older SoCs use, so it is isolated there and the T7 path never sees it. We can drop it future patch.

Quoted 12 lines

[...]

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_dwmac_probe(struct platform_device *pdev) · line 504

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +4 -1
-       ret = meson8b_init_rgmii_delays(dwmac);
+       if (dwmac->data->mac_applies_dt_delays)
+               ret = meson_dwmac_init_dt_delays(dwmac, plat_dat);
+       else
+               ret = meson8b_init_rgmii_delays(dwmac);

From the discussion in v2 I couldn't understand the overall way forward.
I get that new compatible strings should not rely on old, incorrect behavior. But what's the path forward for the other SoCs?

[...]

Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static const struct meson8b_dwmac_data meson_g12a_dwmac_data = { · line 543

Quoted 5 lines
  static const struct meson8b_dwmac_data meson_t7_dwmac_data = {
         .set_phy_mode = meson_axg_set_phy_mode,
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +1 -1
-       .has_prg_eth1_rgmii_rx_delay = true,
         .has_pipeline_clk = true,
+       .mac_applies_dt_delays = true,

This should be a callback function pointer (apply_delays or similar, to match set_phy_mode) unless there's a way to make older SoCs also follow the "correct" RGMII delay specification.

Agreed. V4 will do it.>

Quoted 3 lines

Best regards,
Martin

Thanks
Lucas

#14 lore raw

Re: [PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way

In reply to Lucas Tanure

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c struct meson8b_dwmac_data { · line 85

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +1 -0
@@ -82,6 +82,7 @@ struct meson8b_dwmac_data {
 	int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
 	bool has_prg_eth1_rgmii_rx_delay;
 	bool has_pipeline_clk;
+	bool mac_applies_dt_delays;

Please can you invert this and call it broken delays.

We should make it clear that new devices should not set this, because it wrong, broken.

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +5 -0
+static int meson_dwmac_init_dt_delays(struct meson8b_dwmac *dwmac,
+				      struct plat_stmmacenet_data *plat_dat)
+{
+	struct device_node *np = dwmac->dev->of_node;
+	u32 tx_delay_ps = 0, rx_delay_ps = 0;

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, · line 290

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +10 -0
+	phy_interface_t phy_mode;
+	bool mac_tx, mac_rx;
+
+	mac_tx = !of_property_read_u32(np, "tx-internal-delay-ps", &tx_delay_ps);
+	mac_rx = !of_property_read_u32(np, "rx-internal-delay-ps", &rx_delay_ps);
+
+	/* one step is a quarter of the RGMII clock period, 2ns at 1Gbit/s */
+	if (tx_delay_ps > 6000 || tx_delay_ps % 2000)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "The RGMII TX delay must be 0, 2000, 4000 or 6000ps\n");

tx-internal-delay is not listed in amlogic,meson-dwmac.yaml. Please could you add it, and list the valid values.

Do you have access to the datasheet? Could you check these numbers are correct, because they are larger than typical. 4ns, and 6ns makes no sense, the RGMII standard only calls for 2ns.

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, · line 295

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +5 -0
+
+	/* the RX delay line moves in 200ps steps and reaches 3000ps */
+	if (rx_delay_ps > 3000 || rx_delay_ps % 200)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "The RGMII RX delay range is 0..3000ps in 200ps steps\n");

Please could you listing these values in the binding.

Also, mark that amlogic,tx-delay-ns & amlogic,rx-delay-ns are not valid for this compatible.

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, · line 298

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +3 -0
+
+	phy_mode = phy_fix_phy_mode_for_mac_delays(dwmac->phy_mode, mac_tx,
+						   mac_rx);

This is not correct. This function assumes mac_tx and mac_rx are Boolean values, the MAC is applying the full 2ns delay. However, if rx-internal-delay-ps is only providing 200ps, that is not true.

I would prefer you keep to the usual way of doing things. Allow the MAC to apply small tuning delays, but have the PHY do the 2ns. So don't make any modification to phy-mode.

Quoted 18 lines

static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac) {

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +0 -11
 	u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
@@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 	dwmac->dev = &pdev->dev;
 	dwmac->phy_mode = plat_dat->phy_interface;
 
-	/* 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))
-		dwmac->tx_delay_ns = 2;
-
-	/* RX delay defaults to 0ps since this is what many boards use */
-	if (of_property_read_u32(pdev->dev.of_node, "rx-internal-delay-ps",
-				 &dwmac->rx_delay_ps)) {
-		if (!of_property_read_u32(pdev->dev.of_node,
-					  "amlogic,rx-delay-ns",
-					  &dwmac->rx_delay_ps))

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_dwmac_probe(struct platform_device *pdev) · line 458

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +1 -9
-			/* convert ns to ps */
-			dwmac->rx_delay_ps *= 1000;
-	}
-
-	if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
-		if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
-			dev_err(dwmac->dev,
-				"The RGMII RX delay range is 0..3000ps in 200ps steps");
-			return -EINVAL;
+	if (!dwmac->data->mac_applies_dt_delays) {

I suggest you do this at a higher level. Either call this function if _broken_delay is set, or the other one.

Andrew

#15 lore raw

Re: [PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way

Quoted 10 lines · Andrew Lunn

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c struct meson8b_dwmac_data { · line 85

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +1 -0
@@ -82,6 +82,7 @@ struct meson8b_dwmac_data {
  	int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
  	bool has_prg_eth1_rgmii_rx_delay;
  	bool has_pipeline_clk;
+	bool mac_applies_dt_delays;

Please can you invert this and call it broken delays.

Quoted 2 lines

We should make it clear that new devices should not set this, because it wrong, broken.

Moved to a function for T7. And the previous SoCs have their own function which gets a comment that new SoCs must not use it.

Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +10 -0
+static int meson_dwmac_init_dt_delays(struct meson8b_dwmac *dwmac,
+				      struct plat_stmmacenet_data *plat_dat)
+{
+	struct device_node *np = dwmac->dev->of_node;
+	u32 tx_delay_ps = 0, rx_delay_ps = 0;
+	phy_interface_t phy_mode;
+	bool mac_tx, mac_rx;
+
+	mac_tx = !of_property_read_u32(np, "tx-internal-delay-ps", &tx_delay_ps);
+	mac_rx = !of_property_read_u32(np, "rx-internal-delay-ps", &rx_delay_ps);
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, · line 290

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +5 -0
+
+	/* one step is a quarter of the RGMII clock period, 2ns at 1Gbit/s */
+	if (tx_delay_ps > 6000 || tx_delay_ps % 2000)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "The RGMII TX delay must be 0, 2000, 4000 or 6000ps\n");

tx-internal-delay is not listed in amlogic,meson-dwmac.yaml. Please could you add it, and list the valid values.

Patch 2 of this series adds it to the T7 block with the valid values. That changes in v4, see below.

Quoted 4 lines

Do you have access to the datasheet? Could you check these numbers are correct, because they are larger than typical. 4ns, and 6ns makes no sense, the RGMII standard only calls for 2ns.

Yes. The field is not a delay line. It selects the phase of the TX clock sent to the PHY: 0, 1/4, 1/2 or 3/4 of the clock period. At 1Gbit/s that is 0, 2, 4 or 6ns, which is where the numbers come from (the existing amlogic,tx-delay-ns property lists the same four). Only 1/4 is a usable RGMII delay; 1/2 is an inverted clock and 3/4 is a 2ns lead. And since it is a fraction of the period, the 2ns is only true at 1Gbit/s, at 100Mbit/s the same setting is 10ns. I agree 4000 and 6000 make no sense.

Quoted 11 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, · line 295

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +5 -0
+
+	/* the RX delay line moves in 200ps steps and reaches 3000ps */
+	if (rx_delay_ps > 3000 || rx_delay_ps % 200)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "The RGMII RX delay range is 0..3000ps in 200ps steps\n");

Please could you listing these values in the binding.

Also, mark that amlogic,tx-delay-ns & amlogic,rx-delay-ns are not valid for this compatible.

The RX values are in patch 2 as well, the T7 shares the G12A list (0..3000ps in 200ps steps); v4 drops the 0. The two vendor properties are already rejected for the T7: they are only defined for the older compatibles and the schema has unevaluatedProperties: false. v4 adds an explicit "false" for both in the T7 block so that it is visible.

Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac, · line 298

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +3 -0
+
+	phy_mode = phy_fix_phy_mode_for_mac_delays(dwmac->phy_mode, mac_tx,
+						   mac_rx);

This is not correct. This function assumes mac_tx and mac_rx are Boolean values, the MAC is applying the full 2ns delay. However, if rx-internal-delay-ps is only providing 200ps, that is not true.

Quoted 4 lines

I would prefer you keep to the usual way of doing things. Allow the MAC to apply small tuning delays, but have the PHY do the 2ns. So don't make any modification to phy-mode.

OK. v4 does not touch phy-mode. rx-internal-delay-ps becomes the tuning the MAC adds on top, 200..3000ps. On the TX side the T7 has nothing small to offer, the only step is the 2ns phase, so v4 does not accept tx-internal-delay-ps on the T7 at all, in the binding and in the driver. The VIM4 then uses plain rgmii-id with the PHY adding both delays. That also removes the wrong claim in patch 7 that the RTL8211F TX delay does not work; the real cause was a bootloader value left in the glue register, details in my reply to Martin on patch 7.

Quoted 23 lines
Quoted 23 lines
  static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
  {
  	u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +0 -16
@@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
  	dwmac->dev = &pdev->dev;
  	dwmac->phy_mode = plat_dat->phy_interface;
 
-	/* 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))
-		dwmac->tx_delay_ns = 2;
-
-	/* RX delay defaults to 0ps since this is what many boards use */
-	if (of_property_read_u32(pdev->dev.of_node, "rx-internal-delay-ps",
-				 &dwmac->rx_delay_ps)) {
-		if (!of_property_read_u32(pdev->dev.of_node,
-					  "amlogic,rx-delay-ns",
-					  &dwmac->rx_delay_ps))
-			/* convert ns to ps */
-			dwmac->rx_delay_ps *= 1000;
-	}
-
-	if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static int meson8b_dwmac_probe(struct platform_device *pdev) · line 458

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +1 -4
-		if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
-			dev_err(dwmac->dev,
-				"The RGMII RX delay range is 0..3000ps in 200ps steps");
-			return -EINVAL;
+	if (!dwmac->data->mac_applies_dt_delays) {

I suggest you do this at a higher level. Either call this function if _broken_delay is set, or the other one.

Done through the callback. Probe makes one call, and the parsing of the vendor properties moves into the older function.

Quoted 2 lines

Andrew

#16 lore raw

PATCH v3 5/8 arm64: dts: amlogic: t7: add the ethernet pinctrl nodes

In reply to Lucas Tanure

The SoC brings its ethernet interface out on bank Z, but no pin groups were described, so a board had no way to hand those pins over to the MAC.

Describe them as the two sets a board actually needs: the nine pins the interface always uses, and the five extra ones RGMII adds for its wider data path.

---
 arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 30 +++++++++++++++++++++
 1 file changed, 30 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +30 -0
index 6894c06a836b..7bd53ec16607 100644
@@ -376,6 +376,36 @@ mux {
 					};
 				};
 
+				eth_pins: eth {
+					mux {
+						groups = "eth_mdio",
+							 "eth_mdc",
+							 "eth_rgmii_rx_clk",
+							 "eth_rx_dv",
+							 "eth_rxd0",
+							 "eth_rxd1",
+							 "eth_txen",
+							 "eth_txd0",
+							 "eth_txd1";
+						function = "eth";
+						drive-strength-microamp = <4000>;
+						bias-disable;
+					};
+				};
+
+				eth_rgmii_pins: eth-rgmii {
+					mux {
+						groups = "eth_rxd2_rgmii",
+							 "eth_rxd3_rgmii",
+							 "eth_rgmii_tx_clk",
+							 "eth_txd2_rgmii",
+							 "eth_txd3_rgmii";
+						function = "eth";
+						drive-strength-microamp = <4000>;
+						bias-disable;
+					};
+				};
+
 				i2c0_ao_d_pins: i2c0-ao-d {
 					mux {
 						groups = "i2c0_ao_sck_d",
Signature · 1 line
2.56.0
#17 lore raw

PATCH v3 6/8 arm64: dts: amlogic: t7: add the ethernet controller

In reply to Lucas Tanure

The SoC has a Synopsys gigabit MAC, glue registers for the interface type and clock timing, and a multiplexer that points the management bus at the on-chip 100M PHY or the external pins. None of it was described.

The controller reaches memory through a pipeline stage with its own gate that nothing else claims, so it is switched off as unused. The glue registers share a clock with the multiplexer, which probes only after the controller has programmed them: unless the controller holds that clock itself, the writes are lost and the port keeps the bootloader's delays.

The on-chip PHY follows the G12A; no board in tree uses it, so it is untested. It stays disabled for boards to enable.

Assisted-by LLM
---
 arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 58 +++++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +58 -0
index 7bd53ec16607..94ea22514501 100644
@@ -250,6 +250,33 @@ gic: interrupt-controller@fff01000 {
 			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
 		};
 
+		ethmac: ethernet@fdc00000 {
+			compatible = "amlogic,t7-dwmac",
+				     "snps,dwmac-5.10a",
+				     "snps,dwmac";
+			reg = <0x0 0xfdc00000 0x0 0x10000>,
+			      <0x0 0xfe024000 0x0 0x8>;
+			interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "macirq";
+			clocks = <&clkc_periphs CLKID_SYS_ETH>,
+				 <&scmi_clk CLKID_FCLK_DIV2>,
+				 <&mpll CLKID_MPLL2>,
+				 <&clkc_periphs CLKID_SYS_AMPIPE_ETH>,
+				 <&clkc_periphs CLKID_SYS_ETHPHY>;
+			clock-names = "stmmaceth", "clkin0", "clkin1", "pipeline",
+				      "pclk";
+			power-domains = <&pwrc PWRC_T7_ETH_ID>;
+			rx-fifo-depth = <4096>;
+			tx-fifo-depth = <2048>;
+			status = "disabled";
+
+			mdio0: mdio {
+				compatible = "snps,dwmac-mdio";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+		};
+
 		apb4: bus@fe000000 {
 			compatible = "simple-bus";
 			reg = <0x0 0xfe000000 0x0 0x480000>;
@@ -645,6 +672,37 @@ gpio_intc: interrupt-controller@4080 {
 					<10 11 12 13 14 15 16 17 18 19 20 21>;
 			};
 
+			eth_phy: mdio-multiplexer@28000 {
+				compatible = "amlogic,g12a-mdio-mux";
+				reg = <0x0 0x28000 0x0 0xa4>;
+				clocks = <&clkc_periphs CLKID_SYS_ETHPHY>,
+					 <&xtal>,
+					 <&scmi_clk CLKID_FCLK_50M>;
+				clock-names = "pclk", "clkin0", "clkin1";
+				mdio-parent-bus = <&mdio0>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				ext_mdio: mdio@0 {
+					reg = <0>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+				};
+
+				int_mdio: mdio@1 {
+					reg = <1>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					internal_ephy: ethernet-phy@8 {
+						compatible = "ethernet-phy-id0180.3301",
+							     "ethernet-phy-ieee802.3-c22";
+						interrupts = <GIC_SPI 340 IRQ_TYPE_LEVEL_HIGH>;
+						reg = <8>;
+					};
+				};
+			};
+
 			uart_a: serial@78000 {
 				compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart";
 				reg = <0x0 0x78000 0x0 0x18>;
Signature · 1 line
2.56.0
#18 lore raw

PATCH v3 7/8 arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port

In reply to Lucas Tanure

The board carries a Realtek RTL8211F gigabit PHY on the external management bus, connected to the MAC over RGMII.

Enable the controller, hand it the ethernet pins and point it at the PHY. RGMII needs a delay on each of its two clocks, and on this board both come from inside the chips, not from the board traces. The PHY adds the one on receive. Its transmit delay does not work here, so the controller adds that one.

The PHY interrupt output is wired to GPIOH_6, so link changes are reported instead of polled. The PHY reset is an RC network on the board, not a SoC pin, so there is no reset line to describe.

Assisted-by LLM
---
 .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +20 -0
index 0fa83362b417..c18bde02ac40 100644
@@ -14,6 +14,7 @@ / {
 	compatible = "khadas,vim4", "amlogic,a311d2", "amlogic,t7";
 
 	aliases {
+		ethernet0 = &ethmac;
 		serial0 = &uart_a;
 		mmc0 = &sd_emmc_c;
 		mmc1 = &sd_emmc_b;
@@ -256,6 +257,25 @@ xtal: xtal-clk {
 	};
 };
 
+&ethmac {
+	status = "okay";
+	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
+	pinctrl-names = "default";
+	phy-mode = "rgmii-id";
+	phy-handle = <&external_phy>;
+	tx-internal-delay-ps = <2000>;
+};
+
+&ext_mdio {
+	external_phy: ethernet-phy@0 {
+		/* Realtek RTL8211FD-CG */
+		reg = <0>;
+
+		interrupt-parent = <&gpio_intc>;
+		interrupts = <GPIOH_6 IRQ_TYPE_LEVEL_LOW>;
+	};
+};
+
 &i2c_m_ao_a {
 	status = "okay";
 	pinctrl-0 = <&i2c0_ao_d_pins>;
Signature · 1 line
2.56.0
#19 lore raw

Re: [PATCH v3 7/8] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Quoted 4 lines

RGMII needs a delay on each of its two clocks, and on this board both come from inside the chips, not from the board traces. The PHY adds the one on receive. Its transmit delay does not work here, so the controller adds that one.

[...]

arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 266

Quoted 7 lines

+&ethmac {

arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +6 -0
+       status = "okay";
+       pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
+       pinctrl-names = "default";
+       phy-mode = "rgmii-id";
+       phy-handle = <&external_phy>;
+       tx-internal-delay-ps = <2000>;

You're stating that RTL8211F's TX delay doesn't work but not explaining why. I haven't come across this behavior before and I'm worried that that's an issue with a batch of RTL8211F.
What if the previous/next batch of RTL8211F will have working TX delay again - wouldn't that mean 4ns delay in total unless the RTL8211F driver is changed?

#20 lore raw

Re: [PATCH v3 7/8] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port

Quoted 14 lines · Martin Blumenstingl

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Quoted 4 lines

RGMII needs a delay on each of its two clocks, and on this board both come from inside the chips, not from the board traces. The PHY adds the one on receive. Its transmit delay does not work here, so the controller adds that one.

[...]

arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 266

Quoted 7 lines

+&ethmac {

arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +6 -0
+       status = "okay";
+       pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
+       pinctrl-names = "default";
+       phy-mode = "rgmii-id";
+       phy-handle = <&external_phy>;
+       tx-internal-delay-ps = <2000>;
Quoted 6 lines

You're stating that RTL8211F's TX delay doesn't work but not explaining why. I haven't come across this behavior before and I'm worried that that's an issue with a batch of RTL8211F.
What if the previous/next batch of RTL8211F will have working TX delay again - wouldn't that mean 4ns delay in total unless the RTL8211F driver is changed?

Yes, you are right. After I understood I had a missing clock I re-tested the everything from scratch.

On the T7 the register block with PRG_ETH0/PRG_ETH1 sits behind a clock gate (the "pclk" clock in patches 2 and 6). My first tests ran before I knew about that gate: the block ignored every write and PRG_ETH0 kept the value the bootloader left there, 0x1621. Bit 5 of that value is the TX clock phase select, 1/4 cycle, which is 2ns at 1Gbit/s. So with "rgmii-id" the PHY added 2ns and the MAC added another 2ns nobody asked for, 4ns in total. The CRC errors from that made me believe the PHY TX delay was not working.

With the clock enabled and a plain "rgmii-id" node, no delay property:

PRG_ETH0 = 0x1601 (TX phase 0), PRG_ETH1 = 0x0 RTL8211F page 0xd08: reg 0x11 = 0x0109 (TX delay on),

                       reg 0x15 = 0x0019 (RX delay on)

iperf3: 940 Mbit/s board to PC, 943 Mbit/s PC to board, 0 retransmits 0 CRC errors on both ends

v4 drops tx-internal-delay-ps from the VIM4 node and the wrong sentence from the commit message. The PHY adds both delays, as the generic text expects.

Thanks
Lucas

#21 lore raw

PATCH v3 8/8 dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

In reply to Lucas Tanure

The informative section explains in prose how phy-mode, the delay properties in the MAC node and the mode handed to the PHY fit together, and says itself that developers often get this wrong. A reader has to work through several paragraphs before answering the one question they usually have: for this phy-mode and these properties, which part adds which delay.

Add a table that answers it at a glance, with one row for every combination the properties allow.

Assisted-by LLM
---
 .../bindings/net/ethernet-controller.yaml      | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +18 -0
index 1bafd687dcb1..bba27a9feb61 100644
@@ -339,6 +339,24 @@ additionalProperties: true
 # has added. Failure to remove the delay will result in a
 # non-functioning link.
 #
+# Put together, with the two properties in the MAC node, this is who
+# adds each delay:
+#
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC
+#
+# A property for a clock the PCB already delays is not in this table.
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.
+#
 # Sometimes there is a need to fine tune the delays. Often the MAC or
 # PHY can perform this fine tuning. In the MAC node, the Device Tree
 # properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should
Signature · 1 line
2.56.0
#22 lore raw

Re: [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

Hi Andrew, Hi Lucas,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 354

Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +10 -0
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC

We have some boards where the PCB traces result in part (1200ps) of the delay needed for RGMII (2000ps).
The remainder (800ps) has to be added by either PHY or MAC: the (RTL8211F) PHY can only generate 0 or 2000ps delay so the MAC has to take over.
For the three boards I have in mind, please see $ git grep rx-internal-delay-ps arch/arm64/boot/dts/amlogic/

Quoted 1 line

+# A property for a clock the PCB already delays is not in this table.

Can you please explain this sentence (I'm not a native English speaker)? How I interpret the sentence: The PCB may add delays but those are implicit and not part of the {rx,tx}-internal-delay-ps properties. If the delays added by the PCB don't cover the full 2ns requirement then either MAC or PHY need to add the remainder, see fine-tuning below.

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 358

Quoted 2 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +2 -0
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.

How can I differentiate between "fine tuning" and "mistake"?

Best regards,
Martin

#23 lore raw

Re: [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

Quoted 29 lines · Martin Blumenstingl

Hi Andrew, Hi Lucas,

On Sat, Oct 10, 2026 at 12:59 PM Lucas Tanure <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 354

Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +10 -0
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC

We have some boards where the PCB traces result in part (1200ps) of the delay needed for RGMII (2000ps).
The remainder (800ps) has to be added by either PHY or MAC: the (RTL8211F) PHY can only generate 0 or 2000ps delay so the MAC has to take over.
For the three boards I have in mind, please see $ git grep rx-internal-delay-ps arch/arm64/boot/dts/amlogic/

Quoted 1 line

+# A property for a clock the PCB already delays is not in this table.

Can you please explain this sentence (I'm not a native English speaker)? How I interpret the sentence: The PCB may add delays but those are implicit and not part of the {rx,tx}-internal-delay-ps properties. If the delays added by the PCB don't cover the full 2ns requirement then either MAC or PHY need to add the remainder, see fine-tuning below.

Quoted 7 lines

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 358

Quoted 2 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +2 -0
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.

How can I differentiate between "fine tuning" and "mistake"?

Best regards,
Martin

The patch is wrong. It assumes a present property moves the 2ns from the PHY to the MAC, and Andrew's reply on patch 4 says it does not. I am dropping it in v4.

thanks
Lucas

Acked-by on v3 8/8
#24 lore raw

Re: [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

In reply to Lucas Tanure
Quoted 7 lines · Lucas Tanure

The informative section explains in prose how phy-mode, the delay properties in the MAC node and the mode handed to the PHY fit together, and says itself that developers often get this wrong. A reader has to work through several paragraphs before answering the one question they usually have: for this phy-mode and these properties, which part adds which delay.

Quoted 5 lines

Add a table that answers it at a glance, with one row for every combination the properties allow.

Assisted-by LLM

If the net guys think this is valuable,

(although for something like this, us acking probably ain't needed, ehh?)

Quoted 36 lines
---
 .../bindings/net/ethernet-controller.yaml      | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +18 -0
index 1bafd687dcb1..bba27a9feb61 100644
@@ -339,6 +339,24 @@ additionalProperties: true
 # has added. Failure to remove the delay will result in a
 # non-functioning link.
 #
+# Put together, with the two properties in the MAC node, this is who
+# adds each delay:
+#
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC
+#
+# A property for a clock the PCB already delays is not in this table.
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.
+#
 # Sometimes there is a need to fine tune the delays. Often the MAC or
 # PHY can perform this fine tuning. In the MAC node, the Device Tree
 # properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should
Signature · 1 line
2.56.0
#25 lore raw

Re: [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

Quoted 8 lines · Conor Dooley
Quoted 7 lines · Lucas Tanure

The informative section explains in prose how phy-mode, the delay properties in the MAC node and the mode handed to the PHY fit together, and says itself that developers often get this wrong. A reader has to work through several paragraphs before answering the one question they usually have: for this phy-mode and these properties, which part adds which delay.

Quoted 9 lines
Quoted 5 lines

Add a table that answers it at a glance, with one row for every combination the properties allow.

Assisted-by LLM

If the net guys think this is valuable,

Thanks, but I will drop this patch as is wrong.> (although for something like this, us acking probably ain't needed,

Quoted 38 lines

ehh?)

Quoted 36 lines
---
  .../bindings/net/ethernet-controller.yaml      | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +18 -0
index 1bafd687dcb1..bba27a9feb61 100644
@@ -339,6 +339,24 @@ additionalProperties: true
  # has added. Failure to remove the delay will result in a
  # non-functioning link.
  #
+# Put together, with the two properties in the MAC node, this is who
+# adds each delay:
+#
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC
+#
+# A property for a clock the PCB already delays is not in this table.
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.
+#
  # Sometimes there is a need to fine tune the delays. Often the MAC or
  # PHY can perform this fine tuning. In the MAC node, the Device Tree
  # properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should
Signature · 1 line
2.56.0
reviewer Acked-by on v3 8/8
#26 lore raw

Re: [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

In reply to Lucas Tanure
Quoted 28 lines · Lucas Tanure

The informative section explains in prose how phy-mode, the delay properties in the MAC node and the mode handed to the PHY fit together, and says itself that developers often get this wrong. A reader has to work through several paragraphs before answering the one question they usually have: for this phy-mode and these properties, which part adds which delay.

Add a table that answers it at a glance, with one row for every combination the properties allow.

Assisted-by LLM
---
 .../bindings/net/ethernet-controller.yaml      | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +4 -0
index 1bafd687dcb1..bba27a9feb61 100644
@@ -339,6 +339,24 @@ additionalProperties: true
 # has added. Failure to remove the delay will result in a
 # non-functioning link.
 #
+# Put together, with the two properties in the MAC node, this is who
+# adds each delay:
+#
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 355

Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +10 -0
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC
+#

That would match how the HW is working on the A733 Allwinner too but I'm not entirely sure this is what Andrew had in mind from our previous discussion [1]. Adding him to the thread

[1]: https://lore.kernel.org/linux-sunxi/[email protected]/

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 362

Quoted 7 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +4 -0
+# A property for a clock the PCB already delays is not in this table.
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.
+#
 # Sometimes there is a need to fine tune the delays. Often the MAC or
 # PHY can perform this fine tuning. In the MAC node, the Device Tree
 # properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should
Quoted 3 lines
Signature · 1 line
2.56.0
Signature · 1 line
Jerome
#27 lore raw

Re: [PATCH v3 8/8] dt-bindings: net: ethernet-controller: tabulate who adds the RGMII delays

Quoted 47 lines · Jerome Brunet
Quoted 28 lines · Lucas Tanure

The informative section explains in prose how phy-mode, the delay properties in the MAC node and the mode handed to the PHY fit together, and says itself that developers often get this wrong. A reader has to work through several paragraphs before answering the one question they usually have: for this phy-mode and these properties, which part adds which delay.

Add a table that answers it at a glance, with one row for every combination the properties allow.

Assisted-by LLM
---
  .../bindings/net/ethernet-controller.yaml      | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +4 -0
index 1bafd687dcb1..bba27a9feb61 100644
@@ -339,6 +339,24 @@ additionalProperties: true
  # has added. Failure to remove the delay will result in a
  # non-functioning link.
  #
+# Put together, with the two properties in the MAC node, this is who
+# adds each delay:
+#
+#   phy-mode    tx-internal-delay-ps  rx-internal-delay-ps  TX delay    RX delay

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 355

Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +10 -0
+#   rgmii       -                     -                     PCB trace   PCB trace
+#   rgmii-id    -                     -                     PHY         PHY
+#   rgmii-id    present               -                     MAC         PHY
+#   rgmii-id    -                     present               PHY         MAC
+#   rgmii-id    present               present               MAC         MAC
+#   rgmii-txid  -                     -                     PHY         PCB trace
+#   rgmii-txid  present               -                     MAC         PCB trace
+#   rgmii-rxid  -                     -                     PCB trace   PHY
+#   rgmii-rxid  -                     present               PCB trace   MAC
+#

That would match how the HW is working on the A733 Allwinner too but I'm not entirely sure this is what Andrew had in mind from our previous discussion [1]. Adding him to the thread

[1]: https://lore.kernel.org/linux-sunxi/[email protected]/

Quoted 10 lines

Documentation/devicetree/bindings/net/ethernet-controller.yaml additionalProperties: true · line 362

Quoted 7 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +4 -0
+# A property for a clock the PCB already delays is not in this table.
+# It is either the fine tuning described next, or a mistake the MAC
+# should report as a fatal error.
+#
  # Sometimes there is a need to fine tune the delays. Often the MAC or
  # PHY can perform this fine tuning. In the MAC node, the Device Tree
  # properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should

Thanks, But I will drop this as it is wrong.
Lucas

Quoted 4 lines
Quoted 3 lines
Signature · 1 line
2.56.0