blob: 8829cbad913c05ff94d0009e7852b7171a94307a [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
38#ifndef CONFIG_SPL_BUILD
Lukasz Majewskia3eec242017-10-31 17:58:05 +010039#define CONFIG_SPI_FLASH_MTD
Lukasz Majewskia3eec242017-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 Majewskia3eec242017-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 Majewskia3eec242017-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 Majewskia3eec242017-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 Majewskia3eec242017-10-31 17:58:05 +010080#endif
81
82/* MMC Configs */
Lukasz Majewskia3eec242017-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
Lukasz Majewskia3eec242017-10-31 17:58:05 +010086
87/* allow to overwrite serial and ethaddr */
88#define CONFIG_ENV_OVERWRITE
89#define CONFIG_BAUDRATE 115200
90
91#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewski27aede22018-05-11 16:51:08 +020092#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
93 "run recovery;" \
94 "else if test ${BOOT_FROM} = FACTORY; then " \
Lukasz Majewski13e012f2018-05-11 16:50:59 +020095 "run factory_nfs;" \
96 "else " \
97 "run boot_mmc;" \
Lukasz Majewski27aede22018-05-11 16:51:08 +020098 "fi;fi"
Lukasz Majewskia3eec242017-10-31 17:58:05 +010099#endif
100
101#define PARTS_DEFAULT \
102 /* Linux partitions */ \
103 "partitions=" \
104 "uuid_disk=${uuid_gpt_disk};" \
105 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
106 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
107 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski9fea1ca2018-05-11 16:51:16 +0200108 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100109 "name=data,size=-,uuid=${uuid_gpt_data}\0"
110
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100111#define SWUPDATE_RECOVERY_PROCEDURE \
112 "echo '#######################';" \
113 "echo '# RECOVERY SWUupdate #';" \
114 "echo '#######################';" \
Lukasz Majewski0f055122018-05-11 16:51:18 +0200115 "echo '#######################';" \
116 "echo '# GPT verify #';" \
117 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
118 "echo '# OK ! #';" \
119 "else " \
120 "echo '# FAILED ! #';" \
121 "echo '# GPT RESTORATION #';" \
122 "gpt write mmc ${mmcdev} ${partitions};" \
123 "fi;" \
124 "echo '#######################';" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100125 "setenv loadaddr_swu_initramfs 0x14000000;" \
126 "setenv bootargs console=${console} " \
127 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
128 ":${hostname}::off root=/dev/ram rw;" \
129 "sf probe;" \
130 "sf read ${loadaddr} swu-kernel;" \
131 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200132 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100133
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100134#define SETUP_BOOTARGS \
135 "run set_rootfs_part;" \
136 "setenv bootargs ${bootargs} console=${console} " \
137 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
138 "rootwait rootfstype=ext4 rw; " \
139 "run set_kernel_part;" \
140 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
Lukasz Majewskif008e262018-08-18 22:22:07 +0200141 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100142 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
143
144/* All the numbers are in LBAs */
145#define __TFTP_UPDATE_KERNEL \
146 "tftp_mmc_fitImg=" \
147 "if test ! -n ${kernel_part}; then " \
148 "setenv kernel_part ${kernel_part_active};" \
149 "fi;" \
150 "if tftp ${loadaddr} ${kernel_file}; then " \
151 "setexpr fw_sz ${filesize} / 0x200; " \
152 "setexpr fw_sz ${fw_sz} + 1; " \
153 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
154 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
155 "; fi\0" \
156
157#define TFTP_UPDATE_KERNEL \
158 "setenv kernel_part ${kernel_part_active};" \
159 "run tftp_mmc_fitImg;" \
160 "setenv kernel_part ${kernel_part_backup};" \
161 "run tftp_mmc_fitImg;" \
162
163#define __TFTP_UPDATE_ROOTFS \
164 "tftp_mmc_rootfs=" \
165 "if test ! -n ${rootfs_part}; then " \
166 "setenv rootfs_part ${rootfs_part_active};" \
167 "fi;" \
168 "if tftp ${loadaddr} ${rootfs_file}; then " \
169 "setexpr fw_sz ${filesize} / 0x200; " \
170 "setexpr fw_sz ${fw_sz} + 1; " \
171 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
172 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
173 "; fi\0" \
174
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100175#define TFTP_UPDATE_ROOTFS \
176 "setenv rootfs_part ${rootfs_part_active};" \
177 "run tftp_mmc_rootfs;" \
Lukasz Majewski18ccca52018-05-11 16:51:11 +0200178 "run tftp_mmc_rootfs_bkp;" \
179
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100180
181#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
182 "tftp_sf_fitImg_SWU=" \
183 "if tftp ${loadaddr} ${kernel_file}; then " \
184 "sf probe;" \
185 "sf erase swu-kernel +${filesize};" \
186 "sf write ${loadaddr} swu-kernel ${filesize};" \
187 "; fi\0" \
188
189#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskib5f45432018-05-11 16:51:12 +0200190 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100191 "tftp_sf_initramfs_SWU=" \
192 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
193 "sf probe;" \
194 "sf erase swu-initramfs +${filesize};" \
195 "sf write ${loadaddr} swu-initramfs ${filesize};" \
196 "; fi\0" \
197
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100198#define TFTP_UPDATE_BOOTLOADER \
199 "ubootfile=u-boot.img\0" \
200 "ubootfileSPL=SPL\0" \
201 "tftp_sf_uboot=" \
202 "if tftp ${loadaddr} ${ubootfile}; then " \
203 "sf probe;" \
204 "sf erase u-boot +${filesize};" \
205 "sf write ${loadaddr} u-boot ${filesize}" \
206 "; fi\0" \
207 "tftp_sf_SPL=" \
208 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
209 "sf probe;" \
210 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
211 "sf erase 0x0 +${uboot_SPL_size};" \
212 "sf write ${loadaddr} 0x400 ${filesize};" \
213 "fi\0" \
214
Lukasz Majewski2f4372a2018-05-11 16:51:02 +0200215#define TFTP_UPDATE_SPINOR \
216 "spinorfile=core-image-lwn-display5.spinor\0" \
217 "spinorsize=0x2000000\0" \
218 "tftp_sf_img=" \
219 "if tftp ${loadaddr} ${spinorfile}; then " \
220 "sf probe;" \
221 "sf erase 0x0 ${spinorsize};" \
222 "sf write ${loadaddr} 0x0 ${filesize};" \
223 "fi\0" \
224
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100225#define CONFIG_EXTRA_ENV_SETTINGS \
226 PARTS_DEFAULT \
Lukasz Majewski27aede22018-05-11 16:51:08 +0200227 "gpio_recovery=93\0" \
228 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100229 "display=tianma-tm070-800x480\0" \
230 "board=display5\0" \
231 "mmcdev=0\0" \
232 "altbootcmd=run recovery\0" \
233 "bootdelay=1\0" \
234 "baudrate=115200\0" \
235 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100236 "ethact=FEC\0" \
237 "netdev=eth0\0" \
238 "boot_os=y\0" \
239 "hostname=display5\0" \
240 "loadaddr=0x12000000\0" \
241 "fdtaddr=0x12800000\0" \
Lukasz Majewski5d925402018-05-11 16:51:15 +0200242 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100243 "fdtfile=imx6q-display5.dtb\0" \
244 "fdt_high=0xffffffff\0" \
245 "initrd_high=0xffffffff\0" \
246 "kernel_file=fitImage\0" \
Lukasz Majewskif008e262018-08-18 22:22:07 +0200247 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100248 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
249 "download_kernel=" \
250 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200251 "factory_nfs=" \
Lukasz Majewski4864ba72018-05-11 16:51:00 +0200252 "setenv ipaddr 192.168.1.102;" \
253 "setenv gatewayip 192.168.1.1;" \
254 "setenv netmask 255.255.255.0;" \
255 "setenv serverip 192.168.1.2;" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200256 "echo BOOT: FACTORY (LEG);" \
257 "run boot_nfs\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100258 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
259 "recovery=" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100260 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib78e9c42018-05-11 16:51:05 +0200261 "run boot_swu_recovery\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100262 "boot_tftp=" \
263 "if run download_kernel; then " \
264 "setenv bootargs console=${console} " \
265 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200266 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100267 "fi\0" \
268 "addip=setenv bootargs ${bootargs} " \
269 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
270 "${hostname}:eth0:on" \
271 "\0" \
272 "nfsargs=setenv bootargs " \
273 "root=/dev/nfs rw " \
274 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
275 "\0" \
276 "rootpath=/srv/tftp/DISP5/rootfs\0" \
277 "boot_nfs=" \
278 "if run download_kernel; then " \
279 "run nfsargs;" \
280 "run addip;" \
281 "setenv bootargs ${bootargs} console=${console};" \
282 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200283 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100284 "fi\0" \
285 "falcon_setup=" \
286 "if mmc dev ${mmcdev}; then " \
287 SETUP_BOOTARGS \
288 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
289 "setexpr fw_sz ${fdtargslen} / 0x200; " \
290 "setexpr fw_sz ${fw_sz} + 1; " \
291 "mmc write ${fdtargsaddr} " \
292 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
293 "fi\0" \
294 "boot_mmc=" \
295 "if mmc dev ${mmcdev}; then " \
296 SETUP_BOOTARGS \
Lukasz Majewski1bcbf482018-05-11 16:51:04 +0200297 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100298 "fi\0" \
299 "set_kernel_part=" \
300 "if test ${BOOT_FROM} = ACTIVE; then " \
301 "setenv kernel_part ${kernel_part_active};" \
302 "echo BOOT: ACTIVE;" \
303 "else if test ${BOOT_FROM} = BACKUP; then " \
304 "setenv kernel_part ${kernel_part_backup};" \
305 "echo BOOT: BACKUP;" \
306 "else " \
307 "run recovery;" \
308 "fi;fi\0" \
309 "set_rootfs_part=" \
310 "if test ${BOOT_FROM} = ACTIVE; then " \
311 "setenv rootfs_part ${rootfs_part_active};" \
312 "else if test ${BOOT_FROM} = BACKUP; then " \
313 "setenv rootfs_part ${rootfs_part_backup};" \
314 "else " \
315 "run recovery;" \
316 "fi;fi\0" \
317 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100318 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewski2f4372a2018-05-11 16:51:02 +0200319 TFTP_UPDATE_SPINOR \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100320 "kernel_part_active=1\0" \
321 "kernel_part_backup=3\0" \
322 __TFTP_UPDATE_KERNEL \
323 "rootfs_part_active=2\0" \
324 "rootfs_part_backup=4\0" \
325 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewskidd4ed882018-05-11 16:51:10 +0200326 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100327 __TFTP_UPDATE_ROOTFS \
Lukasz Majewskidd4ed882018-05-11 16:51:10 +0200328 "tftp_mmc_rootfs_bkp=" \
329 "setenv rootfs_part ${rootfs_part_backup};" \
330 "setenv rootfs_file ${rootfs_file_backup};" \
331 "run tftp_mmc_rootfs\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100332 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
333 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
334 "\0" \
335
336/* Miscellaneous configurable options */
337#undef CONFIG_SYS_CBSIZE
338#define CONFIG_SYS_CBSIZE 2048
339
340/* Print Buffer Size */
341#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
342 sizeof(CONFIG_SYS_PROMPT) + 16)
343#define CONFIG_SYS_MAXARGS 32
344#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
345
346#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
347#define CONFIG_SYS_HZ 1000
348
349/* Physical Memory Map */
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100350#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
351#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
352
353#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
354#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
355
356#define CONFIG_SYS_INIT_SP_OFFSET \
357 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
358#define CONFIG_SYS_INIT_SP_ADDR \
359 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
360
361/* Commands */
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100362
Lukasz Majewski76d1d162018-05-11 16:51:09 +0200363/* Watchdog */
Lukasz Majewski76d1d162018-05-11 16:51:09 +0200364#define CONFIG_WATCHDOG_TIMEOUT_MSECS 15000
365
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100366/* ENV config */
367#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
368#define CONFIG_ENV_SIZE (SZ_64K)
369/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
370#define CONFIG_ENV_OFFSET (0x120000)
371#define CONFIG_ENV_SECT_SIZE (SZ_64K)
372#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
373#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
374 CONFIG_ENV_SECT_SIZE)
375#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100376#endif
377
378#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
379#endif /* __CONFIG_H */