uboot-mediatek: add Redmi AX6S as UBI loader
[openwrt/openwrt.git] / package / boot / uboot-mediatek / patches / 452-add-xiaomi-redmi-ax6s.patch
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
5
6 ---
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
15
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 \
24 mt7629-rfb.dtb \
25 mt7981-rfb.dtb \
26 --- /dev/null
27 +++ b/arch/arm/dts/mt7622-xiaomi-redmi-router-ax6s.dts
28 @@ -0,0 +1,166 @@
29 +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
30 +
31 +/dts-v1/;
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"
36 +
37 +/ {
38 + #address-cells = <1>;
39 + #size-cells = <1>;
40 + model = "Xiaomi Redmi Router AX6S";
41 + compatible = "xiaomi,redmi-router-ax6s", "mediatek,mt7622";
42 +
43 + chosen {
44 + stdout-path = &uart0;
45 + tick-timer = &timer0;
46 + };
47 +
48 + aliases {
49 + spi0 = &snand;
50 + ethernet0 = &eth;
51 + };
52 +
53 + memory@40000000 {
54 + device_type = "memory";
55 + reg = <0x40000000 0x8000000>;
56 + };
57 +
58 + leds {
59 + compatible = "gpio-leds";
60 +
61 + led_power_blue: power_blue {
62 + function = LED_FUNCTION_POWER;
63 + color = <LED_COLOR_ID_BLUE>;
64 + gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
65 + };
66 +
67 + led_power_amber: power_amber {
68 + function = LED_FUNCTION_POWER;
69 + color = <LED_COLOR_ID_AMBER>;
70 + gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
71 + };
72 +
73 + led_net_blue: net_blue {
74 + label = "blue:net";
75 + gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
76 + };
77 +
78 + led_net_amber: net_amber {
79 + label = "amber:net";
80 + gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
81 + };
82 +
83 + };
84 +
85 + keys {
86 + compatible = "gpio-keys";
87 +
88 + reset {
89 + label = "reset";
90 + gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
91 + linux,code = <KEY_RESTART>;
92 + };
93 +
94 + mesh {
95 + label = "mesh";
96 + gpios = <&gpio 102 GPIO_ACTIVE_LOW>;
97 + linux,code = <BTN_9>;
98 + linux,input-type = <EV_SW>;
99 + };
100 + };
101 +
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>;
107 + regulator-boot-on;
108 + regulator-always-on;
109 + };
110 +
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>;
116 + regulator-boot-on;
117 + regulator-always-on;
118 + };
119 +};
120 +
121 +&pcie {
122 + pinctrl-names = "default";
123 + pinctrl-0 = <&pcie0_pins>;
124 + status = "okay";
125 +
126 + pcie@0,0 {
127 + status = "okay";
128 + };
129 +};
130 +
131 +&pinctrl {
132 + pcie0_pins: pcie0-pins {
133 + mux {
134 + function = "pcie";
135 + groups = "pcie0_pad_perst",
136 + "pcie0_1_waken",
137 + "pcie0_1_clkreq";
138 + };
139 + };
140 +
141 + snfi_pins: snfi-pins {
142 + mux {
143 + function = "flash";
144 + groups = "snfi";
145 + };
146 + };
147 +
148 + uart0_pins: uart0 {
149 + mux {
150 + function = "uart";
151 + groups = "uart0_0_tx_rx" ;
152 + };
153 + };
154 +
155 + watchdog_pins: watchdog-default {
156 + mux {
157 + function = "watchdog";
158 + groups = "watchdog";
159 + };
160 + };
161 +};
162 +
163 +&snand {
164 + pinctrl-names = "default";
165 + pinctrl-0 = <&snfi_pins>;
166 + quad-spi;
167 + status = "okay";
168 +};
169 +
170 +&uart0 {
171 + pinctrl-names = "default";
172 + pinctrl-0 = <&uart0_pins>;
173 + mediatek,force-highspeed;
174 + status = "okay";
175 +};
176 +
177 +&watchdog {
178 + pinctrl-names = "default";
179 + pinctrl-0 = <&watchdog_pins>;
180 + status = "okay";
181 +};
182 +
183 +&eth {
184 + status = "okay";
185 + mediatek,gmac-id = <0>;
186 + phy-mode = "2500base-x";
187 + mediatek,switch = "mt7531";
188 + reset-gpios = <&gpio 54 GPIO_ACTIVE_HIGH>;
189 +
190 + fixed-link {
191 + speed = <2500>;
192 + full-duplex;
193 + };
194 +};
195 --- /dev/null
196 +++ b/configs/mt7622_xiaomi_redmi-router-ax6s-ubi-loader_defconfig
197 @@ -0,0 +1,98 @@
198 +CONFIG_ARM=y
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
210 +CONFIG_PCI=y
211 +CONFIG_DEBUG_UART=y
212 +CONFIG_FIT=y
213 +CONFIG_BOOTDELAY=30
214 +CONFIG_AUTOBOOT_KEYED=y
215 +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7622-xiaomi-redmi-router-ax6s"
216 +CONFIG_LOGLEVEL=7
217 +CONFIG_PRE_CONSOLE_BUFFER=y
218 +CONFIG_LOG=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
225 +CONFIG_CMD_ASKENV=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
230 +CONFIG_CMD_GPIO=y
231 +CONFIG_CMD_MTD=y
232 +# CONFIG_CMD_BOOTP is not set
233 +CONFIG_CMD_TFTPSRV=y
234 +CONFIG_CMD_PING=y
235 +CONFIG_CMD_HASH=y
236 +CONFIG_CMD_SMC=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)"
241 +CONFIG_CMD_UBI=y
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
251 +CONFIG_PROT_UDP=y
252 +CONFIG_BOOTP_SEND_HOSTNAME=y
253 +CONFIG_NET_RANDOM_ETHADDR=y
254 +CONFIG_NETCONSOLE=y
255 +CONFIG_USE_IPADDR=y
256 +CONFIG_IPADDR="192.168.1.1"
257 +CONFIG_USE_SERVERIP=y
258 +CONFIG_SERVERIP="192.168.1.254"
259 +CONFIG_REGMAP=y
260 +CONFIG_SYSCON=y
261 +CONFIG_BUTTON=y
262 +CONFIG_BUTTON_GPIO=y
263 +CONFIG_CLK=y
264 +CONFIG_GPIO_HOG=y
265 +CONFIG_LED=y
266 +CONFIG_LED_BLINK=y
267 +CONFIG_LED_GPIO=y
268 +# CONFIG_MMC is not set
269 +CONFIG_MTD=y
270 +CONFIG_DM_MTD=y
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
275 +CONFIG_PHY_FIXED=y
276 +CONFIG_MEDIATEK_ETH=y
277 +CONFIG_PCIE_MEDIATEK=y
278 +CONFIG_PHY=y
279 +CONFIG_PINCTRL=y
280 +CONFIG_PINCONF=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
287 +CONFIG_RAM=y
288 +CONFIG_DM_SERIAL=y
289 +CONFIG_MTK_SERIAL=y
290 +CONFIG_SPI=y
291 +CONFIG_DM_SPI=y
292 +CONFIG_UBIFS_SILENCE_MSG=y
293 +CONFIG_LZ4=y
294 +CONFIG_ZSTD=y
295 +CONFIG_HEXDUMP=y
296 --- /dev/null
297 +++ b/xiaomi-redmi-router-ax6s-ubi-loader_env
298 @@ -0,0 +1,22 @@
299 +ipaddr=192.168.1.1
300 +serverip=192.168.1.254
301 +loadaddr=0x46000000
302 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
303 +bootled_pwr=power_blue
304 +bootled_rec=power_amber
305 +bootcmd=run boot_or_recovery
306 +bootconf=config-1
307 +bootdelay=0
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