mediatek: add support for Xiaomi AX3000T (#160)

This commit is contained in:
Aabandon 2023-11-15 20:38:11 +08:00 committed by GitHub
parent ea63ce92bc
commit 194443120a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 178 additions and 23 deletions

View File

@ -27,6 +27,10 @@ CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-clt-r30b1=y
CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_mt7981-clt-r30b1=""
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-clt-r30b1-112M=y
CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_mt7981-clt-r30b1-112M=""
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t=y
CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t=""
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t-stock=y
CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t-stock=""
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_xiaomi_mi-router-wr30u-112m=y
CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_xiaomi_mi-router-wr30u-112m=""
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_xiaomi_mi-router-wr30u-stock=y

View File

@ -28,6 +28,7 @@ cmcc,rax3000m)
*imou,lc-hx3001*)
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x80000" "0x80000" "1"
;;
xiaomi,mi-router-ax3000t* |\
xiaomi,mi-router-wr30u* |\
xiaomi,redmi-router-ax6000*)
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x10000" "0x20000" "1"

View File

@ -724,6 +724,7 @@ setup_model()
*clt,r30b1* |\
cmcc,a10* |\
xiaomi,mi-router-wr30u* |\
xiaomi,mi-router-ax3000t* |\
*rax3000m* |\
h3c,nx30pro |\
konka,komi-a31 |\

View File

@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7981-xiaomi-mi-router.dtsi"
/ {
model = "Xiaomi Mi Router AX3000T (stock layout)";
compatible = "xiaomi,mi-router-ax3000t-stock", "mediatek,mt7981";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "okay";
nfc@57 {
compatible = "nt082c";
reg = <0x57>;
};
};
&partitions {
// ubi_kernel is the ubi partition in stock.
partition@600000 {
label = "ubi_kernel";
reg = <0x600000 0x2200000>;
};
/* ubi is the result of squashing
* consecutive stock partitions:
* - ubi1
* - overlay
* - data
*/
partition@2800000 {
label = "ubi";
reg = <0x2800000 0x4e00000>;
};
partition@7600000 {
label = "KF";
reg = <0x7600000 0x40000>;
};
};
&pio {
i2c_pins: i2c-pins {
mux {
function = "i2c";
groups = "i2c0_1";
};
};
};

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7981-xiaomi-mi-router.dtsi"
/ {
model = "Xiaomi Mi Router AX3000T";
compatible = "xiaomi,mi-router-ax3000t", "mediatek,mt7981";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "okay";
nfc@57 {
compatible = "nt082c";
reg = <0x57>;
};
};
&partitions {
partition@600000 {
label = "ubi";
reg = <0x600000 0x7000000>;
};
partition@7600000 {
label = "KF";
reg = <0x7600000 0x40000>;
};
};
&pio {
i2c_pins: i2c-pins {
mux {
function = "i2c";
groups = "i2c0_1";
};
};
};

View File

@ -1,16 +1,33 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7981-xiaomi-mi-router-wr30u-base.dtsi"
#include "mt7981-xiaomi-mi-router.dtsi"
/ {
model = "Xiaomi Mi Router WR30U (112M UBI layout)";
compatible = "xiaomi,mi-router-wr30u-112m", "mediatek,mt7981";
};
&leds {
led_network_blue {
label = "blue:network";
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
};
led_network_yellow {
label = "yellow:network";
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
};
};
&partitions {
partition@600000 {
label = "ubi";
reg = <0x600000 0x7000000>;
};
partition@7600000 {
label = "KF";
reg = <0x7600000 0x40000>;
};
};

View File

@ -1,13 +1,25 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7981-xiaomi-mi-router-wr30u-base.dtsi"
#include "mt7981-xiaomi-mi-router.dtsi"
/ {
model = "Xiaomi Mi Router WR30U (stock layout)";
compatible = "xiaomi,mi-router-wr30u-stock", "mediatek,mt7981";
};
&leds {
led_network_blue {
label = "blue:network";
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
};
led_network_yellow {
label = "yellow:network";
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
};
};
&partitions {
// ubi_kernel is the ubi partition in stock.
partition@600000 {
@ -25,4 +37,9 @@
label = "ubi";
reg = <0x2800000 0x4e00000>;
};
partition@7600000 {
label = "KF";
reg = <0x7600000 0x40000>;
};
};

View File

