From ba87c0560563fb912ae711b7833eb4bb8ac21056 Mon Sep 17 00:00:00 2001 From: Edward Chow Date: Fri, 13 Dec 2024 13:38:57 +0800 Subject: [PATCH] ath79: convert buffalo WZR-450HP2 to DSA Reimplement switch handling of WZR-450HP2 with DSA. Signed-off-by: Edward Chow --- .../ath79/dts/qca9558_buffalo_wzr-450hp2.dts | 178 ++++++++++++++++-- .../generic/base-files/etc/board.d/01_leds | 7 + .../generic/base-files/etc/board.d/02_network | 8 +- target/linux/ath79/image/generic.mk | 4 + 4 files changed, 181 insertions(+), 16 deletions(-) diff --git a/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts b/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts index 8f19907dfee..cb6ceb0f657 100644 --- a/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts +++ b/target/linux/ath79/dts/qca9558_buffalo_wzr-450hp2.dts @@ -127,35 +127,185 @@ &mdio0 { status = "okay"; - phy0: ethernet-phy@0 { - reg = <0>; + switch@0 { + compatible = "qca,qca8337"; + #address-cells = <1>; + #size-cells = <0>; - qca,ar8327-initvals = < - 0x04 0x07600000 /* PORT0 PAD MODE CTRL: RGMII, to eth0 */ - 0x0c 0x00080080 /* PORT6 PAD MODE CTRL: SGMII, to eth1 */ - 0x10 0x81000080 /* POWER ON STRAP */ - 0x50 0xcc35cc35 /* LED_CTRL0 */ - 0x54 0xca35ca35 /* LED_CTRL1 */ - 0x58 0xc935c935 /* LED_CTRL2 */ - 0x5c 0x03ffff00 /* LED_CTRL3 */ - 0x7c 0x0000007e /* PORT0_STATUS */ - 0x94 0x0000007e /* PORT6_STATUS */ - >; + reg = <0>; + qca,ignore-power-on-sel; + qca,led-open-drain; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + ethernet = <ð0>; + phy-mode = "rgmii-id"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + port@1 { + reg = <1>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&phy_port1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&phy_port2>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-mode = "internal"; + phy-handle = <&phy_port3>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-mode = "internal"; + phy-handle = <&phy_port4>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + 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 = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + + port@6 { + reg = <6>; + ethernet = <ð1>; + phy-mode = "sgmii"; + qca,sgmii-rxclk-falling-edge; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + phy_port1: phy@0 { + reg = <0>; + }; + + phy_port2: phy@1 { + reg = <1>; + }; + + phy_port3: phy@2 { + reg = <2>; + }; + + phy_port4: phy@3 { + reg = <3>; + }; + + phy_port5: phy@4 { + reg = <4>; + }; + }; }; }; +&mdio1 { + status = "okay"; +}; + ð0 { status = "okay"; nvmem-cells = <&macaddr_wan>; nvmem-cell-names = "mac-address"; - phy-handle = <&phy0>; pll-data = <0x56000000 0x00000101 0x00001616>; gmac-config { device = <&gmac>; rgmii-enabled = <1>; }; + + fixed-link { + speed = <1000>; + full-duplex; + }; }; ð1 { diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 6409adb78ad..944d1dd28c2 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -20,6 +20,13 @@ alcatel,hh40v) ucidef_set_led_netdev "wan_data" "WAN Data" "green:wan" "eth0" "tx rx" ucidef_set_led_netdev "wan_link" "WAN Link" "orange:wan" "eth0" "link" ;; +buffalo,wzr-450hp2) + ucidef_set_led_netdev "lan1" "LAN1" "qca8k-0.0:00:green:lan" "lan1" "link-10 link-100 link-1000 tx rx" + ucidef_set_led_netdev "lan2" "LAN2" "qca8k-0.0:01:green:lan" "lan2" "link-10 link-100 link-1000 tx rx" + ucidef_set_led_netdev "lan3" "LAN3" "qca8k-0.0:02:green:lan" "lan3" "link-10 link-100 link-1000 tx rx" + ucidef_set_led_netdev "lan4" "LAN4" "qca8k-0.0:03:green:lan" "lan4" "link-10 link-100 link-1000 tx rx" + ucidef_set_led_netdev "wan" "WAN" "qca8k-0.0:04:green:wan" "wan" "link-10 link-100 link-1000 tx rx" + ;; alfa-network,ap121f|\ alfa-network,ap121fe|\ alfa-network,wifi-camppro-nano-duo|\ diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index dedbaf05b80..9bf40e29c2f 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -214,8 +214,12 @@ ath79_setup_interfaces() "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0" ;; buffalo,wzr-450hp2) - ucidef_add_switch "switch0" \ - "6@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0" + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" + ucidef_set_network_device_conduit "lan1" "eth1" + ucidef_set_network_device_conduit "lan2" "eth1" + ucidef_set_network_device_conduit "lan3" "eth1" + ucidef_set_network_device_conduit "lan4" "eth1" + ucidef_set_network_device_conduit "wan" "eth0" ;; buffalo,wzr-600dhp|\ buffalo,wzr-hp-ag300h|\ diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 79186c28a6d..7f9733d8742 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -763,9 +763,13 @@ define Device/buffalo_wzr-450hp2 $(Device/buffalo_common) SOC := qca9558 DEVICE_MODEL := WZR-450HP2/WZR-450HP2D + DEVICE_PACKAGES := kmod-ag71xx kmod-dsa-qca8k kmod-phy-qca83xx \ + -kmod-ag71xx-legacy -kmod-switch-ip17xx -kmod-switch-ar8xxx -kmod-swconfig -swconfig BUFFALO_PRODUCT := WZR-450HP2 IMAGE_SIZE := 15936k SUPPORTED_DEVICES += wzr-450hp2 + DEVICE_COMPAT_VERSION := 1.1 + DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA endef TARGET_DEVICES += buffalo_wzr-450hp2