Skip to contentSkip to conversation

sunxi: Fix Ethernet on mostly A20 boards

PATCH In review Andre Przywara 4 participants 7 messages Mar 16, 2022 – Mar 21, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover sunxi: Fix Ethernet on mostly A20 boards

Hi,

testing on a BananaPi M1 board revealed that Ethernet has regressed since the last release due to not only one, but two bugs:
- The pinmux and GMAC clock setup for the A20 GMAC is apparently called too early now.
- The updated RGMII phy-mode properties are now taken for real, so many boards are using the wrong RX/TX line delay setup, with mostly fatal consequences.

Fix those two issues to bring Ethernet back on those affected boards.

I refrained from just syncing the DTs from the kernel (to fix the second issue): Recent changes in the mainline DTs require newer kernels to work, which breaks Linux distro installer ISO images running via UEFI. We need to find a solution for that, but not in -rc4, which would be rather late for a normal DT sync anyway.

Please have a look and test on your board!

Cheers,
Andre

Andre Przywara (2):
sunxi: Fix old GMAC pinmux setup
sunxi: dts: Update RGMII phy-mode properties

 arch/arm/dts/sun50i-a64-sopine-baseboard.dts  | 2 +-
 arch/arm/dts/sun50i-h5-nanopi-neo2.dts        | 2 +-
 arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts | 2 +-
 arch/arm/dts/sun6i-a31-hummingbird.dts        | 2 +-
 arch/arm/dts/sun7i-a20-bananapi-m1-plus.dts   | 2 +-
 arch/arm/dts/sun7i-a20-bananapi.dts           | 2 +-
 arch/arm/dts/sun7i-a20-bananapro.dts          | 2 +-
 arch/arm/dts/sun7i-a20-cubietruck.dts         | 2 +-
 arch/arm/dts/sun7i-a20-olinuxino-lime2.dts    | 2 +-
 arch/arm/dts/sun7i-a20-pcduino3-nano.dts      | 2 +-
 arch/arm/dts/sun8i-a83t-bananapi-m3.dts       | 2 +-
 arch/arm/dts/sun8i-a83t-cubietruck-plus.dts   | 2 +-
 arch/arm/dts/sun8i-h3-orangepi-plus.dts       | 2 +-
 arch/arm/dts/sunxi-bananapi-m2-plus.dtsi      | 2 +-
 arch/arm/mach-sunxi/board.c                   | 1 -
 board/sunxi/board.c                           | 3 +++
 16 files changed, 17 insertions(+), 15 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 sunxi: Fix old GMAC pinmux setup

Commit 5bc4cd05d7d4 ("sunxi: move non-essential code out of s_init()") moved the call to eth_init_board() from s_init() into board_init_f(). This means it's now only called from the SPL, which makes sense for most of the other moved low-level functions. However the GMAC pinmux and clock setup in eth_init_board() was not happy about that, so it broke the sun7i GMAC.

Since Ethernet is of no use in the SPL anyway, just move the call into board_init(), which is only run in U-Boot proper.

This fixes Ethernet operation for the A20 SoCs, which broke in v2022.04-rc1, with the above mentioned commit.

---
 arch/arm/mach-sunxi/board.c | 1 -
 board/sunxi/board.c         | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/board.c +0 -1
index 0071de19ffd..9a7673d82dc 100644
@@ -333,7 +333,6 @@ void board_init_f(ulong dummy)
 	clock_init();
 	timer_init();
 	gpio_init();
-	eth_init_board();
 
 	spl_init();
 	preloader_console_init();
board/sunxi/board.c +3 -0
index a0961590479..28f702bc296 100644
@@ -30,6 +30,7 @@
 #include <asm/arch/prcm.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/arch/spl.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
 #include <u-boot/crc.h>
@@ -308,6 +309,8 @@ int board_init(void)
 #endif
 #endif	/* CONFIG_DM_MMC */
 
+	eth_init_board();
+
 	return 0;
 }
 
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] sunxi: Fix old GMAC pinmux setup

Dne sreda, 16. marec 2022 ob 01:54:42 CET je Andre Przywara napisal(a):

