Browse Source

apm821xx: migrate to DSA

The qca8k driver is upstream, unlike swconfig. This applies to the mx60
and wndr4700 only. Fixed up LED definitions as well.

RTL83xx DSA for WNDAP62300/660 is not working.

Signed-off-by: Rosen Penev <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/14037
Signed-off-by: Robert Marko <[email protected]>
Rosen Penev 2 years ago
parent
commit
5815884c3a

+ 2 - 10
target/linux/apm821xx/base-files/etc/board.d/01_leds

@@ -14,14 +14,6 @@ meraki,mr24)
 	ucidef_set_led_wlan "wlan2g_0" "WIFI 2.4GHz-0" "green:wlan-3" "phy0radio"
 	;;
 
-meraki,mx60)
-	ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x20"
-	ucidef_set_led_switch "lan1" "LAN1" "green:lan-0" "switch0" "0x10"
-	ucidef_set_led_switch "lan2" "LAN2" "green:lan-1" "switch0" "0x08"
-	ucidef_set_led_switch "lan3" "LAN3" "green:lan-2" "switch0" "0x04"
-	ucidef_set_led_switch "lan4" "LAN4" "green:lan-3" "switch0" "0x02"
-	;;
-
 netgear,wndap620)
 	ucidef_set_led_switch "lan_act" "LAN (Activity)" "green:activity" "switch0" "0x04" "0x0f" "rx tx"
 	ucidef_set_led_switch "lan_100" "LAN 100Mbps" "amber:lan" "switch0" "0x04" "0x04" "link"
@@ -39,8 +31,8 @@ netgear,wndap660)
 	;;
 
 netgear,wndr4700)
-	ucidef_set_led_switch "wan_green" "WAN (green)" "green:wan" "switch0" "0x20"
-	ucidef_set_led_netdev "wan_yellow" "WAN (yellow)" "yellow:wan" "eth0.2" "tx rx"
+	ucidef_set_led_netdev "wan_green" "WAN (green)" "green:wan" "wan" "link"
+	ucidef_set_led_netdev "wan_yellow" "WAN (yellow)" "yellow:wan" "wan" "tx rx"
 	;;
 
 esac

+ 1 - 2
target/linux/apm821xx/base-files/etc/board.d/02_network

@@ -20,8 +20,7 @@ netgear,wndap660)
 	;;
 meraki,mx60|\
 netgear,wndr4700)
-	ucidef_add_switch "switch0" \
-		"0@eth0" "4:lan" "3:lan" "2:lan" "1:lan" "5:wan"
+	ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
 	;;
 
 *)

+ 1 - 1
target/linux/apm821xx/base-files/etc/uci-defaults/05_fix-compat-version

@@ -5,7 +5,7 @@ meraki,mx60|\
 netgear,wndap620|\
 netgear,wndap660|\
 netgear,wndr4700)
-	uci set system.@system[0].compat_version="2.0"
+	uci set system.@system[0].compat_version="3.0"
 	uci commit system
 	;;
 esac

+ 229 - 11
target/linux/apm821xx/dts/meraki-mx60.dts

