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