Quoted 7 lines

Commit 5bc4cd05d7d4 ("sunxi: move non-essential code out of s_init()") moved the call to eth_init_board() from s_init() into board_init_f(). This means it's now only called from the SPL, which makes sense for most of the other moved low-level functions. However the GMAC pinmux and clock setup in eth_init_board() was not happy about that, so it broke the sun7i GMAC.

Quoted 7 lines

Since Ethernet is of no use in the SPL anyway, just move the call into board_init(), which is only run in U-Boot proper.

This fixes Ethernet operation for the A20 SoCs, which broke in v2022.04-rc1, with the above mentioned commit.

I guess this function will soon go away with introduction of clock and pinctrl driver.

Best regards,
Jernej

Quoted 42 lines
---
 arch/arm/mach-sunxi/board.c | 1 -
 board/sunxi/board.c         | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/board.c +0 -1
index 0071de19ffd..9a7673d82dc 100644
@@ -333,7 +333,6 @@ void board_init_f(ulong dummy)
 	clock_init();
 	timer_init();
 	gpio_init();
-	eth_init_board();
 
 	spl_init();
 	preloader_console_init();
board/sunxi/board.c +3 -0
index a0961590479..28f702bc296 100644
@@ -30,6 +30,7 @@
 #include <asm/arch/prcm.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/arch/spl.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
 #include <u-boot/crc.h>
@@ -308,6 +309,8 @@ int board_init(void)
 #endif
 #endif	/* CONFIG_DM_MMC */
 
+	eth_init_board();
+
 	return 0;
 }
 
Signature · 1 line
2.35.1
#3 lore raw

Re: [PATCH 1/2] sunxi: Fix old GMAC pinmux setup

Quoted 11 lines · On Wed, 16 Mar 2022 17:55:16 +0100 Jernej Škrabec <[email protected]>…

Dne sreda, 16. marec 2022 ob 01:54:42 CET je Andre Przywara napisal(a):

Quoted 10 lines

Commit 5bc4cd05d7d4 ("sunxi: move non-essential code out of s_init()") moved the call to eth_init_board() from s_init() into board_init_f(). This means it's now only called from the SPL, which makes sense for most of the other moved low-level functions. However the GMAC pinmux and clock setup in eth_init_board() was not happy about that, so it broke the sun7i GMAC.

Since Ethernet is of no use in the SPL anyway, just move the call into board_init(), which is only run in U-Boot proper.

Quoted 6 lines
Quoted 4 lines

This fixes Ethernet operation for the A20 SoCs, which broke in v2022.04-rc1, with the above mentioned commit.

Thanks!

Quoted 2 lines

I guess this function will soon go away with introduction of clock and pinctrl driver.

Yes, indeed, forgot to mention this. This is just a stop-gap measure to fix Ethernet before the 2022.04 release.

Cheers,
Andre

Quoted 48 lines

Best regards,
Jernej

Quoted 42 lines
---
 arch/arm/mach-sunxi/board.c | 1 -
 board/sunxi/board.c         | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/board.c +0 -1
index 0071de19ffd..9a7673d82dc 100644
@@ -333,7 +333,6 @@ void board_init_f(ulong dummy)
 	clock_init();
 	timer_init();
 	gpio_init();
-	eth_init_board();
 
 	spl_init();
 	preloader_console_init();
board/sunxi/board.c +3 -0
index a0961590479..28f702bc296 100644
@@ -30,6 +30,7 @@
 #include <asm/arch/prcm.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/arch/spl.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
 #include <u-boot/crc.h>
@@ -308,6 +309,8 @@ int board_init(void)
 #endif
 #endif	/* CONFIG_DM_MMC */
 
+	eth_init_board();
+
 	return 0;
 }
 
Signature · 1 line
2.35.1
Tested-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] sunxi: Fix old GMAC pinmux setup

In reply to Andre Przywara

Andre Przywara <[email protected]> [2022-03-16 00:54:42]:

Quoted 7 lines

