Skip to contentSkip to conversation

add ethernet support to rk3568 dts

PATCH Superseded Michael Riesch 5 participants 10 messages Jul 28, 2021 – Jul 29, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover add ethernet support to rk3568 dts

Hi all,

these patches should be orthogonal to the ongoing work of Peter Geis that aims to introduce the GMAC1 node to the common RK356x dts. The GMAC0 node, which is exclusive to the RK3568, and the Ethernet phy nodes in the RK3568 EVB1 are introduced in this series. The second patch bases on the dts in barebox by Sascha Hauer.

Best regards,
Michael

Michael Riesch (2):
arm64: dts: rockchip: add gmac0 node to rk3568
arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

 .../boot/dts/rockchip/rk3568-evb1-v10.dts     | 69 +++++++++++++++++++
 arch/arm64/boot/dts/rockchip/rk3568.dtsi      | 51 ++++++++++++++
 2 files changed, 120 insertions(+)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 arm64: dts: rockchip: add gmac0 node to rk3568

While both RK3566 and RK3568 feature the gmac1 node, the gmac0 node is exclusive to the RK3568.

---
 arch/arm64/boot/dts/rockchip/rk3568.dtsi | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568.dtsi +51 -0
index da01a59f6f26..ec39a2c593b6 100644
@@ -22,6 +22,57 @@
 		compatible = "rockchip,rk3568-qos", "syscon";
 		reg = <0x0 0xfe190200 0x0 0x20>;
 	};
+
+	gmac0: ethernet@fe2a0000 {
+		compatible = "rockchip,rk3568-gmac", "snps,dwmac-4.20a";
+		reg = <0x0 0xfe2a0000 0x0 0x10000>;
+		interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		rockchip,grf = <&grf>;
+		clocks = <&cru SCLK_GMAC0>, <&cru SCLK_GMAC0_RX_TX>,
+			 <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_MAC0_REFOUT>,
+			 <&cru ACLK_GMAC0>, <&cru PCLK_GMAC0>,
+			 <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_GMAC0_PTP_REF>,
+			 <&cru PCLK_XPCS>;
+		clock-names = "stmmaceth", "mac_clk_rx",
+			      "mac_clk_tx", "clk_mac_refout",
+			      "aclk_mac", "pclk_mac",
+			      "clk_mac_speed", "ptp_ref",
+			      "pclk_xpcs";
+		resets = <&cru SRST_A_GMAC0>;
+		reset-names = "stmmaceth";
+
+		snps,mixed-burst;
+		snps,tso;
+
+		snps,axi-config = <&gmac0_stmmac_axi_setup>;
+		snps,mtl-rx-config = <&gmac0_mtl_rx_setup>;
+		snps,mtl-tx-config = <&gmac0_mtl_tx_setup>;
+		status = "disabled";
+
+		mdio0: mdio {
+			compatible = "snps,dwmac-mdio";
+			#address-cells = <0x1>;
+			#size-cells = <0x0>;
+		};
+
+		gmac0_stmmac_axi_setup: stmmac-axi-config {
+			snps,wr_osr_lmt = <4>;
+			snps,rd_osr_lmt = <8>;
+			snps,blen = <0 0 0 0 16 8 4>;
+		};
+
+		gmac0_mtl_rx_setup: rx-queues-config {
+			snps,rx-queues-to-use = <1>;
+			queue0 {};
+		};
+
+		gmac0_mtl_tx_setup: tx-queues-config {
+			snps,tx-queues-to-use = <1>;
+			queue0 {};
+		};
+	};
 };
 
 &cpu0_opp_table {
Signature · 1 line
2.20.1
#4 lore raw

PATCH 2/2 arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

In reply to Michael Riesch
---
 .../boot/dts/rockchip/rk3568-evb1-v10.dts     | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +69 -0
index 69786557093d..8f4c40d71914 100644
@@ -13,6 +13,11 @@
 	model = "Rockchip RK3568 EVB1 DDR4 V10 Board";
 	compatible = "rockchip,rk3568-evb1-v10", "rockchip,rk3568";
 
+	aliases {
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
+	};
+
 	chosen: chosen {
 		stdout-path = "serial2:1500000n8";
 	};
@@ -67,6 +72,70 @@
 	};
 };
 
