blob: 8ab47abfa85d0ffc36b19d24e76780618f321ff9 [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)
Lukasz Majewskice86bf92017-10-31 17:58:05 +010057
58/*#define CONFIG_MXC_UART*/
59#define CONFIG_MXC_UART_BASE UART5_BASE
60
61/* SPI NOR Flash */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010062
63/* I2C Configs */
64#define CONFIG_SYS_I2C
65#define CONFIG_SYS_I2C_MXC
66#define CONFIG_SYS_I2C_MXC_I2C1
67#define CONFIG_SYS_I2C_MXC_I2C2
68#define CONFIG_SYS_I2C_MXC_I2C3
69#define CONFIG_I2C_MULTI_BUS
70#define CONFIG_SYS_I2C_SPEED 100000
71#define CONFIG_I2C_EDID
72#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
73
74/* Ethernet */
75#ifdef CONFIG_FEC_MXC
76#define IMX_FEC_BASE ENET_BASE_ADDR
77#define CONFIG_FEC_XCV_TYPE RGMII
78#define CONFIG_ETHPRIME "FEC"
79#define CONFIG_FEC_MXC_PHYADDR 0
Lukasz Majewskice86bf92017-10-31 17:58:05 +010080#endif
81
82/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010083#define CONFIG_FSL_USDHC
84#define CONFIG_SYS_FSL_ESDHC_ADDR 0
85#define CONFIG_SYS_FSL_USDHC_NUM 2
86#define CONFIG_SUPPORT_EMMC_BOOT
87
88/* allow to overwrite serial and ethaddr */
89#define CONFIG_ENV_OVERWRITE
90#define CONFIG_BAUDRATE 115200
91
92#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewskid7e065a2018-05-11 16:51:08 +020093#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
94 "run recovery;" \
95 "else if test ${BOOT_FROM} = FACTORY; then " \
Lukasz Majewski48ef4742018-05-11 16:50:59 +020096 "run factory_nfs;" \
97 "else " \
98 "run boot_mmc;" \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +020099 "fi;fi"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100100#endif
101
102#define PARTS_DEFAULT \
103 /* Linux partitions */ \
104 "partitions=" \
105 "uuid_disk=${uuid_gpt_disk};" \
106 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
107 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
108 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski6d46ce02018-05-11 16:51:16 +0200109 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100110 "name=data,size=-,uuid=${uuid_gpt_data}\0"
111
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100112#define SWUPDATE_RECOVERY_PROCEDURE \
113 "echo '#######################';" \
114 "echo '# RECOVERY SWUupdate #';" \
115 "echo '#######################';" \
Lukasz Majewskiac6fb1e2018-05-11 16:51:18 +0200116 "echo '#######################';" \
117 "echo '# GPT verify #';" \
118 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
119 "echo '# OK ! #';" \
120 "else " \
121 "echo '# FAILED ! #';" \
122 "echo '# GPT RESTORATION #';" \
123 "gpt write mmc ${mmcdev} ${partitions};" \
124 "fi;" \
125 "echo '#######################';" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100126 "setenv loadaddr_swu_initramfs 0x14000000;" \
127 "setenv bootargs console=${console} " \
128 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
129 ":${hostname}::off root=/dev/ram rw;" \
130 "sf probe;" \
131 "sf read ${loadaddr} swu-kernel;" \
132 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200133 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100134
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100135#define SETUP_BOOTARGS \
136 "run set_rootfs_part;" \
137 "setenv bootargs ${bootargs} console=${console} " \
138 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
139 "rootwait rootfstype=ext4 rw; " \
140 "run set_kernel_part;" \
141 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200142 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100143 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
144
145/* All the numbers are in LBAs */
146#define __TFTP_UPDATE_KERNEL \
147 "tftp_mmc_fitImg=" \
148 "if test ! -n ${kernel_part}; then " \
149 "setenv kernel_part ${kernel_part_active};" \
150 "fi;" \
151 "if tftp ${loadaddr} ${kernel_file}; then " \
152 "setexpr fw_sz ${filesize} / 0x200; " \
153 "setexpr fw_sz ${fw_sz} + 1; " \
154 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
155 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
156 "; fi\0" \
157
158#define TFTP_UPDATE_KERNEL \
159 "setenv kernel_part ${kernel_part_active};" \
160 "run tftp_mmc_fitImg;" \
161 "setenv kernel_part ${kernel_part_backup};" \
162 "run tftp_mmc_fitImg;" \
163
164#define __TFTP_UPDATE_ROOTFS \
165 "tftp_mmc_rootfs=" \
166 "if test ! -n ${rootfs_part}; then " \
167 "setenv rootfs_part ${rootfs_part_active};" \
168 "fi;" \
169 "if tftp ${loadaddr} ${rootfs_file}; then " \
170 "setexpr fw_sz ${filesize} / 0x200; " \
171 "setexpr fw_sz ${fw_sz} + 1; " \
172 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
173 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
174 "; fi\0" \
175
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100176#define TFTP_UPDATE_ROOTFS \
177 "setenv rootfs_part ${rootfs_part_active};" \
178 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200179 "run tftp_mmc_rootfs_bkp;" \
180
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100181
182#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
183 "tftp_sf_fitImg_SWU=" \
184 "if tftp ${loadaddr} ${kernel_file}; then " \
185 "sf probe;" \
186 "sf erase swu-kernel +${filesize};" \
187 "sf write ${loadaddr} swu-kernel ${filesize};" \
188 "; fi\0" \
189
190#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskia1d657f2018-05-11 16:51:12 +0200191 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100192 "tftp_sf_initramfs_SWU=" \
193 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
194 "sf probe;" \
195 "sf erase swu-initramfs +${filesize};" \
196 "sf write ${loadaddr} swu-initramfs ${filesize};" \
197 "; fi\0" \
198
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100199#define TFTP_UPDATE_BOOTLOADER \
200 "ubootfile=u-boot.img\0" \
201 "ubootfileSPL=SPL\0" \
202 "tftp_sf_uboot=" \
203 "if tftp ${loadaddr} ${ubootfile}; then " \
204 "sf probe;" \
205 "sf erase u-boot +${filesize};" \
206 "sf write ${loadaddr} u-boot ${filesize}" \
207 "; fi\0" \
208 "tftp_sf_SPL=" \
209 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
210 "sf probe;" \
211 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
212 "sf erase 0x0 +${uboot_SPL_size};" \
213 "sf write ${loadaddr} 0x400 ${filesize};" \
214 "fi\0" \
215
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200216#define TFTP_UPDATE_SPINOR \
217 "spinorfile=core-image-lwn-display5.spinor\0" \
218 "spinorsize=0x2000000\0" \
219 "tftp_sf_img=" \
220 "if tftp ${loadaddr} ${spinorfile}; then " \
221 "sf probe;" \
222 "sf erase 0x0 ${spinorsize};" \
223 "sf write ${loadaddr} 0x0 ${filesize};" \
224 "fi\0" \
225
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100226#define CONFIG_EXTRA_ENV_SETTINGS \
227 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200228 "gpio_recovery=93\0" \
229 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100230 "display=tianma-tm070-800x480\0" \
231 "board=display5\0" \
232 "mmcdev=0\0" \
233 "altbootcmd=run recovery\0" \
234 "bootdelay=1\0" \
235 "baudrate=115200\0" \
236 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100237 "ethact=FEC\0" \
238 "netdev=eth0\0" \
239 "boot_os=y\0" \
240 "hostname=display5\0" \
241 "loadaddr=0x12000000\0" \
242 "fdtaddr=0x12800000\0" \
Lukasz Majewski248698e2018-05-11 16:51:15 +0200243 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100244 "fdtfile=imx6q-display5.dtb\0" \
245 "fdt_high=0xffffffff\0" \
246 "initrd_high=0xffffffff\0" \
247 "kernel_file=fitImage\0" \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200248 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100249 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
250 "download_kernel=" \
251 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200252 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200253 "setenv ipaddr 192.168.1.102;" \
254 "setenv gatewayip 192.168.1.1;" \
255 "setenv netmask 255.255.255.0;" \
256 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200257 "echo BOOT: FACTORY (LEG);" \
258 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100259 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
260 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100261 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200262 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100263 "boot_tftp=" \
264 "if run download_kernel; then " \
265 "setenv bootargs console=${console} " \
266 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200267 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100268 "fi\0" \
269 "addip=setenv bootargs ${bootargs} " \
270 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
271 "${hostname}:eth0:on" \
272 "\0" \
273 "nfsargs=setenv bootargs " \
274 "root=/dev/nfs rw " \
275 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
276 "\0" \
277 "rootpath=/srv/tftp/DISP5/rootfs\0" \
278 "boot_nfs=" \
279 "if run download_kernel; then " \
280 "run nfsargs;" \
281 "run addip;" \
282 "setenv bootargs ${bootargs} console=${console};" \
283 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200284 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100285 "fi\0" \
286 "falcon_setup=" \
287 "if mmc dev ${mmcdev}; then " \
288 SETUP_BOOTARGS \
289 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
290 "setexpr fw_sz ${fdtargslen} / 0x200; " \
291 "setexpr fw_sz ${fw_sz} + 1; " \
292 "mmc write ${fdtargsaddr} " \
293 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
294 "fi\0" \
295 "boot_mmc=" \
296 "if mmc dev ${mmcdev}; then " \
297 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200298 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100299 "fi\0" \
300 "set_kernel_part=" \
301 "if test ${BOOT_FROM} = ACTIVE; then " \
302 "setenv kernel_part ${kernel_part_active};" \
303 "echo BOOT: ACTIVE;" \
304 "else if test ${BOOT_FROM} = BACKUP; then " \
305 "setenv kernel_part ${kernel_part_backup};" \
306 "echo BOOT: BACKUP;" \
307 "else " \
308 "run recovery;" \
309 "fi;fi\0" \
310 "set_rootfs_part=" \
311 "if test ${BOOT_FROM} = ACTIVE; then " \
312 "setenv rootfs_part ${rootfs_part_active};" \
313 "else if test ${BOOT_FROM} = BACKUP; then " \
314 "setenv rootfs_part ${rootfs_part_backup};" \
315 "else " \
316 "run recovery;" \
317 "fi;fi\0" \
318 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100319 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200320 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100321 "kernel_part_active=1\0" \
322 "kernel_part_backup=3\0" \
323 __TFTP_UPDATE_KERNEL \
324 "rootfs_part_active=2\0" \
325 "rootfs_part_backup=4\0" \
326 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200327 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100328 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200329 "tftp_mmc_rootfs_bkp=" \
330 "setenv rootfs_part ${rootfs_part_backup};" \
331 "setenv rootfs_file ${rootfs_file_backup};" \
332 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100333 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
334 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
335 "\0" \
336
337/* Miscellaneous configurable options */
338#undef CONFIG_SYS_CBSIZE
339#define CONFIG_SYS_CBSIZE 2048
340
341/* Print Buffer Size */
342#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
343 sizeof(CONFIG_SYS_PROMPT) + 16)
344#define CONFIG_SYS_MAXARGS 32
345#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
346
347#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
348#define CONFIG_SYS_HZ 1000
349
350/* Physical Memory Map */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100351#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
352#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
353
354#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
355#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
356
357#define CONFIG_SYS_INIT_SP_OFFSET \
358 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
359#define CONFIG_SYS_INIT_SP_ADDR \
360 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
361
362/* Commands */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100363
Lukasz Majewski41b99642018-05-11 16:51:09 +0200364/* Watchdog */
Lukasz Majewski41b99642018-05-11 16:51:09 +0200365#define CONFIG_WATCHDOG_TIMEOUT_MSECS 15000
366
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100367/* ENV config */
368#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
369#define CONFIG_ENV_SIZE (SZ_64K)
370/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
371#define CONFIG_ENV_OFFSET (0x120000)
372#define CONFIG_ENV_SECT_SIZE (SZ_64K)
373#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
374#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
375 CONFIG_ENV_SECT_SIZE)
376#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100377#endif
378
379#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
380#endif /* __CONFIG_H */