Merge tag 'xilinx-for-v2022.07-rc4' of https://source.denx.de/u-boot/custodians/u...
[platform/kernel/u-boot.git] / include / configs / display5.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2017
4  * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
5  */
6
7 #ifndef __CONFIG_H
8 #define __CONFIG_H
9
10 #include "mx6_common.h"
11
12 /* Falcon Mode */
13 #define CONFIG_SYS_SPL_ARGS_ADDR        0x18000000
14
15 /* Falcon Mode - MMC support */
16 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR   0x3F00
17 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS  \
18         (CONFIG_CMD_SPL_WRITE_SIZE / 512)
19
20 /*
21  * display5 SPI-NOR memory layout
22  *
23  * The definition can be found in Kconfig's
24  * CONFIG_MTDIDS_DEFAULT and CONFIG_MTDPARTS_DEFAULT
25  *
26  * 0x000000 - 0x020000 : SPI.SPL (128KiB)
27  * 0x020000 - 0x120000 : SPI.u-boot (1MiB)
28  * 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB)
29  * 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB)
30  * 0x140000 - 0x740000 : SPI.swupdate-kernel-FIT (6MiB)
31  * 0x740000 - 0x1B40000 : SPI.swupdate-initramfs  (20MiB)
32  * 0x1B40000 - 0x1F00000 : SPI.reserved (3840KiB)
33  * 0x1F00000 - 0x2000000 : SPI.factory  (1MiB)
34  */
35
36 /* Below values are "dummy" - only to avoid build break */
37 #define CONFIG_SYS_SPI_KERNEL_OFFS      0x150000
38 #define CONFIG_SYS_SPI_ARGS_OFFS        0x140000
39 #define CONFIG_SYS_SPI_ARGS_SIZE        0x10000
40
41 #include "imx6_spl.h"
42
43 #define CONFIG_MXC_UART_BASE            UART5_BASE
44
45 /* I2C Configs */
46 #define CONFIG_I2C_MULTI_BUS
47
48 /* MMC Configs */
49 #define CONFIG_SYS_FSL_ESDHC_ADDR       0
50 #define CONFIG_SYS_FSL_USDHC_NUM        2
51
52 #define PARTS_DEFAULT \
53         /* Linux partitions */ \
54         "partitions=" \
55         "uuid_disk=${uuid_gpt_disk};" \
56         "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
57         "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
58         "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
59         "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
60         "name=data,size=-,uuid=${uuid_gpt_data}\0"
61
62 #define SWUPDATE_RECOVERY_PROCEDURE \
63         "echo '#######################';" \
64         "echo '# RECOVERY SWUupdate  #';" \
65         "echo '#######################';" \
66         "echo '#######################';" \
67         "echo '# GPT verify          #';" \
68         "if gpt verify mmc ${mmcdev} ${partitions}; then " \
69                 "echo '# OK !                #';" \
70         "else " \
71                 "echo '# FAILED !            #';" \
72                 "echo '# GPT RESTORATION     #';" \
73                 "gpt write mmc ${mmcdev} ${partitions};" \
74         "fi;" \
75         "echo '#######################';" \
76         "setenv loadaddr_swu_initramfs 0x14000000;" \
77         "setenv bootargs console=${console} " \
78                 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
79                 ":${hostname}::off root=/dev/ram rw;" \
80         "sf probe;" \
81         "sf read ${loadaddr} swu-kernel;" \
82         "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
83         "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
84
85 #define SETUP_BOOTARGS \
86         "run set_rootfs_part;" \
87         "setenv bootargs ${bootargs} console=${console} "         \
88                       "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
89                       "rootwait rootfstype=ext4 rw; " \
90         "run set_kernel_part;" \
91         "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
92         "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
93         "setenv fdt_conf imx6q-${board}-${display}.dtb; "
94
95 /* All the numbers are in LBAs */
96 #define __TFTP_UPDATE_KERNEL \
97         "tftp_mmc_fitImg=" \
98            "if test ! -n ${kernel_part}; then " \
99                "setenv kernel_part ${kernel_part_active};" \
100            "fi;" \
101            "if tftp ${loadaddr} ${kernel_file}; then " \
102                "setexpr fw_sz ${filesize} / 0x200; " \
103                "setexpr fw_sz ${fw_sz} + 1; "  \
104                "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
105                "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
106            "; fi\0" \
107
108 #define TFTP_UPDATE_KERNEL \
109         "setenv kernel_part ${kernel_part_active};" \
110         "run tftp_mmc_fitImg;" \
111         "setenv kernel_part ${kernel_part_backup};" \
112         "run tftp_mmc_fitImg;" \
113
114 #define __TFTP_UPDATE_ROOTFS \
115         "tftp_mmc_rootfs=" \
116            "if test ! -n ${rootfs_part}; then " \
117                "setenv rootfs_part ${rootfs_part_active};" \
118            "fi;" \
119            "if tftp ${loadaddr} ${rootfs_file}; then " \
120                "setexpr fw_sz ${filesize} / 0x200; " \
121                "setexpr fw_sz ${fw_sz} + 1; "  \
122                "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
123                "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
124            "; fi\0" \
125
126 #define TFTP_UPDATE_ROOTFS \
127         "setenv rootfs_part ${rootfs_part_active};" \
128         "run tftp_mmc_rootfs;" \
129         "run tftp_mmc_rootfs_bkp;" \
130
131
132 #define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
133         "tftp_sf_fitImg_SWU=" \
134             "if tftp ${loadaddr} ${kernel_file}; then " \
135                 "sf probe;" \
136                 "sf erase swu-kernel +${filesize};" \
137                 "sf write ${loadaddr} swu-kernel ${filesize};" \
138         "; fi\0"          \
139
140 #define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
141         "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
142         "tftp_sf_initramfs_SWU=" \
143             "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
144                 "sf probe;" \
145                 "sf erase swu-initramfs +${filesize};" \
146                 "sf write ${loadaddr} swu-initramfs ${filesize};" \
147         "; fi\0"          \
148
149 #define TFTP_UPDATE_BOOTLOADER \
150         "ubootfile=u-boot.img\0" \
151         "ubootfileSPL=SPL\0" \
152         "tftp_sf_uboot=" \
153             "if tftp ${loadaddr} ${ubootfile}; then " \
154                 "sf probe;" \
155                 "sf erase u-boot +${filesize};" \
156                 "sf write ${loadaddr} u-boot ${filesize}" \
157         "; fi\0"          \
158         "tftp_sf_SPL="    \
159             "if tftp ${loadaddr} ${ubootfileSPL}; then " \
160                 "sf probe;" \
161                 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
162                 "sf erase 0x0 +${uboot_SPL_size};" \
163                 "sf write ${loadaddr} 0x400 ${filesize};" \
164         "fi\0" \
165
166 #define TFTP_UPDATE_SPINOR \
167         "spinorfile=core-image-lwn-display5.spinor\0" \
168         "spinorsize=0x2000000\0" \
169         "tftp_sf_img=" \
170             "if tftp ${loadaddr} ${spinorfile}; then " \
171                 "sf probe;" \
172                 "sf erase 0x0 ${spinorsize};" \
173                 "sf write ${loadaddr} 0x0 ${filesize};" \
174         "fi\0" \
175
176 #define CONFIG_EXTRA_ENV_SETTINGS         \
177         PARTS_DEFAULT \
178         "gpio_recovery=93\0" \
179         "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
180         "display=tianma-tm070-800x480\0" \
181         "board=display5\0" \
182         "mmcdev=0\0" \
183         "altbootcmd=run recovery\0" \
184         "bootdelay=1\0" \
185         "baudrate=115200\0" \
186         "ethact=FEC\0" \
187         "netdev=eth0\0" \
188         "boot_os=y\0" \
189         "hostname=display5\0" \
190         "loadaddr=0x12000000\0" \
191         "fdtaddr=0x12800000\0" \
192         "console=ttymxc4,115200 quiet cma=256M\0" \
193         "fdtfile=imx6q-display5.dtb\0" \
194         "fdt_high=0xffffffff\0" \
195         "initrd_high=0xffffffff\0" \
196         "kernel_file=fitImage\0" \
197         "fitImg_fw_sz=0x2200\0" \
198         "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
199         "download_kernel=" \
200                 "tftpboot ${loadaddr} ${kernel_file};\0" \
201         "factory_nfs=" \
202              "setenv ipaddr 192.168.1.102;" \
203              "setenv gatewayip 192.168.1.1;" \
204              "setenv netmask 255.255.255.0;" \
205              "setenv serverip 192.168.1.2;" \
206              "echo BOOT: FACTORY (LEG);" \
207              "run boot_nfs\0" \
208         "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
209         "recovery=" \
210              "echo BOOT: RECOVERY: SWU;" \
211              "run boot_swu_recovery\0" \
212         "boot_tftp=" \
213         "if run download_kernel; then "   \
214              "setenv bootargs console=${console} " \
215              "root=/dev/mmcblk0p2 rootwait;" \
216              "bootm ${loadaddr} - ${fdtaddr};reset;" \
217         "fi\0" \
218         "addip=setenv bootargs ${bootargs} " \
219         "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
220             "${hostname}:eth0:on"         \
221         "\0"      \
222         "nfsargs=setenv bootargs " \
223         "root=/dev/nfs rw "       \
224         "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
225         "\0" \
226         "rootpath=/srv/tftp/DISP5/rootfs\0" \
227         "boot_nfs=" \
228         "if run download_kernel; then "   \
229              "run nfsargs;"       \
230              "run addip;"         \
231              "setenv bootargs ${bootargs} console=${console};"    \
232              "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
233              "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
234         "fi\0" \
235         "falcon_setup=" \
236         "if mmc dev ${mmcdev}; then "     \
237              SETUP_BOOTARGS \
238              "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
239              "setexpr fw_sz ${fdtargslen} / 0x200; " \
240              "setexpr fw_sz ${fw_sz} + 1; "  \
241              "mmc write ${fdtargsaddr} " \
242              __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
243         "fi\0" \
244         "boot_mmc=" \
245         "if mmc dev ${mmcdev}; then "     \
246              SETUP_BOOTARGS \
247              "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
248         "fi\0" \
249         "set_kernel_part=" \
250         "if test ${BOOT_FROM} = ACTIVE; then " \
251              "setenv kernel_part ${kernel_part_active};" \
252              "echo BOOT: ACTIVE;" \
253         "else if test ${BOOT_FROM} = BACKUP; then " \
254              "setenv kernel_part ${kernel_part_backup};" \
255              "echo BOOT: BACKUP;" \
256         "else " \
257              "run recovery;" \
258         "fi;fi\0" \
259         "set_rootfs_part=" \
260         "if test ${BOOT_FROM} = ACTIVE; then " \
261              "setenv rootfs_part ${rootfs_part_active};" \
262         "else if test ${BOOT_FROM} = BACKUP; then " \
263              "setenv rootfs_part ${rootfs_part_backup};" \
264         "else " \
265              "run recovery;" \
266         "fi;fi\0" \
267         "BOOT_FROM=ACTIVE\0" \
268         TFTP_UPDATE_BOOTLOADER \
269         TFTP_UPDATE_SPINOR \
270         "kernel_part_active=1\0" \
271         "kernel_part_backup=3\0" \
272         __TFTP_UPDATE_KERNEL \
273         "rootfs_part_active=2\0" \
274         "rootfs_part_backup=4\0" \
275         "rootfs_file=core-image-lwn-display5.ext4\0" \
276         "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
277         __TFTP_UPDATE_ROOTFS \
278         "tftp_mmc_rootfs_bkp=" \
279            "setenv rootfs_part ${rootfs_part_backup};" \
280            "setenv rootfs_file ${rootfs_file_backup};" \
281            "run tftp_mmc_rootfs\0" \
282         TFTP_UPDATE_RECOVERY_SWU_KERNEL \
283         TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
284         "\0" \
285
286 /* Miscellaneous configurable options */
287 #undef CONFIG_SYS_CBSIZE
288 #define CONFIG_SYS_CBSIZE               2048
289
290 /* Print Buffer Size */
291 #define CONFIG_SYS_PBSIZE               (CONFIG_SYS_CBSIZE + \
292                                          sizeof(CONFIG_SYS_PROMPT) + 16)
293 #define CONFIG_SYS_MAXARGS              32
294 #define CONFIG_SYS_BARGSIZE             CONFIG_SYS_CBSIZE
295
296 #define CONFIG_STANDALONE_LOAD_ADDR     0x10001000
297
298 /* Physical Memory Map */
299 #define PHYS_SDRAM                      MMDC0_ARB_BASE_ADDR
300 #define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM
301
302 #define CONFIG_SYS_INIT_RAM_ADDR        IRAM_BASE_ADDR
303 #define CONFIG_SYS_INIT_RAM_SIZE        IRAM_SIZE
304
305 #define CONFIG_SYS_INIT_SP_OFFSET \
306         (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
307 #define CONFIG_SYS_INIT_SP_ADDR \
308         (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
309
310 /* ENV config */
311 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
312 /* The 0x120000 value corresponds to above SPI-NOR memory MAP */
313 #endif
314
315 #define CONFIG_MXC_USB_PORTSC           (PORT_PTS_UTMI | PORT_PTS_PTW)
316 #endif /* __CONFIG_H */