+&gmac0 {
+	phy-mode = "rgmii";
+	clock_in_out = "output";
+
+	assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
+	assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>;
+	assigned-clock-rates = <0>, <125000000>;
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&gmac0_miim
+		     &gmac0_tx_bus2
+		     &gmac0_rx_bus2
+		     &gmac0_rgmii_clk
+		     &gmac0_rgmii_bus>;
+
+	tx_delay = <0x3c>;
+	rx_delay = <0x2f>;
+
+	phy-handle = <&rgmii_phy0>;
+	status = "okay";
+};
+
+&gmac1 {
+	phy-mode = "rgmii";
+	clock_in_out = "output";
+
+	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>;
+	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>;
+	assigned-clock-rates = <0>, <125000000>;
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&gmac1m1_miim
+		     &gmac1m1_tx_bus2
+		     &gmac1m1_rx_bus2
+		     &gmac1m1_rgmii_clk
+		     &gmac1m1_rgmii_bus>;
+
+	tx_delay = <0x4f>;
+	rx_delay = <0x26>;
+
+	phy-handle = <&rgmii_phy1>;
+	status = "okay";
+};
+
+&mdio0 {
+	rgmii_phy0: phy@0 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reset-gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>;
+		reset-assert-us = <20000>;
+		reset-deassert-us = <100000>;
+		reg = <0x0>;
+	};
+};
+
+&mdio1 {
+	rgmii_phy1: phy@0 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reset-gpios = <&gpio2 RK_PD1 GPIO_ACTIVE_LOW>;
+		reset-assert-us = <20000>;
+		reset-deassert-us = <100000>;
+		reg = <0x0>;
+	};
+};
+
 &sdhci {
 	bus-width = <8>;
 	max-frequency = <200000000>;
Signature · 1 line
2.20.1
maintainer
#2 lore raw

Re: [PATCH 1/2] arm64: dts: rockchip: add gmac0 node to rk3568

In reply to Michael Riesch

Hi,

Am Mittwoch, 28. Juli 2021, 18:10:19 CEST schrieb Michael Riesch:

Quoted 27 lines

While both RK3566 and RK3568 feature the gmac1 node, the gmac0 node is exclusive to the RK3568.

---
 arch/arm64/boot/dts/rockchip/rk3568.dtsi | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568.dtsi +11 -0
index da01a59f6f26..ec39a2c593b6 100644
@@ -22,6 +22,57 @@
 		compatible = "rockchip,rk3568-qos", "syscon";
 		reg = <0x0 0xfe190200 0x0 0x20>;
 	};
+
+	gmac0: ethernet@fe2a0000 {
+		compatible = "rockchip,rk3568-gmac", "snps,dwmac-4.20a";
+		reg = <0x0 0xfe2a0000 0x0 0x10000>;
+		interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		rockchip,grf = <&grf>;
+		clocks = <&cru SCLK_GMAC0>, <&cru SCLK_GMAC0_RX_TX>,
+			 <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_MAC0_REFOUT>,
+			 <&cru ACLK_GMAC0>, <&cru PCLK_GMAC0>,

arch/arm64/boot/dts/rockchip/rk3568.dtsi line 45

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3568.dtsi +10 -0
+			 <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_GMAC0_PTP_REF>,
+			 <&cru PCLK_XPCS>;
+		clock-names = "stmmaceth", "mac_clk_rx",
+			      "mac_clk_tx", "clk_mac_refout",
+			      "aclk_mac", "pclk_mac",
+			      "clk_mac_speed", "ptp_ref",
+			      "pclk_xpcs";
+		resets = <&cru SRST_A_GMAC0>;
+		reset-names = "stmmaceth";
+

is this missing a rockchip,grf phandle?

gmac1 has one and the driver side also does want to access the grf for both controllers.

Heiko

Quoted 34 lines
arch/arm64/boot/dts/rockchip/rk3568.dtsi +30 -0
+		snps,mixed-burst;
+		snps,tso;
+
+		snps,axi-config = <&gmac0_stmmac_axi_setup>;
+		snps,mtl-rx-config = <&gmac0_mtl_rx_setup>;
+		snps,mtl-tx-config = <&gmac0_mtl_tx_setup>;
+		status = "disabled";
+
+		mdio0: mdio {
+			compatible = "snps,dwmac-mdio";
+			#address-cells = <0x1>;
+			#size-cells = <0x0>;
+		};
+
+		gmac0_stmmac_axi_setup: stmmac-axi-config {
+			snps,wr_osr_lmt = <4>;
+			snps,rd_osr_lmt = <8>;
+			snps,blen = <0 0 0 0 16 8 4>;
+		};
+
+		gmac0_mtl_rx_setup: rx-queues-config {
+			snps,rx-queues-to-use = <1>;
+			queue0 {};
+		};
+
+		gmac0_mtl_tx_setup: tx-queues-config {
+			snps,tx-queues-to-use = <1>;
+			queue0 {};
+		};
+	};
 };
 
 &cpu0_opp_table {
#5 lore raw

Re: [PATCH 2/2] arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

In reply to Michael Riesch

Hi Michael,

Quoted 62 lines · Michael Riesch
---
 .../boot/dts/rockchip/rk3568-evb1-v10.dts     | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +42 -0
index 69786557093d..8f4c40d71914 100644
@@ -13,6 +13,11 @@
 	model = "Rockchip RK3568 EVB1 DDR4 V10 Board";
 	compatible = "rockchip,rk3568-evb1-v10", "rockchip,rk3568";
 
+	aliases {
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
+	};
+
 	chosen: chosen {
 		stdout-path = "serial2:1500000n8";
 	};
@@ -67,6 +72,70 @@
 	};
 };
 
