Skip to contentSkip to conversation

Add ethernet support for the Amlogic T7

PATCH Superseded Lucas Tanure 5 participants 18 messages Nov 3 – Nov 16

Subsystems (6)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add ethernet support for the Amlogic T7

The T7 has the same ethernet glue as the G12A. This adds the binding, the driver support and the device tree nodes, and enables the port on the Khadas VIM4.

Two clocks are new. The pipeline stage between the controller and the DRAM has its own gate, which nothing else claims. The glue registers sit in a block gated by sys_ethphy, so far claimed only by the MDIO mux, which probes after the glue is programmed: every write to PRG_ETH0/1 was lost. The T7 node lists that clock as "pclk".

The delays follow ethernet-controller.yaml: phy-mode is never changed, the PHY adds the 2ns, and the T7 accepts only rx-internal-delay-ps, as fine tuning. Its TX side is a quarter-period phase selector with no small step, so tx-internal-delay-ps is not valid for it. The VIM4 is plain rgmii-id.

Tested on v7.4-rc1 on the Khadas VIM4: 940/941Mbit/s with iperf3, no CRC error.

Overlaps with Xianwei Zhao's "[PATCH v2 0/3] t7: add some nodes for Amlogc t7."; I will drop or rebase whatever overlaps once we agree.

Changes since v4:
- patch 4: the old delay code is left untouched; the T7 only gets a callback of its own, and the probe parsing it shares validates the RX value (Andrew); no NULL check on the callback (Martin)
- 0 accepted for rx-internal-delay-ps, the T7 joins the G12A list (Andrew)
- comment on the deprecated vendor delay properties (Andrew)
- the MDIO mux and the on-chip PHY bus start disabled in the dtsi; the VIM4 enables the mux (Sashiko)

Changes since v3:
- phy-mode untouched, the PHY adds the 2ns, rx-internal-delay-ps is tuning only, tx-internal-delay-ps not valid for the T7 (Andrew)
- 0 dropped from rx-internal-delay-ps (Martin); vendor delay properties explicitly false for the T7 (Andrew)
- init_delays callback; patch 4 renamed (Martin, Andrew)
- VIM4 without tx-internal-delay-ps, the PHY TX delay works (Martin)
- Meson8m2 moved to the dwmac-3.70a list; its boards warn in dtbs_check until Martin's dtsi patch lands (Martin, Conor)
- the delay table in ethernet-controller.yaml dropped
- Martin's Reviewed-by on patch 3

Changes since v2:
- T7-only delay path (Andrew), PHY mode from phy_fix_phy_mode_for_mac_delays() (Maxime)
- tx-internal-delay-ps checked against the hardware values (Sashiko)
- vendor delay properties not valid for the T7 (Neil, Andrew)
- no max-speed on either PHY (Andrew); VIM4 PHY interrupt on GPIOH_6 (Sashiko)
- the T7 node owns sys_ethphy as "pclk"
- no longer RFC; Conor's Ack dropped from patch 2 and Neil's R-b from patch 6

Changes since v1:
- the driver honours the generic delay properties; VIM4 moved to rgmii-id with tx-internal-delay-ps = <2000>, Neil's R-b dropped

Lucas Tanure (7):
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: follow the generic RGMII delay rules on
the T7
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

 .../bindings/net/amlogic,meson-dwmac.yaml     | 88 ++++++++++++++----
 .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 23 +++++
 arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi   | 90 +++++++++++++++++++
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   | 61 ++++++++++++-
 4 files changed, 246 insertions(+), 16 deletions(-)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.56.0
#1 lore raw

PATCH v5 1/7 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 use: Meson6 falls back to "snps,dwmac" alone, the others also name the 3.70a core. The Meson8m2 reports a 3.70a core too, so it joins that list; its dtsi gets the missing entry in a separate patch. The example used a two-entry form no device tree has, so give it the Meson GXBB combination.

---
 .../bindings/net/amlogic,meson-dwmac.yaml     | 29 +++++++++----------
 1 file changed, 14 insertions(+), 15 deletions(-)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +14 -15
