[openwrt/openwrt] mediatek: filogic: Add support for Wavlink WL-WN586X3

LEDE Commits lede-commits at lists.infradead.org
Sun Jun 9 06:00:25 PDT 2024


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/33db9146071a470f4f8781d7d11fa2ad43069707

commit 33db9146071a470f4f8781d7d11fa2ad43069707
Author: Sijia Huang <engineer31 at win-star.com>
AuthorDate: Wed Mar 6 20:12:11 2024 -0600

    mediatek: filogic: Add support for Wavlink WL-WN586X3
    
    Hardware
    --------
    - SOC: MediaTek MT7981
    - ram: 256MB DDR3
    - FLASH: 16MB SPI-NOR
    - Ethernet: 2x1Gb Lan 1x1Gb Wan
    - WIFI: MediaTek MT7981 2x2 DBDC 802.11ax 2T2R (2.4/5)
    - LEDs: 2xLan 1x Wan 1x WIFI 1xSTATUS
    
    MAC table, same as stock firmware:
    LAN: 80:3F:5D:xx:xx:x1 partition "hw" at 0x44e (ASCII)
    WAN: 80:3F:5D:xx:xx:x2 partition "hw" at 0x460 (ASCII)
     2G: 80:3F:5D:xx:xx:x3 partition "factory" at 0x4 (binary), on label
     5G: 80:3F:5D:xx:xx:x3 Same as 2G
    
    Installation Method 1: ssh
    --------------------------
    1. Connect PC to the lan port. Set the PC IP to 192.168.10.100 if
       required.
    2. Navigate to http://192.168.10.1/
    3. Log into the Wavlink WebGUI. Default username/password is
       admin/admin.
    4. Use WebGUI to upgrade the firmware to
       WAVLINK_WN586X3-A_M86X3A_V240113_WO-GDBYFM-modified.bin
       downloaded from
       https://github.com/themaverickdm/firmware-misc/tree/main/wavlink/wl-wn586x3
       Warning: All settings will be lost!
    5. Wait about 5 minutes, and after flashing is completed, log into
       the router using (with admin123 as password):
       ssh root at 192.168.10.1
    6. scp the openwrt image file onto the router, usually under /tmp
       somewhere.
       openwrt-mediatek-filogic-wavlink_wl-wn586x3-squashfs-sysupgrade.bin
    7. Flash openwrt image file like so:
       mtd write \
         openwrt-mediatek-filogic-wavlink_wl-wn586x3-squashfs-sysupgrade.bin \
         firmware
       Warning: Previous firmware will be overwritten!
    8. Wait about 5 minutes, and after the flashing is completed, set
       the PC IP to 192.168.1.100 if required and log into the router
       like so:
       ssh root at 192.168.1.1
    
    Installation Method 2: u-boot
    -----------------------------
    1. Connect UART:  TX-> 586X3 RX, RX-> 586X3 TX, GND-> 586 GND.
    2. Connect PC to the wan (not lan!) port.
    3. Setup the tftp server on PC, set IP to 192.168.10.100,
    4. Power on the device. Select '2' to upgrade firmware in Uboot.
    5. Input the image name and start to upgrade.
    
    Uboot console log:
    
    CPU:   MediaTek MT7981
    Model: mt7981-rfb
    DRAM:  256 MiB
    Core:  34 devices, 13 uclasses, devicetree: embed
    Loading Environment from nowhere... OK
    In:    serial at 11002000
    Out:   serial at 11002000
    Err:   serial at 11002000
    Net:
    Warning: ethernet at 15100000 (eth0) using random MAC address -
    02:47:fb:b2:53:2d
    eth0: ethernet at 15100000
    UBOOT WN586X3A
    gpio: pin 9 (gpio 9) value is 0
    gpio: pin 10 (gpio 10) value is 0
    gpio: pin 5 (gpio 5) value is 0
    gpio: pin 12 (gpio 12) value is 0
    gpio: pin 13 (gpio 13) value is 0
    
      *** U-Boot Boot Menu ***
    
          1. Startup system (Default)
          2. Upgrade firmware
          3. Upgrade ATF BL2
          4. Upgrade ATF FIP
          5. Upgrade single image
          6. Load image
          0. U-Boot console
    
    Co-authored-by: R Maru <deviantmaru at gmail.com>
    Signed-off-by: R Maru <deviantmaru at gmail.com>
    Signed-off-by: Sijia Huang <engineer31 at win-star.com>