Commit 5bc4cd05d7d4 ("sunxi: move non-essential code out of s_init()") moved the call to eth_init_board() from s_init() into board_init_f(). This means it's now only called from the SPL, which makes sense for most of the other moved low-level functions. However the GMAC pinmux and clock setup in eth_init_board() was not happy about that, so it broke the sun7i GMAC.

Quoted 5 lines

Since Ethernet is of no use in the SPL anyway, just move the call into board_init(), which is only run in U-Boot proper.

This fixes Ethernet operation for the A20 SoCs, which broke in v2022.04-rc1, with the above mentioned commit.

Quoted 41 lines
---
 arch/arm/mach-sunxi/board.c | 1 -
 board/sunxi/board.c         | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/board.c +0 -1
index 0071de19ffd..9a7673d82dc 100644
@@ -333,7 +333,6 @@ void board_init_f(ulong dummy)
 	clock_init();
 	timer_init();
 	gpio_init();
-	eth_init_board();
 
 	spl_init();
 	preloader_console_init();
board/sunxi/board.c +3 -0
index a0961590479..28f702bc296 100644
@@ -30,6 +30,7 @@
 #include <asm/arch/prcm.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/arch/spl.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
 #include <u-boot/crc.h>
@@ -308,6 +309,8 @@ int board_init(void)
 #endif
 #endif	/* CONFIG_DM_MMC */
 
+	eth_init_board();
+
 	return 0;
 }
 
Signature · 1 line
2.35.1
#5 lore raw

PATCH 2/2 sunxi: dts: Update RGMII phy-mode properties

In reply to Andre Przywara

Commit f11513d99787 ("net: phy: realtek: Add tx/rx delay config for 8211e") made the Realtek PHY driver honour the phy-mode DT property, to set up the proper delay scheme for the RX and TX lines. A similar change in the kernel revealed that those properties were mostly wrong. The kernel DTs got updated over the last few months, but we were missing out on the U-Boot version.

Just sync in the phy-mode properties from the mainline kernel, v5.17-rc7, to avoid the breaking DT sync that late in the cycle.

This fixes Ethernet operation on the affected boards.

---
 arch/arm/dts/sun50i-a64-sopine-baseboard.dts  | 2 +-
 arch/arm/dts/sun50i-h5-nanopi-neo2.dts        | 2 +-
 arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts | 2 +-
 arch/arm/dts/sun6i-a31-hummingbird.dts        | 2 +-
 arch/arm/dts/sun7i-a20-bananapi-m1-plus.dts   | 2 +-
 arch/arm/dts/sun7i-a20-bananapi.dts           | 2 +-
 arch/arm/dts/sun7i-a20-bananapro.dts          | 2 +-
 arch/arm/dts/sun7i-a20-cubietruck.dts         | 2 +-
 arch/arm/dts/sun7i-a20-olinuxino-lime2.dts    | 2 +-
 arch/arm/dts/sun7i-a20-pcduino3-nano.dts      | 2 +-
 arch/arm/dts/sun8i-a83t-bananapi-m3.dts       | 2 +-
 arch/arm/dts/sun8i-a83t-cubietruck-plus.dts   | 2 +-
 arch/arm/dts/sun8i-h3-orangepi-plus.dts       | 2 +-
 arch/arm/dts/sunxi-bananapi-m2-plus.dtsi      | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)
arch/arm/dts/sun50i-a64-sopine-baseboard.dts +1 -1
index e22b94c8364..5e66ce1a334 100644
@@ -79,7 +79,7 @@
 &emac {
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii_pins>;
-	phy-mode = "rgmii-id";
+	phy-mode = "rgmii-txid";
 	phy-handle = <&ext_rgmii_phy>;
 	phy-supply = <&reg_dc1sw>;
 	status = "okay";
arch/arm/dts/sun50i-h5-nanopi-neo2.dts +1 -1
index 02f8e72f0ca..05486cccee1 100644
@@ -75,7 +75,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_gmac_3v3>;
 	phy-handle = <&ext_rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 };
 
arch/arm/dts/sun50i-h5-orangepi-zero-plus.dts +1 -1
index d13980ed7a7..7ec5ac850a0 100644
@@ -69,7 +69,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_gmac_3v3>;
 	phy-handle = <&ext_rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 };
 
