blob: 72526d9bb82d9ade38b6d97dc6f8d11874c5b32b [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 Majewski75056052019-09-03 16:38:43 +020036/* SPI Flash Configs */
37#if defined(CONFIG_SPL_BUILD)
38#undef CONFIG_DM_SPI
39#undef CONFIG_DM_SPI_FLASH
Lukasz Majewskice86bf92017-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"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010048
Lukasz Majewskice86bf92017-10-31 17:58:05 +010049#define CONFIG_MXC_UART_BASE UART5_BASE
50
Lukasz Majewskice86bf92017-10-31 17:58:05 +010051/* I2C Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010052#define CONFIG_I2C_MULTI_BUS
Lukasz Majewskice86bf92017-10-31 17:58:05 +010053
54/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010055#define CONFIG_SYS_FSL_ESDHC_ADDR 0
56#define CONFIG_SYS_FSL_USDHC_NUM 2
Lukasz Majewskice86bf92017-10-31 17:58:05 +010057
Lukasz Majewskice86bf92017-10-31 17:58:05 +010058#define PARTS_DEFAULT \
59 /* Linux partitions */ \
60 "partitions=" \
61 "uuid_disk=${uuid_gpt_disk};" \
62 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
63 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
64 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski6d46ce02018-05-11 16:51:16 +020065 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010066 "name=data,size=-,uuid=${uuid_gpt_data}\0"
67
Lukasz Majewskice86bf92017-10-31 17:58:05 +010068#define SWUPDATE_RECOVERY_PROCEDURE \
69 "echo '#######################';" \
70 "echo '# RECOVERY SWUupdate #';" \
71 "echo '#######################';" \
Lukasz Majewskiac6fb1e2018-05-11 16:51:18 +020072 "echo '#######################';" \
73 "echo '# GPT verify #';" \
74 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
75 "echo '# OK ! #';" \
76 "else " \
77 "echo '# FAILED ! #';" \
78 "echo '# GPT RESTORATION #';" \
79 "gpt write mmc ${mmcdev} ${partitions};" \
80 "fi;" \
81 "echo '#######################';" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010082 "setenv loadaddr_swu_initramfs 0x14000000;" \
83 "setenv bootargs console=${console} " \
84 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
85 ":${hostname}::off root=/dev/ram rw;" \
86 "sf probe;" \
87 "sf read ${loadaddr} swu-kernel;" \
88 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +020089 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010090
Lukasz Majewskice86bf92017-10-31 17:58:05 +010091#define SETUP_BOOTARGS \
92 "run set_rootfs_part;" \
93 "setenv bootargs ${bootargs} console=${console} " \
94 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
95 "rootwait rootfstype=ext4 rw; " \
96 "run set_kernel_part;" \
97 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +020098 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010099 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
100
101/* All the numbers are in LBAs */
102#define __TFTP_UPDATE_KERNEL \
103 "tftp_mmc_fitImg=" \
104 "if test ! -n ${kernel_part}; then " \
105 "setenv kernel_part ${kernel_part_active};" \
106 "fi;" \
107 "if tftp ${loadaddr} ${kernel_file}; then " \
108 "setexpr fw_sz ${filesize} / 0x200; " \
109 "setexpr fw_sz ${fw_sz} + 1; " \
110 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
111 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
112 "; fi\0" \
113
114#define TFTP_UPDATE_KERNEL \
115 "setenv kernel_part ${kernel_part_active};" \
116 "run tftp_mmc_fitImg;" \
117 "setenv kernel_part ${kernel_part_backup};" \
118 "run tftp_mmc_fitImg;" \
119
120#define __TFTP_UPDATE_ROOTFS \
121 "tftp_mmc_rootfs=" \
122 "if test ! -n ${rootfs_part}; then " \
123 "setenv rootfs_part ${rootfs_part_active};" \
124 "fi;" \
125 "if tftp ${loadaddr} ${rootfs_file}; then " \
126 "setexpr fw_sz ${filesize} / 0x200; " \
127 "setexpr fw_sz ${fw_sz} + 1; " \
128 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
129 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
130 "; fi\0" \
131
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100132#define TFTP_UPDATE_ROOTFS \
133 "setenv rootfs_part ${rootfs_part_active};" \
134 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200135 "run tftp_mmc_rootfs_bkp;" \
136
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100137
138#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
139 "tftp_sf_fitImg_SWU=" \
140 "if tftp ${loadaddr} ${kernel_file}; then " \
141 "sf probe;" \
142 "sf erase swu-kernel +${filesize};" \
143 "sf write ${loadaddr} swu-kernel ${filesize};" \
144 "; fi\0" \
145
146#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskia1d657f2018-05-11 16:51:12 +0200147 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100148 "tftp_sf_initramfs_SWU=" \
149 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
150 "sf probe;" \
151 "sf erase swu-initramfs +${filesize};" \
152 "sf write ${loadaddr} swu-initramfs ${filesize};" \
153 "; fi\0" \
154
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100155#define TFTP_UPDATE_BOOTLOADER \
156 "ubootfile=u-boot.img\0" \
157 "ubootfileSPL=SPL\0" \
158 "tftp_sf_uboot=" \
159 "if tftp ${loadaddr} ${ubootfile}; then " \
160 "sf probe;" \
161 "sf erase u-boot +${filesize};" \
162 "sf write ${loadaddr} u-boot ${filesize}" \
163 "; fi\0" \
164 "tftp_sf_SPL=" \
165 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
166 "sf probe;" \
167 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
168 "sf erase 0x0 +${uboot_SPL_size};" \
169 "sf write ${loadaddr} 0x400 ${filesize};" \
170 "fi\0" \
171
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200172#define TFTP_UPDATE_SPINOR \
173 "spinorfile=core-image-lwn-display5.spinor\0" \
174 "spinorsize=0x2000000\0" \
175 "tftp_sf_img=" \
176 "if tftp ${loadaddr} ${spinorfile}; then " \
177 "sf probe;" \
178 "sf erase 0x0 ${spinorsize};" \
179 "sf write ${loadaddr} 0x0 ${filesize};" \
180 "fi\0" \
181
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100182#define CONFIG_EXTRA_ENV_SETTINGS \
183 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200184 "gpio_recovery=93\0" \
185 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100186 "display=tianma-tm070-800x480\0" \
187 "board=display5\0" \
188 "mmcdev=0\0" \
189 "altbootcmd=run recovery\0" \
190 "bootdelay=1\0" \
191 "baudrate=115200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100192 "ethact=FEC\0" \
193 "netdev=eth0\0" \
194 "boot_os=y\0" \
195 "hostname=display5\0" \
196 "loadaddr=0x12000000\0" \
197 "fdtaddr=0x12800000\0" \
Lukasz Majewski248698e2018-05-11 16:51:15 +0200198 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100199 "fdtfile=imx6q-display5.dtb\0" \
200 "fdt_high=0xffffffff\0" \
201 "initrd_high=0xffffffff\0" \
202 "kernel_file=fitImage\0" \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200203 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100204 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
205 "download_kernel=" \
206 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200207 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200208 "setenv ipaddr 192.168.1.102;" \
209 "setenv gatewayip 192.168.1.1;" \
210 "setenv netmask 255.255.255.0;" \
211 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200212 "echo BOOT: FACTORY (LEG);" \
213 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100214 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
215 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100216 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200217 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100218 "boot_tftp=" \
219 "if run download_kernel; then " \
220 "setenv bootargs console=${console} " \
221 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200222 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100223 "fi\0" \
224 "addip=setenv bootargs ${bootargs} " \
225 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
226 "${hostname}:eth0:on" \
227 "\0" \
228 "nfsargs=setenv bootargs " \
229 "root=/dev/nfs rw " \
230 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
231 "\0" \
232 "rootpath=/srv/tftp/DISP5/rootfs\0" \
233 "boot_nfs=" \
234 "if run download_kernel; then " \
235 "run nfsargs;" \
236 "run addip;" \
237 "setenv bootargs ${bootargs} console=${console};" \
238 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200239 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100240 "fi\0" \
241 "falcon_setup=" \
242 "if mmc dev ${mmcdev}; then " \
243 SETUP_BOOTARGS \
244 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
245 "setexpr fw_sz ${fdtargslen} / 0x200; " \
246 "setexpr fw_sz ${fw_sz} + 1; " \
247 "mmc write ${fdtargsaddr} " \
248 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
249 "fi\0" \
250 "boot_mmc=" \
251 "if mmc dev ${mmcdev}; then " \
252 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200253 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100254 "fi\0" \
255 "set_kernel_part=" \
256 "if test ${BOOT_FROM} = ACTIVE; then " \
257 "setenv kernel_part ${kernel_part_active};" \
258 "echo BOOT: ACTIVE;" \
259 "else if test ${BOOT_FROM} = BACKUP; then " \
260 "setenv kernel_part ${kernel_part_backup};" \
261 "echo BOOT: BACKUP;" \
262 "else " \
263 "run recovery;" \
264 "fi;fi\0" \
265 "set_rootfs_part=" \
266 "if test ${BOOT_FROM} = ACTIVE; then " \
267 "setenv rootfs_part ${rootfs_part_active};" \
268 "else if test ${BOOT_FROM} = BACKUP; then " \
269 "setenv rootfs_part ${rootfs_part_backup};" \
270 "else " \
271 "run recovery;" \
272 "fi;fi\0" \
273 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100274 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200275 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100276 "kernel_part_active=1\0" \
277 "kernel_part_backup=3\0" \
278 __TFTP_UPDATE_KERNEL \
279 "rootfs_part_active=2\0" \
280 "rootfs_part_backup=4\0" \
281 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200282 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100283 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200284 "tftp_mmc_rootfs_bkp=" \
285 "setenv rootfs_part ${rootfs_part_backup};" \
286 "setenv rootfs_file ${rootfs_file_backup};" \
287 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100288 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
289 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
290 "\0" \
291
292/* Miscellaneous configurable options */
293#undef CONFIG_SYS_CBSIZE
294#define CONFIG_SYS_CBSIZE 2048
295
296/* Print Buffer Size */
297#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
298 sizeof(CONFIG_SYS_PROMPT) + 16)
299#define CONFIG_SYS_MAXARGS 32
300#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
301
302#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100303
304/* Physical Memory Map */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100305#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
306#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
307
308#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
309#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
310
311#define CONFIG_SYS_INIT_SP_OFFSET \
312 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
313#define CONFIG_SYS_INIT_SP_ADDR \
314 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
315
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100316/* ENV config */
317#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100318/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100319#endif
320
321#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
322#endif /* __CONFIG_H */