---
 .../mediatek/dts/mt7981b-wavlink-wl-wn586x3.dts    | 270 +++++++++++++++++++++
 .../filogic/base-files/etc/board.d/01_leds         |   4 +
 .../filogic/base-files/etc/board.d/02_network      |   3 +-
 target/linux/mediatek/image/filogic.mk             |  11 +
 4 files changed, 287 insertions(+), 1 deletion(-)

diff --git a/target/linux/mediatek/dts/mt7981b-wavlink-wl-wn586x3.dts b/target/linux/mediatek/dts/mt7981b-wavlink-wl-wn586x3.dts
new file mode 100644
index 0000000000..62be0faa4a
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7981b-wavlink-wl-wn586x3.dts
@@ -0,0 +1,270 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+/dts-v1/;
+
+#include "mt7981.dtsi"
+
+/ {
+	model = "WAVLINK WL-WN586X3";
+	compatible = "wavlink,wl-wn586x3", "mediatek,mt7981";
+
+	aliases {
+		label-mac-device = &wifi;
+		led-boot = &led_status_blue;
+		led-failsafe = &led_status_blue;
+		led-running = &led_status_blue;
+		led-upgrade = &led_status_blue;
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		button-reset {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 11 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led-0 {
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_WAN;
+			gpios = <&pio 5 GPIO_ACTIVE_LOW>;
+		};
+
+		led-1 {
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_WLAN;
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "phy1tpt";
+		};
+
+		led_status_blue: led-2 {
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_STATUS;
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+		};
+
+		led-3 {
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_LAN;
+			function-enumerator = <1>;
+			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
+		};
+
+		led-4 {
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_LAN;
+			function-enumerator = <2>;
+			gpios = <&pio 13 GPIO_ACTIVE_LOW>;
+		};
+
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&eth {
+	status = "okay";
+
+	gmac0: mac at 0 {
+		compatible = "mediatek,eth-mac";
+		reg = <0>;
+		phy-mode = "2500base-x";
+		nvmem-cells = <&macaddr_hw_44e 0>;
+		nvmem-cell-names = "mac-address";
+
+		fixed-link {
+			speed = <2500>;
+			full-duplex;
+			pause;
+		};
+	};
+
+	gmac1: mac at 1 {
+		compatible = "mediatek,eth-mac";
+		reg = <1>;
+		phy-mode = "gmii";
+		phy-handle = <&int_gbe_phy>;
+		nvmem-cells = <&macaddr_hw_44e 1>;
+		nvmem-cell-names = "mac-address";
+	};
+};
+
+&mdio_bus {
+	switch: switch at 1f {
+		compatible = "mediatek,mt7531";
+		reg = <31>;
+		reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&pio>;
+		interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
+	};
+};
+
+&spi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi0_flash_pins>;
+	status = "disabled";
+};
+
+&spi2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi2_flash_pins>;
+	status = "okay";
+
+	flash at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+
+		spi-max-frequency = <25000000>;
+		spi-tx-bus-width = <4>;
+		spi-rx-bus-width = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 00000 {
+				label = "bl2";
+				reg = <0x00000 0x40000>;
+				read-only;
+			};
+
+			partition at 40000 {
+				label = "u-boot-env";
+				reg = <0x40000 0x10000>;
+				read-only;
+			};
+
+			factory: partition at 50000 {
+				label = "factory";
+				reg = <0x50000 0xb0000>;
+				read-only;
+
+				nvmem-layout {
+					compatible = "fixed-layout";
+					#address-cells = <1>;
+					#size-cells = <1>;
+
+					macaddr_factory_4: macaddr at 4 {
+						compatible = "mac-base";
+						reg = <0x4 0x6>;
+						#nvmem-cell-cells = <1>;
+					};
+				};
+			};
+
+			partition at 100000 {
+				label = "fip";
+				reg = <0x100000 0x80000>;
+				read-only;
+			};
+
+			partition at f0000 {
+				label = "firmware";
+				reg = <0x180000 0xe00000>;
+			};
+
+			partition at f80000 {
+				label = "hw";
+				reg = <0xf80000 0x80000>;
+
+				nvmem-layout {
+					compatible = "fixed-layout";
+					#address-cells = <1>;
+					#size-cells = <1>;
+
+					macaddr_hw_44e: macaddr at 44e {
+						compatible = "mac-base";
+						reg = <0x44e 0x11>;
+						#nvmem-cell-cells = <1>;
+					};
+				};
+			};
+		};
+	};
+};
+
+&pio {
+	spi0_flash_pins: spi0-pins {
+		mux {
+			function = "spi";
+			groups = "spi0", "spi0_wp_hold";
+		};
+	};
+
+	spi2_flash_pins: spi2-pins {
+		mux {
+			function = "spi";
+			groups = "spi2", "spi2_wp_hold";
+		};
+
+		conf-pu {
+			pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
+			drive-strength = <8>;
+			bias-pull-up = <103>;
+		};
+
+		conf-pd {
+			pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
+			drive-strength = <8>;
+			bias-pull-down = <103>;
+		};
+	};
+};
+
+&switch {
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port at 1 {
+			reg = <1>;
+			label = "lan2";
+		};
+
+		port at 2 {
+			reg = <2>;
+			label = "lan1";
+		};
+
+		port at 6 {
+			reg = <6>;
+			ethernet = <&gmac0>;
+			phy-mode = "2500base-x";
+
+			fixed-link {
+				speed = <2500>;
+				full-duplex;
+				pause;
+			};
+		};
+	};
+};
+
+&wifi {
+	status = "okay";
+	mediatek,mtd-eeprom = <&factory 0x0>;
+	nvmem-cells = <&macaddr_factory_4 0>;
+	nvmem-cell-names = "mac-address";
+};
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
index 50ffb7e5d9..ca462d2005 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
@@ -91,6 +91,10 @@ smartrg,sdg-8734)
 	ucidef_set_led_netdev "wan-green" "WAN" "mdio-bus:00:green:wan" "wan" "link_2500 link_5000"
 	ucidef_set_led_netdev "wan-orange" "WAN" "mdio-bus:00:orange:wan" "wan" "link_100 link_1000"
 	ucidef_set_led_netdev "wan-white" "WAN" "mdio-bus:00:white:wan" "wan" "link_10000"
