[PATCH v2] sunxi: bring up DSA b53 switch on Lamobo R1

Daniel Golle daniel at makrotopia.org
Sun Sep 12 16:48:05 PDT 2021


Build cortexa7 subtarget with DSA driver for MDIO-connected Broadcom
BCM53xxx switches. This is needed for the Lamobo R1 aka. BananaPi
BPi-R1 board which comes with such a switch IC.

Remove old swconfig driver from target kernel config as the only board
using it is now supported by the DSA driver.

No changes to device tree are needed as upstream DTS already got a
DSA switch definition and we are just using that upstream source.

Update default network config of the Lamobo R1 to create lan bridge
with all 4 lan ports.

Introduce DEVICE_COMPAT_VERSION for the board to inform users about
having the re-create their network configuration and add device alias
as Bananapi BPi-R1 while at it.

Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
I do not have the hardware for testing myself, just following user
reporting non-working image with current swconfig hackery in forums:

https://forum.openwrt.org/t/banana-pi-r1-not-able-to-create-a-working-image/105984/5


 .../sunxi/base-files/etc/board.d/02_network   |  3 +-
 .../base-files/etc/board.d/05_compat-version  | 15 ++++
 target/linux/sunxi/config-5.4                 |  4 -
 target/linux/sunxi/cortexa7/config-5.4        | 12 +++
 target/linux/sunxi/image/cortexa7.mk          |  6 +-
 ...un7i-Add-BCM53125-switch-nodes-to-th.patch | 86 -------------------
 6 files changed, 33 insertions(+), 93 deletions(-)
 create mode 100644 target/linux/sunxi/base-files/etc/board.d/05_compat-version
 delete mode 100644 target/linux/sunxi/patches-5.4/310-Revert-ARM-dts-sun7i-Add-BCM53125-switch-nodes-to-th.patch

diff --git a/target/linux/sunxi/base-files/etc/board.d/02_network b/target/linux/sunxi/base-files/etc/board.d/02_network
index 5b59333b1f..d5c615e7f2 100644
--- a/target/linux/sunxi/base-files/etc/board.d/02_network
+++ b/target/linux/sunxi/base-files/etc/board.d/02_network
@@ -11,8 +11,7 @@ friendlyarm,nanopi-r1)
 	ucidef_set_interfaces_lan_wan "eth1" "eth0"
 	;;
 lamobo,lamobo-r1)
-	ucidef_add_switch "switch0" \
-		"4:lan:1" "0:lan:2" "1:lan:3" "2:lan:4" "3:wan" "8 at eth0"
+	ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan
 	;;
 olimex,a20-olinuxino-micro)
 	ucidef_set_interface_lan "wlan0"
diff --git a/target/linux/sunxi/base-files/etc/board.d/05_compat-version b/target/linux/sunxi/base-files/etc/board.d/05_compat-version
new file mode 100644
index 0000000000..3fc777eb69
--- /dev/null
+++ b/target/linux/sunxi/base-files/etc/board.d/05_compat-version
@@ -0,0 +1,15 @@
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+case "$(board_name)" in
+	lamobo,lamobo-r1)
+		ucidef_set_compat_version "1.1"
+		;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/sunxi/config-5.4 b/target/linux/sunxi/config-5.4
index 377234b828..e01a2cbd5e 100644
--- a/target/linux/sunxi/config-5.4
+++ b/target/linux/sunxi/config-5.4
@@ -523,10 +523,6 @@ CONFIG_SUNXI_SRAM=y
 CONFIG_SUNXI_WATCHDOG=y
 CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
-CONFIG_SWCONFIG=y
-CONFIG_SWCONFIG_B53=y
-CONFIG_SWCONFIG_B53_PHY_DRIVER=y
-CONFIG_SWCONFIG_B53_PHY_FIXUP=y
 CONFIG_SWIOTLB=y
 CONFIG_SWPHY=y
 CONFIG_SWP_EMULATE=y
diff --git a/target/linux/sunxi/cortexa7/config-5.4 b/target/linux/sunxi/cortexa7/config-5.4
index 0b3697028f..4ead820881 100644
--- a/target/linux/sunxi/cortexa7/config-5.4
+++ b/target/linux/sunxi/cortexa7/config-5.4
@@ -13,3 +13,15 @@ CONFIG_MDIO_BUS_MUX=y
 # CONFIG_PINCTRL_SUN50I_H6 is not set
 # CONFIG_PINCTRL_SUN50I_H6_R is not set
 CONFIG_UNWINDER_ARM=y
