blob: bcb1ac2bd003e032c879a5a2ec757ed86cb00bc9 [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)
36 */
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 Majewskia3eec242017-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 Majewskia3eec242017-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 Majewskia3eec242017-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 Majewski13e012f2018-05-11 16:50:59 +0200103#define CONFIG_BOOTCOMMAND "if test ${BOOT_FROM} = FACTORY; then " \
104 "run factory_nfs;" \
105 "else " \
106 "run boot_mmc;" \
107 "fi"
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100108#endif
109
110#define PARTS_DEFAULT \
111 /* Linux partitions */ \
112 "partitions=" \
113 "uuid_disk=${uuid_gpt_disk};" \
114 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
115 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
116 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
117 "name=rootfs2,size=1528M,uuid=${uuid_gpt_rootfs2};" \
118 "name=data,size=-,uuid=${uuid_gpt_data}\0"
119
120#define FACTORY_PROCEDURE \
121 "echo '#######################';" \
122 "echo '# Factory Boot #';" \
123 "echo '#######################';" \
124 "env default -a;" \
125 "saveenv;" \
126 "gpt write mmc ${mmcdev} ${partitions};" \
127 "run tftp_sf_SPL;" \
128 "run tftp_sf_uboot;" \
129 TFTP_UPDATE_KERNEL \
130 "run tftp_sf_fitImg_recovery;" \
131 "run tftp_sf_fitImg_SWU;" \
132 "run tftp_sf_initramfs_SWU;" \
133 TFTP_UPDATE_ROOTFS \
134 "echo '#######################';" \
135 "echo '# END - OK #';" \
136 "echo '#######################';" \
137 "setenv bootcmd 'env default -a; saveenv; run falcon_setup; reset';" \
138 "setenv boot_os 'n';" \
139 "saveenv;" \
140 "reset;"
141
142#define SWUPDATE_RECOVERY_PROCEDURE \
143 "echo '#######################';" \
144 "echo '# RECOVERY SWUupdate #';" \
145 "echo '#######################';" \
146 "setenv loadaddr_swu_initramfs 0x14000000;" \
147 "setenv bootargs console=${console} " \
148 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
149 ":${hostname}::off root=/dev/ram rw;" \
150 "sf probe;" \
151 "sf read ${loadaddr} swu-kernel;" \
152 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
153 "bootm ${loadaddr} ${loadaddr_swu_initramfs};"
154
155#define KERNEL_RECOVERY_PROCEDURE \
156 "echo '#######################';" \
157 "echo '# RECOVERY KERNEL IMG #';" \
158 "echo '#######################';" \
159 "sf probe;" \
160 "sf read ${loadaddr} lin-recovery;" \
161 "bootm;"
162
163#define SETUP_BOOTARGS \
164 "run set_rootfs_part;" \
165 "setenv bootargs ${bootargs} console=${console} " \
166 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
167 "rootwait rootfstype=ext4 rw; " \
168 "run set_kernel_part;" \
169 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
170 "mmc read ${loadaddr} ${lba_start} 0x2000; " \
171 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
172
173/* All the numbers are in LBAs */
174#define __TFTP_UPDATE_KERNEL \
175 "tftp_mmc_fitImg=" \
176 "if test ! -n ${kernel_part}; then " \
177 "setenv kernel_part ${kernel_part_active};" \
178 "fi;" \
179 "if tftp ${loadaddr} ${kernel_file}; then " \
180 "setexpr fw_sz ${filesize} / 0x200; " \
181 "setexpr fw_sz ${fw_sz} + 1; " \
182 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
183 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
184 "; fi\0" \
185
186#define TFTP_UPDATE_KERNEL \
187 "setenv kernel_part ${kernel_part_active};" \
188 "run tftp_mmc_fitImg;" \
189 "setenv kernel_part ${kernel_part_backup};" \
190 "run tftp_mmc_fitImg;" \
191
192#define __TFTP_UPDATE_ROOTFS \
193 "tftp_mmc_rootfs=" \
194 "if test ! -n ${rootfs_part}; then " \
195 "setenv rootfs_part ${rootfs_part_active};" \
196 "fi;" \
197 "if tftp ${loadaddr} ${rootfs_file}; then " \
198 "setexpr fw_sz ${filesize} / 0x200; " \
199 "setexpr fw_sz ${fw_sz} + 1; " \
200 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
201 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
202 "; fi\0" \
203
204/* To save some considerable time, we only once download the rootfs image */
205/* and store it on 'active' and 'backup' rootfs partitions */
206#define TFTP_UPDATE_ROOTFS \
207 "setenv rootfs_part ${rootfs_part_active};" \
208 "run tftp_mmc_rootfs;" \
209 "part start mmc ${mmcdev} ${rootfs_part_backup} lba_start;" \
210 "mmc write ${loadaddr} ${lba_start} ${fw_sz};" \
211
212#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
213 "tftp_sf_fitImg_SWU=" \
214 "if tftp ${loadaddr} ${kernel_file}; then " \
215 "sf probe;" \
216 "sf erase swu-kernel +${filesize};" \
217 "sf write ${loadaddr} swu-kernel ${filesize};" \
218 "; fi\0" \
219
220#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
221 "swu_initramfs_file=swupdate-image-display5.ext3.gz.u-boot\0" \
222 "tftp_sf_initramfs_SWU=" \
223 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
224 "sf probe;" \
225 "sf erase swu-initramfs +${filesize};" \
226 "sf write ${loadaddr} swu-initramfs ${filesize};" \
227 "; fi\0" \
228
229#define TFTP_UPDATE_RECOVERY_KERNEL_INITRAMFS \
230 "kernel_recovery_file=fitImage-initramfs\0" \
231 "tftp_sf_fitImg_recovery=" \
232 "if tftp ${loadaddr} ${kernel_recovery_file}; then " \
233 "sf probe;" \
234 "sf erase lin-recovery +${filesize};" \
235 "sf write ${loadaddr} lin-recovery ${filesize};" \
236 "; fi\0" \
237
238#define TFTP_UPDATE_BOOTLOADER \
239 "ubootfile=u-boot.img\0" \
240 "ubootfileSPL=SPL\0" \
241 "tftp_sf_uboot=" \
242 "if tftp ${loadaddr} ${ubootfile}; then " \
243 "sf probe;" \
244 "sf erase u-boot +${filesize};" \
245 "sf write ${loadaddr} u-boot ${filesize}" \
246 "; fi\0" \
247 "tftp_sf_SPL=" \
248 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
249 "sf probe;" \
250 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
251 "sf erase 0x0 +${uboot_SPL_size};" \
252 "sf write ${loadaddr} 0x400 ${filesize};" \
253 "fi\0" \
254
255#define CONFIG_EXTRA_ENV_SETTINGS \
256 PARTS_DEFAULT \
257 "display=tianma-tm070-800x480\0" \
258 "board=display5\0" \
259 "mmcdev=0\0" \
260 "altbootcmd=run recovery\0" \
261 "bootdelay=1\0" \
262 "baudrate=115200\0" \
263 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \
264 "factory=" FACTORY_PROCEDURE "\0" \
265 "bootlimit=3\0" \
266 "ethact=FEC\0" \
267 "netdev=eth0\0" \
268 "boot_os=y\0" \
269 "hostname=display5\0" \
270 "loadaddr=0x12000000\0" \
271 "fdtaddr=0x12800000\0" \
272 "console=ttymxc4,115200 quiet\0" \
273 "fdtfile=imx6q-display5.dtb\0" \
274 "fdt_high=0xffffffff\0" \
275 "initrd_high=0xffffffff\0" \
276 "kernel_file=fitImage\0" \
277 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
278 "download_kernel=" \
279 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200280 "factory_nfs=" \
Lukasz Majewski4864ba72018-05-11 16:51:00 +0200281 "setenv ipaddr 192.168.1.102;" \
282 "setenv gatewayip 192.168.1.1;" \
283 "setenv netmask 255.255.255.0;" \
284 "setenv serverip 192.168.1.2;" \
Lukasz Majewski13e012f2018-05-11 16:50:59 +0200285 "echo BOOT: FACTORY (LEG);" \
286 "run boot_nfs\0" \
Lukasz Majewskia3eec242017-10-31 17:58:05 +0100287 "boot_kernel_recovery=" KERNEL_RECOVERY_PROCEDURE "\0" \
288 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
289 "recovery=" \
290 "if test ${BOOT_FROM_RECOVERY} = SWU; then " \
291 "echo BOOT: RECOVERY: SWU;" \
292 "run boot_swu_recovery;" \
293 "else " \
294 "echo BOOT: RECOVERY: Linux;" \
295 "run boot_kernel_recovery;" \
296 "fi\0" \
297 "boot_tftp=" \
298 "if run download_kernel; then " \
299 "setenv bootargs console=${console} " \
300 "root=/dev/mmcblk0p2 rootwait;" \
301 "bootm ${loadaddr} - ${fdtaddr};" \
302 "fi\0" \
303 "addip=setenv bootargs ${bootargs} " \
304 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
305 "${hostname}:eth0:on" \
306 "\0" \
307 "nfsargs=setenv bootargs " \
308 "root=/dev/nfs rw " \
309 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
310 "\0" \
311 "rootpath=/srv/tftp/DISP5/rootfs\0" \
312 "boot_nfs=" \
313 "if run download_kernel; then " \
314 "run nfsargs;" \
315 "run addip;" \
316 "setenv bootargs ${bootargs} console=${console};" \
317 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
318 "bootm ${loadaddr}#conf@${fdt_conf};" \
319 "fi\0" \
320 "falcon_setup=" \
321 "if mmc dev ${mmcdev}; then " \
322 SETUP_BOOTARGS \
323 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
324 "setexpr fw_sz ${fdtargslen} / 0x200; " \
325 "setexpr fw_sz ${fw_sz} + 1; " \
326 "mmc write ${fdtargsaddr} " \
327 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
328 "fi\0" \
329 "boot_mmc=" \
330 "if mmc dev ${mmcdev}; then " \
331 SETUP_BOOTARGS \
332 "bootm ${loadaddr}#conf@${fdt_conf};" \
333 "fi\0" \
334 "set_kernel_part=" \
335 "if test ${BOOT_FROM} = ACTIVE; then " \
336 "setenv kernel_part ${kernel_part_active};" \
337 "echo BOOT: ACTIVE;" \
338 "else if test ${BOOT_FROM} = BACKUP; then " \
339 "setenv kernel_part ${kernel_part_backup};" \
340 "echo BOOT: BACKUP;" \
341 "else " \
342 "run recovery;" \
343 "fi;fi\0" \
344 "set_rootfs_part=" \
345 "if test ${BOOT_FROM} = ACTIVE; then " \
346 "setenv rootfs_part ${rootfs_part_active};" \
347 "else if test ${BOOT_FROM} = BACKUP; then " \
348 "setenv rootfs_part ${rootfs_part_backup};" \
349 "else " \
350 "run recovery;" \
351 "fi;fi\0" \
352 "BOOT_FROM=ACTIVE\0" \
353 "BOOT_FROM_RECOVERY=Linux\0" \
354 TFTP_UPDATE_BOOTLOADER \
355 "kernel_part_active=1\0" \
356 "kernel_part_backup=3\0" \
357 __TFTP_UPDATE_KERNEL \
358 "rootfs_part_active=2\0" \
359 "rootfs_part_backup=4\0" \
360 "rootfs_file=core-image-lwn-display5.ext4\0" \
361 __TFTP_UPDATE_ROOTFS \
362 TFTP_UPDATE_RECOVERY_KERNEL_INITRAMFS \
363 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
364 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
365 "\0" \
366
367/* Miscellaneous configurable options */
368#undef CONFIG_SYS_CBSIZE
369#define CONFIG_SYS_CBSIZE 2048
370
371/* Print Buffer Size */
372#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
373 sizeof(CONFIG_SYS_PROMPT) + 16)
374#define CONFIG_SYS_MAXARGS 32
375#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
376
377#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
378#define CONFIG_SYS_HZ 1000
379
380/* Physical Memory Map */
381#define CONFIG_NR_DRAM_BANKS 1
382#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
383#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
384
385#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
386#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
387
388#define CONFIG_SYS_INIT_SP_OFFSET \
389 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
390#define CONFIG_SYS_INIT_SP_ADDR \
391 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
392
393/* Commands */
394#define CONFIG_MTD_PARTITIONS
395#define CONFIG_MTD_DEVICE
396
397/* ENV config */
398#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
399#define CONFIG_ENV_SIZE (SZ_64K)
400/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
401#define CONFIG_ENV_OFFSET (0x120000)
402#define CONFIG_ENV_SECT_SIZE (SZ_64K)
403#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
404#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \
405 CONFIG_ENV_SECT_SIZE)
406#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
407
408#define CONFIG_ENV_SPI_BUS CONFIG_SF_DEFAULT_BUS
409#define CONFIG_ENV_SPI_CS CONFIG_SF_DEFAULT_CS
410#define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE
411#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
412#endif
413
414#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
415#endif /* __CONFIG_H */