index 9c9cc3ef384d..e769c9bb70d8 100644
@@ -129,20 +129,19 @@ 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,meson8m2-dwmac
+              - amlogic,meson-gxbb-dwmac
+              - amlogic,meson-axg-dwmac
+              - amlogic,meson-g12a-dwmac
+          - const: snps,dwmac-3.70a
+          - const: snps,dwmac
+      - items:
+          - const: amlogic,meson6-dwmac
+          - const: snps,dwmac
 
   reg:
     items:
@@ -175,7 +174,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

PATCH v5 2/7 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 its own gate; nothing else claims it, so it is switched off as unused and transfers never finish. The glue registers sit in a block clocked together with the MDIO multiplexer, which probes after the controller has programmed them: the writes are lost and the port keeps the bootloader's delays.

So the T7 gets its own clock list, without the timing adjustment clock it never uses. Its delays follow ethernet-controller.yaml: the PHY adds the 2ns, and only the receive delay line offers fine tuning, so only rx-internal-delay-ps is valid here.

Assisted-by LLM
---
 .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +59 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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 PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
           contains:
             enum:
               - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
     then:
       properties:
         rx-internal-delay-ps:
@@ -142,6 +197,10 @@ properties:
       - items:
           - const: amlogic,meson6-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
#3 lore raw

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

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: net: amlogic,meson-dwmac: unwieldy per-compatible conditionals --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: net: amlogic,meson-dwmac: unwieldy per-compatible conditionals --

commit bbd012595ac6470b2960164c914c68e801ea5738
Author: Lucas Tanure <[email protected]>

dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac

This commit adds the amlogic,t7-dwmac compatible string to the Amlogic Meson DWMAC device tree binding schema, specifying its five-clock list and restricting its delay properties to rx-internal-delay-ps.

Quoted 4 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +0 -0
index e769c9bb70d84..6de013e3e8f63 100644

[ ... ]

Quoted 50 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +46 -0
@@ -57,6 +58,59 @@ 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 PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # Delay definitions for Meson8b and newer
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:

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

Quoted 10 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +7 -0
+              - 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

[Severity: Low]
This isn't a runtime bug, but the per-compatible if-then conditionals under allOf in Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml are getting quite unwieldy with the addition of amlogic,t7-dwmac.

The T7 variant differs substantially from the older variants in this binding:
it uses snps,dwmac-5.10a instead of snps,dwmac-3.70a, has a distinct five-clock list (stmmaceth, clkin0, clkin1, pipeline, pclk without timing-adjustment), and disallows tx-internal-delay-ps as well as amlogic,tx-delay-ns and amlogic,rx-delay-ns.

Inserting the amlogic,t7-dwmac block into the middle of allOf also splits the existing conditional for the five Meson8b-through-G12A compatibles into two separate if-then blocks with identical enum lists:

- if:
properties:
compatible:
contains:
enum:
- amlogic,meson8b-dwmac
- amlogic,meson8m2-dwmac
- amlogic,meson-gxbb-dwmac
- amlogic,meson-axg-dwmac
- amlogic,meson-g12a-dwmac

Furthermore, because amlogic,tx-delay-ns and amlogic,rx-delay-ns are only defined inside that second Meson8b-through-G12A conditional and not in the top-level properties block (with unevaluatedProperties: false at the bottom of the schema), setting them to false in the amlogic,t7-dwmac block is redundant, while leaving rx-internal-delay-ps: default: 0 inside the Meson8b-through-G12A block omits that default for amlogic,t7-dwmac.

Would it be cleaner to split amlogic,t7-dwmac into a separate binding schema document rather than adding more per-compatible conditionals to amlogic,meson-dwmac.yaml?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

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

In reply to Lucas Tanure
Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 30 lines
---
 .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +10 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ allOf:
             - const: clkin1
             - const: timing-adjustment
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,t7-dwmac
+    then:
+      properties:
+        clocks:
+          items:

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

Quoted 10 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +10 -0
+            - 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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

Quoted 46 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
           contains:
             enum:
               - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
     then:
       properties:
         rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
       - items:
           - const: amlogic,meson6-dwmac
           - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Best regards,
Krzysztof

#5 lore raw

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

