blob: 3cb6365367ee4a42a1495794f4e09bf05c96b9bc [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)
33 * 0x140000 - 0x940000 : SPI.fitImage-recovery (8MiB)
34 * 0x940000 - 0xD40000 : SPI.swupdate-kernel-FIT (4MiB)
35 * 0xD40000 - 0x1540000 : SPI.swupdate-initramfs (8MiB)
Lukasz Majewski86d759e2018-05-11 16:51:01 +020036 * 0x1540000 - 0x1640000 : SPI.factory (1MiB)
Lukasz Majewskia3eec242017-10-31 17:58:05 +010037 */
38
39#ifndef CONFIG_SPL_BUILD
40#define CONFIG_MTD_DEVICE
41#define CONFIG_SPI_FLASH_MTD
42#define CONFIG_MTD_PARTITIONS
43#endif
44
45/* Below values are "dummy" - only to avoid build break */
46#define CONFIG_SYS_SPI_KERNEL_OFFS 0x150000
47#define CONFIG_SYS_SPI_ARGS_OFFS 0x140000
48#define CONFIG_SYS_SPI_ARGS_SIZE 0x10000
49
50#include "imx6_spl.h"
51#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000
Lukasz Majewskia3eec242017-10-31 17:58:05 +010052
53#define CONFIG_CMDLINE_TAG
54#define CONFIG_SETUP_MEMORY_TAGS
55#define CONFIG_INITRD_TAG
56#define CONFIG_REVISION_TAG
57
58/* Size of malloc() pool */
59#define CONFIG_SYS_MALLOC_LEN (16 * 1024 * 1024)
60#define CONFIG_MISC_INIT_R
61
62/*#define CONFIG_MXC_UART*/
63#define CONFIG_MXC_UART_BASE UART5_BASE
64
65/* SPI NOR Flash */
66#ifdef CONFIG_CMD_SF
Lukasz Majewskia3eec242017-10-31 17:58:05 +010067#define CONFIG_SF_DEFAULT_BUS 1
68#define CONFIG_SF_DEFAULT_CS (0 | (IMX_GPIO_NR(5, 29) << 8))
69#define CONFIG_SF_DEFAULT_SPEED 50000000
70#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
71#endif
72
73/* I2C Configs */
74#define CONFIG_SYS_I2C
75#define CONFIG_SYS_I2C_MXC
76#define CONFIG_SYS_I2C_MXC_I2C1
77#define CONFIG_SYS_I2C_MXC_I2C2
78#define CONFIG_SYS_I2C_MXC_I2C3
79#define CONFIG_I2C_MULTI_BUS
80#define CONFIG_SYS_I2C_SPEED 100000
81#define CONFIG_I2C_EDID
82#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
83
84/* Ethernet */
85#ifdef CONFIG_FEC_MXC
86#define IMX_FEC_BASE ENET_BASE_ADDR
87#define CONFIG_FEC_XCV_TYPE RGMII
88#define CONFIG_ETHPRIME "FEC"
89#define CONFIG_FEC_MXC_PHYADDR 0
90#define CONFIG_MII
91#endif
92
93/* MMC Configs */
Lukasz Majewskia3eec242017-10-31 17:58:05 +010094#define CONFIG_FSL_USDHC
95#define CONFIG_SYS_FSL_ESDHC_ADDR 0
96#define CONFIG_SYS_FSL_USDHC_NUM 2
97#define CONFIG_SUPPORT_EMMC_BOOT
98
99/* allow to overwrite serial and ethaddr */
100#define CONFIG_ENV_OVERWRITE
101#define CONFIG_BAUDRATE 115200
102
103#ifndef CONFIG_BOOTCOMMAND
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200104#define CONFIG_BOOTCOMMAND "if test ${BOOT_FROM} = FACTORY; then " \
105 "run factory_nfs;" \
106 "else " \
107 "run boot_mmc;" \
108 "fi"
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100109#endif
110
111#define PARTS_DEFAULT \
112 /* Linux partitions */ \
113 "partitions=" \
114 "uuid_disk=${uuid_gpt_disk};" \
115 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
116 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
117 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
118 "name=rootfs2,size=1528M,uuid=${uuid_gpt_rootfs2};" \
119 "name=data,size=-,uuid=${uuid_gpt_data}\0"
120
121#define FACTORY_PROCEDURE \
122 "echo '#######################';" \
123 "echo '# Factory Boot #';" \
124 "echo '#######################';" \
125 "env default -a;" \
126 "saveenv;" \
127 "gpt write mmc ${mmcdev} ${partitions};" \
128 "run tftp_sf_SPL;" \
129 "run tftp_sf_uboot;" \
130 TFTP_UPDATE_KERNEL \
131 "run tftp_sf_fitImg_recovery;" \
132 "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;" \
154 "bootm ${loadaddr} ${loadaddr_swu_initramfs};"
155
156#define KERNEL_RECOVERY_PROCEDURE \
157 "echo '#######################';" \
158 "echo '# RECOVERY KERNEL IMG #';" \
159 "echo '#######################';" \
160 "sf probe;" \
161 "sf read ${loadaddr} lin-recovery;" \
162 "bootm;"
163
164#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
205/* To save some considerable time, we only once download the rootfs image */
206/* and store it on 'active' and 'backup' rootfs partitions */
207#define TFTP_UPDATE_ROOTFS \
208 "setenv rootfs_part ${rootfs_part_active};" \
209 "run tftp_mmc_rootfs;" \
210 "part start mmc ${mmcdev} ${rootfs_part_backup} lba_start;" \
211 "mmc write ${loadaddr} ${lba_start} ${fw_sz};" \
212
213#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
214 "tftp_sf_fitImg_SWU=" \
215 "if tftp ${loadaddr} ${kernel_file}; then " \
216 "sf probe;" \
217 "sf erase swu-kernel +${filesize};" \
218 "sf write ${loadaddr} swu-kernel ${filesize};" \
219 "; fi\0" \
220
221#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
222 "swu_initramfs_file=swupdate-image-display5.ext3.gz.u-boot\0" \
223 "tftp_sf_initramfs_SWU=" \
224 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
225 "sf probe;" \
226 "sf erase swu-initramfs +${filesize};" \
227 "sf write ${loadaddr} swu-initramfs ${filesize};" \
228 "; fi\0" \
229
230#define TFTP_UPDATE_RECOVERY_KERNEL_INITRAMFS \
231 "kernel_recovery_file=fitImage-initramfs\0" \
232 "tftp_sf_fitImg_recovery=" \
233 "if tftp ${loadaddr} ${kernel_recovery_file}; then " \
234 "sf probe;" \
235 "sf erase lin-recovery +${filesize};" \
236 "sf write ${loadaddr} lin-recovery ${filesize};" \
237 "; fi\0" \
238
239#define TFTP_UPDATE_BOOTLOADER \
240 "ubootfile=u-boot.img\0" \
241 "ubootfileSPL=SPL\0" \
242 "tftp_sf_uboot=" \
243 "if tftp ${loadaddr} ${ubootfile}; then " \
244 "sf probe;" \
245 "sf erase u-boot +${filesize};" \
246 "sf write ${loadaddr} u-boot ${filesize}" \
247 "; fi\0" \
248 "tftp_sf_SPL=" \
249 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
250 "sf probe;" \
251 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
252 "sf erase 0x0 +${uboot_SPL_size};" \
253 "sf write ${loadaddr} 0x400 ${filesize};" \
254 "fi\0" \
255
Lukasz Majewski2f4372a2018-05-11 16:51:02 +0200256#define TFTP_UPDATE_SPINOR \
257 "spinorfile=core-image-lwn-display5.spinor\0" \
258 "spinorsize=0x2000000\0" \
259 "tftp_sf_img=" \
260 "if tftp ${loadaddr} ${spinorfile}; then " \
261 "sf probe;" \
262 "sf erase 0x0 ${spinorsize};" \
263 "sf write ${loadaddr} 0x0 ${filesize};" \
264 "fi\0" \
265
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100266#define CONFIG_EXTRA_ENV_SETTINGS \
267 PARTS_DEFAULT \
268 "display=tianma-tm070-800x480\0" \
269 "board=display5\0" \
270 "mmcdev=0\0" \
271 "altbootcmd=run recovery\0" \
272 "bootdelay=1\0" \
273 "baudrate=115200\0" \
274 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
275 "factory=" FACTORY_PROCEDURE "\0" \
276 "bootlimit=3\0" \
277 "ethact=FEC\0" \
278 "netdev=eth0\0" \
279 "boot_os=y\0" \
280 "hostname=display5\0" \
281 "loadaddr=0x12000000\0" \
282 "fdtaddr=0x12800000\0" \
283 "console=ttymxc4,115200 quiet\0" \
284 "fdtfile=imx6q-display5.dtb\0" \
285 "fdt_high=0xffffffff\0" \
286 "initrd_high=0xffffffff\0" \
287 "kernel_file=fitImage\0" \
288 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
289 "download_kernel=" \
290 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200291 "factory_nfs=" \
Lukasz Majewski4864ba72018-05-11 16:51:00 +0200292 "setenv ipaddr 192.168.1.102;" \
293 "setenv gatewayip 192.168.1.1;" \
294 "setenv netmask 255.255.255.0;" \
295 "setenv serverip 192.168.1.2;" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200296 "echo BOOT: FACTORY (LEG);" \
297 "run boot_nfs\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100298 "boot_kernel_recovery=" KERNEL_RECOVERY_PROCEDURE "\0" \
299 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
300 "recovery=" \
301 "if test ${BOOT_FROM_RECOVERY} = SWU; then " \
302 "echo BOOT: RECOVERY: SWU;" \
303 "run boot_swu_recovery;" \
304 "else " \
305 "echo BOOT: RECOVERY: Linux;" \
306 "run boot_kernel_recovery;" \
307 "fi\0" \
308 "boot_tftp=" \
309 "if run download_kernel; then " \
310 "setenv bootargs console=${console} " \
311 "root=/dev/mmcblk0p2 rootwait;" \
312 "bootm ${loadaddr} - ${fdtaddr};" \
313 "fi\0" \
314 "addip=setenv bootargs ${bootargs} " \
315 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
316 "${hostname}:eth0:on" \
317 "\0" \
318 "nfsargs=setenv bootargs " \
319 "root=/dev/nfs rw " \
320 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
321 "\0" \
322 "rootpath=/srv/tftp/DISP5/rootfs\0" \
323 "boot_nfs=" \
324 "if run download_kernel; then " \
325 "run nfsargs;" \
326 "run addip;" \
327 "setenv bootargs ${bootargs} console=${console};" \
328 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
329 "bootm ${loadaddr}#conf@${fdt_conf};" \
330 "fi\0" \
331 "falcon_setup=" \
332 "if mmc dev ${mmcdev}; then " \
333 SETUP_BOOTARGS \
334 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
335 "setexpr fw_sz ${fdtargslen} / 0x200; " \
336 "setexpr fw_sz ${fw_sz} + 1; " \
337 "mmc write ${fdtargsaddr} " \
338 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
339 "fi\0" \
340 "boot_mmc=" \
341 "if mmc dev ${mmcdev}; then " \
342 SETUP_BOOTARGS \
343 "bootm ${loadaddr}#conf@${fdt_conf};" \
344 "fi\0" \
345 "set_kernel_part=" \
346 "if test ${BOOT_FROM} = ACTIVE; then " \
347 "setenv kernel_part ${kernel_part_active};" \
348 "echo BOOT: ACTIVE;" \
349 "else if test ${BOOT_FROM} = BACKUP; then " \
350 "setenv kernel_part ${kernel_part_backup};" \
351 "echo BOOT: BACKUP;" \
352 "else " \
353 "run recovery;" \
354 "fi;fi\0" \
355 "set_rootfs_part=" \
356 "if test ${BOOT_FROM} = ACTIVE; then " \
357 "setenv rootfs_part ${rootfs_part_active};" \
358 "else if test ${BOOT_FROM} = BACKUP; then " \
359 "setenv rootfs_part ${rootfs_part_backup};" \
360 "else " \
361 "run recovery;" \
362 "fi;fi\0" \
363 "BOOT_FROM=ACTIVE\0" \
364 "BOOT_FROM_RECOVERY=Linux\0" \
365 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewski2f4372a2018-05-11 16:51:02 +0200366 TFTP_UPDATE_SPINOR \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100367 "kernel_part_active=1\0" \
368 "kernel_part_backup=3\0" \
369 __TFTP_UPDATE_KERNEL \
370 "rootfs_part_active=2\0" \
371 "rootfs_part_backup=4\0" \
372 "rootfs_file=core-image-lwn-display5.ext4\0" \
373 __TFTP_UPDATE_ROOTFS \
374 TFTP_UPDATE_RECOVERY_KERNEL_INITRAMFS \
375 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
376 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
377 "\0" \
378
379/* Miscellaneous configurable options */
380#undef CONFIG_SYS_CBSIZE
381#define CONFIG_SYS_CBSIZE 2048
382
383/* Print Buffer Size */
384#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
385 sizeof(CONFIG_SYS_PROMPT) + 16)
386#define CONFIG_SYS_MAXARGS 32
387#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
388
389#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
390#define CONFIG_SYS_HZ 1000
391
392/* Physical Memory Map */
393#define CONFIG_NR_DRAM_BANKS 1
394#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
395#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
396
397#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
398#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
399
400#define CONFIG_SYS_INIT_SP_OFFSET \
401 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
402#define CONFIG_SYS_INIT_SP_ADDR \
403 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
404
405/* Commands */
406#define CONFIG_MTD_PARTITIONS
407#define CONFIG_MTD_DEVICE
408
409/* ENV config */
410#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
411#define CONFIG_ENV_SIZE (SZ_64K)
412/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
413#define CONFIG_ENV_OFFSET (0x120000)
414#define CONFIG_ENV_SECT_SIZE (SZ_64K)
415#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
416#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
417 CONFIG_ENV_SECT_SIZE)
418#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
419
420#define CONFIG_ENV_SPI_BUS CONFIG_SF_DEFAULT_BUS
421#define CONFIG_ENV_SPI_CS CONFIG_SF_DEFAULT_CS
422#define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE
423#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
424#endif
425
426#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
427#endif /* __CONFIG_H */