+wavlink,wl-wn586x3)
+	ucidef_set_led_netdev "lan-1" "lan-1" "blue:lan-1" "lan1" "link tx rx"
+	ucidef_set_led_netdev "lan-2" "lan-2" "blue:lan-2" "lan2" "link tx rx"
+	ucidef_set_led_netdev "wan" "wan" "blue:wan" "eth1" "link tx rx"
 	;;
 xiaomi,mi-router-wr30u-stock|\
 xiaomi,mi-router-wr30u-ubootmod)
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 10dabc965a..cf777a63df 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -96,7 +96,8 @@ mediatek_setup_interfaces()
 	yuncore,ax835)
 		ucidef_set_interfaces_lan_wan lan wan
 		;;
-	tplink,tl-xdr6086)
+	tplink,tl-xdr6086|\
+	wavlink,wl-wn586x3)
 		ucidef_set_interfaces_lan_wan "lan1 lan2" eth1
 		;;
 	xiaomi,mi-router-ax3000t|\
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 884ededd32..28a0f066af 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -1161,6 +1161,17 @@ define Device/unielec_u7981-01-nand
 endef
 TARGET_DEVICES += unielec_u7981-01-nand
 
+define Device/wavlink_wl-wn586x3
+  DEVICE_VENDOR := WAVLINK
+  DEVICE_MODEL := WL-WN586X3
+  DEVICE_DTS := mt7981b-wavlink-wl-wn586x3
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_DTS_LOADADDR := 0x47000000
+  IMAGE_SIZE := 15424k
+  DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware
+endef
+TARGET_DEVICES += wavlink_wl-wn586x3
+
 define Device/xiaomi_mi-router-ax3000t
   DEVICE_VENDOR := Xiaomi
   DEVICE_MODEL := Mi Router AX3000T




More information about the lede-commits mailing list