Quoted 10 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 8 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
       - items:
           - const: amlogic,meson6-dwmac
           - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Never mind, now I looked at patch #1.

Best regards,
Krzysztof

#6 lore raw

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

In reply to Krzysztof Kozlowski

Hi Krzysztof, Lucas,

Quoted 43 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 35 lines
---
  .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
  1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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
Quoted 8 lines

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

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+                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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

I see that the clock in the dts patch corresponds to <&clkc_periphs CLKID_SYS_ETHPHY>. This clock provides the working clock for the APB Bus of the ETH PHY controller, and this clock will affect the register reading and writing of the ETH PHY (including the ETH_PLL). See section 15.3.4.2 RegisterDescription in A311D2 Datasheet for details.

Quoted 66 lines
Quoted 48 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
            contains:
              enum:
                - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
      then:
        properties:
          rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
        - items:
            - const: amlogic,meson6-dwmac
            - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

Signature · 2 lines
Best regards,
Chuan
#7 lore raw

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

Quoted 56 lines · Chuan Liu

Hi Krzysztof, Lucas,

Quoted 43 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 35 lines
---
  .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
  1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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
Quoted 8 lines

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

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+                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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

Quoted 5 lines

I see that the clock in the dts patch corresponds to <&clkc_periphs CLKID_SYS_ETHPHY>. This clock provides the working clock for the APB Bus of the ETH PHY controller, and this clock will affect the register reading and writing of the ETH PHY (including the ETH_PLL). See section 15.3.4.2 RegisterDescription in A311D2 Datasheet for details.

Thanks. That section is the PHY block at 0xfe028000, the region of the mdio multiplexer node. The registers in this description are PRG_ETH0 and PRG_ETH1 in eth_top at 0xfe024000. On the VIM4 the same gate feeds them too: with it off they read as zero and ignore writes. My datasheet revisions do not say which clock feeds eth_top. Can you confirm it is this one?

Thanks,
Lucas

Quoted 72 lines
Quoted 59 lines
Quoted 49 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
            contains:
              enum:
                - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
      then:
        properties:
          rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
        - items:
            - const: amlogic,meson6-dwmac
            - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Quoted 8 lines

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

--
Best regards,
Chuan

#8 lore raw

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

Hi Lucas,

Quoted 65 lines · Lucas Tanure

[ EXTERNAL EMAIL ]

Quoted 56 lines · Chuan Liu

Hi Krzysztof, Lucas,

Quoted 43 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 35 lines
---
   .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
   1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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
Quoted 8 lines

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

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+                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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

Quoted 5 lines

I see that the clock in the dts patch corresponds to <&clkc_periphs CLKID_SYS_ETHPHY>. This clock provides the working clock for the APB Bus of the ETH PHY controller, and this clock will affect the register reading and writing of the ETH PHY (including the ETH_PLL). See section 15.3.4.2 RegisterDescription in A311D2 Datasheet for details.

Quoted 6 lines

Thanks. That section is the PHY block at 0xfe028000, the region of the mdio multiplexer node. The registers in this description are PRG_ETH0 and PRG_ETH1 in eth_top at 0xfe024000. On the VIM4 the same gate feeds them too: with it off they read as zero and ignore writes. My datasheet revisions do not say which clock feeds eth_top. Can you confirm it is this one?

The information I can confirm is:
- The base address of eth_phy is 0xfe028000, and its corresponding
APB clock is <&clkc_periphs CLKID_SYS_ETHPHY>.
- The base address of eth_top is 0xfe024000, and the base address of
eth_mac is 0xfdc00000; their corresponding APB clock is <&clkc_periphs CLKID_SYS_ETH>.

The CPU reads and writes the registers of these peripheral controllers (or Processing Units) via the APB. Consequently, the registers of these controllers cannot be read and written properly if the corresponding APB clock (sys_clk/clk81) is not enabled.

Quoted 76 lines

Thanks,
Lucas

Quoted 72 lines
Quoted 59 lines
Quoted 49 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
             contains:
               enum:
                 - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
       then:
         properties:
           rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
         - items:
             - const: amlogic,meson6-dwmac
             - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Quoted 8 lines

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

