blob: 6b428c188446cec45fd851b295d53622437365d7 [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
39#define CONFIG_MTD_DEVICE
40#define CONFIG_SPI_FLASH_MTD
41#define CONFIG_MTD_PARTITIONS
42#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"
50#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000
Lukasz Majewskice86bf92017-10-31 17:58:05 +010051
52#define CONFIG_CMDLINE_TAG
53#define CONFIG_SETUP_MEMORY_TAGS
54#define CONFIG_INITRD_TAG
55#define CONFIG_REVISION_TAG
56
57/* Size of malloc() pool */
58#define CONFIG_SYS_MALLOC_LEN (16 * 1024 * 1024)
59#define CONFIG_MISC_INIT_R
60
61/*#define CONFIG_MXC_UART*/
62#define CONFIG_MXC_UART_BASE UART5_BASE
63
64/* SPI NOR Flash */
65#ifdef CONFIG_CMD_SF
Lukasz Majewskice86bf92017-10-31 17:58:05 +010066#define CONFIG_SF_DEFAULT_BUS 1
67#define CONFIG_SF_DEFAULT_CS (0 | (IMX_GPIO_NR(5, 29) << 8))
68#define CONFIG_SF_DEFAULT_SPEED 50000000
69#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
70#endif
71
72/* I2C Configs */
73#define CONFIG_SYS_I2C
74#define CONFIG_SYS_I2C_MXC
75#define CONFIG_SYS_I2C_MXC_I2C1
76#define CONFIG_SYS_I2C_MXC_I2C2
77#define CONFIG_SYS_I2C_MXC_I2C3
78#define CONFIG_I2C_MULTI_BUS
79#define CONFIG_SYS_I2C_SPEED 100000
80#define CONFIG_I2C_EDID
81#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
82
83/* Ethernet */
84#ifdef CONFIG_FEC_MXC
85#define IMX_FEC_BASE ENET_BASE_ADDR
86#define CONFIG_FEC_XCV_TYPE RGMII
87#define CONFIG_ETHPRIME "FEC"
88#define CONFIG_FEC_MXC_PHYADDR 0
89#define CONFIG_MII
90#endif
91
92/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010093#define CONFIG_FSL_USDHC
94#define CONFIG_SYS_FSL_ESDHC_ADDR 0
95#define CONFIG_SYS_FSL_USDHC_NUM 2
96#define CONFIG_SUPPORT_EMMC_BOOT
97
98/* allow to overwrite serial and ethaddr */
99#define CONFIG_ENV_OVERWRITE
100#define CONFIG_BAUDRATE 115200
101
102#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200103#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
104 "run recovery;" \
105 "else if test ${BOOT_FROM} = FACTORY; then " \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200106 "run factory_nfs;" \
107 "else " \
108 "run boot_mmc;" \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200109 "fi;fi"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100110#endif
111
112#define PARTS_DEFAULT \
113 /* Linux partitions */ \
114 "partitions=" \
115 "uuid_disk=${uuid_gpt_disk};" \
116 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
117 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
118 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
119 "name=rootfs2,size=1528M,uuid=${uuid_gpt_rootfs2};" \
120 "name=data,size=-,uuid=${uuid_gpt_data}\0"
121
122#define FACTORY_PROCEDURE \
123 "echo '#######################';" \
124 "echo '# Factory Boot #';" \
125 "echo '#######################';" \
126 "env default -a;" \
127 "saveenv;" \
128 "gpt write mmc ${mmcdev} ${partitions};" \
129 "run tftp_sf_SPL;" \
130 "run tftp_sf_uboot;" \
131 TFTP_UPDATE_KERNEL \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100132 "run tftp_sf_fitImg_SWU;" \
133 "run tftp_sf_initramfs_SWU;" \
134 TFTP_UPDATE_ROOTFS \
135 "echo '#######################';" \
136 "echo '# END - OK #';" \
137 "echo '#######################';" \
138 "setenv bootcmd 'env default -a; saveenv; run falcon_setup; reset';" \
139 "setenv boot_os 'n';" \
140 "saveenv;" \
141 "reset;"
142
143#define SWUPDATE_RECOVERY_PROCEDURE \
144 "echo '#######################';" \
145 "echo '# RECOVERY SWUupdate #';" \
146 "echo '#######################';" \
147 "setenv loadaddr_swu_initramfs 0x14000000;" \
148 "setenv bootargs console=${console} " \
149 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
150 ":${hostname}::off root=/dev/ram rw;" \
151 "sf probe;" \
152 "sf read ${loadaddr} swu-kernel;" \
153 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200154 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100155
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100156#define SETUP_BOOTARGS \
157 "run set_rootfs_part;" \
158 "setenv bootargs ${bootargs} console=${console} " \
159 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
160 "rootwait rootfstype=ext4 rw; " \
161 "run set_kernel_part;" \
162 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
163 "mmc read ${loadaddr} ${lba_start} 0x2000; " \
164 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
165
166/* All the numbers are in LBAs */
167#define __TFTP_UPDATE_KERNEL \
168 "tftp_mmc_fitImg=" \
169 "if test ! -n ${kernel_part}; then " \
170 "setenv kernel_part ${kernel_part_active};" \
171 "fi;" \
172 "if tftp ${loadaddr} ${kernel_file}; then " \
173 "setexpr fw_sz ${filesize} / 0x200; " \
174 "setexpr fw_sz ${fw_sz} + 1; " \
175 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
176 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
177 "; fi\0" \
178
179#define TFTP_UPDATE_KERNEL \
180 "setenv kernel_part ${kernel_part_active};" \
181 "run tftp_mmc_fitImg;" \
182 "setenv kernel_part ${kernel_part_backup};" \
183 "run tftp_mmc_fitImg;" \
184
185#define __TFTP_UPDATE_ROOTFS \
186 "tftp_mmc_rootfs=" \
187 "if test ! -n ${rootfs_part}; then " \
188 "setenv rootfs_part ${rootfs_part_active};" \
189 "fi;" \
190 "if tftp ${loadaddr} ${rootfs_file}; then " \
191 "setexpr fw_sz ${filesize} / 0x200; " \
192 "setexpr fw_sz ${fw_sz} + 1; " \
193 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
194 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
195 "; fi\0" \
196
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100197#define TFTP_UPDATE_ROOTFS \
198 "setenv rootfs_part ${rootfs_part_active};" \
199 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200200 "run tftp_mmc_rootfs_bkp;" \
201
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100202
203#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
204 "tftp_sf_fitImg_SWU=" \
205 "if tftp ${loadaddr} ${kernel_file}; then " \
206 "sf probe;" \
207 "sf erase swu-kernel +${filesize};" \
208 "sf write ${loadaddr} swu-kernel ${filesize};" \
209 "; fi\0" \
210
211#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
212 "swu_initramfs_file=swupdate-image-display5.ext3.gz.u-boot\0" \
213 "tftp_sf_initramfs_SWU=" \
214 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
215 "sf probe;" \
216 "sf erase swu-initramfs +${filesize};" \
217 "sf write ${loadaddr} swu-initramfs ${filesize};" \
218 "; fi\0" \
219
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100220#define TFTP_UPDATE_BOOTLOADER \
221 "ubootfile=u-boot.img\0" \
222 "ubootfileSPL=SPL\0" \
223 "tftp_sf_uboot=" \
224 "if tftp ${loadaddr} ${ubootfile}; then " \
225 "sf probe;" \
226 "sf erase u-boot +${filesize};" \
227 "sf write ${loadaddr} u-boot ${filesize}" \
228 "; fi\0" \
229 "tftp_sf_SPL=" \
230 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
231 "sf probe;" \
232 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
233 "sf erase 0x0 +${uboot_SPL_size};" \
234 "sf write ${loadaddr} 0x400 ${filesize};" \
235 "fi\0" \
236
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200237#define TFTP_UPDATE_SPINOR \
238 "spinorfile=core-image-lwn-display5.spinor\0" \
239 "spinorsize=0x2000000\0" \
240 "tftp_sf_img=" \
241 "if tftp ${loadaddr} ${spinorfile}; then " \
242 "sf probe;" \
243 "sf erase 0x0 ${spinorsize};" \
244 "sf write ${loadaddr} 0x0 ${filesize};" \
245 "fi\0" \
246
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100247#define CONFIG_EXTRA_ENV_SETTINGS \
248 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200249 "gpio_recovery=93\0" \
250 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100251 "display=tianma-tm070-800x480\0" \
252 "board=display5\0" \
253 "mmcdev=0\0" \
254 "altbootcmd=run recovery\0" \
255 "bootdelay=1\0" \
256 "baudrate=115200\0" \
257 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
258 "factory=" FACTORY_PROCEDURE "\0" \
259 "bootlimit=3\0" \
260 "ethact=FEC\0" \
261 "netdev=eth0\0" \
262 "boot_os=y\0" \
263 "hostname=display5\0" \
264 "loadaddr=0x12000000\0" \
265 "fdtaddr=0x12800000\0" \
266 "console=ttymxc4,115200 quiet\0" \
267 "fdtfile=imx6q-display5.dtb\0" \
268 "fdt_high=0xffffffff\0" \
269 "initrd_high=0xffffffff\0" \
270 "kernel_file=fitImage\0" \
271 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
272 "download_kernel=" \
273 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200274 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200275 "setenv ipaddr 192.168.1.102;" \
276 "setenv gatewayip 192.168.1.1;" \
277 "setenv netmask 255.255.255.0;" \
278 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200279 "echo BOOT: FACTORY (LEG);" \
280 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100281 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
282 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100283 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200284 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100285 "boot_tftp=" \
286 "if run download_kernel; then " \
287 "setenv bootargs console=${console} " \
288 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200289 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100290 "fi\0" \
291 "addip=setenv bootargs ${bootargs} " \
292 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
293 "${hostname}:eth0:on" \
294 "\0" \
295 "nfsargs=setenv bootargs " \
296 "root=/dev/nfs rw " \
297 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
298 "\0" \
299 "rootpath=/srv/tftp/DISP5/rootfs\0" \
300 "boot_nfs=" \
301 "if run download_kernel; then " \
302 "run nfsargs;" \
303 "run addip;" \
304 "setenv bootargs ${bootargs} console=${console};" \
305 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200306 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100307 "fi\0" \
308 "falcon_setup=" \
309 "if mmc dev ${mmcdev}; then " \
310 SETUP_BOOTARGS \
311 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
312 "setexpr fw_sz ${fdtargslen} / 0x200; " \
313 "setexpr fw_sz ${fw_sz} + 1; " \
314 "mmc write ${fdtargsaddr} " \
315 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
316 "fi\0" \
317 "boot_mmc=" \
318 "if mmc dev ${mmcdev}; then " \
319 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200320 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100321 "fi\0" \
322 "set_kernel_part=" \
323 "if test ${BOOT_FROM} = ACTIVE; then " \
324 "setenv kernel_part ${kernel_part_active};" \
325 "echo BOOT: ACTIVE;" \
326 "else if test ${BOOT_FROM} = BACKUP; then " \
327 "setenv kernel_part ${kernel_part_backup};" \
328 "echo BOOT: BACKUP;" \
329 "else " \
330 "run recovery;" \
331 "fi;fi\0" \
332 "set_rootfs_part=" \
333 "if test ${BOOT_FROM} = ACTIVE; then " \
334 "setenv rootfs_part ${rootfs_part_active};" \
335 "else if test ${BOOT_FROM} = BACKUP; then " \
336 "setenv rootfs_part ${rootfs_part_backup};" \
337 "else " \
338 "run recovery;" \
339 "fi;fi\0" \
340 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100341 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200342 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100343 "kernel_part_active=1\0" \
344 "kernel_part_backup=3\0" \
345 __TFTP_UPDATE_KERNEL \
346 "rootfs_part_active=2\0" \
347 "rootfs_part_backup=4\0" \
348 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200349 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100350 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200351 "tftp_mmc_rootfs_bkp=" \
352 "setenv rootfs_part ${rootfs_part_backup};" \
353 "setenv rootfs_file ${rootfs_file_backup};" \
354 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100355 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
356 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
357 "\0" \
358
359/* Miscellaneous configurable options */
360#undef CONFIG_SYS_CBSIZE
361#define CONFIG_SYS_CBSIZE 2048
362
363/* Print Buffer Size */
364#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
365 sizeof(CONFIG_SYS_PROMPT) + 16)
366#define CONFIG_SYS_MAXARGS 32
367#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
368
369#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
370#define CONFIG_SYS_HZ 1000
371
372/* Physical Memory Map */
373#define CONFIG_NR_DRAM_BANKS 1
374#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
375#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
376
377#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
378#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
379
380#define CONFIG_SYS_INIT_SP_OFFSET \
381 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
382#define CONFIG_SYS_INIT_SP_ADDR \
383 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
384
385/* Commands */
386#define CONFIG_MTD_PARTITIONS
387#define CONFIG_MTD_DEVICE
388
Lukasz Majewski41b99642018-05-11 16:51:09 +0200389/* Watchdog */
390#define CONFIG_HW_WATCHDOG
391#define CONFIG_IMX_WATCHDOG
392#define CONFIG_WATCHDOG_TIMEOUT_MSECS 15000
393
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100394/* ENV config */
395#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
396#define CONFIG_ENV_SIZE (SZ_64K)
397/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
398#define CONFIG_ENV_OFFSET (0x120000)
399#define CONFIG_ENV_SECT_SIZE (SZ_64K)
400#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
401#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
402 CONFIG_ENV_SECT_SIZE)
403#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
404
405#define CONFIG_ENV_SPI_BUS CONFIG_SF_DEFAULT_BUS
406#define CONFIG_ENV_SPI_CS CONFIG_SF_DEFAULT_CS
407#define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE
408#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
409#endif
410
411#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
412#endif /* __CONFIG_H */