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