filogic: add support for ASUS TUF-AX4200

Hardware
--------
SOC:   MediaTek MT7986
RAM:   512MB DDR3
FLASH: 256MB SPI-NAND (Winbond W25N02KV)
WIFI:  Mediatek MT7986 DBDC 802.11ax 2.4/5 GHz
ETH:   MediaTek MT7531 Switch
       MaxLinear GPY211C 2.5 N-Base-T PHY
UART:  3V3 115200 8N1 (Pinout silkscreened / Do not ocnnect VCC)

Installation
------------

1. Download the OpenWrt initramfs image. Copy the image to a TFTP server
   reachable at 192.168.1.66/24. Rename the image to tufax4200.bin.

2. Connect the TFTP server to the AX4200. Conect to the serial console,
   interrupt the autoboot process by pressing '4' when prompted.

3. Download & Boot the OpenWrt initramfs image.

   $ setenv ipaddr 192.168.1.1
   $ setenv serverip 192.168.1.66
   $ tftpboot 0x46000000 tufax4200.bin
   $ bootm 0x46000000

4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device
   using scp and install using sysupgrade.

   $ sysupgrade -n <path-to-sysupgrade.bin>

Missing features
----------------

 - The LAN port LEDs are driven by the switch but OpenWrt does not
   correctly configure the output.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer 2023-01-26 17:39:43 +01:00
parent 652d5ac152
commit e7c399bee6
7 changed files with 368 additions and 0 deletions

View File

@ -0,0 +1,291 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include "mt7986a.dtsi"
/ {
model = "ASUS TUF-AX4200";
compatible = "asus,tuf-ax4200", "mediatek,mt7986a";
aliases {
serial0 = &uart0;
led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
};
chosen {
stdout-path = "serial0:115200n8";
bootargs-override = "ubi.mtd=UBI_DEV";
};
memory {
reg = <0 0x40000000 0 0x20000000>;
};
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
mesh {
label = "wps";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
};
leds {
compatible = "gpio-leds";
wlan24 {
label = "white:wlan24";
gpios = <&pio 1 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "phy0tpt";
};
wlan5 {
label = "white:wlan5";
gpios = <&pio 2 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "phy1tpt";
};
led_system: system {
label = "white:system";
gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
};
wan-red {
label = "red:wan";
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
};
};
reg_3p3v: regulator-3p3v {
compatible = "regulator-fixed";
regulator-name = "fixed-3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
reg_5v: regulator-5v {
compatible = "regulator-fixed";
regulator-name = "fixed-5V";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-boot-on;
regulator-always-on;
};
};
&eth {
status = "okay";
gmac0: mac@0 {
/* LAN */
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
gmac1: mac@1 {
/* WAN */
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "2500base-x";
phy-handle = <&phy6>;
};
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
};
};
&mdio {
phy6: phy@6 {
compatible = "ethernet-phy-ieee802.3-c45";
reg = <6>;
reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>;
reset-assert-us = <10000>;
reset-deassert-us = <10000>;
/* LED0: CONN (WAN white) */
mxl,led-config = <0x00f0 0x0 0x0 0x0>;
};
switch: switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
reset-assert-us = <10000>;
reset-deassert-us = <10000>;
};
};
&pio {
spi_flash_pins: spi-flash-pins-33-to-38 {
mux {
function = "spi";
groups = "spi0", "spi0_wp_hold";
};
conf-pu {
pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
drive-strength = <8>;
mediatek,pull-up-adv = <0>; /* bias-disable */
};
conf-pd {
pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
drive-strength = <8>;
mediatek,pull-down-adv = <0>; /* bias-disable */
};
};
wf_2g_5g_pins: wf_2g_5g-pins {
mux {
function = "wifi";
groups = "wf_2g", "wf_5g";
};
conf {
pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
"WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
"WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
"WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
"WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
"WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
"WF1_TOP_CLK", "WF1_TOP_DATA";
drive-strength = <4>;
};
};
wf_dbdc_pins: wf-dbdc-pins {
mux {
function = "wifi";
groups = "wf_dbdc";
};
conf {
pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
"WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
"WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
"WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
"WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
"WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
"WF1_TOP_CLK", "WF1_TOP_DATA";
drive-strength = <4>;
};
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi_flash_pins>;
status = "okay";
spi_nand_flash: flash@0 {
compatible = "spi-nand";
#address-cells = <1>;
#size-cells = <1>;
reg = <0>;
spi-max-frequency = <20000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
partitions: partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "bootloader";
reg = <0x0 0x400000>;
read-only;
};
partition@400000 {
label = "UBI_DEV";
reg = <0x400000 0xfc00000>;
};
};
};
};
&switch {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@1 {
reg = <1>;
label = "lan1";
};
port@2 {
reg = <2>;
label = "lan2";
};
port@3 {
reg = <3>;
label = "lan3";
};
port@4 {
reg = <4>;
label = "lan4";
};
port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
&wmac {
status = "okay";
pinctrl-names = "default", "dbdc";
pinctrl-0 = <&wf_2g_5g_pins>;
pinctrl-1 = <&wf_dbdc_pins>;
};
&uart0 {
status = "okay";
};
&ssusb {
vusb33-supply = <&reg_3p3v>;
vbus-supply = <&reg_5v>;
status = "okay";
};
&usb_phy {
status = "okay";
};

View File

@ -8,6 +8,10 @@ mediatek_setup_interfaces()
local board="$1"
case $board in
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth1"
;;
mediatek,mt7986a-rfb|\
mediatek,mt7986b-rfb)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" eth1
@ -34,6 +38,12 @@ mediatek_setup_macs()
local label_mac=""
case $board in
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
wan_mac="${addr}"
lan_mac="${addr}"
;;
xiaomi,redmi-router-ax6000-stock|\
xiaomi,redmi-router-ax6000-ubootmod)
wan_mac=$(mtd_get_mac_ascii Bdata ethaddr_wan)

