From 194443120ace9d73f8af9d96d5156087c26b6406 Mon Sep 17 00:00:00 2001 From: Aabandon <31271387+Aabandon@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:38:11 +0800 Subject: [PATCH] mediatek: add support for Xiaomi AX3000T (#160) --- defconfig/mt7981-ax3000.config | 4 ++ package/boot/uboot-envtools/files/mediatek | 1 + target/linux/mediatek/base-files/sbin/smp.sh | 1 + .../mt7981-xiaomi-mi-router-ax3000t-stock.dts | 53 +++++++++++++++++++ .../mt7981-xiaomi-mi-router-ax3000t.dts | 41 ++++++++++++++ .../mt7981-xiaomi-mi-router-wr30u-112m.dts | 19 ++++++- .../mt7981-xiaomi-mi-router-wr30u-stock.dts | 19 ++++++- ...base.dtsi => mt7981-xiaomi-mi-router.dtsi} | 19 +------ target/linux/mediatek/image/mt7981.mk | 29 ++++++++++ .../mt7981/base-files/etc/board.d/02_network | 2 + .../mt7981/base-files/lib/upgrade/platform.sh | 13 +++-- 11 files changed, 178 insertions(+), 23 deletions(-) create mode 100644 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t-stock.dts create mode 100644 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t.dts rename target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/{mt7981-xiaomi-mi-router-wr30u-base.dtsi => mt7981-xiaomi-mi-router.dtsi} (91%) diff --git a/defconfig/mt7981-ax3000.config b/defconfig/mt7981-ax3000.config index b788a7a6fa..c0e0878e94 100644 --- a/defconfig/mt7981-ax3000.config +++ b/defconfig/mt7981-ax3000.config @@ -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 diff --git a/package/boot/uboot-envtools/files/mediatek b/package/boot/uboot-envtools/files/mediatek index 4178ec7527..2787267dd5 100644 --- a/package/boot/uboot-envtools/files/mediatek +++ b/package/boot/uboot-envtools/files/mediatek @@ -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" diff --git a/target/linux/mediatek/base-files/sbin/smp.sh b/target/linux/mediatek/base-files/sbin/smp.sh index f612645def..59aedbef54 100755 --- a/target/linux/mediatek/base-files/sbin/smp.sh +++ b/target/linux/mediatek/base-files/sbin/smp.sh @@ -724,6 +724,7 @@ setup_model() *clt,r30b1* |\ cmcc,a10* |\ xiaomi,mi-router-wr30u* |\ + xiaomi,mi-router-ax3000t* |\ *rax3000m* |\ h3c,nx30pro |\ konka,komi-a31 |\ diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t-stock.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t-stock.dts new file mode 100644 index 0000000000..574f41a6b0 --- /dev/null +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t-stock.dts @@ -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"; + }; + }; +}; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t.dts new file mode 100644 index 0000000000..62eb997799 --- /dev/null +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-ax3000t.dts @@ -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"; + }; + }; +}; \ No newline at end of file diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-112m.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-112m.dts index 8bcb221a2c..9274d8fe3f 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-112m.dts +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-112m.dts @@ -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>; + }; }; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-stock.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-stock.dts index 141f4d0c82..76c42d5f0c 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-stock.dts +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-stock.dts @@ -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>; + }; }; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-base.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router.dtsi similarity index 91% rename from target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-base.dtsi rename to target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router.dtsi index 59d54cd5f7..4d7e754985 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router-wr30u-base.dtsi +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-xiaomi-mi-router.dtsi @@ -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 @@ -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>; - }; }; }; diff --git a/target/linux/mediatek/image/mt7981.mk b/target/linux/mediatek/image/mt7981.mk index b6064d2a6d..346515b9ae 100644 --- a/target/linux/mediatek/image/mt7981.mk +++ b/target/linux/mediatek/image/mt7981.mk @@ -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 diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network index 927e2659f8..6f3224a12f 100755 --- a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network @@ -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) diff --git a/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh index 935c9b7967..b1fee1e48b 100644 --- a/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh @@ -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 }