@ -1,4 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include <dt-bindings/input/input.h>
@ -40,7 +40,7 @@
};
};
leds {
leds: leds {
compatible = "gpio-leds";
led_system_blue: system_blue {
@ -52,16 +52,6 @@
label = "yellow:system";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
};
led_network_blue {
label = "blue:network";
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
};
led_network_yellow {
label = "yellow:network";
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
};
};
gsw: gsw@0 {
@ -211,11 +201,6 @@
label = "crash_log";
reg = <0x5c0000 0x40000>;
};
partition@7600000 {
label = "KF";
reg = <0x7600000 0x40000>;
};
};
};

View File

@ -303,6 +303,35 @@ define Device/xiaomi_mi-router-wr30u-112m
endef
TARGET_DEVICES += xiaomi_mi-router-wr30u-112m
define Device/xiaomi_mi-router-ax3000t-stock
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Mi Router AX3000T (stock layout)
DEVICE_DTS := mt7981-xiaomi-mi-router-ax3000t-stock
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 34816k
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += xiaomi_mi-router-ax3000t-stock
define Device/xiaomi_mi-router-ax3000t
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Mi Router AX3000T
DEVICE_DTS := mt7981-xiaomi-mi-router-ax3000t
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 114688k
KERNEL_IN_UBI := 1
IMAGES += factory.bin
IMAGE/factory.ubi := append-ubi | check-size $$$$(IMAGE_SIZE)
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += xiaomi_mi-router-ax3000t
define Device/glinet_gl-mt3000
DEVICE_VENDOR := GL.iNet
DEVICE_MODEL := GL-MT3000

View File

@ -22,6 +22,7 @@ mediatek_setup_interfaces()
*2500wan-p5*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan
;;
xiaomi,mi-router-ax3000t* |\
xiaomi,mi-router-wr30u*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
@ -146,6 +147,7 @@ mediatek_setup_macs()
mtk_facrory_write_mac Factory 4 "$wifi_mac"
fi
;;
xiaomi,mi-router-ax3000t* |\
xiaomi,mi-router-wr30u*)
wan_mac=$(mtd_get_mac_ascii Bdata ethaddr_wan)
lan_mac=$(mtd_get_mac_ascii Bdata ethaddr)

View File

@ -14,7 +14,7 @@ nand_remove_ubiblock() {
fi
}
xiaomi_wr30u_nand_upgrade_tar()
xiaomi_mt7981_nand_upgrade_tar()
{
CI_UBIPART=ubi
local tar_file="$1"
@ -138,7 +138,7 @@ xiaomi_wr30u_nand_upgrade_tar()
nand_do_upgrade_success
}
xiaomi_wr30u_initial_setup()
xiaomi_mt7981_initial_setup()
{
# initialize UBI and setup uboot-env if it's running on initramfs
[ "$(rootfs_type)" = "tmpfs" ] || return 0
@ -176,6 +176,7 @@ xiaomi_wr30u_initial_setup()
local board=$(board_name)
case "$board" in
xiaomi,mi-router-ax3000t-stock|\
xiaomi,mi-router-wr30u-stock)
fw_setenv mtdparts "nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),34816k(ubi),34816k(ubi1),32768k(overlay),12288k(data),256k(KF)"
;;
@ -187,6 +188,7 @@ platform_do_upgrade() {
case "$board" in
xiaomi,mi-router-wr30u-112m|\
xiaomi,mi-router-ax3000t|\
*mt3000* |\
glinet,x3000-emmc |\
*xe3000* |\
@ -214,8 +216,9 @@ platform_do_upgrade() {
*emmc*)
mtk_mmc_do_upgrade "$1"
;;
xiaomi,mi-router-ax3000t-stock|\
xiaomi,mi-router-wr30u-stock)
xiaomi_wr30u_nand_upgrade_tar "$1"
xiaomi_mt7981_nand_upgrade_tar "$1"
;;
*)
default_do_upgrade "$1"
@ -240,6 +243,7 @@ platform_check_image() {
*360,t7* |\
xiaomi,mi-router-wr30u-stock|\
xiaomi,mi-router-wr30u-112m|\
xiaomi,mi-router-ax3000t* |\
*abt,asr3000* |\
*cetron,ct3003* |\
*clt,r30b1* |\
@ -278,8 +282,9 @@ platform_pre_upgrade() {
local board=$(board_name)
case "$board" in
xiaomi,mi-router-ax3000t-stock|\
xiaomi,mi-router-wr30u-stock)
xiaomi_wr30u_initial_setup
xiaomi_mt7981_initial_setup
;;
esac
}