+&gmac0 {
+	phy-mode = "rgmii";
+	clock_in_out = "output";
+
+	assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
+	assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>;
+	assigned-clock-rates = <0>, <125000000>;
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&gmac0_miim
+		     &gmac0_tx_bus2
+		     &gmac0_rx_bus2
+		     &gmac0_rgmii_clk
+		     &gmac0_rgmii_bus>;
+
+	tx_delay = <0x3c>;
+	rx_delay = <0x2f>;
+
+	phy-handle = <&rgmii_phy0>;
+	status = "okay";
+};
+
+&gmac1 {
+	phy-mode = "rgmii";
+	clock_in_out = "output";
+
+	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>;
+	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>;
+	assigned-clock-rates = <0>, <125000000>;
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&gmac1m1_miim
+		     &gmac1m1_tx_bus2
+		     &gmac1m1_rx_bus2
+		     &gmac1m1_rgmii_clk
+		     &gmac1m1_rgmii_bus>;
+

arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts line 121

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +9 -0
+	tx_delay = <0x4f>;
+	rx_delay = <0x26>;
+
+	phy-handle = <&rgmii_phy1>;
+	status = "okay";
+};
+
+&mdio0 {
 
+	rgmii_phy0: phy@0 {

Could you test with ethernet-phy.yaml?

$nodename:

    pattern: "^ethernet-phy(@[a-f0-9]+)?$"

arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts line 125

Quoted 5 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +5 -0
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reset-gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>;
+		reset-assert-us = <20000>;
+		reset-deassert-us = <100000>;
+		reg = <0x0>;

Sort order is:
compatible
reg
(interrupts)
The rest in alphabetical order.

arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts line 130

Quoted 6 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +5 -0
+	};
+};
+
+&mdio1 {
 
+	rgmii_phy1: phy@0 {

dito

arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts line 135

Quoted 5 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +5 -0
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reset-gpios = <&gpio2 RK_PD1 GPIO_ACTIVE_LOW>;
+		reset-assert-us = <20000>;
+		reset-deassert-us = <100000>;
+		reg = <0x0>;

dito

Quoted 7 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +3 -0
+	};
+};
+
 &sdhci {
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +0 -0
 	bus-width = <8>;
 	max-frequency = <200000000>;
maintainer
#3 lore raw

Re: [PATCH 1/2] arm64: dts: rockchip: add gmac0 node to rk3568

In reply to Heiko Stübner

Am Mittwoch, 28. Juli 2021, 18:43:24 CEST schrieb Heiko Stübner:

Quoted 11 lines

Hi,

Am Mittwoch, 28. Juli 2021, 18:10:19 CEST schrieb Michael Riesch:

Quoted 8 lines

While both RK3566 and RK3568 feature the gmac1 node, the gmac0 node is exclusive to the RK3568.

---
 arch/arm64/boot/dts/rockchip/rk3568.dtsi | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Quoted 16 lines
Quoted 6 lines
arch/arm64/boot/dts/rockchip/rk3568.dtsi +0 -0
index da01a59f6f26..ec39a2c593b6 100644
@@ -22,6 +22,57 @@
 		compatible = "rockchip,rk3568-qos", "syscon";

arch/arm64/boot/dts/rockchip/rk3568.dtsi line 32

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3568.dtsi +8 -0
 		reg = <0x0 0xfe190200 0x0 0x20>;
 	};
+
+	gmac0: ethernet@fe2a0000 {
+		compatible = "rockchip,rk3568-gmac", "snps,dwmac-4.20a";
+		reg = <0x0 0xfe2a0000 0x0 0x10000>;
+		interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		rockchip,grf = <&grf>;

Johan thankfully pointed out that the grf is hiding up here, so this should move below reset-names ;-)

Heiko

Quoted 58 lines

arch/arm64/boot/dts/rockchip/rk3568.dtsi line 45

Quoted 13 lines
arch/arm64/boot/dts/rockchip/rk3568.dtsi +13 -0
+		clocks = <&cru SCLK_GMAC0>, <&cru SCLK_GMAC0_RX_TX>,
+			 <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_MAC0_REFOUT>,
+			 <&cru ACLK_GMAC0>, <&cru PCLK_GMAC0>,
+			 <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_GMAC0_PTP_REF>,
+			 <&cru PCLK_XPCS>;
+		clock-names = "stmmaceth", "mac_clk_rx",
+			      "mac_clk_tx", "clk_mac_refout",
+			      "aclk_mac", "pclk_mac",
+			      "clk_mac_speed", "ptp_ref",
+			      "pclk_xpcs";
+		resets = <&cru SRST_A_GMAC0>;
+		reset-names = "stmmaceth";
+

