blob: 182399a390f166af39f838a94e68f7b0817bbb35 [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"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010048
49#define CONFIG_CMDLINE_TAG
50#define CONFIG_SETUP_MEMORY_TAGS
51#define CONFIG_INITRD_TAG
52#define CONFIG_REVISION_TAG
53
54/* Size of malloc() pool */
55#define CONFIG_SYS_MALLOC_LEN (16 * 1024 * 1024)
Lukasz Majewskice86bf92017-10-31 17:58:05 +010056
Lukasz Majewskice86bf92017-10-31 17:58:05 +010057#define CONFIG_MXC_UART_BASE UART5_BASE
58
Lukasz Majewskice86bf92017-10-31 17:58:05 +010059/* I2C Configs */
60#define CONFIG_SYS_I2C
61#define CONFIG_SYS_I2C_MXC
62#define CONFIG_SYS_I2C_MXC_I2C1
63#define CONFIG_SYS_I2C_MXC_I2C2
64#define CONFIG_SYS_I2C_MXC_I2C3
65#define CONFIG_I2C_MULTI_BUS
66#define CONFIG_SYS_I2C_SPEED 100000
67#define CONFIG_I2C_EDID
68#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
69
70/* Ethernet */
71#ifdef CONFIG_FEC_MXC
72#define IMX_FEC_BASE ENET_BASE_ADDR
73#define CONFIG_FEC_XCV_TYPE RGMII
74#define CONFIG_ETHPRIME "FEC"
75#define CONFIG_FEC_MXC_PHYADDR 0
Lukasz Majewskice86bf92017-10-31 17:58:05 +010076#endif
77
78/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010079#define CONFIG_SYS_FSL_ESDHC_ADDR 0
80#define CONFIG_SYS_FSL_USDHC_NUM 2
Lukasz Majewskice86bf92017-10-31 17:58:05 +010081
82/* allow to overwrite serial and ethaddr */
83#define CONFIG_ENV_OVERWRITE
84#define CONFIG_BAUDRATE 115200
85
86#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewskid7e065a2018-05-11 16:51:08 +020087#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
88 "run recovery;" \
89 "else if test ${BOOT_FROM} = FACTORY; then " \
Lukasz Majewski48ef4742018-05-11 16:50:59 +020090 "run factory_nfs;" \
91 "else " \
92 "run boot_mmc;" \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +020093 "fi;fi"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010094#endif
95
96#define PARTS_DEFAULT \
97 /* Linux partitions */ \
98 "partitions=" \
99 "uuid_disk=${uuid_gpt_disk};" \
100 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
101 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
102 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski6d46ce02018-05-11 16:51:16 +0200103 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100104 "name=data,size=-,uuid=${uuid_gpt_data}\0"
105
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100106#define SWUPDATE_RECOVERY_PROCEDURE \
107 "echo '#######################';" \
108 "echo '# RECOVERY SWUupdate #';" \
109 "echo '#######################';" \
Lukasz Majewskiac6fb1e2018-05-11 16:51:18 +0200110 "echo '#######################';" \
111 "echo '# GPT verify #';" \
112 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
113 "echo '# OK ! #';" \
114 "else " \
115 "echo '# FAILED ! #';" \
116 "echo '# GPT RESTORATION #';" \
117 "gpt write mmc ${mmcdev} ${partitions};" \
118 "fi;" \
119 "echo '#######################';" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100120 "setenv loadaddr_swu_initramfs 0x14000000;" \
121 "setenv bootargs console=${console} " \
122 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
123 ":${hostname}::off root=/dev/ram rw;" \
124 "sf probe;" \
125 "sf read ${loadaddr} swu-kernel;" \
126 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200127 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100128
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100129#define SETUP_BOOTARGS \
130 "run set_rootfs_part;" \
131 "setenv bootargs ${bootargs} console=${console} " \
132 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
133 "rootwait rootfstype=ext4 rw; " \
134 "run set_kernel_part;" \
135 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200136 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100137 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
138
139/* All the numbers are in LBAs */
140#define __TFTP_UPDATE_KERNEL \
141 "tftp_mmc_fitImg=" \
142 "if test ! -n ${kernel_part}; then " \
143 "setenv kernel_part ${kernel_part_active};" \
144 "fi;" \
145 "if tftp ${loadaddr} ${kernel_file}; then " \
146 "setexpr fw_sz ${filesize} / 0x200; " \
147 "setexpr fw_sz ${fw_sz} + 1; " \
148 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
149 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
150 "; fi\0" \
151
152#define TFTP_UPDATE_KERNEL \
153 "setenv kernel_part ${kernel_part_active};" \
154 "run tftp_mmc_fitImg;" \
155 "setenv kernel_part ${kernel_part_backup};" \
156 "run tftp_mmc_fitImg;" \
157
158#define __TFTP_UPDATE_ROOTFS \
159 "tftp_mmc_rootfs=" \
160 "if test ! -n ${rootfs_part}; then " \
161 "setenv rootfs_part ${rootfs_part_active};" \
162 "fi;" \
163 "if tftp ${loadaddr} ${rootfs_file}; then " \
164 "setexpr fw_sz ${filesize} / 0x200; " \
165 "setexpr fw_sz ${fw_sz} + 1; " \
166 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
167 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
168 "; fi\0" \
169
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100170#define TFTP_UPDATE_ROOTFS \
171 "setenv rootfs_part ${rootfs_part_active};" \
172 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200173 "run tftp_mmc_rootfs_bkp;" \
174
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100175
176#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
177 "tftp_sf_fitImg_SWU=" \
178 "if tftp ${loadaddr} ${kernel_file}; then " \
179 "sf probe;" \
180 "sf erase swu-kernel +${filesize};" \
181 "sf write ${loadaddr} swu-kernel ${filesize};" \
182 "; fi\0" \
183
184#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskia1d657f2018-05-11 16:51:12 +0200185 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100186 "tftp_sf_initramfs_SWU=" \
187 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
188 "sf probe;" \
189 "sf erase swu-initramfs +${filesize};" \
190 "sf write ${loadaddr} swu-initramfs ${filesize};" \
191 "; fi\0" \
192
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100193#define TFTP_UPDATE_BOOTLOADER \
194 "ubootfile=u-boot.img\0" \
195 "ubootfileSPL=SPL\0" \
196 "tftp_sf_uboot=" \
197 "if tftp ${loadaddr} ${ubootfile}; then " \
198 "sf probe;" \
199 "sf erase u-boot +${filesize};" \
200 "sf write ${loadaddr} u-boot ${filesize}" \
201 "; fi\0" \
202 "tftp_sf_SPL=" \
203 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
204 "sf probe;" \
205 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
206 "sf erase 0x0 +${uboot_SPL_size};" \
207 "sf write ${loadaddr} 0x400 ${filesize};" \
208 "fi\0" \
209
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200210#define TFTP_UPDATE_SPINOR \
211 "spinorfile=core-image-lwn-display5.spinor\0" \
212 "spinorsize=0x2000000\0" \
213 "tftp_sf_img=" \
214 "if tftp ${loadaddr} ${spinorfile}; then " \
215 "sf probe;" \
216 "sf erase 0x0 ${spinorsize};" \
217 "sf write ${loadaddr} 0x0 ${filesize};" \
218 "fi\0" \
219
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100220#define CONFIG_EXTRA_ENV_SETTINGS \
221 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200222 "gpio_recovery=93\0" \
223 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100224 "display=tianma-tm070-800x480\0" \
225 "board=display5\0" \
226 "mmcdev=0\0" \
227 "altbootcmd=run recovery\0" \
228 "bootdelay=1\0" \
229 "baudrate=115200\0" \
230 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100231 "ethact=FEC\0" \
232 "netdev=eth0\0" \
233 "boot_os=y\0" \
234 "hostname=display5\0" \
235 "loadaddr=0x12000000\0" \
236 "fdtaddr=0x12800000\0" \
Lukasz Majewski248698e2018-05-11 16:51:15 +0200237 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100238 "fdtfile=imx6q-display5.dtb\0" \
239 "fdt_high=0xffffffff\0" \
240 "initrd_high=0xffffffff\0" \
241 "kernel_file=fitImage\0" \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200242 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100243 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
244 "download_kernel=" \
245 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200246 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200247 "setenv ipaddr 192.168.1.102;" \
248 "setenv gatewayip 192.168.1.1;" \
249 "setenv netmask 255.255.255.0;" \
250 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200251 "echo BOOT: FACTORY (LEG);" \
252 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100253 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
254 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100255 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200256 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100257 "boot_tftp=" \
258 "if run download_kernel; then " \
259 "setenv bootargs console=${console} " \
260 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200261 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100262 "fi\0" \
263 "addip=setenv bootargs ${bootargs} " \
264 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
265 "${hostname}:eth0:on" \
266 "\0" \
267 "nfsargs=setenv bootargs " \
268 "root=/dev/nfs rw " \
269 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
270 "\0" \
271 "rootpath=/srv/tftp/DISP5/rootfs\0" \
272 "boot_nfs=" \
273 "if run download_kernel; then " \
274 "run nfsargs;" \
275 "run addip;" \
276 "setenv bootargs ${bootargs} console=${console};" \
277 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200278 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100279 "fi\0" \
280 "falcon_setup=" \
281 "if mmc dev ${mmcdev}; then " \
282 SETUP_BOOTARGS \
283 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
284 "setexpr fw_sz ${fdtargslen} / 0x200; " \
285 "setexpr fw_sz ${fw_sz} + 1; " \
286 "mmc write ${fdtargsaddr} " \
287 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
288 "fi\0" \
289 "boot_mmc=" \
290 "if mmc dev ${mmcdev}; then " \
291 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200292 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100293 "fi\0" \
294 "set_kernel_part=" \
295 "if test ${BOOT_FROM} = ACTIVE; then " \
296 "setenv kernel_part ${kernel_part_active};" \
297 "echo BOOT: ACTIVE;" \
298 "else if test ${BOOT_FROM} = BACKUP; then " \
299 "setenv kernel_part ${kernel_part_backup};" \
300 "echo BOOT: BACKUP;" \
301 "else " \
302 "run recovery;" \
303 "fi;fi\0" \
304 "set_rootfs_part=" \
305 "if test ${BOOT_FROM} = ACTIVE; then " \
306 "setenv rootfs_part ${rootfs_part_active};" \
307 "else if test ${BOOT_FROM} = BACKUP; then " \
308 "setenv rootfs_part ${rootfs_part_backup};" \
309 "else " \
310 "run recovery;" \
311 "fi;fi\0" \
312 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100313 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200314 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100315 "kernel_part_active=1\0" \
316 "kernel_part_backup=3\0" \
317 __TFTP_UPDATE_KERNEL \
318 "rootfs_part_active=2\0" \
319 "rootfs_part_backup=4\0" \
320 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200321 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100322 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200323 "tftp_mmc_rootfs_bkp=" \
324 "setenv rootfs_part ${rootfs_part_backup};" \
325 "setenv rootfs_file ${rootfs_file_backup};" \
326 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100327 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
328 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
329 "\0" \
330
331/* Miscellaneous configurable options */
332#undef CONFIG_SYS_CBSIZE
333#define CONFIG_SYS_CBSIZE 2048
334
335/* Print Buffer Size */
336#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
337 sizeof(CONFIG_SYS_PROMPT) + 16)
338#define CONFIG_SYS_MAXARGS 32
339#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
340
341#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
342#define CONFIG_SYS_HZ 1000
343
344/* Physical Memory Map */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100345#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
346#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
347
348#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
349#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
350
351#define CONFIG_SYS_INIT_SP_OFFSET \
352 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
353#define CONFIG_SYS_INIT_SP_ADDR \
354 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
355
Lukasz Majewski41b99642018-05-11 16:51:09 +0200356/* Watchdog */
Lukasz Majewski41b99642018-05-11 16:51:09 +0200357
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100358/* ENV config */
359#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
360#define CONFIG_ENV_SIZE (SZ_64K)
361/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
362#define CONFIG_ENV_OFFSET (0x120000)
363#define CONFIG_ENV_SECT_SIZE (SZ_64K)
364#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
365#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
366 CONFIG_ENV_SECT_SIZE)
367#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100368#endif
369
370#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
371#endif /* __CONFIG_H */