@@ -92,23 +92,241 @@
 
 &EMAC0 {
 	status = "okay";
-	phy-handle = <&phy0>;
+
+	fixed-link {
+		speed = <1000>;
+		full-duplex;
+	};
 
 	mdio {
 		#address-cells = <1>;
 		#size-cells = <0>;
-		phy0: ethernet-phy@0 {
+
+		phy_port1: phy@0 {
 			compatible = "ethernet-phy-id004d.d034";
 			reg = <0>;
-			qca,mib-poll-interval = <500>;
-
-			qca,ar8327-initvals = <
-				0x0010 0x40000000
-				0x0624 0x007f7f7f
-				0x0004 0x07a00000	/* PAD0_MODE */
-				0x000c 0x01000000	/* PAD6_MODE */
-				0x007c 0x0000007e	/* PORT0_STATUS */
-			>;
+		};
+
+		phy_port2: phy@1 {
+			compatible = "ethernet-phy-id004d.d034";
+			reg = <1>;
+		};
+
+		phy_port3: phy@2 {
+			compatible = "ethernet-phy-id004d.d034";
+			reg = <2>;
+		};
+
+		phy_port4: phy@3 {
+			compatible = "ethernet-phy-id004d.d034";
+			reg = <3>;
+		};
+
+		phy_port5: phy@4 {
+			compatible = "ethernet-phy-id004d.d034";
+			reg = <4>;
+		};
+
+		switch0@10 {
+			compatible = "qca,qca8327";
+			reg = <0x10>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+					ethernet = <&EMAC0>;
+					phy-mode = "rgmii-id";
+					tx-internal-delay-ps = <2000>;
+
+					fixed-link {
+						speed = <1000>;
+						full-duplex;
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+					label = "lan4";
+					phy-mode = "internal";
+					phy-handle = <&phy_port1>;
+
+					leds {
+						#address-cells = <1>;
+						#size-cells = <0>;
+
+						led@0 {
+							reg = <0>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <0>;
+							default-state = "keep";
+						};
+
+						led@1 {
+							reg = <1>;
+							color = <LED_COLOR_ID_ORANGE>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <1>;
+							default-state = "keep";
+						};
+
+						led@2 {
+							reg = <2>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <2>;
+							default-state = "keep";
+						};
+					};
+				};
+
+				port@2 {
+					reg = <2>;
+					label = "lan3";
+					phy-mode = "internal";
+					phy-handle = <&phy_port2>;
+
+					leds {
+						#address-cells = <1>;
+						#size-cells = <0>;
+
+						led@0 {
+							reg = <0>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <0>;
+							default-state = "keep";
+						};
+
+						led@1 {
+							reg = <1>;
+							color = <LED_COLOR_ID_ORANGE>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <1>;
+							default-state = "keep";
+						};
+
+						led@2 {
+							reg = <2>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <2>;
+							default-state = "keep";
+						};
+					};
+				};
+
+				port@3 {
+					reg = <3>;
+					label = "lan2";
+					phy-mode = "internal";
+					phy-handle = <&phy_port3>;
+
+					leds {
+						#address-cells = <1>;
+						#size-cells = <0>;
+
+						led@0 {
+							reg = <0>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <0>;
+							default-state = "keep";
+						};
+
+						led@1 {
+							reg = <1>;
+							color = <LED_COLOR_ID_ORANGE>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <1>;
+							default-state = "keep";
+						};
+
+						led@2 {
+							reg = <2>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <2>;
+							default-state = "keep";
+						};
+					};
+				};
+
+				port@4 {
+					reg = <4>;
+					label = "lan1";
+					phy-mode = "internal";
+					phy-handle = <&phy_port4>;
+
+					leds {
+						#address-cells = <1>;
+						#size-cells = <0>;
+
+						led@0 {
+							reg = <0>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <0>;
+							default-state = "keep";
+						};
+
+						led@1 {
+							reg = <1>;
+							color = <LED_COLOR_ID_ORANGE>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <1>;
+							default-state = "keep";
+						};
+
+						led@2 {
+							reg = <2>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_LAN;
+							function-enumerator = <2>;
+							default-state = "keep";
+						};
+					};
+				};
+
+				port@5 {
+					reg = <5>;
+					label = "wan";
+					phy-mode = "internal";
+					phy-handle = <&phy_port5>;
+
+					leds {
+						#address-cells = <1>;
+						#size-cells = <0>;
+
+						led@0 {
+							reg = <0>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_WAN;
+							function-enumerator = <0>;
+							default-state = "keep";
+						};
+
+						led@1 {
+							reg = <1>;
+							color = <LED_COLOR_ID_ORANGE>;
+							function = LED_FUNCTION_WAN;
+							function-enumerator = <1>;
+							default-state = "keep";
+						};
+
+						led@2 {
+							reg = <2>;
+							color = <LED_COLOR_ID_GREEN>;
+							function = LED_FUNCTION_WAN;
+							function-enumerator = <2>;
+							default-state = "keep";
+						};
+					};
+				};
+			};
 		};
 	};
 };

+ 81 - 12
target/linux/apm821xx/dts/netgear-wndr4700.dts

