blob: 692a95938b8a4fb36b38c7b8753f4a9cacb83ce3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Lukasz Majewskice86bf92017-10-31 17:58:05 +01002/*
3 * Copyright (C) 2017
4 * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
Lukasz Majewskice86bf92017-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 Majewski72829882018-05-11 16:51:06 +020033 * 0x140000 - 0x540000 : SPI.swupdate-kernel-FIT (4MiB)
34 * 0x540000 - 0x1540000 : SPI.swupdate-initramfs (16MiB)
Lukasz Majewski7401d0e2018-05-11 16:51:01 +020035 * 0x1540000 - 0x1640000 : SPI.factory (1MiB)
Lukasz Majewskice86bf92017-10-31 17:58:05 +010036 */
37
38#ifndef CONFIG_SPL_BUILD
Lukasz Majewskice86bf92017-10-31 17:58:05 +010039#define CONFIG_SPI_FLASH_MTD
Lukasz Majewskice86bf92017-10-31 17:58:05 +010040#endif
41
42/* Below values are "dummy" - only to avoid build break */
43#define CONFIG_SYS_SPI_KERNEL_OFFS 0x150000
44#define CONFIG_SYS_SPI_ARGS_OFFS 0x140000
45#define CONFIG_SYS_SPI_ARGS_SIZE 0x10000
46
47#include "imx6_spl.h"
48#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000
Lukasz Majewskice86bf92017-10-31 17:58:05 +010049
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#define CONFIG_MISC_INIT_R
58
59/*#define CONFIG_MXC_UART*/
60#define CONFIG_MXC_UART_BASE UART5_BASE
61
62/* SPI NOR Flash */
63#ifdef CONFIG_CMD_SF
Lukasz Majewskice86bf92017-10-31 17:58:05 +010064#define CONFIG_SF_DEFAULT_BUS 1
65#define CONFIG_SF_DEFAULT_CS (0 | (IMX_GPIO_NR(5, 29) << 8))
66#define CONFIG_SF_DEFAULT_SPEED 50000000
67#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
68#endif
69
70/* I2C Configs */
71#define CONFIG_SYS_I2C
72#define CONFIG_SYS_I2C_MXC
73#define CONFIG_SYS_I2C_MXC_I2C1
74#define CONFIG_SYS_I2C_MXC_I2C2
75#define CONFIG_SYS_I2C_MXC_I2C3
76#define CONFIG_I2C_MULTI_BUS
77#define CONFIG_SYS_I2C_SPEED 100000
78#define CONFIG_I2C_EDID
79#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
80
81/* Ethernet */
82#ifdef CONFIG_FEC_MXC
83#define IMX_FEC_BASE ENET_BASE_ADDR
84#define CONFIG_FEC_XCV_TYPE RGMII
85#define CONFIG_ETHPRIME "FEC"
86#define CONFIG_FEC_MXC_PHYADDR 0
87#define CONFIG_MII
88#endif
89
90/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010091#define CONFIG_FSL_USDHC
92#define CONFIG_SYS_FSL_ESDHC_ADDR 0
93#define CONFIG_SYS_FSL_USDHC_NUM 2
94#define CONFIG_SUPPORT_EMMC_BOOT
95
96/* allow to overwrite serial and ethaddr */
97#define CONFIG_ENV_OVERWRITE
98#define CONFIG_BAUDRATE 115200
99
100#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200101#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
102 "run recovery;" \
103 "else if test ${BOOT_FROM} = FACTORY; then " \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200104 "run factory_nfs;" \
105 "else " \
106 "run boot_mmc;" \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200107 "fi;fi"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100108#endif
109
110#define PARTS_DEFAULT \
111 /* Linux partitions */ \
112 "partitions=" \
113 "uuid_disk=${uuid_gpt_disk};" \
114 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
115 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
116 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski6d46ce02018-05-11 16:51:16 +0200117 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100118 "name=data,size=-,uuid=${uuid_gpt_data}\0"
119
120#define FACTORY_PROCEDURE \
121 "echo '#######################';" \
122 "echo '# Factory Boot #';" \
123 "echo '#######################';" \
124 "env default -a;" \
125 "saveenv;" \
126 "gpt write mmc ${mmcdev} ${partitions};" \
127 "run tftp_sf_SPL;" \
128 "run tftp_sf_uboot;" \
129 TFTP_UPDATE_KERNEL \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100130 "run tftp_sf_fitImg_SWU;" \
131 "run tftp_sf_initramfs_SWU;" \
132 TFTP_UPDATE_ROOTFS \
133 "echo '#######################';" \
134 "echo '# END - OK #';" \
135 "echo '#######################';" \
136 "setenv bootcmd 'env default -a; saveenv; run falcon_setup; reset';" \
137 "setenv boot_os 'n';" \
138 "saveenv;" \
139 "reset;"
140
141#define SWUPDATE_RECOVERY_PROCEDURE \
142 "echo '#######################';" \
143 "echo '# RECOVERY SWUupdate #';" \
144 "echo '#######################';" \
Lukasz Majewskiac6fb1e2018-05-11 16:51:18 +0200145 "echo '#######################';" \
146 "echo '# GPT verify #';" \
147 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
148 "echo '# OK ! #';" \
149 "else " \
150 "echo '# FAILED ! #';" \
151 "echo '# GPT RESTORATION #';" \
152 "gpt write mmc ${mmcdev} ${partitions};" \
153 "fi;" \
154 "echo '#######################';" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100155 "setenv loadaddr_swu_initramfs 0x14000000;" \
156 "setenv bootargs console=${console} " \
157 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
158 ":${hostname}::off root=/dev/ram rw;" \
159 "sf probe;" \
160 "sf read ${loadaddr} swu-kernel;" \
161 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200162 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100163
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100164#define SETUP_BOOTARGS \
165 "run set_rootfs_part;" \
166 "setenv bootargs ${bootargs} console=${console} " \
167 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
168 "rootwait rootfstype=ext4 rw; " \
169 "run set_kernel_part;" \
170 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
171 "mmc read ${loadaddr} ${lba_start} 0x2000; " \
172 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
173
174/* All the numbers are in LBAs */
175#define __TFTP_UPDATE_KERNEL \
176 "tftp_mmc_fitImg=" \
177 "if test ! -n ${kernel_part}; then " \
178 "setenv kernel_part ${kernel_part_active};" \
179 "fi;" \
180 "if tftp ${loadaddr} ${kernel_file}; then " \
181 "setexpr fw_sz ${filesize} / 0x200; " \
182 "setexpr fw_sz ${fw_sz} + 1; " \
183 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
184 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
185 "; fi\0" \
186
187#define TFTP_UPDATE_KERNEL \
188 "setenv kernel_part ${kernel_part_active};" \
189 "run tftp_mmc_fitImg;" \
190 "setenv kernel_part ${kernel_part_backup};" \
191 "run tftp_mmc_fitImg;" \
192
193#define __TFTP_UPDATE_ROOTFS \
194 "tftp_mmc_rootfs=" \
195 "if test ! -n ${rootfs_part}; then " \
196 "setenv rootfs_part ${rootfs_part_active};" \
197 "fi;" \
198 "if tftp ${loadaddr} ${rootfs_file}; then " \
199 "setexpr fw_sz ${filesize} / 0x200; " \
200 "setexpr fw_sz ${fw_sz} + 1; " \
201 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
202 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
203 "; fi\0" \
204
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100205#define TFTP_UPDATE_ROOTFS \
206 "setenv rootfs_part ${rootfs_part_active};" \
207 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200208 "run tftp_mmc_rootfs_bkp;" \
209
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100210
211#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
212 "tftp_sf_fitImg_SWU=" \
213 "if tftp ${loadaddr} ${kernel_file}; then " \
214 "sf probe;" \
215 "sf erase swu-kernel +${filesize};" \
216 "sf write ${loadaddr} swu-kernel ${filesize};" \
217 "; fi\0" \
218
219#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskia1d657f2018-05-11 16:51:12 +0200220 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100221 "tftp_sf_initramfs_SWU=" \
222 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
223 "sf probe;" \
224 "sf erase swu-initramfs +${filesize};" \
225 "sf write ${loadaddr} swu-initramfs ${filesize};" \
226 "; fi\0" \
227
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100228#define TFTP_UPDATE_BOOTLOADER \
229 "ubootfile=u-boot.img\0" \
230 "ubootfileSPL=SPL\0" \
231 "tftp_sf_uboot=" \
232 "if tftp ${loadaddr} ${ubootfile}; then " \
233 "sf probe;" \
234 "sf erase u-boot +${filesize};" \
235 "sf write ${loadaddr} u-boot ${filesize}" \
236 "; fi\0" \
237 "tftp_sf_SPL=" \
238 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
239 "sf probe;" \
240 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
241 "sf erase 0x0 +${uboot_SPL_size};" \
242 "sf write ${loadaddr} 0x400 ${filesize};" \
243 "fi\0" \
244
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200245#define TFTP_UPDATE_SPINOR \
246 "spinorfile=core-image-lwn-display5.spinor\0" \
247 "spinorsize=0x2000000\0" \
248 "tftp_sf_img=" \
249 "if tftp ${loadaddr} ${spinorfile}; then " \
250 "sf probe;" \
251 "sf erase 0x0 ${spinorsize};" \
252 "sf write ${loadaddr} 0x0 ${filesize};" \
253 "fi\0" \
254
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100255#define CONFIG_EXTRA_ENV_SETTINGS \
256 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200257 "gpio_recovery=93\0" \
258 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100259 "display=tianma-tm070-800x480\0" \
260 "board=display5\0" \
261 "mmcdev=0\0" \
262 "altbootcmd=run recovery\0" \
263 "bootdelay=1\0" \
264 "baudrate=115200\0" \
265 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
266 "factory=" FACTORY_PROCEDURE "\0" \
267 "bootlimit=3\0" \
268 "ethact=FEC\0" \
269 "netdev=eth0\0" \
270 "boot_os=y\0" \
271 "hostname=display5\0" \
272 "loadaddr=0x12000000\0" \
273 "fdtaddr=0x12800000\0" \
Lukasz Majewski248698e2018-05-11 16:51:15 +0200274 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100275 "fdtfile=imx6q-display5.dtb\0" \
276 "fdt_high=0xffffffff\0" \
277 "initrd_high=0xffffffff\0" \
278 "kernel_file=fitImage\0" \
279 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
280 "download_kernel=" \
281 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200282 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200283 "setenv ipaddr 192.168.1.102;" \
284 "setenv gatewayip 192.168.1.1;" \
285 "setenv netmask 255.255.255.0;" \
286 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200287 "echo BOOT: FACTORY (LEG);" \
288 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100289 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
290 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100291 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200292 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100293 "boot_tftp=" \
294 "if run download_kernel; then " \
295 "setenv bootargs console=${console} " \
296 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200297 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100298 "fi\0" \
299 "addip=setenv bootargs ${bootargs} " \
300 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
301 "${hostname}:eth0:on" \
302 "\0" \
303 "nfsargs=setenv bootargs " \
304 "root=/dev/nfs rw " \
305 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
306 "\0" \
307 "rootpath=/srv/tftp/DISP5/rootfs\0" \
308 "boot_nfs=" \
309 "if run download_kernel; then " \
310 "run nfsargs;" \
311 "run addip;" \
312 "setenv bootargs ${bootargs} console=${console};" \
313 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200314 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100315 "fi\0" \
316 "falcon_setup=" \
317 "if mmc dev ${mmcdev}; then " \
318 SETUP_BOOTARGS \
319 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
320 "setexpr fw_sz ${fdtargslen} / 0x200; " \
321 "setexpr fw_sz ${fw_sz} + 1; " \
322 "mmc write ${fdtargsaddr} " \
323 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
324 "fi\0" \
325 "boot_mmc=" \
326 "if mmc dev ${mmcdev}; then " \
327 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200328 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100329 "fi\0" \
330 "set_kernel_part=" \
331 "if test ${BOOT_FROM} = ACTIVE; then " \
332 "setenv kernel_part ${kernel_part_active};" \
333 "echo BOOT: ACTIVE;" \
334 "else if test ${BOOT_FROM} = BACKUP; then " \
335 "setenv kernel_part ${kernel_part_backup};" \
336 "echo BOOT: BACKUP;" \
337 "else " \
338 "run recovery;" \
339 "fi;fi\0" \
340 "set_rootfs_part=" \
341 "if test ${BOOT_FROM} = ACTIVE; then " \
342 "setenv rootfs_part ${rootfs_part_active};" \
343 "else if test ${BOOT_FROM} = BACKUP; then " \
344 "setenv rootfs_part ${rootfs_part_backup};" \
345 "else " \
346 "run recovery;" \
347 "fi;fi\0" \
348 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100349 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200350 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100351 "kernel_part_active=1\0" \
352 "kernel_part_backup=3\0" \
353 __TFTP_UPDATE_KERNEL \
354 "rootfs_part_active=2\0" \
355 "rootfs_part_backup=4\0" \
356 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200357 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100358 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200359 "tftp_mmc_rootfs_bkp=" \
360 "setenv rootfs_part ${rootfs_part_backup};" \
361 "setenv rootfs_file ${rootfs_file_backup};" \
362 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100363 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
364 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
365 "\0" \
366
367/* Miscellaneous configurable options */
368#undef CONFIG_SYS_CBSIZE
369#define CONFIG_SYS_CBSIZE 2048
370
371/* Print Buffer Size */
372#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
373 sizeof(CONFIG_SYS_PROMPT) + 16)
374#define CONFIG_SYS_MAXARGS 32
375#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
376
377#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
378#define CONFIG_SYS_HZ 1000
379
380/* Physical Memory Map */
381#define CONFIG_NR_DRAM_BANKS 1
382#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
383#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
384
385#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
386#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
387
388#define CONFIG_SYS_INIT_SP_OFFSET \
389 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
390#define CONFIG_SYS_INIT_SP_ADDR \
391 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
392
393/* Commands */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100394
Lukasz Majewski41b99642018-05-11 16:51:09 +0200395/* Watchdog */
396#define CONFIG_HW_WATCHDOG
397#define CONFIG_IMX_WATCHDOG
398#define CONFIG_WATCHDOG_TIMEOUT_MSECS 15000
399
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100400/* ENV config */
401#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
402#define CONFIG_ENV_SIZE (SZ_64K)
403/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
404#define CONFIG_ENV_OFFSET (0x120000)
405#define CONFIG_ENV_SECT_SIZE (SZ_64K)
406#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
407#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
408 CONFIG_ENV_SECT_SIZE)
409#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
410
411#define CONFIG_ENV_SPI_BUS CONFIG_SF_DEFAULT_BUS
412#define CONFIG_ENV_SPI_CS CONFIG_SF_DEFAULT_CS
413#define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE
414#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
415#endif
416
417#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
418#endif /* __CONFIG_H */