Add ethernet support for the Amlogic T7
Subsystems (6)
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, so the port could not be used.
This adds the binding, the driver support and the device tree nodes, and enables the port on the Khadas VIM4, which has an external RTL8211F over RGMII.
What is not like the G12A: the controller reaches DRAM through a pipeline stage with a gate of its own, sys_ampipe_eth. Nothing else needs that gate, so clk_disable_unused switches it off and transfers stop. The T7 therefore gets its own clock list, with the gate as a fourth entry, and the driver requires it. The MMC controllers on this SoC have the same arrangement, and that fix is already upstream.
Tested on next-20261002 on a VIM4, with "clk: meson: t7: keep the memory fabric clocks running" (clk-meson-next) applied on top. That patch is needed before any DMA on this SoC works. With unused clocks being disabled normally, the port comes up at 1Gbit/s, 930Mbit/s sustained receive, and no MAC error counters move.
This 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, snps,dwmac-4.00 and three clocks. On my board the MAC reports Synopsys ID 0x51, which is DWMAC_CORE_5_10 in common.h, and the port does not survive the unused clock sweep without the pipeline gate. I am sending this so the code is on the list, not to race, and I will drop or rebase whatever overlaps once we agree. Patch 1 is the oneOf rewrite Conor asked for on that thread.
Lucas Tanure (6):
dt-bindings: net: amlogic,meson-dwmac: spell out the compatible
combinations
dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac
net: stmmac: dwmac-meson8b: add support for the Amlogic 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 | 77 ++++++++++++---- .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 28 ++++++ arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 87 +++++++++++++++++++ .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 19 ++++ 4 files changed, 196 insertions(+), 15 deletions(-)
base-commit: f0406245cb9855e6318335a8a223551354291a46
Signature · 1 line
2.56.0
RFC PATCH 1/6 dt-bindings: net: amlogic,meson-dwmac: spell out 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
@@ -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
RFC PATCH 2/6 dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac
In reply to Lucas TanureThe T7 has the same ethernet glue as the G12A, but the controller reaches DRAM through a pipeline stage that the hardware design inserts in the bus path. That stage has a gate of its own, which no other member of the family has. Nothing else in Linux claims the gate, so it is switched off as unused and the port can then no longer complete a transfer.
Describing it means a fourth clock, and the fourth clock of the existing list is the one driving the timing adjustment logic. The T7 applies the RGMII RX delay through PRG_ETH1 and never enables that logic, so it has no use for that clock. Give the T7 a list of its own with the pipeline gate as the fourth entry, under the same name the SD/eMMC controllers of this SoC already use for the equivalent stage on their own bus path. All four entries are required, since the port cannot move data without any of them.
The RX delay range is the one the G12A has, since it is the same register field.
The compatible pairs the T7 name with the 5.10a Synopsys core the MAC reports, and with the generic fallback.
--- .../bindings/net/amlogic,meson-dwmac.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +47 -0
@@ -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,47 @@ allOf: - const: clkin1 - const: timing-adjustment + # The T7 applies the RGMII RX delay through PRG_ETH1 and never enables the + # timing adjustment logic, so it has no timing-adjustment clock. What it does + # need is the gate of the pipeline stage the controller reaches DRAM through. + - 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. + + clock-names: + items: + - const: stmmaceth + - const: clkin0 + - const: clkin1 + - const: pipeline + + # Delay definitions for Meson8b and newer (including T7) + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8b-dwmac + - amlogic,meson8m2-dwmac + - amlogic,meson-gxbb-dwmac + - amlogic,meson-axg-dwmac + - amlogic,meson-g12a-dwmac + - amlogic,t7-dwmac + then: + properties: amlogic,tx-delay-ns: enum: [0, 2, 4, 6] default: 2
@@ -106,6 +148,7 @@ allOf: contains: enum: - amlogic,meson-g12a-dwmac + - amlogic,t7-dwmac then: properties: rx-internal-delay-ps:
@@ -143,6 +186,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
RFC PATCH 3/6 net: stmmac: dwmac-meson8b: add support for the Amlogic T7
In reply to Lucas TanureThe 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 the T7 does not share is how the controller reaches DRAM: the bus path goes through a pipeline stage with a gate of its own, and no device other than the controller has any use for that gate. Claim it and hold it enabled for as long as the controller is bound, otherwise it is switched off as unused and a transfer that has been started can never complete.
Give the T7 match data of its own so that only it looks the clock up, and require the clock instead of treating it as optional: the controller cannot do DMA without it, and failing the probe with a clear message beats booting and hitting 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
@@ -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
RFC PATCH 4/6 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 @@ 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
RFC PATCH 5/6 arm64: dts: amlogic: t7: add the ethernet controller
In reply to Lucas TanureThe SoC pairs a Synopsys gigabit MAC with a small block of glue registers that selects the interface type and trims the clock timing, and with a multiplexer that points the management bus at either the on-chip 100M PHY or the external pins. None of it was described, so the port could not be used at all.
Add the controller and the multiplexer. The MAC reports a 5.10a core. The path the controller reaches memory over runs through a pipeline stage with a gate of its own, so hand that to the controller as well; nothing else claims it and it would otherwise be switched off as unused, leaving the port unable to complete a transfer.
The on-chip PHY behind the second port of the multiplexer is described the way the G12A does it. No board in tree uses it and that path is untested.
The controller is left disabled for boards to enable.
--- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 57 +++++++++++++++++++++ 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +57 -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", + "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>; + clock-names = "stmmaceth", "clkin0", "clkin1", "pipeline"; + 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,38 @@ 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>; + max-speed = <100>; + }; + }; + }; + uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>;
Signature · 1 line
2.56.0
RFC PATCH 6/6 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.
Enable the controller, hand it the ethernet pins and point it at the PHY. The clock delays RGMII needs are supplied by the MAC rather than the PHY: 2ns on transmit and 2000ps on receive, the values the vendor kernel programs.
The PHY interrupt output is wired to GPIOH_6, so describe it and let link changes be reported instead of polled. The PHY reset pin is driven by an RC network on the board, not by the SoC, so there is no reset line to describe.
Tested at 930Mbit/s sustained receive over a minute, with no MAC error counters moving in either direction.
--- .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +28 -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,33 @@ xtal: xtal-clk { }; }; +ðmac { + status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + + /* + * The RGMII clock delays are added by the MAC, so the PHY is + * asked for the mode that adds none. + */ + phy-mode = "rgmii"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; + rx-internal-delay-ps = <2000>; +}; + +&ext_mdio { + external_phy: ethernet-phy@0 { + /* Realtek RTL8211FD-CG */ + reg = <0>; + max-speed = <1000>; + + interrupt-parent = <&gpio_intc>; + /* RGMII_INT on GPIOH_6 */ + interrupts = <154 IRQ_TYPE_LEVEL_LOW>; + }; +}; + &i2c_m_ao_a { status = "okay"; pinctrl-0 = <&i2c0_ao_d_pins>;
Signature · 1 line
2.56.0
Re: [RFC PATCH 3/6] net: stmmac: dwmac-meson8b: add support for the Amlogic T7
In reply to Lucas TanureQuoted 69 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 the T7 does not share is how the controller reaches DRAM: the bus path goes through a pipeline stage with a gate of its own, and no device other than the controller has any use for that gate. Claim it and hold it enabled for as long as the controller is bound, otherwise it is switched off as unused and a transfer that has been started can never complete.
Give the T7 match data of its own so that only it looks the clock up, and require the clock instead of treating it as optional: the controller cannot do DMA without it, and failing the probe with a clear message beats booting and hitting an undiagnosable hang later.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +15
-0@@ -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" ,
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static const struct of_device_id meson8b_dwmac_match[] = { · line 524
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +4
-0@@ -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);
Thanks,
Neil
Re: [RFC PATCH 4/6] arm64: dts: amlogic: t7: add the ethernet pinctrl nodes
In reply to Lucas TanureQuoted 45 lines · 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.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+)arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +23
-0@@ -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",
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi mux { · line 411
Quoted 10 lines
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +7
-0+ "eth_txd3_rgmii"; + function = "eth"; + drive-strength-microamp = <4000>; + bias-disable; + }; + }; + i2c0_ao_d_pins: i2c0-ao-d { mux { groups = "i2c0_ao_sck_d",
Thanks,
Neil
Re: [RFC PATCH 5/6] arm64: dts: amlogic: t7: add the ethernet controller
In reply to Lucas TanureQuoted 89 lines · Lucas Tanure
The SoC pairs a Synopsys gigabit MAC with a small block of glue registers that selects the interface type and trims the clock timing, and with a multiplexer that points the management bus at either the on-chip 100M PHY or the external pins. None of it was described, so the port could not be used at all.
Add the controller and the multiplexer. The MAC reports a 5.10a core. The path the controller reaches memory over runs through a pipeline stage with a gate of its own, so hand that to the controller as well; nothing else claims it and it would otherwise be switched off as unused, leaving the port unable to complete a transfer.
The on-chip PHY behind the second port of the multiplexer is described the way the G12A does it. No board in tree uses it and that path is untested.
The controller is left disabled for boards to enable.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 57 +++++++++++++++++++++ 1 file changed, 57 insertions(+)arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +50
-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", + "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>; + clock-names = "stmmaceth", "clkin0", "clkin1", "pipeline"; + 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,38 @@ 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";
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi gpio_intc: interrupt-controller@4080 { · line 707
Quoted 10 lines
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +7
-0+ interrupts = <GIC_SPI 340 IRQ_TYPE_LEVEL_HIGH>; + reg = <8>; + max-speed = <100>; + }; + }; + }; + uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>;
Thanks,
Neil
Re: [RFC PATCH 6/6] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
In reply to Lucas TanureQuoted 58 lines · 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. The clock delays RGMII needs are supplied by the MAC rather than the PHY: 2ns on transmit and 2000ps on receive, the values the vendor kernel programs.
The PHY interrupt output is wired to
GPIOH_6, so describe it and let link changes be reported instead of polled. The PHY reset pin is driven by an RC network on the board, not by the SoC, so there is no reset line to describe.Tested at 930Mbit/s sustained receive over a minute, with no MAC error counters moving in either direction.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +21
-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,33 @@ xtal: xtal-clk { }; }; +ðmac { + status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + + /* + * The RGMII clock delays are added by the MAC, so the PHY is + * asked for the mode that adds none. + */ + phy-mode = "rgmii"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; + rx-internal-delay-ps = <2000>; +}; + +&ext_mdio { + external_phy: ethernet-phy@0 { + /* Realtek RTL8211FD-CG */ + reg = <0>; + max-speed = <1000>;
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 289
Quoted 10 lines
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +7
-0+ + interrupt-parent = <&gpio_intc>; + /* RGMII_INT on GPIOH_6 */ + interrupts = <154 IRQ_TYPE_LEVEL_LOW>; + }; +}; + &i2c_m_ao_a { status = "okay"; pinctrl-0 = <&i2c0_ao_d_pins>;
Thanks,
Neil
Maxime Chevallier
maintainerRe: [RFC PATCH 6/6] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
In reply to Lucas TanureHi Lucas,
Quoted 38 lines · 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. The clock delays RGMII needs are supplied by the MAC rather than the PHY: 2ns on transmit and 2000ps on receive, the values the vendor kernel programs.
The PHY interrupt output is wired to
GPIOH_6, so describe it and let link changes be reported instead of polled. The PHY reset pin is driven by an RC network on the board, not by the SoC, so there is no reset line to describe.Tested at 930Mbit/s sustained receive over a minute, with no MAC error counters moving in either direction.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +1
-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,33 @@ xtal: xtal-clk { }; };
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 269
Quoted 10 lines
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +10
-0+ðmac { + status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + + /* + * The RGMII clock delays are added by the MAC, so the PHY is + * asked for the mode that adds none. + */ + phy-mode = "rgmii";
In devicetree, "rgmii" means that the delays are inserted at the hardware level, i.e. with longer PCB traces for the clock. With the above comment, this is therefore wrong.
As a rule of thumb, "phy-mode = rgmii" is almost always wrong.
The right behaviour here is to represent the HW as it is, that is to say pass phy-mode = "rgmii-id"; delays are internal. In DT we don't say who inserts the delays (MAC or PHY), that's for the drive to figure out.
If the MAC inserts the delays, then it needs to fixup the mode passed to the PHY so that they follow this doc :
https://www.kernel.org/doc/html/v7.2/networking/phy.html#rg-mii-electrical-interface-considerations
Maxime
Maxime Chevallier
maintainerRe: [RFC PATCH 3/6] net: stmmac: dwmac-meson8b: add support for the Amlogic T7
In reply to Lucas TanureHi Lucas,
Quoted 18 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 the T7 does not share is how the controller reaches DRAM: the bus path goes through a pipeline stage with a gate of its own, and no device other than the controller has any use for that gate. Claim it and hold it enabled for as long as the controller is bound, otherwise it is switched off as unused and a transfer that has been started can never complete.
Give the T7 match data of its own so that only it looks the clock up, and require the clock instead of treating it as optional: the controller cannot do DMA without it, and failing the probe with a clear message beats booting and hitting an undiagnosable hang later.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>---
[...]
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c static const struct meson8b_dwmac_data meson_g12a_dwmac_data = { · line 493
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +3
-0+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,
Hmpf sorry this falls onto your series, but looking at the code it seems that this glue has the RGMII handling backwards...
In meson8b_init_rgmii_delays :
switch (dwmac->phy_mode) {
case PHY_INTERFACE_MODE_RGMII:
delay_config = tx_dly_config | rx_adj_config;
break;
case PHY_INTERFACE_MODE_RGMII_RXID:
delay_config = tx_dly_config;
cfg_rxclk_dly = 0;
break;
case PHY_INTERFACE_MODE_RGMII_TXID:
delay_config = rx_adj_config;
break;
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RMII:
delay_config = 0;
cfg_rxclk_dly = 0; This is the behaviour one would expect from a PHY perspective.
And indeed, 66 amlogic dts have "phy-mode = rgmii".
grep "phy-mode = \"rgmii\"" $(find arch/ | grep amlogic) | wc -l 66
I really think all these 66 "rgmii" instance should have been "rgmii-id"...
It's probably too late to change that though :(
Maxime
Re: [RFC PATCH 6/6] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
In reply to Maxime ChevallierQuoted 62 lines · Maxime Chevallier
Hi Lucas,
Quoted 38 lines · 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. The clock delays RGMII needs are supplied by the MAC rather than the PHY: 2ns on transmit and 2000ps on receive, the values the vendor kernel programs.
The PHY interrupt output is wired to
GPIOH_6, so describe it and let link changes be reported instead of polled. The PHY reset pin is driven by an RC network on the board, not by the SoC, so there is no reset line to describe.Tested at 930Mbit/s sustained receive over a minute, with no MAC error counters moving in either direction.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- .../amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +1
-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,33 @@ xtal: xtal-clk { }; };arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 269
Quoted 10 lines
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +10
-0+ðmac { + status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + + /* + * The RGMII clock delays are added by the MAC, so the PHY is + * asked for the mode that adds none. + */ + phy-mode = "rgmii";In devicetree, "rgmii" means that the delays are inserted at the hardware level, i.e. with longer PCB traces for the clock. With the above comment, this is therefore wrong.
As a rule of thumb, "phy-mode = rgmii" is almost always wrong.
The right behaviour here is to represent the HW as it is, that is to say pass phy-mode = "rgmii-id"; delays are internal. In DT we don't say who inserts the delays (MAC or PHY), that's for the drive to figure out.
Quoted 6 lines
If the MAC inserts the delays, then it needs to fixup the mode passed to the PHY so that they follow this doc :
https://www.kernel.org/doc/html/v7.2/networking/phy.html#rg-mii-electrical-interface-considerations
Maxime
Hi Maxime,
Thanks for the review. You are right about what the mode names mean, but after a few tests I do not think this board can follow it. I tried all three:
rgmii-id 23 of 23 received frames had a bad CRC, DHCP never
completes.
rgmii-txid receive becomes perfect, but then the peer sees nothing
we send, not even an error counter.
rgmii 1Gbit/s, 930Mbit/s sustained, no error counter moving.
There was nothing to tune on the PHY side either: the RTL8211F delays are single enable bits, TXCR bit 8 and RXCR bit 3, on or off.
The modes whose names promise internal delays are the same ones where the glue switches its own off, so there is no value that is both right by phy.rst and working here. Keeping "rgmii" and the comment, so the next person sees why before trying it. Glad to help test and convert this board if the driver's phy-mode handling is ever reworked along with the other Amlogic boards.
Thanks,
Lucas
Re: [RFC PATCH 1/6] dt-bindings: net: amlogic,meson-dwmac: spell out the compatible combinations
In reply to Lucas Tanurepw-bot: not-applicable
Re: [RFC PATCH 2/6] dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac
In reply to Lucas TanureQuoted 53 lines · Lucas Tanure
The T7 has the same ethernet glue as the G12A, but the controller reaches DRAM through a pipeline stage that the hardware design inserts in the bus path. That stage has a gate of its own, which no other member of the family has. Nothing else in Linux claims the gate, so it is switched off as unused and the port can then no longer complete a transfer.
Describing it means a fourth clock, and the fourth clock of the existing list is the one driving the timing adjustment logic. The T7 applies the RGMII RX delay through
PRG_ETH1and never enables that logic, so it has no use for that clock. Give the T7 a list of its own with the pipeline gate as the fourth entry, under the same name the SD/eMMC controllers of this SoC already use for the equivalent stage on their own bus path. All four entries are required, since the port cannot move data without any of them.The RX delay range is the one the G12A has, since it is the same register field.
The compatible pairs the T7 name with the 5.10a Synopsys core the MAC reports, and with the generic fallback.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- .../bindings/net/amlogic,meson-dwmac.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +10
-0@@ -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,47 @@ allOf: - const: clkin1 - const: timing-adjustment + # The T7 applies the RGMII RX delay through PRG_ETH1 and never enables the + # timing adjustment logic, so it has no timing-adjustment clock. What it does + # need is the gate of the pipeline stage the controller reaches DRAM through. + - if: + properties: + compatible: + contains: + const: amlogic,t7-dwmac + then:
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 79
Quoted 10 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +10
-0+ 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.
Have you checked that this actually works as a limiter to only 4 clocks? There's an additionalItems: true in the snps,dwmac.yaml that I don't know if will permit random additional items here.
Cheers,
Conor.
Quoted 47 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +27
-0+ + clock-names: + items: + - const: stmmaceth + - const: clkin0 + - const: clkin1 + - const: pipeline + + # Delay definitions for Meson8b and newer (including T7) + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8b-dwmac + - amlogic,meson8m2-dwmac + - amlogic,meson-gxbb-dwmac + - amlogic,meson-axg-dwmac + - amlogic,meson-g12a-dwmac + - amlogic,t7-dwmac + then: + properties: amlogic,tx-delay-ns: enum: [0, 2, 4, 6] default: 2@@ -106,6 +148,7 @@ allOf: contains: enum: - amlogic,meson-g12a-dwmac + - amlogic,t7-dwmac then: properties: rx-internal-delay-ps:@@ -143,6 +186,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
Re: [RFC PATCH 6/6] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
In reply to Lucas Tanurearch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 272
Quoted 13 lines
+ðmac {
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +12
-0+ status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + + /* + * The RGMII clock delays are added by the MAC, so the PHY is + * asked for the mode that adds none. + */ + phy-mode = "rgmii"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; + rx-internal-delay-ps = <2000>;
I agree with Maxime here, rgmii is wrong. We really need to understand what is going on here, especially since you are asking for the MAC to do the usual 2ns, nothing special.
Is the PHY not actually inserting the correct delay? What does the datasheet say?
Also, we have one vendor property and one generic property. Can amlogic,tx-delay-ns be replaced by tx-internal-delay-ps? But that comes later, once we have determined these properties really must be used.
Humm, what is meson8b_init_rgmii_delays() doing? What is phydev->interface in the PHY driver.
Please take a read on:
and figure out what is going on here, because at a first look, it seems broken.
Andrew
Re: [RFC PATCH 6/6] arm64: dts: amlogic: t7: khadas-vim4: enable the ethernet port
Quoted 15 lines · Andrew Lunn
Quoted 4 lines
+ðmac {
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +2
-0+ status = "okay"; + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>;arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts xtal: xtal-clk { · line 272
Quoted 10 lines
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +10
-0+ pinctrl-names = "default"; + + /* + * The RGMII clock delays are added by the MAC, so the PHY is + * asked for the mode that adds none. + */ + phy-mode = "rgmii"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; + rx-internal-delay-ps = <2000>;
Quoted 5 lines
I agree with Maxime here, rgmii is wrong. We really need to understand what is going on here, especially since you are asking for the MAC to do the usual 2ns, nothing special.
Is the PHY not actually inserting the correct delay?
It does. The PHY driver shows both delay bits going from off to on, so nothing was strapped and the bootloader did not set them.
I swept the MAC RX clock delay and counted CRC errors, to see where the good window is:
MAC does RX delay, PHY none: clean 400 .. 3800ps PHY does RX delay, MAC adds: clean 0 .. 1600ps
Same window, moved 11 steps. So the PHY gives about 2200ps, and the first window is centred at 2100ps. It is right.
Transmit is the broken one. With rgmii-txid the peer sees nothing we send.
What does the
Quoted 1 line
datasheet say?
The A311D2 covers both ways of doing it. Table 5-21, RGMII receive:
PHY internal delay on: needs 1.2ns setup and 1.2ns hold
PHY internal delay off: needs -0.5 .. 0.5ns skew
with a note to check setup/hold when the PHY delay is on, and skew when it is off. Table 5-22 does the same for transmit, separate numbers for "clock delay added" and "no clock delay added".
So the MAC doing the delay is a documented mode of this SoC.
What it does not say is why the PHY TX delay misses. I asked Khadas about the clock trace lengths, no answer yet.
Quoted 5 lines
Also, we have one vendor property and one generic property. Can amlogic,tx-delay-ns be replaced by tx-internal-delay-ps? But that comes later, once we have determined these properties really must be used.
A new version of the series will have a fix for it. It will prefer the generic one.
One thing to know: that register field is a fraction of the clock period, not a time.
The driver comment says "8ns / 4 * tx_dly_val". A quarter cycle is 2ns at 1Gbit and 10ns
at 100Mbit, so 2000 is only true at gigabit.
Quoted 2 lines
Humm, what is
meson8b_init_rgmii_delays()doing?
It picks the MAC delays from phy-mode alone, with the sense inverted:
rgmii MAC adds both delays rgmii-rxid MAC adds TX rgmii-txid MAC adds RX rgmii-id MAC adds none
So the mode that says the delays are internal is the one where the MAC switches its own off. It also ignores the *-internal-delay-ps properties in those modes. With rgmii-id and both of them set I get:
phy-mode rgmii-id: tx-delay-ns 2 rx-delay-ps 2000
-> PRG_ETH0 delay_config 0x0, PRG_ETH1 cfg_rxclk_dly 0x0
What is
Quoted 1 line
phydev->interfacein the PHY driver.
Whatever phy-mode says, dwmac-meson8b.c never rewrites it. Which means the MAC and the PHY always split the job:
rgmii MAC both PHY none rgmii-rxid MAC TX PHY RX rgmii-txid MAC RX PHY TX rgmii-id MAC none PHY both
They never both delay the same clock, and never both skip it. So the driver is self consistent, it is just labelled backwards from phy.rst. That is why the boards using "rgmii" work, and why rgmii-id is the one that does not here: it is the mode that hands everything to the PHY.
Quoted 9 lines
Please take a read on:
and figure out what is going on here, because at a first look, it seems broken.
Andrew
It is broken. phy-mode describes the PCB, but dwmac-meson8b.c reads it as which chip adds the delay. The labels are backwards, and in rgmii-id both *-internal-delay-ps properties are ignored.
I measured each direction with an eye scan. The PHY RX delay is fine, about 2200ps. Its TX delay does not work at all, so the MAC must do that one.
Fix: in the -id modes each *-internal-delay-ps property means the MAC does that delay, and the PHY is told to do the rest:
both properties MAC does TX and RX PHY told rgmii
tx property only MAC does TX PHY told rgmii-rxid rx property only MAC does RX PHY told rgmii-txid no property MAC does nothing PHY told rgmii-id
Boards without those properties keep today's behaviour, so meson8b-odroidc1 and meson8m2-mxiii-plus are untouched.
Vim4 will use phy-mode = "rgmii-id" with tx-internal-delay-ps = <2000>. 935Mbit/s both ways, no CRC errors.
I am sending a v2 with the fix for dwmac-meson8b.c as its own patch.
Thanks
Lucas
Re: [RFC PATCH 2/6] dt-bindings: net: amlogic,meson-dwmac: add amlogic,t7-dwmac
In reply to Conor DooleyQuoted 59 lines · Conor Dooley
Quoted 57 lines · Lucas Tanure
The T7 has the same ethernet glue as the G12A, but the controller reaches DRAM through a pipeline stage that the hardware design inserts in the bus path. That stage has a gate of its own, which no other member of the family has. Nothing else in Linux claims the gate, so it is switched off as unused and the port can then no longer complete a transfer.
Describing it means a fourth clock, and the fourth clock of the existing list is the one driving the timing adjustment logic. The T7 applies the RGMII RX delay through
PRG_ETH1and never enables that logic, so it has no use for that clock. Give the T7 a list of its own with the pipeline gate as the fourth entry, under the same name the SD/eMMC controllers of this SoC already use for the equivalent stage on their own bus path. All four entries are required, since the port cannot move data without any of them.The RX delay range is the one the G12A has, since it is the same register field.
The compatible pairs the T7 name with the 5.10a Synopsys core the MAC reports, and with the generic fallback.
Assisted-by LLMSigned-off-by Lucas Tanure <[email protected]>--- .../bindings/net/amlogic,meson-dwmac.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +14
-0@@ -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,47 @@ allOf: - const: clkin1 - const: timing-adjustment + # The T7 applies the RGMII RX delay through PRG_ETH1 and never enables the + # timing adjustment logic, so it has no timing-adjustment clock. What it does + # need is the gate of the pipeline stage the controller reaches DRAM through. + - if: + properties: + compatible: + contains: + const: amlogic,t7-dwmac + then: + properties: + clocks: + items: + - description: GMAC main clock
Quoted 8 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml allOf: · line 79
Quoted 6 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +6
-0+ - 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.Have you checked that this actually works as a limiter to only 4 clocks?
I have now, and it does limit to four. Adding
a fifth clock to the board gets rejected:
ethernet@fdc00000 (amlogic,t7-dwmac): clock-names:
['stmmaceth', 'clkin0', 'clkin1', 'pipeline', 'bogus'] is too long
Quoted 2 lines
There's an additionalItems: true in the snps,dwmac.yaml that I don't know if will permit random additional items here.
There are two checks on clocks and both have to pass: snps,dwmac.yaml allows 1 to 10 items, the t7 branch allows exactly 4. The
additionalItems: true only relaxes the first one, so the second still rejects a fifth clock. The "exactly 4" is not something I wrote - dt-schema's _fixup_items_size() sets minItems and maxItems from the length of the items list.
Quoted 51 lines
Cheers,
Conor.Quoted 47 lines
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +27
-1+ + clock-names: + items: + - const: stmmaceth + - const: clkin0 + - const: clkin1 + - const: pipeline + + # Delay definitions for Meson8b and newer (including T7) + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8b-dwmac + - amlogic,meson8m2-dwmac + - amlogic,meson-gxbb-dwmac + - amlogic,meson-axg-dwmac + - amlogic,meson-g12a-dwmac + - amlogic,t7-dwmac + then: + properties: amlogic,tx-delay-ns: enum: [0, 2, 4, 6] default: 2@@ -106,6 +148,7 @@ allOf: contains: enum: - amlogic,meson-g12a-dwmac + - amlogic,t7-dwmac then: properties: rx-internal-delay-ps:@@ -143,6 +186,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: --2.56.0