blob: 6600b94ac3a76ce2df7b376b5b1c3071c673761e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Lukasz Majewskia3eec242017-10-31 17:58:05 +01002/*
3 * Copyright (C) 2017
4 * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
Lukasz Majewskia3eec242017-10-31 17:58:05 +01005 */
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)
Lukasz Majewski1fa328f2018-05-11 16:51:06 +020033 * 0x140000 - 0x540000 : SPI.swupdate-kernel-FIT (4MiB)
34 * 0x540000 - 0x1540000 : SPI.swupdate-initramfs (16MiB)
Lukasz Majewski86d759e2018-05-11 16:51:01 +020035 * 0x1540000 - 0x1640000 : SPI.factory (1MiB)
Lukasz Majewskia3eec242017-10-31 17:58:05 +010036 */
37
Lukasz Majewskie95b4bd2019-09-03 16:38:43 +020038/* SPI Flash Configs */
39#if defined(CONFIG_SPL_BUILD)
40#undef CONFIG_DM_SPI
41#undef CONFIG_DM_SPI_FLASH
Lukasz Majewskia3eec242017-10-31 17:58:05 +010042#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"
Lukasz Majewskia3eec242017-10-31 17:58:05 +010050
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)
Lukasz Majewskia3eec242017-10-31 17:58:05 +010058
Lukasz Majewskia3eec242017-10-31 17:58:05 +010059#define CONFIG_MXC_UART_BASE UART5_BASE
60
Lukasz Majewskia3eec242017-10-31 17:58:05 +010061/* I2C Configs */
Lukasz Majewskia3eec242017-10-31 17:58:05 +010062#define CONFIG_I2C_MULTI_BUS
Lukasz Majewskia3eec242017-10-31 17:58:05 +010063
64/* MMC Configs */
Lukasz Majewskia3eec242017-10-31 17:58:05 +010065#define CONFIG_SYS_FSL_ESDHC_ADDR 0
66#define CONFIG_SYS_FSL_USDHC_NUM 2
Lukasz Majewskia3eec242017-10-31 17:58:05 +010067
68/* allow to overwrite serial and ethaddr */
69#define CONFIG_ENV_OVERWRITE
70#define CONFIG_BAUDRATE 115200
71
72#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewski27aede22018-05-11 16:51:08 +020073#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
74 "run recovery;" \
75 "else if test ${BOOT_FROM} = FACTORY; then " \
Lukasz Majewski13e012f2018-05-11 16:50:59 +020076 "run factory_nfs;" \
77 "else " \
78 "run boot_mmc;" \
Lukasz Majewski27aede22018-05-11 16:51:08 +020079 "fi;fi"
Lukasz Majewskia3eec242017-10-31 17:58:05 +010080#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};" \
Lukasz Majewski9fea1ca2018-05-11 16:51:16 +020089 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +010090 "name=data,size=-,uuid=${uuid_gpt_data}\0"
91
Lukasz Majewskia3eec242017-10-31 17:58:05 +010092#define SWUPDATE_RECOVERY_PROCEDURE \
93 "echo '#######################';" \
94 "echo '# RECOVERY SWUupdate #';" \
95 "echo '#######################';" \
Lukasz Majewski0f055122018-05-11 16:51:18 +020096 "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 '#######################';" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100106 "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;" \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200113 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100114
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100115#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; " \
Lukasz Majewskif008e262018-08-18 22:22:07 +0200122 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100123 "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
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100156#define TFTP_UPDATE_ROOTFS \
157 "setenv rootfs_part ${rootfs_part_active};" \
158 "run tftp_mmc_rootfs;" \
Lukasz Majewski18ccca52018-05-11 16:51:11 +0200159 "run tftp_mmc_rootfs_bkp;" \
160
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100161
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 \
Lukasz Majewskib5f45432018-05-11 16:51:12 +0200171 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100172 "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
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100179#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
Lukasz Majewski2f4372a2018-05-11 16:51:02 +0200196#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
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100206#define CONFIG_EXTRA_ENV_SETTINGS \
207 PARTS_DEFAULT \
Lukasz Majewski27aede22018-05-11 16:51:08 +0200208 "gpio_recovery=93\0" \
209 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100210 "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" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100217 "ethact=FEC\0" \
218 "netdev=eth0\0" \
219 "boot_os=y\0" \
220 "hostname=display5\0" \
221 "loadaddr=0x12000000\0" \
222 "fdtaddr=0x12800000\0" \
Lukasz Majewski5d925402018-05-11 16:51:15 +0200223 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100224 "fdtfile=imx6q-display5.dtb\0" \
225 "fdt_high=0xffffffff\0" \
226 "initrd_high=0xffffffff\0" \
227 "kernel_file=fitImage\0" \
Lukasz Majewskif008e262018-08-18 22:22:07 +0200228 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100229 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
230 "download_kernel=" \
231 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200232 "factory_nfs=" \
Lukasz Majewski4864ba72018-05-11 16:51:00 +0200233 "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;" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200237 "echo BOOT: FACTORY (LEG);" \
238 "run boot_nfs\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100239 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
240 "recovery=" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100241 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib78e9c42018-05-11 16:51:05 +0200242 "run boot_swu_recovery\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100243 "boot_tftp=" \
244 "if run download_kernel; then " \
245 "setenv bootargs console=${console} " \
246 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200247 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100248 "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; " \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200264 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100265 "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 \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200278 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100279 "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" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100299 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewski2f4372a2018-05-11 16:51:02 +0200300 TFTP_UPDATE_SPINOR \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100301 "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" \
Lukasz Majewskidd4ed882018-05-11 16:51:10 +0200307 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100308 __TFTP_UPDATE_ROOTFS \
Lukasz Majewskidd4ed882018-05-11 16:51:10 +0200309 "tftp_mmc_rootfs_bkp=" \
310 "setenv rootfs_part ${rootfs_part_backup};" \
311 "setenv rootfs_file ${rootfs_file_backup};" \
312 "run tftp_mmc_rootfs\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100313 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 */
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100331#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
Lukasz Majewski76d1d162018-05-11 16:51:09 +0200342/* Watchdog */
Lukasz Majewskid5354f52019-09-03 16:38:45 +0200343#if defined(CONFIG_SPL_BUILD)
344#undef CONFIG_WDT
345#undef CONFIG_WATCHDOG
346#define CONFIG_HW_WATCHDOG
347#endif
Lukasz Majewski76d1d162018-05-11 16:51:09 +0200348
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100349/* ENV config */
350#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100351/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100352#endif
353
354#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
355#endif /* __CONFIG_H */