View File

@ -0,0 +1,21 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
board=$(board_name)
case "$FIRMWARE" in
"mediatek/mt7986_eeprom_mt7976_dbdc.bin")
case "$board" in
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
caldata_extract_ubi "Factory" 0x0 0x1000
;;
esac
;;
*)
exit 1
;;
esac

View File

@ -10,6 +10,15 @@ PHYNBR=${DEVPATH##*/phy}
board=$(board_name)
case "$board" in
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
# Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
# addresses on mutiple VIFs with the other radio. Set LA bit and increment
# mac-address instead.
[ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
;;
bananapi,bpi-r3)
addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2)
[ "$PHYNBR" = "0" ] && macaddr_unsetbit $addr 6 > /sys${DEVPATH}/macaddress

View File

@ -0,0 +1,14 @@
. /lib/functions/system.sh
preinit_set_mac_address() {
case $(board_name) in
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
ip link set dev eth0 address "$addr"
ip link set dev eth1 address "$addr"
;;
esac
}
boot_hook_add preinit_main preinit_set_mac_address

View File

@ -42,6 +42,11 @@ platform_do_upgrade() {
local board=$(board_name)
case "$board" in
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
bananapi,bpi-r3)
local rootdev="$(cmdline_get_var root)"
rootdev="${rootdev##*/}"

View File

@ -38,6 +38,24 @@ define Build/mt7986-gpt
rm $@.tmp
endef
define Device/asus_tuf-ax4200
DEVICE_VENDOR := ASUS
DEVICE_MODEL := TUF-AX4200
DEVICE_DTS := mt7986a-asus-tuf-ax4200
DEVICE_DTS_DIR := ../dts
DEVICE_DTS_LOADADDR := 0x47000000
DEVICE_PACKAGES := kmod-usb3
IMAGES := sysupgrade.bin
KERNEL_LOADADDR := 0x48000000
KERNEL = kernel-bin | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
KERNEL_INITRAMFS := kernel-bin | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += asus_tuf-ax4200
define Device/bananapi_bpi-r3
DEVICE_VENDOR := Bananapi
DEVICE_MODEL := BPi-R3