uboot-mediatek: add support for Xiaomi Redmi Router AX6000
[openwrt/openwrt.git] / package / boot / uboot-mediatek / patches / 431-add-xiaomi_redmi-ax6000.patch
1 --- /dev/null
2 +++ b/configs/mt7986_xiaomi_redmi-ax6000_defconfig
3 @@ -0,0 +1,175 @@
4 +CONFIG_ARM=y
5 +CONFIG_POSITION_INDEPENDENT=y
6 +CONFIG_ARCH_MEDIATEK=y
7 +CONFIG_TARGET_MT7986=y
8 +CONFIG_SYS_TEXT_BASE=0x41e00000
9 +CONFIG_SYS_MALLOC_F_LEN=0x4000
10 +CONFIG_NR_DRAM_BANKS=1
11 +CONFIG_DEFAULT_DEVICE_TREE="mt7986a-xiaomi_redmi-ax6000"
12 +CONFIG_DEFAULT_ENV_FILE="xiaomi_redmi-ax6000_env"
13 +CONFIG_DEFAULT_FDT_FILE="mediatek/mt7986a-xiaomi_redmi-ax6000.dtb"
14 +CONFIG_OF_LIBFDT_OVERLAY=y
15 +CONFIG_DEBUG_UART_BASE=0x11002000
16 +CONFIG_DEBUG_UART_CLOCK=40000000
17 +CONFIG_DEBUG_UART=y
18 +CONFIG_SYS_LOAD_ADDR=0x46000000
19 +CONFIG_SMBIOS_PRODUCT_NAME=""
20 +CONFIG_AUTOBOOT_KEYED=y
21 +CONFIG_BOOTDELAY=30
22 +CONFIG_AUTOBOOT_MENU_SHOW=y
23 +CONFIG_CFB_CONSOLE_ANSI=y
24 +CONFIG_BOARD_LATE_INIT=y
25 +CONFIG_BUTTON=y
26 +CONFIG_BUTTON_GPIO=y
27 +CONFIG_GPIO_HOG=y
28 +CONFIG_CMD_ENV_FLAGS=y
29 +CONFIG_FIT=y
30 +CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
31 +# CONFIG_LED is not set
32 +# CONFIG_LED_BLINK is not set
33 +# CONFIG_LED_GPIO is not set
34 +CONFIG_LOGLEVEL=7
35 +CONFIG_LOG=y
36 +CONFIG_SYS_PROMPT="MT7986> "
37 +CONFIG_CMD_BOOTMENU=y
38 +CONFIG_CMD_BOOTP=y
39 +CONFIG_CMD_BUTTON=y
40 +CONFIG_CMD_CACHE=y
41 +CONFIG_CMD_CDP=y
42 +CONFIG_CMD_CPU=y
43 +CONFIG_CMD_DHCP=y
44 +CONFIG_CMD_DM=y
45 +CONFIG_CMD_DNS=y
46 +CONFIG_CMD_ECHO=y
47 +CONFIG_CMD_ENV_READMEM=y
48 +CONFIG_CMD_ERASEENV=y
49 +# CONFIG_CMD_EXT4 is not set
50 +# CONFIG_CMD_FAT is not set
51 +CONFIG_CMD_FDT=y
52 +# CONFIG_CMD_FS_GENERIC is not set
53 +# CONFIG_CMD_FS_UUID is not set
54 +CONFIG_CMD_GPIO=y
55 +# CONFIG_CMD_GPT is not set
56 +CONFIG_CMD_HASH=y
57 +CONFIG_CMD_ITEST=y
58 +# CONFIG_CMD_LED is not set
59 +CONFIG_CMD_LICENSE=y
60 +CONFIG_CMD_LINK_LOCAL=y
61 +# CONFIG_CMD_MBR is not set
62 +CONFIG_CMD_MTD=y
63 +# CONFIG_CMD_PCI is not set
64 +CONFIG_CMD_PSTORE=y
65 +CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
66 +CONFIG_CMD_SF_TEST=y
67 +CONFIG_CMD_PING=y
68 +CONFIG_CMD_PXE=y
69 +# CONFIG_CMD_PWM is not set
70 +CONFIG_CMD_SMC=y
71 +CONFIG_CMD_TFTPBOOT=y
72 +CONFIG_CMD_TFTPSRV=y
73 +CONFIG_CMD_UBI=y
74 +CONFIG_CMD_UBI_RENAME=y
75 +CONFIG_CMD_UBIFS=y
76 +CONFIG_CMD_ASKENV=y
77 +CONFIG_CMD_PART=y
78 +CONFIG_CMD_RARP=y
79 +CONFIG_CMD_SETEXPR=y
80 +CONFIG_CMD_SLEEP=y
81 +CONFIG_CMD_SNTP=y
82 +CONFIG_CMD_SOURCE=y
83 +CONFIG_CMD_STRINGS=y
84 +# CONFIG_CMD_USB is not set
85 +# CONFIG_CMD_FLASH is not set
86 +CONFIG_CMD_UUID=y
87 +CONFIG_DISPLAY_CPUINFO=y
88 +CONFIG_DM_MTD=y
89 +CONFIG_DM_REGULATOR=y
90 +CONFIG_DM_REGULATOR_FIXED=y
91 +CONFIG_DM_REGULATOR_GPIO=y
92 +# CONFIG_DM_USB is not set
93 +# CONFIG_DM_PWM is not set
94 +# CONFIG_PWM_MTK is not set
95 +CONFIG_HUSH_PARSER=y
96 +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
97 +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
98 +CONFIG_VERSION_VARIABLE=y
99 +CONFIG_PARTITION_UUIDS=y
100 +CONFIG_NETCONSOLE=y
101 +CONFIG_REGMAP=y
102 +CONFIG_SYSCON=y
103 +CONFIG_CLK=y
104 +CONFIG_DM_GPIO=y
105 +# CONFIG_DM_SCSI is not set
106 +# CONFIG_AHCI is not set
107 +CONFIG_PHY=y
108 +# CONFIG_PHY_MTK_TPHY is not set
109 +CONFIG_PHY_FIXED=y
110 +CONFIG_DM_ETH=y
111 +CONFIG_MEDIATEK_ETH=y
112 +# CONFIG_PCI is not set
113 +# CONFIG_MMC is not set
114 +# CONFIG_DM_MMC is not set
115 +CONFIG_MTD=y
116 +CONFIG_MTD_UBI_FASTMAP=y
117 +# CONFIG_DM_PCI is not set
118 +# CONFIG_PCIE_MEDIATEK is not set
119 +CONFIG_PINCTRL=y
120 +CONFIG_PINCONF=y
121 +# CONFIG_PINCTRL_MT7622 is not set
122 +CONFIG_POWER_DOMAIN=y
123 +CONFIG_PRE_CONSOLE_BUFFER=y
124 +CONFIG_PRE_CON_BUF_ADDR=0x4007EF00
125 +CONFIG_MTK_POWER_DOMAIN=y
126 +CONFIG_RAM=y
127 +CONFIG_DM_SERIAL=y
128 +CONFIG_MTK_SERIAL=y
129 +CONFIG_SPI=y
130 +# CONFIG_I2C is not set
131 +CONFIG_DM_SPI=y
132 +CONFIG_MTK_SPI_NAND=y
133 +CONFIG_MTK_SPI_NAND_MTD=y
134 +CONFIG_SYSRESET_WATCHDOG=y
135 +CONFIG_WDT_MTK=y
136 +CONFIG_LZO=y
137 +CONFIG_ZSTD=y
138 +CONFIG_HEXDUMP=y
139 +CONFIG_RANDOM_UUID=y
140 +CONFIG_REGEX=y
141 +# CONFIG_USB is not set
142 +# CONFIG_USB_HOST is not set
143 +# CONFIG_USB_XHCI_HCD is not set
144 +# CONFIG_USB_XHCI_MTK is not set
145 +# CONFIG_USB_STORAGE is not set
146 +CONFIG_OF_EMBED=y
147 +CONFIG_ENV_OVERWRITE=y
148 +CONFIG_ENV_IS_IN_UBI=y
149 +CONFIG_ENV_UBI_PART="ubi"
150 +CONFIG_ENV_SIZE=0x1f000
151 +CONFIG_ENV_SIZE_REDUND=0x1f000
152 +CONFIG_ENV_UBI_VOLUME="ubootenv"
153 +CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
154 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
155 +CONFIG_NET_RANDOM_ETHADDR=y
156 +CONFIG_REGMAP=y
157 +CONFIG_SYSCON=y
158 +CONFIG_CLK=y
159 +CONFIG_PHY_FIXED=y
160 +CONFIG_DM_ETH=y
161 +CONFIG_MEDIATEK_ETH=y
162 +CONFIG_PINCTRL=y
163 +CONFIG_PINCONF=y
164 +CONFIG_PINCTRL_MT7986=y
165 +CONFIG_POWER_DOMAIN=y
166 +CONFIG_MTK_POWER_DOMAIN=y
167 +CONFIG_DM_REGULATOR=y
168 +CONFIG_DM_REGULATOR_FIXED=y
169 +CONFIG_DM_SERIAL=y
170 +CONFIG_MTK_SERIAL=y
171 +CONFIG_HEXDUMP=y
172 +CONFIG_USE_DEFAULT_ENV_FILE=y
173 +CONFIG_MTD_SPI_NAND=y
174 +CONFIG_MTK_SPIM=y
175 +CONFIG_CMD_MTD=y
176 +CONFIG_CMD_NAND=y
177 +CONFIG_CMD_NAND_TRIMFFS=y
178 +CONFIG_LMB_MAX_REGIONS=64
179 --- /dev/null
180 +++ b/arch/arm/dts/mt7986a-xiaomi_redmi-ax6000.dts
181 @@ -0,0 +1,152 @@
182 +// SPDX-License-Identifier: GPL-2.0
183 +/*
184 + * Copyright (c) 2021 MediaTek Inc.
185 + * Author: Sam Shih <sam.shih@mediatek.com>
186 + */
187 +
188 +/dts-v1/;
189 +#include "mt7986.dtsi"
190 +#include <dt-bindings/gpio/gpio.h>
191 +
192 +/ {
193 + #address-cells = <1>;
194 + #size-cells = <1>;
195 + model = "Xiaomi Redmi AX6000";
196 + compatible = "mediatek,mt7986", "mediatek,mt7986-sd-rfb";
197 +
198 + chosen {
199 + stdout-path = &uart0;
200 + tick-timer = &timer0;
201 + };
202 +
203 + keys {
204 + compatible = "gpio-keys";
205 + factory {
206 + label = "reset";
207 + gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
208 + };
209 + mesh {
210 + label = "mesh";
211 + gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
212 + };
213 + };
214 +};
215 +
216 +&uart0 {
217 + status = "okay";
218 +};
219 +
220 +&uart1 {
221 + pinctrl-names = "default";
222 + pinctrl-0 = <&uart1_pins>;
223 + status = "disabled";
224 +};
225 +
226 +&eth {
227 + status = "okay";
228 + mediatek,gmac-id = <0>;
229 + phy-mode = "sgmii";
230 + mediatek,switch = "mt7531";
231 + reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
232 +
233 + fixed-link {
234 + speed = <1000>;
235 + full-duplex;
236 + };
237 +};
238 +
239 +&pinctrl {
240 + spic_pins: spi1-pins-func-1 {
241 + mux {
242 + function = "spi";
243 + groups = "spi1_2";
244 + };
245 + };
246 +
247 + uart1_pins: spi1-pins-func-3 {
248 + mux {
249 + function = "uart";
250 + groups = "uart1_2";
251 + };
252 + };
253 +
254 + spi_flash_pins: spi0-pins-func-1 {
255 + mux {
256 + function = "flash";
257 + groups = "spi0", "spi0_wp_hold";
258 + };
259 +
260 + conf-pu {
261 + pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
262 + drive-strength = <MTK_DRIVE_8mA>;
263 + bias-pull-up = <MTK_PUPD_SET_R1R0_00>;
264 + };
265 +
266 + conf-pd {
267 + pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
268 + drive-strength = <MTK_DRIVE_8mA>;
269 + bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
270 + };
271 + };
272 +};
273 +
274 +&spi0 {
275 + #address-cells = <1>;
276 + #size-cells = <0>;
277 + pinctrl-names = "default";
278 + pinctrl-0 = <&spi_flash_pins>;
279 + status = "okay";
280 + must_tx;
281 + enhance_timing;
282 + dma_ext;
283 + ipm_design;
284 + support_quad;
285 + tick_dly = <1>;
286 + sample_sel = <0>;
287 +
288 + spi_nand@0 {
289 + compatible = "spi-nand";
290 + reg = <0>;
291 + spi-max-frequency = <52000000>;
292 +
293 + partitions {
294 + compatible = "fixed-partitions";
295 + #address-cells = <1>;
296 + #size-cells = <1>;
297 +
298 + partition@0 {
299 + label = "bl2";
300 + reg = <0x0 0x80000>;
301 + };
302 +
303 + partition@100000 {
304 + label = "nvram";
305 + reg = <0x100000 0x40000>;
306 + };
307 +
308 + partition@140000 {
309 + label = "bdata";
310 + reg = <0x140000 0x40000>;
311 + };
312 +
313 + partition@180000 {
314 + label = "factory";
315 + reg = <0x180000 0x200000>;
316 + };
317 +
318 + partition@380000 {
319 + label = "fip";
320 + reg = <0x380000 0x200000>;
321 + };
322 +
323 + partition@600000 {
324 + label = "ubi";
325 + reg = <0x580000 0x7a80000>;
326 + };
327 + };
328 + };
329 +};
330 +
331 +&watchdog {
332 + status = "disabled";
333 +};
334 --- /dev/null
335 +++ b/xiaomi_redmi-ax6000_env
336 @@ -0,0 +1,55 @@
337 +ethaddr_factory=mtd read factory 0x40080000 0x0 0x20000 && env readmem -b ethaddr 0x40080004 0x6 ; setenv ethaddr_factory
338 +ipaddr=192.168.1.1
339 +serverip=192.168.1.254
340 +loadaddr=0x46000000
341 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
342 +bootargs=console=ttyS0,115200n8 console_msg_format=syslog
343 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi
344 +bootconf=config-1
345 +bootdelay=0
346 +bootfile=openwrt-mediatek-filogic-xiaomi_redmi-router-ax6000-ubootmod-initramfs-recovery.itb
347 +bootfile_bl2=openwrt-mediatek-filogic-xiaomi_redmi-router-ax6000-ubootmod-preloader.bin
348 +bootfile_fip=openwrt-mediatek-filogic-xiaomi_redmi-router-ax6000-ubootmod-bl31-uboot.fip
349 +bootfile_upg=openwrt-mediatek-filogic-xiaomi_redmi-router-ax6000-ubootmod-squashfs-sysupgrade.itb
350 +bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
351 +bootmenu_default=0
352 +bootmenu_delay=0
353 +bootmenu_title= \e[0;34m( ( ( \e[1;39mOpenWrt\e[0;34m ) ) )
354 +bootmenu_0=Initialize environment.=run _firstboot
355 +bootmenu_0d=Run default boot command.=run boot_default
356 +bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
357 +bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
358 +bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
359 +bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
360 +bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
361 +bootmenu_6=\e[31mLoad BL31+U-Boot FIP via TFTP then write to NAND.\e[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
362 +bootmenu_7=\e[31mLoad BL2 preloader via TFTP then write to NAND.\e[0m=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
363 +bootmenu_8=Reboot.=reset
364 +bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
365 +boot_first=if button reset ; then run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
366 +boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
367 +boot_production=run ubi_read_production && bootm $loadaddr#$bootconf
368 +boot_recovery=run ubi_read_recovery && bootm $loadaddr#$bootconf
369 +boot_ubi=run boot_production ; run boot_recovery ; run boot_tftp_forever
370 +boot_tftp_forever=while true ; do run boot_tftp_recovery ; sleep 1 ; done
371 +boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
372 +boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
373 +boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
374 +boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run mtd_write_fip && run reset_factory
375 +boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2
376 +part_fit=fit
377 +reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800
378 +mtd_write_fip=mtd erase fip && mtd write fip $loadaddr
379 +mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr
380 +ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic 0 ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic 1
381 +ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset
382 +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
383 +ubi_read_production=ubi read $loadaddr $part_fit && iminfo $loadaddr && run ubi_prepare_rootfs
384 +ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
385 +ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
386 +ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
387 +ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
388 +_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
389 +_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; run boot_first
390 +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
391 +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title \e[33m$ver\e[0m"