is this missing a rockchip,grf phandle?

gmac1 has one and the driver side also does want to access the grf for both controllers.

Heiko

Quoted 34 lines
arch/arm64/boot/dts/rockchip/rk3568.dtsi +30 -0
+		snps,mixed-burst;
+		snps,tso;
+
+		snps,axi-config = <&gmac0_stmmac_axi_setup>;
+		snps,mtl-rx-config = <&gmac0_mtl_rx_setup>;
+		snps,mtl-tx-config = <&gmac0_mtl_tx_setup>;
+		status = "disabled";
+
+		mdio0: mdio {
+			compatible = "snps,dwmac-mdio";
+			#address-cells = <0x1>;
+			#size-cells = <0x0>;
+		};
+
+		gmac0_stmmac_axi_setup: stmmac-axi-config {
+			snps,wr_osr_lmt = <4>;
+			snps,rd_osr_lmt = <8>;
+			snps,blen = <0 0 0 0 16 8 4>;
+		};
+
+		gmac0_mtl_rx_setup: rx-queues-config {
+			snps,rx-queues-to-use = <1>;
+			queue0 {};
+		};
+
+		gmac0_mtl_tx_setup: tx-queues-config {
+			snps,tx-queues-to-use = <1>;
+			queue0 {};
+		};
+	};
 };
 
 &cpu0_opp_table {
#6 lore raw

Re: [PATCH 2/2] arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

In reply to Michael Riesch
Quoted 2 lines · Michael Riesch

+&gmac0 {

(quoted diff) +1 -0
+	phy-mode = "rgmii";

...

arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts line 91

Quoted 3 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +3 -0
+
+	tx_delay = <0x3c>;
+	rx_delay = <0x2f>;

Hi Michael

In general, we try to have the PHY introduce the RGMII delays, not the MAC. Did you try

phy-mode = "rgmii-id";

and remove these delay values? It is hard for me to say if that will work because i've no idea what 0x3c and 0x2f means? Are they equivalent to 2ns?

Andrew

#7 lore raw

Re: [PATCH 2/2] arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

Quoted 12 lines · Andrew Lunn
Quoted 2 lines · Michael Riesch

+&gmac0 {
+ phy-mode = "rgmii";

...

arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts line 91

Quoted 3 lines
arch/arm64/boot/dts/rockchip/rk3568-evb1-v10.dts +3 -0
+
+     tx_delay = <0x3c>;
+     rx_delay = <0x2f>;

Hi Michael

Quoted 8 lines

In general, we try to have the PHY introduce the RGMII delays, not the MAC. Did you try

phy-mode = "rgmii-id";

and remove these delay values? It is hard for me to say if that will work because i've no idea what 0x3c and 0x2f means? Are they equivalent to 2ns?

Unfortunately the driver and TRM are both rather non-specific as to how this works.
The driver sets the tx_delay to 0x30 and rx_delay to 0x10 if these values are not defined, or sets them both to 0 in case of rgmii_id.

Generally all rockchip boards use this value instead of the rgmii_id, I imagine because it's more consistent to tune here than the hit or miss support of the phy drivers.
The usual course of action is to test to find the lowest and highest working values and take the median value to plug in here.

Quoted 2 lines

Andrew

#8 lore raw

Re: [PATCH 2/2] arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

Quoted 3 lines

Generally all rockchip boards use this value instead of the rgmii_id, I imagine because it's more consistent to tune here than the hit or miss support of the phy drivers.

Most PHY drivers actually implement it correctly, since by default, most systems get the PHY to do the delays.

But if most Rockchip boards do it this way, there is a lot to be said for consistence, so this is fine by me.

Andrew

#9 lore raw

Re: [PATCH 2/2] arm64: dts: rockchip: rk3568-evb1-v10: add ethernet support

Hello Andrew, Peter,

Quoted 9 lines · Andrew Lunn
Quoted 3 lines

Generally all rockchip boards use this value instead of the rgmii_id, I imagine because it's more consistent to tune here than the hit or miss support of the phy drivers.

Most PHY drivers actually implement it correctly, since by default, most systems get the PHY to do the delays.

But if most Rockchip boards do it this way, there is a lot to be said for consistence, so this is fine by me.

I have tested a dts without the delays and with phy-mode = "rgmii-id" and it seems to work just fine.

Although consistency with other Rockchip boards is something one should consider, I think I'll go along the "rgmii-id" path since this seems to be a more general convention.

Thanks for your comments, I'll submit a v2.

Regards, Michael