blob: 38ac86928929d2809e44f371917b0d10dc73c055 [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)
19#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 0x100 /* 128KiB */
20
21/*
22 * display5 SPI-NOR memory layout
23 *
24 * The definition can be found in Kconfig's
25 * CONFIG_MTDIDS_DEFAULT and CONFIG_MTDPARTS_DEFAULT
26 *
27 * 0x000000 - 0x020000 : SPI.SPL (128KiB)
28 * 0x020000 - 0x120000 : SPI.u-boot (1MiB)
29 * 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB)
30 * 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB)
Lukasz Majewskia3d18cd2020-05-13 17:45:15 +020031 * 0x140000 - 0x740000 : SPI.swupdate-kernel-FIT (6MiB)
32 * 0x740000 - 0x1B40000 : SPI.swupdate-initramfs (20MiB)
33 * 0x1B40000 - 0x1F00000 : SPI.reserved (3840KiB)
34 * 0x1F00000 - 0x2000000 : SPI.factory (1MiB)
Lukasz Majewskice86bf92017-10-31 17:58:05 +010035 */
36
Lukasz Majewski75056052019-09-03 16:38:43 +020037/* SPI Flash Configs */
38#if defined(CONFIG_SPL_BUILD)
39#undef CONFIG_DM_SPI
40#undef CONFIG_DM_SPI_FLASH
Lukasz Majewskice86bf92017-10-31 17:58:05 +010041#endif
42
43/* Below values are "dummy" - only to avoid build break */
44#define CONFIG_SYS_SPI_KERNEL_OFFS 0x150000
45#define CONFIG_SYS_SPI_ARGS_OFFS 0x140000
46#define CONFIG_SYS_SPI_ARGS_SIZE 0x10000
47
48#include "imx6_spl.h"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010049
Lukasz Majewskice86bf92017-10-31 17:58:05 +010050#define CONFIG_MXC_UART_BASE UART5_BASE
51
Lukasz Majewskice86bf92017-10-31 17:58:05 +010052/* I2C Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010053#define CONFIG_I2C_MULTI_BUS
Lukasz Majewskice86bf92017-10-31 17:58:05 +010054
55/* MMC Configs */
Lukasz Majewskice86bf92017-10-31 17:58:05 +010056#define CONFIG_SYS_FSL_ESDHC_ADDR 0
57#define CONFIG_SYS_FSL_USDHC_NUM 2
Lukasz Majewskice86bf92017-10-31 17:58:05 +010058
Lukasz Majewskice86bf92017-10-31 17:58:05 +010059#define PARTS_DEFAULT \
60 /* Linux partitions */ \
61 "partitions=" \
62 "uuid_disk=${uuid_gpt_disk};" \
63 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
64 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
65 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
Lukasz Majewski6d46ce02018-05-11 16:51:16 +020066 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010067 "name=data,size=-,uuid=${uuid_gpt_data}\0"
68
Lukasz Majewskice86bf92017-10-31 17:58:05 +010069#define SWUPDATE_RECOVERY_PROCEDURE \
70 "echo '#######################';" \
71 "echo '# RECOVERY SWUupdate #';" \
72 "echo '#######################';" \
Lukasz Majewskiac6fb1e2018-05-11 16:51:18 +020073 "echo '#######################';" \
74 "echo '# GPT verify #';" \
75 "if gpt verify mmc ${mmcdev} ${partitions}; then " \
76 "echo '# OK ! #';" \
77 "else " \
78 "echo '# FAILED ! #';" \
79 "echo '# GPT RESTORATION #';" \
80 "gpt write mmc ${mmcdev} ${partitions};" \
81 "fi;" \
82 "echo '#######################';" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +010083 "setenv loadaddr_swu_initramfs 0x14000000;" \
84 "setenv bootargs console=${console} " \
85 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
86 ":${hostname}::off root=/dev/ram rw;" \
87 "sf probe;" \
88 "sf read ${loadaddr} swu-kernel;" \
89 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +020090 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
Lukasz Majewskice86bf92017-10-31 17:58:05 +010091
Lukasz Majewskice86bf92017-10-31 17:58:05 +010092#define SETUP_BOOTARGS \
93 "run set_rootfs_part;" \
94 "setenv bootargs ${bootargs} console=${console} " \
95 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
96 "rootwait rootfstype=ext4 rw; " \
97 "run set_kernel_part;" \
98 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +020099 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100100 "setenv fdt_conf imx6q-${board}-${display}.dtb; "
101
102/* All the numbers are in LBAs */
103#define __TFTP_UPDATE_KERNEL \
104 "tftp_mmc_fitImg=" \
105 "if test ! -n ${kernel_part}; then " \
106 "setenv kernel_part ${kernel_part_active};" \
107 "fi;" \
108 "if tftp ${loadaddr} ${kernel_file}; then " \
109 "setexpr fw_sz ${filesize} / 0x200; " \
110 "setexpr fw_sz ${fw_sz} + 1; " \
111 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
112 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
113 "; fi\0" \
114
115#define TFTP_UPDATE_KERNEL \
116 "setenv kernel_part ${kernel_part_active};" \
117 "run tftp_mmc_fitImg;" \
118 "setenv kernel_part ${kernel_part_backup};" \
119 "run tftp_mmc_fitImg;" \
120
121#define __TFTP_UPDATE_ROOTFS \
122 "tftp_mmc_rootfs=" \
123 "if test ! -n ${rootfs_part}; then " \
124 "setenv rootfs_part ${rootfs_part_active};" \
125 "fi;" \
126 "if tftp ${loadaddr} ${rootfs_file}; then " \
127 "setexpr fw_sz ${filesize} / 0x200; " \
128 "setexpr fw_sz ${fw_sz} + 1; " \
129 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
130 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
131 "; fi\0" \
132
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100133#define TFTP_UPDATE_ROOTFS \
134 "setenv rootfs_part ${rootfs_part_active};" \
135 "run tftp_mmc_rootfs;" \
Lukasz Majewskia2a603e2018-05-11 16:51:11 +0200136 "run tftp_mmc_rootfs_bkp;" \
137
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100138
139#define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
140 "tftp_sf_fitImg_SWU=" \
141 "if tftp ${loadaddr} ${kernel_file}; then " \
142 "sf probe;" \
143 "sf erase swu-kernel +${filesize};" \
144 "sf write ${loadaddr} swu-kernel ${filesize};" \
145 "; fi\0" \
146
147#define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
Lukasz Majewskia1d657f2018-05-11 16:51:12 +0200148 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100149 "tftp_sf_initramfs_SWU=" \
150 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
151 "sf probe;" \
152 "sf erase swu-initramfs +${filesize};" \
153 "sf write ${loadaddr} swu-initramfs ${filesize};" \
154 "; fi\0" \
155
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100156#define TFTP_UPDATE_BOOTLOADER \
157 "ubootfile=u-boot.img\0" \
158 "ubootfileSPL=SPL\0" \
159 "tftp_sf_uboot=" \
160 "if tftp ${loadaddr} ${ubootfile}; then " \
161 "sf probe;" \
162 "sf erase u-boot +${filesize};" \
163 "sf write ${loadaddr} u-boot ${filesize}" \
164 "; fi\0" \
165 "tftp_sf_SPL=" \
166 "if tftp ${loadaddr} ${ubootfileSPL}; then " \
167 "sf probe;" \
168 "setexpr uboot_SPL_size ${filesize} + 0x400;" \
169 "sf erase 0x0 +${uboot_SPL_size};" \
170 "sf write ${loadaddr} 0x400 ${filesize};" \
171 "fi\0" \
172
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200173#define TFTP_UPDATE_SPINOR \
174 "spinorfile=core-image-lwn-display5.spinor\0" \
175 "spinorsize=0x2000000\0" \
176 "tftp_sf_img=" \
177 "if tftp ${loadaddr} ${spinorfile}; then " \
178 "sf probe;" \
179 "sf erase 0x0 ${spinorsize};" \
180 "sf write ${loadaddr} 0x0 ${filesize};" \
181 "fi\0" \
182
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100183#define CONFIG_EXTRA_ENV_SETTINGS \
184 PARTS_DEFAULT \
Lukasz Majewskid7e065a2018-05-11 16:51:08 +0200185 "gpio_recovery=93\0" \
186 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100187 "display=tianma-tm070-800x480\0" \
188 "board=display5\0" \
189 "mmcdev=0\0" \
190 "altbootcmd=run recovery\0" \
191 "bootdelay=1\0" \
192 "baudrate=115200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100193 "ethact=FEC\0" \
194 "netdev=eth0\0" \
195 "boot_os=y\0" \
196 "hostname=display5\0" \
197 "loadaddr=0x12000000\0" \
198 "fdtaddr=0x12800000\0" \
Lukasz Majewski248698e2018-05-11 16:51:15 +0200199 "console=ttymxc4,115200 quiet cma=256M\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100200 "fdtfile=imx6q-display5.dtb\0" \
201 "fdt_high=0xffffffff\0" \
202 "initrd_high=0xffffffff\0" \
203 "kernel_file=fitImage\0" \
Lukasz Majewskif1b7c772018-08-18 22:22:07 +0200204 "fitImg_fw_sz=0x2200\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100205 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
206 "download_kernel=" \
207 "tftpboot ${loadaddr} ${kernel_file};\0" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200208 "factory_nfs=" \
Lukasz Majewskif4ad68a2018-05-11 16:51:00 +0200209 "setenv ipaddr 192.168.1.102;" \
210 "setenv gatewayip 192.168.1.1;" \
211 "setenv netmask 255.255.255.0;" \
212 "setenv serverip 192.168.1.2;" \
Lukasz Majewski48ef4742018-05-11 16:50:59 +0200213 "echo BOOT: FACTORY (LEG);" \
214 "run boot_nfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100215 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
216 "recovery=" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100217 "echo BOOT: RECOVERY: SWU;" \
Lukasz Majewskib259fff2018-05-11 16:51:05 +0200218 "run boot_swu_recovery\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100219 "boot_tftp=" \
220 "if run download_kernel; then " \
221 "setenv bootargs console=${console} " \
222 "root=/dev/mmcblk0p2 rootwait;" \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200223 "bootm ${loadaddr} - ${fdtaddr};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100224 "fi\0" \
225 "addip=setenv bootargs ${bootargs} " \
226 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
227 "${hostname}:eth0:on" \
228 "\0" \
229 "nfsargs=setenv bootargs " \
230 "root=/dev/nfs rw " \
231 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
232 "\0" \
233 "rootpath=/srv/tftp/DISP5/rootfs\0" \
234 "boot_nfs=" \
235 "if run download_kernel; then " \
236 "run nfsargs;" \
237 "run addip;" \
238 "setenv bootargs ${bootargs} console=${console};" \
239 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200240 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100241 "fi\0" \
242 "falcon_setup=" \
243 "if mmc dev ${mmcdev}; then " \
244 SETUP_BOOTARGS \
245 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
246 "setexpr fw_sz ${fdtargslen} / 0x200; " \
247 "setexpr fw_sz ${fw_sz} + 1; " \
248 "mmc write ${fdtargsaddr} " \
249 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
250 "fi\0" \
251 "boot_mmc=" \
252 "if mmc dev ${mmcdev}; then " \
253 SETUP_BOOTARGS \
Lukasz Majewski37bf2032018-05-11 16:51:04 +0200254 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100255 "fi\0" \
256 "set_kernel_part=" \
257 "if test ${BOOT_FROM} = ACTIVE; then " \
258 "setenv kernel_part ${kernel_part_active};" \
259 "echo BOOT: ACTIVE;" \
260 "else if test ${BOOT_FROM} = BACKUP; then " \
261 "setenv kernel_part ${kernel_part_backup};" \
262 "echo BOOT: BACKUP;" \
263 "else " \
264 "run recovery;" \
265 "fi;fi\0" \
266 "set_rootfs_part=" \
267 "if test ${BOOT_FROM} = ACTIVE; then " \
268 "setenv rootfs_part ${rootfs_part_active};" \
269 "else if test ${BOOT_FROM} = BACKUP; then " \
270 "setenv rootfs_part ${rootfs_part_backup};" \
271 "else " \
272 "run recovery;" \
273 "fi;fi\0" \
274 "BOOT_FROM=ACTIVE\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100275 TFTP_UPDATE_BOOTLOADER \
Lukasz Majewskibac6fe72018-05-11 16:51:02 +0200276 TFTP_UPDATE_SPINOR \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100277 "kernel_part_active=1\0" \
278 "kernel_part_backup=3\0" \
279 __TFTP_UPDATE_KERNEL \
280 "rootfs_part_active=2\0" \
281 "rootfs_part_backup=4\0" \
282 "rootfs_file=core-image-lwn-display5.ext4\0" \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200283 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100284 __TFTP_UPDATE_ROOTFS \
Lukasz Majewski7fbc6362018-05-11 16:51:10 +0200285 "tftp_mmc_rootfs_bkp=" \
286 "setenv rootfs_part ${rootfs_part_backup};" \
287 "setenv rootfs_file ${rootfs_file_backup};" \
288 "run tftp_mmc_rootfs\0" \
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100289 TFTP_UPDATE_RECOVERY_SWU_KERNEL \
290 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
291 "\0" \
292
293/* Miscellaneous configurable options */
294#undef CONFIG_SYS_CBSIZE
295#define CONFIG_SYS_CBSIZE 2048
296
297/* Print Buffer Size */
298#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
299 sizeof(CONFIG_SYS_PROMPT) + 16)
300#define CONFIG_SYS_MAXARGS 32
301#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
302
303#define CONFIG_STANDALONE_LOAD_ADDR 0x10001000
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100304
305/* Physical Memory Map */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100306#define PHYS_SDRAM MMDC0_ARB_BASE_ADDR
307#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM
308
309#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
310#define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE
311
312#define CONFIG_SYS_INIT_SP_OFFSET \
313 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
314#define CONFIG_SYS_INIT_SP_ADDR \
315 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
316
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100317/* ENV config */
318#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100319/* The 0x120000 value corresponds to above SPI-NOR memory MAP */
Lukasz Majewskice86bf92017-10-31 17:58:05 +0100320#endif
321
322#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)
323#endif /* __CONFIG_H */