--
Best regards,
Chuan

Signature · 2 lines
Best regards,
Chuan
#9 lore raw

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

Quoted 76 lines · Chuan Liu

Hi Lucas,

Quoted 65 lines · Lucas Tanure

[ EXTERNAL EMAIL ]

Quoted 56 lines · Chuan Liu

Hi Krzysztof, Lucas,

Quoted 43 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 35 lines
---
   .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
   1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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
Quoted 8 lines

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

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+                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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

Quoted 5 lines

I see that the clock in the dts patch corresponds to <&clkc_periphs CLKID_SYS_ETHPHY>. This clock provides the working clock for the APB Bus of the ETH PHY controller, and this clock will affect the register reading and writing of the ETH PHY (including the ETH_PLL). See section 15.3.4.2 RegisterDescription in A311D2 Datasheet for details.

Quoted 6 lines

Thanks. That section is the PHY block at 0xfe028000, the region of the mdio multiplexer node. The registers in this description are PRG_ETH0 and PRG_ETH1 in eth_top at 0xfe024000. On the VIM4 the same gate feeds them too: with it off they read as zero and ignore writes. My datasheet revisions do not say which clock feeds eth_top. Can you confirm it is this one?

Quoted 6 lines

The information I can confirm is:
- The base address of eth_phy is 0xfe028000, and its corresponding
APB clock is <&clkc_periphs CLKID_SYS_ETHPHY>.
- The base address of eth_top is 0xfe024000, and the base address of
eth_mac is 0xfdc00000; their corresponding APB clock is <&clkc_periphs CLKID_SYS_ETH>.

That is not what the VIM4 does. The stmmac core enables CLKID_SYS_ETH before any glue code runs. With that clock on and CLKID_SYS_ETHPHY off, PRG_ETH0 and PRG_ETH1 read as zero and the driver's writes are lost: U-Boot's 0xa0000 was still in PRG_ETH1 after the driver had written 0. Enabling CLKID_SYS_ETHPHY right before the write makes it land. That was the v3 bug, every frame a CRC error. I repeated it today on the running kernel, toggling only bit 4 of CLKCTRL_SYS_CLK_EN0_REG0 from user space, every other gate left on:

  both gates on        EN0=ffffffff EN1=ffffffff PRG_ETH0=00001601
  ethphy off, eth on   EN0=ffffffef EN1=ffffffff PRG_ETH0=00000000
  ethphy restored      EN0=ffffffff EN1=ffffffff PRG_ETH0=00001601

So on this chip CLKID_SYS_ETH alone does not give access to eth_top. Could the register interface of eth_top sit behind the eth_phy APB slave? Either way the MAC node has to enable CLKID_SYS_ETHPHY, and the binding will describe it as the clock of the glue registers.

Quoted 78 lines

The CPU reads and writes the registers of these peripheral controllers (or Processing Units) via the APB. Consequently, the registers of these controllers cannot be read and written properly if the corresponding APB clock (sys_clk/clk81) is not enabled.

Quoted 72 lines

Thanks,
Lucas

Quoted 68 lines
Quoted 67 lines
Quoted 49 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
             contains:
               enum:
                 - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
       then:
         properties:
           rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
         - items:
             - const: amlogic,meson6-dwmac
             - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

--
Best regards,
Chuan

--
Best regards,
Chuan

Thanks,
Lucas

#10 lore raw

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

Hi Lucas,

Quoted 96 lines · Lucas Tanure

[ EXTERNAL EMAIL ]

Quoted 76 lines · Chuan Liu

Hi Lucas,

Quoted 65 lines · Lucas Tanure

[ EXTERNAL EMAIL ]

Quoted 56 lines · Chuan Liu

Hi Krzysztof, Lucas,

Quoted 43 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 35 lines
---
    .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
    1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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
Quoted 8 lines

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

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+                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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

Quoted 5 lines

I see that the clock in the dts patch corresponds to <&clkc_periphs CLKID_SYS_ETHPHY>. This clock provides the working clock for the APB Bus of the ETH PHY controller, and this clock will affect the register reading and writing of the ETH PHY (including the ETH_PLL). See section 15.3.4.2 RegisterDescription in A311D2 Datasheet for details.