arch/arm/dts/sun6i-a31-hummingbird.dts +1 -1
index ce4f9e9834b..2c143580350 100644
@@ -162,7 +162,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_pins_rgmii_a>, <&gmac_phy_reset_pin_hummingbird>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	snps,reset-gpio = <&pio 0 21 GPIO_ACTIVE_HIGH>;
 	snps,reset-active-low;
 	snps,reset-delays-us = <0 10000 30000>;
arch/arm/dts/sun7i-a20-bananapi-m1-plus.dts +1 -1
index e2bfe005883..4dbcad1343b 100644
@@ -130,7 +130,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	phy-supply = <&reg_gmac_3v3>;
 	status = "okay";
 
arch/arm/dts/sun7i-a20-bananapi.dts +1 -1
index 81bc85d398c..33040c43bce 100644
@@ -132,7 +132,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	phy-supply = <&reg_gmac_3v3>;
 	status = "okay";
 
arch/arm/dts/sun7i-a20-bananapro.dts +1 -1
index 0176e9de018..8a75545e228 100644
@@ -110,7 +110,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	phy-supply = <&reg_gmac_3v3>;
 	status = "okay";
 
arch/arm/dts/sun7i-a20-cubietruck.dts +1 -1
index 99f531b8d2a..46a9f4669e1 100644
@@ -151,7 +151,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 
 	phy1: ethernet-phy@1 {
arch/arm/dts/sun7i-a20-olinuxino-lime2.dts +1 -1
index 4e1c590eb09..996201665b7 100644
@@ -112,7 +112,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 
 	phy1: ethernet-phy@1 {
arch/arm/dts/sun7i-a20-pcduino3-nano.dts +1 -1
index 538ea15fa32..205eaae44a0 100644
@@ -115,7 +115,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy = <&phy1>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 
 	phy1: ethernet-phy@1 {
arch/arm/dts/sun8i-a83t-bananapi-m3.dts +1 -1
index eaff6fa4018..2beafe3a31d 100644
@@ -123,7 +123,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_sw>;
 	phy-handle = <&rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	allwinner,rx-delay-ps = <700>;
 	allwinner,tx-delay-ps = <700>;
 	status = "okay";
arch/arm/dts/sun8i-a83t-cubietruck-plus.dts +1 -1
index 5dba4fc310f..ecd9ff38a8b 100644
@@ -160,7 +160,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_dldo4>;
 	phy-handle = <&rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 	status = "okay";
 };
 
arch/arm/dts/sun8i-h3-orangepi-plus.dts +1 -1
index 97f497854e0..d05fa679dcd 100644
@@ -85,7 +85,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_gmac_3v3>;
 	phy-handle = <&ext_rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 
 	status = "okay";
 };
arch/arm/dts/sunxi-bananapi-m2-plus.dtsi +1 -1
index 39263e74fbb..8e5cb3b3fd6 100644
@@ -126,7 +126,7 @@
 	pinctrl-0 = <&emac_rgmii_pins>;
 	phy-supply = <&reg_gmac_3v3>;
 	phy-handle = <&ext_rgmii_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rgmii-id";
 
 	status = "okay";
 };
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] sunxi: dts: Update RGMII phy-mode properties

Quoted 7 lines · Andre Przywara

Commit f11513d99787 ("net: phy: realtek: Add tx/rx delay config for 8211e") made the Realtek PHY driver honour the phy-mode DT property, to set up the proper delay scheme for the RX and TX lines. A similar change in the kernel revealed that those properties were mostly wrong. The kernel DTs got updated over the last few months, but we were missing out on the U-Boot version.

Quoted 6 lines

Just sync in the phy-mode properties from the mainline kernel, v5.17-rc7, to avoid the breaking DT sync that late in the cycle.

This fixes Ethernet operation on the affected boards.

Verified against the updated files from Linux. I suppose I broke this by not sending a DT sync series during the same release cycle. Hopefully we can get DT syncing unblocked soon and merged for the next release.

Regards,
Samuel