+CONFIG_NET_DEVLINK=y
+CONFIG_NET_DSA=y
+CONFIG_NET_DSA_TAG_BRCM=y
+CONFIG_NET_DSA_TAG_BRCM_COMMON=y
+CONFIG_NET_DSA_TAG_BRCM_PREPEND=y
+CONFIG_NET_SWITCHDEV=y
+CONFIG_B53=y
+CONFIG_B53_MDIO_DRIVER=y
+# CONFIG_B53_MMAP_DRIVER is not set
+# CONFIG_B53_SERDES is not set
+# CONFIG_B53_SPI_DRIVER is not set
+# CONFIG_B53_SRAB_DRIVER is not set
diff --git a/target/linux/sunxi/image/cortexa7.mk b/target/linux/sunxi/image/cortexa7.mk
index 59f11bc83c..28fac13064 100644
--- a/target/linux/sunxi/image/cortexa7.mk
+++ b/target/linux/sunxi/image/cortexa7.mk
@@ -64,7 +64,11 @@ TARGET_DEVICES += friendlyarm_zeropi
 define Device/lamobo_lamobo-r1
   DEVICE_VENDOR := Lamobo
   DEVICE_MODEL := Lamobo R1
-  DEVICE_PACKAGES:=kmod-ata-sunxi kmod-rtl8192cu swconfig wpad-basic-wolfssl
+  DEVICE_ALT0_VENDOR := Bananapi
+  DEVICE_ALT0_MODEL := BPi-R1
+  DEVICE_PACKAGES := kmod-ata-sunxi kmod-rtl8192cu wpad-basic-wolfssl
+  DEVICE_COMPAT_VERSION := 1.1
+  DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA
   SOC := sun7i-a20
 endef
 TARGET_DEVICES += lamobo_lamobo-r1
diff --git a/target/linux/sunxi/patches-5.4/310-Revert-ARM-dts-sun7i-Add-BCM53125-switch-nodes-to-th.patch b/target/linux/sunxi/patches-5.4/310-Revert-ARM-dts-sun7i-Add-BCM53125-switch-nodes-to-th.patch
deleted file mode 100644
index 79c1671de1..0000000000
--- a/target/linux/sunxi/patches-5.4/310-Revert-ARM-dts-sun7i-Add-BCM53125-switch-nodes-to-th.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From 49cd9ea6dc8d68eb519ccd9f31c9730dec8a181a Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke at hauke-m.de>
-Date: Thu, 8 Mar 2018 22:14:50 +0100
-Subject: [PATCH] Revert "ARM: dts: sun7i: Add BCM53125 switch nodes to the
- lamobo-r1 board"
-
-This reverts the changes needed for the upstream b53 DSA switch driver 
-to use the OpenWrt b43 swconfig switch driver.
-
-This reverts commit 0cdefd5b5485ee6eb3512a75739d09a4090176ed.
-This reverts commit d7b9eaff5f0ca00726336b4c0c3c29decf30412a.
----
- arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts | 60 ++-----------------------------
- 1 file changed, 3 insertions(+), 57 deletions(-)
-
---- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
-+++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
-@@ -120,65 +120,13 @@
- &gmac {
- 	pinctrl-names = "default";
- 	pinctrl-0 = <&gmac_rgmii_pins>;
-+	phy = <&phy1>;
- 	phy-mode = "rgmii";
- 	phy-supply = <&reg_gmac_3v3>;
- 	status = "okay";
- 
--	fixed-link {
--		speed = <1000>;
--		full-duplex;
--	};
--
--	mdio {
--		compatible = "snps,dwmac-mdio";
--		#address-cells = <1>;
--		#size-cells = <0>;
--
--		switch: ethernet-switch at 1e {
--			compatible = "brcm,bcm53125";
--			reg = <30>;
--
--			ports {
--				#address-cells = <1>;
--				#size-cells = <0>;
--
--				port0: port at 0 {
--					reg = <0>;
--					label = "lan2";
--				};
--
--				port1: port at 1 {
--					reg = <1>;
--					label = "lan3";
--				};
--
--				port2: port at 2 {
--					reg = <2>;
--					label = "lan4";
--				};
--
--				port3: port at 3 {
--					reg = <3>;
--					label = "wan";
--				};
--
--				port4: port at 4 {
--					reg = <4>;
--					label = "lan1";
--				};
--
--				port8: port at 8 {
--					reg = <8>;
--					label = "cpu";
--					ethernet = <&gmac>;
--					phy-mode = "rgmii-txid";
--					fixed-link {
--						speed = <1000>;
--						full-duplex;
--					};
--				};
--			};
--		};
-+	phy1: ethernet-phy at 1 {
-+		reg = <1>;
- 	};
- };
- 
-- 
2.33.0




More information about the openwrt-devel mailing list