Quoted 6 lines

Thanks. That section is the PHY block at 0xfe028000, the region of the mdio multiplexer node. The registers in this description are PRG_ETH0 and PRG_ETH1 in eth_top at 0xfe024000. On the VIM4 the same gate feeds them too: with it off they read as zero and ignore writes. My datasheet revisions do not say which clock feeds eth_top. Can you confirm it is this one?

Quoted 6 lines

The information I can confirm is:
- The base address of eth_phy is 0xfe028000, and its corresponding
APB clock is <&clkc_periphs CLKID_SYS_ETHPHY>.
- The base address of eth_top is 0xfe024000, and the base address of
eth_mac is 0xfdc00000; their corresponding APB clock is <&clkc_periphs CLKID_SYS_ETH>.

That is not what the VIM4 does. The stmmac core enables CLKID_SYS_ETH before any glue code runs. With that clock on and CLKID_SYS_ETHPHY off, PRG_ETH0 and PRG_ETH1 read as zero and the driver's writes are lost: U-Boot's 0xa0000 was still in PRG_ETH1 after the driver had written 0. Enabling CLKID_SYS_ETHPHY right before the write makes it land. That was the v3 bug, every frame a CRC error. I repeated it today on the running kernel, toggling only bit 4 of CLKCTRL_SYS_CLK_EN0_REG0 from user space, every other gate left on:

Quoted 4 lines
   both gates on        EN0=ffffffff EN1=ffffffff PRG_ETH0=00001601
   ethphy off, eth on   EN0=ffffffef EN1=ffffffff PRG_ETH0=00000000
   ethphy restored      EN0=ffffffff EN1=ffffffff PRG_ETH0=00001601

Sorry that the information I gave before is not completely accurate. The conclusion you drew from the test is correct. The relationship between them should be:

    - eth_mac:  works with CLKID_SYS_ETH only
    - eth_phy:  works with CLKID_SYS_ETHPHY only
    - eth_top:  needs both CLKID_SYS_ETH and CLKID_SYS_ETHPHY
Quoted 3 lines

So on this chip CLKID_SYS_ETH alone does not give access to eth_top. Could the register interface of eth_top sit behind the eth_phy APB slave?

eth_top is the glue between the eth_mac and eth_phy domains, its registers are consumed on both sides of that boundary, so a register access has to complete in both clock domains - with either gate off, reads return zero and writes are lost.

Quoted 92 lines

Either way the MAC node has to enable CLKID_SYS_ETHPHY, and the binding will describe it as the clock of the glue registers.

Quoted 78 lines

The CPU reads and writes the registers of these peripheral controllers (or Processing Units) via the APB. Consequently, the registers of these controllers cannot be read and written properly if the corresponding APB clock (sys_clk/clk81) is not enabled.

Quoted 72 lines

Thanks,
Lucas

Quoted 68 lines
Quoted 67 lines
Quoted 49 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
              contains:
                enum:
                  - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
        then:
          properties:
            rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
          - items:
              - const: amlogic,meson6-dwmac
              - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

--
Best regards,
Chuan

--
Best regards,
Chuan

Thanks,
Lucas

Signature · 2 lines
Best regards,
Chuan
#11 lore raw

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

In reply to Krzysztof Kozlowski
Quoted 42 lines · Krzysztof Kozlowski
Quoted 2 lines · Lucas Tanure
Assisted-by LLM

Drop this one.

Quoted 35 lines
---
 .../bindings/net/amlogic,meson-dwmac.yaml     | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +15 -0
index e769c9bb70d8..6de013e3e8f6 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,59 @@ 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
Quoted 8 lines

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

Quoted 5 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +5 -0
+                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.

This sounds like you take clock from other block. That's wrong, that device should take its own clock.

It is this device's clock, the description is misleading. PRG_ETH0 and PRG_ETH1 are the glue registers of this controller, the second reg entry of the node. The gate is named after the PHY block at 0xfe028000, which the mdio multiplexer node lists too, but it also feeds these registers: with it off they read as zero and ignore writes, and no other gate brings them back. The stmmac core enables "pclk" before touching them. v7 will say:

- description:
APB clock of the glue registers PRG_ETH0 and PRG_ETH1. Without it, they read as zero and ignore writes.

Thanks,
Lucas

Quoted 61 lines
Quoted 48 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +35 -0
+
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: clkin0
+            - const: clkin1
+            - const: pipeline
+            - const: pclk
+
+        # The PHY adds the 2ns RGMII delays, see ethernet-controller.yaml.
+        # The RX delay line of this glue is fine tuning in 200ps steps,
+        # added on top of what phy-mode describes. The TX side has no fine
+        # tuning: its only step is a quarter of the clock period, the full
+        # 2ns at 1Gbit/s, so the TX property is not accepted.
+        tx-internal-delay-ps: false
+
+        # Deprecated: new SoCs use the standard *-internal-delay-ps
+        # properties instead.
+        amlogic,tx-delay-ns: false
+        amlogic,rx-delay-ns: false
+
+  # 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 +160,7 @@ allOf:
           contains:
             enum:
               - amlogic,meson-g12a-dwmac
+              - amlogic,t7-dwmac
     then:
       properties:
         rx-internal-delay-ps:

Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml properties: · line 203

Quoted 7 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +4 -0
@@ -142,6 +197,10 @@ properties:
       - items:
           - const: amlogic,meson6-dwmac
           - const: snps,dwmac
+      - items:
+          - const: amlogic,t7-dwmac
+          - const: snps,dwmac-5.10a
+          - const: snps,dwmac

I see no such hunk in the code, so not sure how to review this.

Best regards,
Krzysztof

#12 lore raw

PATCH v5 3/7 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
#13 lore raw

PATCH v5 4/7 net: stmmac: dwmac-meson8b: follow the generic RGMII delay rules on the T7

In reply to Lucas Tanure

The delay code reads phy-mode as the list of delays this glue has to add, falls back to a 2ns transmit delay when no property asks for one, and takes the vendor delay properties. ethernet-controller.yaml says the opposite: the PHY adds the 2ns delays, and the MAC properties only hold small fine tuning added on top. Every board in the tree depends on the old reading, so it stays as it is.

No T7 board uses this glue yet, so the T7 gets a path of its own that follows the generic rules: the receive delay line is fine tuning in 200ps steps, and the transmit side, a quarter-period phase step, offers none, so the transmit property is refused.

Assisted-by LLM
---
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   | 42 ++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +41 -1
index 450f7b4b29a6..c8bd15b6780b 100644
@@ -80,6 +80,7 @@ struct meson8b_dwmac;
 
 struct meson8b_dwmac_data {
 	int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
+	int (*init_delays)(struct meson8b_dwmac *dwmac);
 	bool has_prg_eth1_rgmii_rx_delay;
 	bool has_pipeline_clk;
 };
@@ -338,6 +339,41 @@ static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
 	return 0;
 }
 
+/*
+ * The T7 follows ethernet-controller.yaml: the PHY adds the 2ns RGMII
+ * delays and this glue only fine tunes the RX clock on top of what
+ * phy-mode describes. Its TX clock has no fine tuning, the only step is
+ * a quarter of the clock period, so the TX property is refused, and so
+ * are the vendor properties of the older SoCs.
+ */
+static int meson_t7_init_delays(struct meson8b_dwmac *dwmac)
+{
+	struct device_node *np = dwmac->dev->of_node;
+	u32 cfg_rxclk_dly = 0;
+
+	if (of_property_present(np, "tx-internal-delay-ps") ||
+	    of_property_present(np, "amlogic,tx-delay-ns") ||
+	    of_property_present(np, "amlogic,rx-delay-ns"))
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "only rx-internal-delay-ps is supported, the PHY adds the RGMII delays\n");
+
+	if (phy_interface_mode_is_rgmii(dwmac->phy_mode))
+		cfg_rxclk_dly = FIELD_PREP(PRG_ETH1_CFG_RXCLK_DLY,
+					   dwmac->rx_delay_ps / 200);
+	else if (dwmac->rx_delay_ps)
+		return dev_err_probe(dwmac->dev, -EINVAL,
+				     "rx-internal-delay-ps needs an RGMII phy-mode\n");
+
+	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, 0);
+
+	meson8b_dwmac_mask_bits(dwmac, PRG_ETH1, PRG_ETH1_CFG_RXCLK_DLY,
+				cfg_rxclk_dly);
+
+	return 0;
+}
+
 static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
 {
 	int ret;
@@ -452,7 +488,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 					     "missing pipeline clock\n");
 	}
 