@@ -350,24 +350,93 @@
 
 &EMAC0 {
 	status = "okay";
-	phy-handle = <&phy0>;
 	fifo-entry-size = <10>;
 
+	fixed-link {
+		speed = <1000>;
+		full-duplex;
+	};
+
 	mdio {
 		#address-cells = <1>;
 		#size-cells = <0>;
-		phy0: ethernet-phy@0 {
-			device_type = "ethernet-phy";
+
+		phy_port1: phy@0 {
 			reg = <0>;
-			qca,mib-poll-interval = <500>;
-
-			qca,ar8327-initvals = <
-				0x0010 0x40000000
-				0x0624 0x007f7f7f
-				0x0004 0x07a00000	/* PAD0_MODE */
-				0x000c 0x01000000	/* PAD6_MODE */
-				0x007c 0x0000007e	/* PORT0_STATUS */
-			>;
+		};
+
+		phy_port2: phy@1 {
+			reg = <1>;
+		};
+
+		phy_port3: phy@2 {
+			reg = <2>;
+		};
+
+		phy_port4: phy@3 {
+			reg = <3>;
+		};
+
+		phy_port5: phy@4 {
+			reg = <4>;
+		};
+
+		switch0@10 {
+			compatible = "qca,qca8327";
+			reg = <0x10>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+					label = "cpu";
+					ethernet = <&EMAC0>;
+					phy-mode = "rgmii-id";
+					tx-internal-delay-ps = <2000>;
+
+					fixed-link {
+						speed = <1000>;
+						full-duplex;
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+					label = "lan4";
+					phy-mode = "internal";
+					phy-handle = <&phy_port1>;
+				};
+
+				port@2 {
+					reg = <2>;
+					label = "lan3";
+					phy-mode = "internal";
+					phy-handle = <&phy_port2>;
+				};
+
+				port@3 {
+					reg = <3>;
+					label = "lan2";
+					phy-mode = "internal";
+					phy-handle = <&phy_port3>;
+				};
+
+				port@4 {
+					reg = <4>;
+					label = "lan1";
+					phy-mode = "internal";
+					phy-handle = <&phy_port4>;
+				};
+
+				port@5 {
+					reg = <5>;
+					label = "wan";
+					phy-mode = "internal";
+					phy-handle = <&phy_port5>;
+				};
+			};
 		};
 	};
 };

+ 5 - 1
target/linux/apm821xx/image/nand.mk

@@ -50,8 +50,9 @@ define Device/meraki_mx60
   KERNEL := kernel-bin | libdeflate-gzip | MuImage-initramfs gzip
   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   UBINIZE_OPTS := -E 5
-  DEVICE_COMPAT_VERSION := 2.0
+  DEVICE_COMPAT_VERSION := 3.0
   DEVICE_COMPAT_MESSAGE := uboot's bootcmd has to be updated to support standard multi-image uImages. \
+       Network swconfig configuration cannot be upgraded to DSA. \
        Upgrade via sysupgrade mechanism is not possible.
 endef
 TARGET_DEVICES += meraki_mx60
@@ -88,6 +89,9 @@ endef
 TARGET_DEVICES += netgear_wndap660
 
 define Device/netgear_wndr4700
+  DEVICE_COMPAT_VERSION := 3.0
+  DEVICE_COMPAT_MESSAGE := Network swconfig configuration cannot be upgraded to DSA. \
+       Upgrade via sysupgrade mechanism is not possible.
   DEVICE_VENDOR := NETGEAR
   DEVICE_MODEL := Centria N900 WNDR4700
   DEVICE_ALT0_VENDOR := NETGEAR

+ 9 - 3
target/linux/apm821xx/nand/config-default

@@ -1,5 +1,3 @@
-CONFIG_AT803X_PHY=y
-CONFIG_AR8216_PHY=y
 # CONFIG_SATA_DWC_OLD_DMA is not set
 CONFIG_IKAREM=y
 # CONFIG_PCI_DISABLE_COMMON_QUIRKS is not set
@@ -26,6 +24,15 @@ CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_BEB_LIMIT=20
 CONFIG_MTD_UBI_BLOCK=y
 CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_NET_DEVLINK=y
+CONFIG_NET_DSA=y
+CONFIG_NET_DSA_QCA8K=y
+CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT=y
+CONFIG_NET_DSA_TAG_QCA=y
+CONFIG_NET_SWITCHDEV=y
+CONFIG_PHYLINK=y
+CONFIG_QCA83XX_PHY=y
+CONFIG_QCOM_NET_PHYLIB=y
 CONFIG_UBIFS_FS=y
 CONFIG_RTL8366_SMI=y
 CONFIG_RTL8367B_PHY=y
@@ -33,4 +40,3 @@ CONFIG_SENSORS_LM90=y
 CONFIG_SENSORS_TC654=y
 CONFIG_SWCONFIG=y
 CONFIG_SWCONFIG_LEDS=y
-