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