1 From 57dc777bddf0baf3c27177576c40b5113309ce54 Mon Sep 17 00:00:00 2001
2 From: Chuanhong Guo <gch981213@gmail.com>
3 Date: Sat, 2 Mar 2024 20:30:16 +0800
4 Subject: [PATCH] add xiaomi redmi ax6s
7 arch/arm/dts/Makefile | 1 +
8 .../dts/mt7622-xiaomi-redmi-router-ax6s.dts | 166 ++++++++++++++++++
9 ...omi_redmi-router-ax6s-ubi-loader_defconfig | 98 +++++++++++
10 xiaomi-redmi-router-ax6s-ubi-loader_env | 22 +++
11 4 files changed, 287 insertions(+)
12 create mode 100644 arch/arm/dts/mt7622-xiaomi-redmi-router-ax6s.dts
13 create mode 100644 configs/mt7622_xiaomi_redmi-router-ax6s-ubi-loader_defconfig
14 create mode 100644 xiaomi-redmi-router-ax6s-ubi-loader_env
16 --- a/arch/arm/dts/Makefile
17 +++ b/arch/arm/dts/Makefile
18 @@ -1425,6 +1425,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
19 mt7622-linksys-e8450-ubi.dtb \
20 mt7622-ubnt-unifi-6-lr.dtb \
21 mt7622-ubnt-unifi-6-lr-v3.dtb \
22 + mt7622-xiaomi-redmi-router-ax6s.dtb \
23 mt7623n-bananapi-bpi-r2.dtb \
27 +++ b/arch/arm/dts/mt7622-xiaomi-redmi-router-ax6s.dts
29 +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
32 +#include <dt-bindings/input/linux-event-codes.h>
33 +#include <dt-bindings/leds/common.h>
34 +#include "mt7622.dtsi"
35 +#include "mt7622-u-boot.dtsi"
38 + #address-cells = <1>;
40 + model = "Xiaomi Redmi Router AX6S";
41 + compatible = "xiaomi,redmi-router-ax6s", "mediatek,mt7622";
44 + stdout-path = &uart0;
45 + tick-timer = &timer0;
54 + device_type = "memory";
55 + reg = <0x40000000 0x8000000>;
59 + compatible = "gpio-leds";
61 + led_power_blue: power_blue {
62 + function = LED_FUNCTION_POWER;
63 + color = <LED_COLOR_ID_BLUE>;
64 + gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
67 + led_power_amber: power_amber {
68 + function = LED_FUNCTION_POWER;
69 + color = <LED_COLOR_ID_AMBER>;
70 + gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
73 + led_net_blue: net_blue {
75 + gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
78 + led_net_amber: net_amber {
79 + label = "amber:net";
80 + gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
86 + compatible = "gpio-keys";
90 + gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
91 + linux,code = <KEY_RESTART>;
96 + gpios = <&gpio 102 GPIO_ACTIVE_LOW>;
97 + linux,code = <BTN_9>;
98 + linux,input-type = <EV_SW>;
102 + reg_1p8v: regulator-1p8v {
103 + compatible = "regulator-fixed";
104 + regulator-name = "fixed-1.8V";
105 + regulator-min-microvolt = <1800000>;
106 + regulator-max-microvolt = <1800000>;
108 + regulator-always-on;
111 + reg_3p3v: regulator-3p3v {
112 + compatible = "regulator-fixed";
113 + regulator-name = "fixed-3.3V";
114 + regulator-min-microvolt = <3300000>;
115 + regulator-max-microvolt = <3300000>;
117 + regulator-always-on;
122 + pinctrl-names = "default";
123 + pinctrl-0 = <&pcie0_pins>;
132 + pcie0_pins: pcie0-pins {
135 + groups = "pcie0_pad_perst",
141 + snfi_pins: snfi-pins {
143 + function = "flash";
148 + uart0_pins: uart0 {
151 + groups = "uart0_0_tx_rx" ;
155 + watchdog_pins: watchdog-default {
157 + function = "watchdog";
158 + groups = "watchdog";
164 + pinctrl-names = "default";
165 + pinctrl-0 = <&snfi_pins>;
171 + pinctrl-names = "default";
172 + pinctrl-0 = <&uart0_pins>;
173 + mediatek,force-highspeed;
178 + pinctrl-names = "default";
179 + pinctrl-0 = <&watchdog_pins>;
185 + mediatek,gmac-id = <0>;
186 + phy-mode = "2500base-x";
187 + mediatek,switch = "mt7531";
188 + reset-gpios = <&gpio 54 GPIO_ACTIVE_HIGH>;
196 +++ b/configs/mt7622_xiaomi_redmi-router-ax6s-ubi-loader_defconfig
199 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y
200 +CONFIG_POSITION_INDEPENDENT=y
201 +CONFIG_ARCH_MEDIATEK=y
202 +CONFIG_TEXT_BASE=0x41e00000
203 +CONFIG_SYS_MALLOC_F_LEN=0x4000
204 +CONFIG_NR_DRAM_BANKS=1
205 +CONFIG_DEFAULT_DEVICE_TREE="mt7622-xiaomi-redmi-router-ax6s"
206 +CONFIG_PRE_CON_BUF_ADDR=0x4007EF00
207 +CONFIG_DEBUG_UART_BASE=0x11002000
208 +CONFIG_DEBUG_UART_CLOCK=25000000
209 +CONFIG_SYS_LOAD_ADDR=0x40080000
214 +CONFIG_AUTOBOOT_KEYED=y
215 +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7622-xiaomi-redmi-router-ax6s"
217 +CONFIG_PRE_CONSOLE_BUFFER=y
219 +CONFIG_BOARD_LATE_INIT=y
220 +CONFIG_LAST_STAGE_INIT=y
221 +CONFIG_HUSH_PARSER=y
222 +# CONFIG_AUTO_COMPLETE is not set
223 +CONFIG_SYS_PROMPT="MT7622> "
224 +CONFIG_CMD_LICENSE=y
226 +CONFIG_CMD_ERASEENV=y
227 +CONFIG_CMD_ENV_FLAGS=y
228 +# CONFIG_CMD_UNLZ4 is not set
229 +# CONFIG_CMD_UNZIP is not set
232 +# CONFIG_CMD_BOOTP is not set
233 +CONFIG_CMD_TFTPSRV=y
237 +CONFIG_CMD_FS_GENERIC=y
238 +CONFIG_CMD_FS_UUID=y
239 +CONFIG_CMD_MTDPARTS=y
240 +CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-nand0:512k(preloader),2816k(reserved),117248k(ubi)"
242 +CONFIG_CMD_UBI_RENAME=y
243 +CONFIG_DOS_PARTITION=y
244 +CONFIG_EFI_PARTITION=y
245 +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
246 +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
247 +CONFIG_USE_DEFAULT_ENV_FILE=y
248 +CONFIG_DEFAULT_ENV_FILE="xiaomi-redmi-router-ax6s-ubi-loader_env"
249 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
250 +CONFIG_VERSION_VARIABLE=y
252 +CONFIG_BOOTP_SEND_HOSTNAME=y
253 +CONFIG_NET_RANDOM_ETHADDR=y
256 +CONFIG_IPADDR="192.168.1.1"
257 +CONFIG_USE_SERVERIP=y
258 +CONFIG_SERVERIP="192.168.1.254"
262 +CONFIG_BUTTON_GPIO=y
268 +# CONFIG_MMC is not set
271 +CONFIG_MTK_SPI_NAND=y
272 +CONFIG_MTK_SPI_NAND_MTD=y
273 +CONFIG_UBI_SILENCE_MSG=y
274 +CONFIG_MTD_UBI_FASTMAP=y
276 +CONFIG_MEDIATEK_ETH=y
277 +CONFIG_PCIE_MEDIATEK=y
281 +CONFIG_PINCTRL_MT7622=y
282 +CONFIG_POWER_DOMAIN=y
283 +CONFIG_MTK_POWER_DOMAIN=y
284 +CONFIG_DM_REGULATOR=y
285 +CONFIG_DM_REGULATOR_FIXED=y
286 +CONFIG_DM_REGULATOR_GPIO=y
292 +CONFIG_UBIFS_SILENCE_MSG=y
297 +++ b/xiaomi-redmi-router-ax6s-ubi-loader_env
300 +serverip=192.168.1.254
302 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
303 +bootled_pwr=power_blue
304 +bootled_rec=power_amber
305 +bootcmd=run boot_or_recovery
308 +bootfile=openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-initramfs-recovery.itb
309 +bootfile_upg=openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.itb
310 +boot_or_recovery=run boot_production ; led $bootled_pwr off ; led $bootled_rec on ; if ubi check fit ; then run boot_tftp_forever ; else run tftp_production ; fi
311 +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
312 +boot_tftp_forever=while true ; do run boot_tftp ; sleep 1 ; done
313 +boot_production=run ubi_read_production && bootm $loadaddr#$bootconf
314 +ubi_format=ubi detach ; mtd erase ubi && ubi part ubi
315 +ubi_init=ubi part ubi || run ubi_format
316 +ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
317 +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
318 +ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic 2 && ubi write $loadaddr fit $filesize
319 +ubi_read_production=run ubi_init && ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
320 +tftp_production=tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && run ubi_write_production && reset