Add ethernet support for the Amlogic T7
v8 cover Add ethernet support for the Amlogic T7
Patches 1 to 4 of v7, the bindings and the driver, are in net-next:
2297f88ce0b8 dt-bindings: net: amlogic,meson-dwmac: list the compatible combinations 18029931478b dt-bindings: net: add amlogic,t7-dwmac
c4c851a3325e net: stmmac: dwmac-meson8b: add support for the Amlogic T7 4fdc7da7e13d net: stmmac: dwmac-meson8b: follow the generic RGMII delay rules on the T7
This version carries the rest: a new binding patch for the MDIO multiplexer, and the three device tree patches. Patch 1 is for netdev, patches 2 to 4 for the Amlogic tree; the device tree patches build without the driver part.
The T7 has the same ethernet glue as the G12A. The glue registers sit in a block gated by sys_ethphy, so the controller node lists that clock as "pclk", and the pipeline stage between the controller and the DRAM has a gate of its own, listed as well. The MDIO multiplexer gets a T7 compatible with the G12A one as fallback. The VIM4 is plain rgmii-id, with the PHY at the address its pins strap.
Tested on v7.4-rc2 on the Khadas VIM4 with the PHY at address 1:
941/944Mbit/s with iperf3, no error. A scan of the bus shows the PHY at 0 and at 1 and nothing else.
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 v7:
- patches 1 to 4 of v7 are in net-next and are not resent; the numbers below are the new ones
- new patch 1: the MDIO multiplexer binding gets "amlogic,t7-mdio-mux" with the G12A compatible as fallback, and patch 3 uses it in the multiplexer node (Martin)
- patch 4: the VIM4 PHY node uses address 1, where the PHY is strapped; address 0 only worked through the RTL8211F broadcast address (Martin)
- patch 2: Martin's Reviewed-by
Changes since v6:
- no Assisted-by trailer (Krzysztof)
- patch 2: the T7 gets a binding file of its own (Rob, Sashiko); the pclk description names the glue registers (Krzysztof); rx-internal-delay-ps as constraints, default 0, maximum 3000, multipleOf 200 (Rob); tx-internal-delay-ps stays false, the meta-schema refuses "not" on a top-level property, so the reason is a comment above it (Rob); "snps,dwmac" dropped from the compatible list (Rob)
- patch 6: "snps,dwmac" dropped from the node (Rob)
- patch 4: Andrew's Reviewed-by
Changes since v5:
- patch 2: the T7 block follows the Meson8b..G12A block instead of splitting it in two; default: 0 for rx-internal-delay-ps on the T7 (Sashiko). The explicit false lines stay, as asked in review.
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 (4):
dt-bindings: net: amlogic,g12a-mdio-mux: add the T7 compatible
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,g12a-mdio-mux.yaml | 6 +- .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 23 +++++ arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 88 +++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-)
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
Signature · 1 line
2.56.1
PATCH v8 1/4 dt-bindings: net: amlogic,g12a-mdio-mux: add the T7 compatible
The T7 has the same management bus multiplexer as the G12A, in front of the same on-chip 100M PHY, and the G12A driver runs it unchanged. But a device tree that names only the G12A string leaves no way to tell the two apart later: if a difference between the two blocks turns up, every T7 board would have to change its compatible to get the fix.
Give the T7 a compatible of its own with the G12A one as fallback, so the existing driver keeps binding and a T7-specific match can be added without touching the boards.
--- .../devicetree/bindings/net/amlogic,g12a-mdio-mux.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/amlogic,g12a-mdio-mux.yaml +5 -1
@@ -19,7 +19,11 @@ allOf: properties: compatible: - const: amlogic,g12a-mdio-mux + oneOf: + - const: amlogic,g12a-mdio-mux + - items: + - const: amlogic,t7-mdio-mux + - const: amlogic,g12a-mdio-mux reg: maxItems: 1
Signature · 1 line
2.56.1
PATCH v8 2/4 arm64: dts: amlogic: t7: add the ethernet pinctrl nodes
In reply to Lucas TanureThe 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
@@ -376,6 +376,36 @@ }; }; + 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.1
PATCH v8 3/4 arm64: dts: amlogic: t7: add the ethernet controller
In reply to Lucas TanureThe 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.
--- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +58 -0
@@ -250,6 +250,31 @@ interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>; }; + ethmac: ethernet@fdc00000 { + compatible = "amlogic,t7-dwmac", "snps,dwmac-5.10a"; + 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 +670,39 @@ <10 11 12 13 14 15 16 17 18 19 20 21>; }; + eth_phy: mdio-multiplexer@28000 { + compatible = "amlogic,t7-mdio-mux", "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.1
PATCH v8 4/4 arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
In reply to Lucas TanureThe board carries a Realtek RTL8211F gigabit PHY on the external management bus, connected to the MAC over RGMII. Its address pins strap it to 1; it also answers on 0, the RTL8211F broadcast address, so the vendor tree lists 0.
Enable the controller and the management bus multiplexer, hand the controller the ethernet pins and point it at the PHY. 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 is on GPIOH_6, so link changes are reported, not polled. The reset is an RC network on the board, not a SoC pin: no reset line.
--- .../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
@@ -14,6 +14,7 @@ compatible = "khadas,vim4", "amlogic,a311d2", "amlogic,t7"; aliases { + ethernet0 = ðmac; serial0 = &uart_a; mmc0 = &sd_emmc_c; mmc1 = &sd_emmc_b;
@@ -256,6 +257,28 @@ }; }; +ðmac { + status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + phy-mode = "rgmii-id"; + phy-handle = <&external_phy>; +}; + +ð_phy { + status = "okay"; +}; + +&ext_mdio { + external_phy: ethernet-phy@1 { + /* Realtek RTL8211FD-CG */ + reg = <1>; + + 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.1
Re: [PATCH v8 1/4] dt-bindings: net: amlogic,g12a-mdio-mux: add the T7 compatible
In reply to Lucas TanureQuoted 10 lines · Lucas Tanure
The T7 has the same management bus multiplexer as the G12A, in front of the same on-chip 100M PHY, and the G12A driver runs it unchanged. But a device tree that names only the G12A string leaves no way to tell the two apart later: if a difference between the two blocks turns up, every T7 board would have to change its compatible to get the fix.
Give the T7 a compatible of its own with the G12A one as fallback, so the existing driver keeps binding and a T7-specific match can be added without touching the boards.
Drop paragraph, no need to explain obvious schema and driver is irrelevant here.
Quoted 5 lines
Signed-off-by Lucas Tanure <[email protected]>--- .../devicetree/bindings/net/amlogic,g12a-mdio-mux.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Best regards,
Krzysztof
[email protected]
AI reviewRe: [PATCH v8 3/4] arm64: dts: amlogic: t7: add the ethernet controller
In reply to Lucas TanureThank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] arm64: dts: amlogic: t7: ethmac uses unmatched compatible amlogic,t7-dwmac - [High] arm64: dts…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] arm64: dts: amlogic: t7: ethmac uses unmatched compatible amlogic,t7-dwmac
- [High] arm64: dts: amlogic: t7: ethmac pipeline clock is never claimed by driver
- [Medium] arm64: dts: amlogic: t7: undocumented ethmac compatible and clocks in binding
--
commit 4e3c40142c3d0de22878c5872271d7ab4185032f
Author: Lucas Tanure <[email protected]>
arm64: dts: amlogic: t7: add the ethernet controller
This commit adds the Devicetree nodes for the Amlogic T7 Ethernet MAC, its MDIO bus, and the MDIO multiplexer with the internal 100M PHY.
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi gic: interrupt-controller@fff01000 { · line 256
Quoted 12 lines
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +4
-0@@ -250,6 +250,31 @@ 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"; + reg = <0x0 0xfdc00000 0x0 0x10000>, + <0x0 0xfe024000 0x0 0x8>;
[Severity: High]
Can any platform driver bind to ethmac with this compatible list?
meson8b_dwmac_match[] in drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c has no entry for amlogic,t7-dwmac, and ethmac does not list a fallback compatible such as amlogic,meson-g12a-dwmac. No platform driver matches snps,dwmac-5.10a directly either (it is only checked in stmmac_probe_config_dt() after a glue driver has already bound), so ethmac never probes when enabled by a board.
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi line 265
Quoted 9 lines
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +9
-0+ 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";
[Severity: High]
Does any driver actually claim and enable the "pipeline" clock (CLKID_SYS_AMPIPE_ETH)?
Neither meson8b_dwmac_probe() (which only requests "timing-adjustment", "clkin0", and "clkin1") nor stmmac_probe_config_dt() (which only requests "stmmaceth", "pclk", and "ptp_ref") acquires a clock named "pipeline". Because t7_sys_ampipe_eth in drivers/clk/meson/t7-peripherals.c is defined with flags = 0, CLKID_SYS_AMPIPE_ETH remains unclaimed and is gated off by clk_disable_unused(), breaking Ethernet DMA access to memory.
[Severity: Medium]
Are the new compatible strings and clocks documented in Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml?
The binding schema does not allow amlogic,t7-dwmac or snps,dwmac-5.10a in compatible, and its clocks and clock-names properties only allow up to four entries (stmmaceth, clkin0, clkin1, and timing-adjustment) without "pipeline" or "pclk", causing dtbs_check validation to fail.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3