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