blob: 7bd653364d3365c171bfa78ea3702f33d5118d70 [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 */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010013#define CONFIG_SYS_SPL_ARGS_ADDR 0x18000000
Lukasz Majewskice86bf92017-10-31 17:58:05 +010014
15/* Falcon Mode - MMC support */
16#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR 0x3F00
17#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS \
18 (CONFIG_CMD_SPL_WRITE_SIZE / 512)
Lukasz Majewskice86bf92017-10-31 17:58:05 +010019
20/*
21 * display5 SPI-NOR memory layout
22 *
23 * The definition can be found in Kconfig's
24 * CONFIG_MTDIDS_DEFAULT and CONFIG_MTDPARTS_DEFAULT
25 *
26 * 0x000000 - 0x020000 : SPI.SPL (128KiB)
27 * 0x020000 - 0x120000 : SPI.u-boot (1MiB)
28 * 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB)
29 * 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB)
Lukasz Majewskia3d18cd2020-05-13 17:45:15 +020030 * 0x140000 - 0x740000 : SPI.swupdate-kernel-FIT (6MiB)
31 * 0x740000 - 0x1B40000 : SPI.swupdate-initramfs (20MiB)
32 * 0x1B40000 - 0x1F00000 : SPI.reserved (3840KiB)
33 * 0x1F00000 - 0x2000000 : SPI.factory (1MiB)
Lukasz Majewskice86bf92017-10-31 17:58:05 +010034 */
35
Lukasz Majewskice86bf92017-10-31 17:58:05 +010036/* Below values are "dummy" - only to avoid build break */
37#define CONFIG_SYS_SPI_KERNEL_OFFS 0x150000
38#define CONFIG_SYS_SPI_ARGS_OFFS 0x140000
39#define CONFIG_SYS_SPI_ARGS_SIZE 0x10000
40
41#include "imx6_spl.h"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010042
Lukasz Majewskice86bf92017-10-31 17:58:05 +010043#define CONFIG_MXC_UART_BASE UART5_BASE
44
Lukasz Majewskice86bf92017-10-31 17:58:05 +010045/* I2C Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010046#define CONFIG_I2C_MULTI_BUS
Lukasz Majewskice86bf92017-10-31 17:58:05 +010047
48/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010049#define CONFIG_SYS_FSL_ESDHC_ADDR 0
50#define CONFIG_SYS_FSL_USDHC_NUM 2
Lukasz Majewskice86bf92017-10-31 17:58:05 +010051
Lukasz Majewskice86bf92017-10-31 17:58:05 +010052#define PARTS_DEFAULT \
53 /* Linux partitions */ \
54 "partitions=" \
55 "uuid_disk=${uuid_gpt_disk};" \
56 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
57 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
58 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski6d46ce02018-05-11 16:51:16 +020059 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010060 "name=data,size=-,uuid=${uuid_gpt_data}\0"
61
Lukasz Majewskice86bf92017-10-31 17:58:05 +010062#define SWUPDATE_RECOVERY_PROCEDURE \
63 "echo '#######################';" \
64 "echo '# RECOVERY SWUupdate #';" \
65 "echo '#######################';" \
Lukasz Majewskiac6fb1e2018-05-11 16:51:18 +020066 "echo '#######################';" \
67 "echo '# GPT verify #';" \
68 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
69 "echo '# OK ! #';" \
70 "else " \
71 "echo '# FAILED ! #';" \
72 "echo '# GPT RESTORATION #';" \
73 "gpt write mmc ${mmcdev} ${partitions};" \
74 "fi;" \
75 "echo '#######################';" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010076 "setenv loadaddr_swu_initramfs 0x14000000;" \
77 "setenv bootargs console=${console} " \
78 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
79 ":${hostname}::off root=/dev/ram rw;" \
80 "sf probe;" \
81 "sf read ${loadaddr} swu-kernel;" \
82 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +020083 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010084
Lukasz Majewskice86bf92017-10-31 17:58:05 +010085#define SETUP_BOOTARGS \
86 "run set_rootfs_part;" \
87 "setenv bootargs ${bootargs} console=${console} " \
88 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
89 "rootwait rootfstype=ext4 rw; " \
90 "run set_kernel_part;" \
91 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +020092 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010093 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
94
95/* All the numbers are in LBAs */
96#define __TFTP_UPDATE_KERNEL \
97 "tftp_mmc_fitImg=" \
98 "if test ! -n ${kernel_part}; then " \
99 "setenv kernel_part ${kernel_part_active};" \
100 "fi;" \
101 "if tftp ${loadaddr} ${kernel_file}; then " \
102 "setexpr fw_sz ${filesize} / 0x200; " \
103 "setexpr fw_sz ${fw_sz} + 1; " \
104 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
105 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
106 "; fi\0" \
107
108#define TFTP_UPDATE_KERNEL \
109 "setenv kernel_part ${kernel_part_active};" \
110 "run tftp_mmc_fitImg;" \
111 "setenv kernel_part ${kernel_part_backup};" \
112 "run tftp_mmc_fitImg;" \
113
114#define __TFTP_UPDATE_ROOTFS \
115 "tftp_mmc_rootfs=" \
116 "if test ! -n ${rootfs_part}; then " \
117 "setenv rootfs_part ${rootfs_part_active};" \
118 "fi;" \
119 "if tftp ${loadaddr} ${rootfs_file}; then " \
120 "setexpr fw_sz ${filesize} / 0x200; " \
121 "setexpr fw_sz ${fw_sz} + 1; " \
122 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
123 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
124 "; fi\0" \
125
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100126#define TFTP_UPDATE_ROOTFS \
127 "setenv rootfs_part ${rootfs_part_active};" \
128 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200129 "run tftp_mmc_rootfs_bkp;" \
130
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100131
132#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
133 "tftp_sf_fitImg_SWU=" \
134 "if tftp ${loadaddr} ${kernel_file}; then " \
135 "sf probe;" \
136 "sf erase swu-kernel +${filesize};" \
137 "sf write ${loadaddr} swu-kernel ${filesize};" \
138 "; fi\0" \
139
140#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskia1d657f2018-05-11 16:51:12 +0200141 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100142 "tftp_sf_initramfs_SWU=" \
143 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
144 "sf probe;" \
145 "sf erase swu-initramfs +${filesize};" \
146 "sf write ${loadaddr} swu-initramfs ${filesize};" \
147 "; fi\0" \
148
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100149#define TFTP_UPDATE_BOOTLOADER \
150 "ubootfile=u-boot.img\0" \
151 "ubootfileSPL=SPL\0" \
152 "tftp_sf_uboot=" \
153 "if tftp ${loadaddr} ${ubootfile}; then " \
154 "sf probe;" \
155 "sf erase u-boot +${filesize};" \
156 "sf write ${loadaddr} u-boot ${filesize}" \
157 "; fi\0" \
158 "tftp_sf_SPL=" \
159 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
160 "sf probe;" \
161 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
162 "sf erase 0x0 +${uboot_SPL_size};" \
163 "sf write ${loadaddr} 0x400 ${filesize};" \
164 "fi\0" \
165
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200166#define TFTP_UPDATE_SPINOR \
167 "spinorfile=core-image-lwn-display5.spinor\0" \
168 "spinorsize=0x2000000\0" \
169 "tftp_sf_img=" \
170 "if tftp ${loadaddr} ${spinorfile}; then " \
171 "sf probe;" \
172 "sf erase 0x0 ${spinorsize};" \
173 "sf write ${loadaddr} 0x0 ${filesize};" \
174 "fi\0" \
175
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100176#define CONFIG_EXTRA_ENV_SETTINGS \
177 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200178 "gpio_recovery=93\0" \
179 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100180 "display=tianma-tm070-800x480\0" \
181 "board=display5\0" \
182 "mmcdev=0\0" \
183 "altbootcmd=run recovery\0" \
184 "bootdelay=1\0" \
185 "baudrate=115200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100186 "ethact=FEC\0" \
187 "netdev=eth0\0" \
188 "boot_os=y\0" \
189 "hostname=display5\0" \
190 "loadaddr=0x12000000\0" \
191 "fdtaddr=0x12800000\0" \
Lukasz Majewski248698e2018-05-11 16:51:15 +0200192 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100193 "fdtfile=imx6q-display5.dtb\0" \
194 "fdt_high=0xffffffff\0" \
195 "initrd_high=0xffffffff\0" \
196 "kernel_file=fitImage\0" \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200197 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100198 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
199 "download_kernel=" \
200 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200201 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200202 "setenv ipaddr 192.168.1.102;" \
203 "setenv gatewayip 192.168.1.1;" \
204 "setenv netmask 255.255.255.0;" \
205 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200206 "echo BOOT: FACTORY (LEG);" \
207 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100208 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
209 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100210 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200211 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100212 "boot_tftp=" \
213 "if run download_kernel; then " \
214 "setenv bootargs console=${console} " \
215 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200216 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100217 "fi\0" \
218 "addip=setenv bootargs ${bootargs} " \
219 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
220 "${hostname}:eth0:on" \
221 "\0" \
222 "nfsargs=setenv bootargs " \
223 "root=/dev/nfs rw " \
224 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
225 "\0" \
226 "rootpath=/srv/tftp/DISP5/rootfs\0" \
227 "boot_nfs=" \
228 "if run download_kernel; then " \
229 "run nfsargs;" \
230 "run addip;" \
231 "setenv bootargs ${bootargs} console=${console};" \
232 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200233 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100234 "fi\0" \
235 "falcon_setup=" \
236 "if mmc dev ${mmcdev}; then " \
237 SETUP_BOOTARGS \
238 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
239 "setexpr fw_sz ${fdtargslen} / 0x200; " \
240 "setexpr fw_sz ${fw_sz} + 1; " \
241 "mmc write ${fdtargsaddr} " \
242 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
243 "fi\0" \
244 "boot_mmc=" \
245 "if mmc dev ${mmcdev}; then " \
246 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200247 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100248 "fi\0" \
249 "set_kernel_part=" \
250 "if test ${BOOT_FROM} = ACTIVE; then " \
251 "setenv kernel_part ${kernel_part_active};" \
252 "echo BOOT: ACTIVE;" \
253 "else if test ${BOOT_FROM} = BACKUP; then " \
254 "setenv kernel_part ${kernel_part_backup};" \
255 "echo BOOT: BACKUP;" \
256 "else " \
257 "run recovery;" \
258 "fi;fi\0" \
259 "set_rootfs_part=" \
260 "if test ${BOOT_FROM} = ACTIVE; then " \
261 "setenv rootfs_part ${rootfs_part_active};" \
262 "else if test ${BOOT_FROM} = BACKUP; then " \
263 "setenv rootfs_part ${rootfs_part_backup};" \
264 "else " \
265 "run recovery;" \
266 "fi;fi\0" \
267 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100268 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200269 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100270 "kernel_part_active=1\0" \
271 "kernel_part_backup=3\0" \
272 __TFTP_UPDATE_KERNEL \
273 "rootfs_part_active=2\0" \
274 "rootfs_part_backup=4\0" \
275 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200276 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100277 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200278 "tftp_mmc_rootfs_bkp=" \
279 "setenv rootfs_part ${rootfs_part_backup};" \
280 "setenv rootfs_file ${rootfs_file_backup};" \
281 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100282 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
283 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
284 "\0" \
285
286/* Miscellaneous configurable options */
287#undef CONFIG_SYS_CBSIZE
288#define CONFIG_SYS_CBSIZE 2048
289
290/* Print Buffer Size */
291#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
292 sizeof(CONFIG_SYS_PROMPT) + 16)
293#define CONFIG_SYS_MAXARGS 32
294#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
295
296#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100297
298/* Physical Memory Map */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100299#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
300#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
301
302#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
303#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
304
305#define CONFIG_SYS_INIT_SP_OFFSET \
306 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
307#define CONFIG_SYS_INIT_SP_ADDR \
308 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
309
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100310/* ENV config */
311#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100312/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100313#endif
314
315#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
316#endif /* __CONFIG_H */