-	ret = meson8b_init_rgmii_delays(dwmac);
+	ret = dwmac->data->init_delays(dwmac);
 	if (ret)
 		return ret;
 
@@ -475,21 +511,25 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 
 static const struct meson8b_dwmac_data meson8b_dwmac_data = {
 	.set_phy_mode = meson8b_set_phy_mode,
+	.init_delays = meson8b_init_rgmii_delays,
 	.has_prg_eth1_rgmii_rx_delay = false,
 };
 
 static const struct meson8b_dwmac_data meson_axg_dwmac_data = {
 	.set_phy_mode = meson_axg_set_phy_mode,
+	.init_delays = meson8b_init_rgmii_delays,
 	.has_prg_eth1_rgmii_rx_delay = false,
 };
 
 static const struct meson8b_dwmac_data meson_g12a_dwmac_data = {
 	.set_phy_mode = meson_axg_set_phy_mode,
+	.init_delays = meson8b_init_rgmii_delays,
 	.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,
+	.init_delays = meson_t7_init_delays,
 	.has_prg_eth1_rgmii_rx_delay = true,
 	.has_pipeline_clk = true,
 };
Signature · 1 line
2.56.0
Reviewed-by on v5 4/7
#14 lore raw

Re: [PATCH v5 4/7] net: stmmac: dwmac-meson8b: follow the generic RGMII delay rules on the T7

Quoted 7 lines · Lucas Tanure

The delay code reads phy-mode as the list of delays this glue has to add, falls back to a 2ns transmit delay when no property asks for one, and takes the vendor delay properties. ethernet-controller.yaml says the opposite: the PHY adds the 2ns delays, and the MAC properties only hold small fine tuning added on top. Every board in the tree depends on the old reading, so it stays as it is.

Quoted 7 lines

No T7 board uses this glue yet, so the T7 gets a path of its own that follows the generic rules: the receive delay line is fine tuning in 200ps steps, and the transmit side, a quarter-period phase step, offers none, so the transmit property is refused.

Assisted-by LLM

Andrew

#15 lore raw

PATCH v5 5/7 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
#16 lore raw

PATCH v5 6/7 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 a gate nothing else claims, so it is switched off as unused. The glue registers share a clock with the multiplexer, which probes after the controller has programmed them: unless the controller holds that clock, the writes are lost and the port keeps the bootloader's delays.

The multiplexer and the on-chip PHY bus start disabled: a board enables the multiplexer with the controller, and the on-chip bus only when it uses that PHY.

Assisted-by LLM
---
 arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 60 +++++++++++++++++++++
 1 file changed, 60 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +60 -0
index 7bd53ec16607..f15fd8f6cdd2 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,39 @@ 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>;
+				status = "disabled";
+
+				ext_mdio: mdio@0 {
+					reg = <0>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+				};
+
+				int_mdio: mdio@1 {
+					reg = <1>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+					status = "disabled";
+
+					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
#17 lore raw

PATCH v5 7/7 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 and the management bus multiplexer, hand the controller the ethernet pins and point it at the PHY on the external bus. RGMII needs a delay on each of its two clocks. The board traces add none, so the PHY adds both, which is what rgmii-id asks of it.

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 | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +23 -0
index 0fa83362b417..93327b993d39 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,28 @@ xtal: xtal-clk {
 	};
 };
 
+&ethmac {
+	status = "okay";
+	pinctrl-0 = <&eth_pins>, <&eth_rgmii_pins>;
+	pinctrl-names = "default";
+	phy-mode = "rgmii-id";
+	phy-handle = <&external_phy>;
+};
+
+&eth_phy {
+	status = "okay";
+};
+
+&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