apm821xx: migrate to DSA
authorRosen Penev <rosenp@gmail.com>
Mon, 9 Oct 2023 20:15:52 +0000 (13:15 -0700)
committerRobert Marko <robimarko@gmail.com>
Sun, 15 Sep 2024 11:16:44 +0000 (13:16 +0200)
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 <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/14037
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/apm821xx/base-files/etc/board.d/01_leds
target/linux/apm821xx/base-files/etc/board.d/02_network
target/linux/apm821xx/base-files/etc/uci-defaults/05_fix-compat-version
target/linux/apm821xx/dts/meraki-mx60.dts
target/linux/apm821xx/dts/netgear-wndr4700.dts
target/linux/apm821xx/image/nand.mk
target/linux/apm821xx/nand/config-default

index c384d24a30e6c23755d2e6239244eea0a9661161..f83888deeb31e99380d40e061d3b2e4666a0c810 100644 (file)
@@ -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
index 756ea348b45adbf99696f96d276665f487d685ed..dfcf4be8b9cdcd3cc79c7ebfc2da4d49a77ec746 100644 (file)
@@ -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"
        ;;
 
 *)
index d34b4051be3d7d73be45344282c738cc5b008e80..00d3954e5f481b5f19a7475612e53f192f6ad743 100644 (file)
@@ -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
index d9568d92635b4db64a29347123850a094f86213e..6e4df54bd26e2c5ca8edfb8caf171e72b44fe3dd 100644 (file)
 
 &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";
+                                               };
+                                       };
+                               };
+                       };
                };
        };
 };
index 851a3192b39b8434d4504d8b3a702a532b4d7f7c..4ef05937d39d29ed1dee829157b1af2682fe0ab3 100644 (file)
 
 &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>;
+                               };
+                       };
                };
        };
 };
index 69eb386126a9c025c6d4832134df9847c85bbda3..92bdaa87d03372d320e71c44f5866ad33ab15a8f 100644 (file)
@@ -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
index 7070b34b93d0eeac5abd0bd2b1dec66af9ada1e7..ab7d790870ef082a9526986cd16d5e1d58bb85f7 100644 (file)
@@ -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
-