xref: /openbmc/u-boot/include/configs/display5.h (revision 09d84117)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2017
4  * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
5  */
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 - 0x540000 : SPI.swupdate-kernel-FIT (4MiB)
34  * 0x540000 - 0x1540000 : SPI.swupdate-initramfs  (16MiB)
35  * 0x1540000 - 0x1640000 : SPI.factory  (1MiB)
36  */
37 
38 #ifndef CONFIG_SPL_BUILD
39 #define CONFIG_SPI_FLASH_MTD
40 #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"
48 #define CONFIG_SYS_SPI_U_BOOT_OFFS	0x20000
49 
50 #define CONFIG_CMDLINE_TAG
51 #define CONFIG_SETUP_MEMORY_TAGS
52 #define CONFIG_INITRD_TAG
53 #define CONFIG_REVISION_TAG
54 
55 /* Size of malloc() pool */
56 #define CONFIG_SYS_MALLOC_LEN		(16 * 1024 * 1024)
57 
58 /*#define CONFIG_MXC_UART*/
59 #define CONFIG_MXC_UART_BASE		UART5_BASE
60 
61 /* SPI NOR Flash */
62 #ifdef CONFIG_CMD_SF
63 #define CONFIG_SF_DEFAULT_BUS		1
64 #define CONFIG_SF_DEFAULT_CS		(0 | (IMX_GPIO_NR(5, 29) << 8))
65 #define CONFIG_SF_DEFAULT_SPEED		50000000
66 #define CONFIG_SF_DEFAULT_MODE		SPI_MODE_0
67 #endif
68 
69 /* I2C Configs */
70 #define CONFIG_SYS_I2C
71 #define CONFIG_SYS_I2C_MXC
72 #define CONFIG_SYS_I2C_MXC_I2C1
73 #define CONFIG_SYS_I2C_MXC_I2C2
74 #define CONFIG_SYS_I2C_MXC_I2C3
75 #define CONFIG_I2C_MULTI_BUS
76 #define CONFIG_SYS_I2C_SPEED		100000
77 #define CONFIG_I2C_EDID
78 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN  2
79 
80 /* Ethernet */
81 #ifdef CONFIG_FEC_MXC
82 #define IMX_FEC_BASE			ENET_BASE_ADDR
83 #define CONFIG_FEC_XCV_TYPE		RGMII
84 #define CONFIG_ETHPRIME			"FEC"
85 #define CONFIG_FEC_MXC_PHYADDR		0
86 #endif
87 
88 /* MMC Configs */
89 #define CONFIG_FSL_USDHC
90 #define CONFIG_SYS_FSL_ESDHC_ADDR	0
91 #define CONFIG_SYS_FSL_USDHC_NUM	2
92 #define CONFIG_SUPPORT_EMMC_BOOT
93 
94 /* allow to overwrite serial and ethaddr */
95 #define CONFIG_ENV_OVERWRITE
96 #define CONFIG_BAUDRATE			115200
97 
98 #ifndef CONFIG_BOOTCOMMAND
99 #define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
100 	     "run recovery;" \
101 	"else if test ${BOOT_FROM} = FACTORY; then " \
102 	     "run factory_nfs;" \
103 	"else " \
104 	     "run boot_mmc;" \
105 	"fi;fi"
106 #endif
107 
108 #define PARTS_DEFAULT \
109 	/* Linux partitions */ \
110 	"partitions=" \
111 	"uuid_disk=${uuid_gpt_disk};" \
112 	"name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \
113 	"name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \
114 	"name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \
115 	"name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \
116 	"name=data,size=-,uuid=${uuid_gpt_data}\0"
117 
118 #define FACTORY_PROCEDURE \
119 	"echo '#######################';" \
120 	"echo '# Factory Boot        #';" \
121 	"echo '#######################';" \
122 	"env default -a;" \
123 	"saveenv;" \
124 	"gpt write mmc ${mmcdev} ${partitions};" \
125 	"run tftp_sf_SPL;" \
126 	"run tftp_sf_uboot;" \
127 	TFTP_UPDATE_KERNEL \
128 	"run tftp_sf_fitImg_SWU;" \
129 	"run tftp_sf_initramfs_SWU;" \
130 	TFTP_UPDATE_ROOTFS \
131 	"echo '#######################';" \
132 	"echo '# END - OK            #';" \
133 	"echo '#######################';" \
134 	"setenv bootcmd 'env default -a; saveenv; run falcon_setup; reset';" \
135 	"setenv boot_os 'n';" \
136 	"saveenv;" \
137 	"reset;"
138 
139 #define SWUPDATE_RECOVERY_PROCEDURE \
140 	"echo '#######################';" \
141 	"echo '# RECOVERY SWUupdate  #';" \
142 	"echo '#######################';" \
143 	"echo '#######################';" \
144 	"echo '# GPT verify          #';" \
145 	"if gpt verify mmc ${mmcdev} ${partitions}; then " \
146 		"echo '# OK !                #';" \
147 	"else " \
148 		"echo '# FAILED !            #';" \
149 		"echo '# GPT RESTORATION     #';" \
150 		"gpt write mmc ${mmcdev} ${partitions};" \
151 	"fi;" \
152 	"echo '#######################';" \
153 	"setenv loadaddr_swu_initramfs 0x14000000;" \
154 	"setenv bootargs console=${console} " \
155 		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
156 		":${hostname}::off root=/dev/ram rw;" \
157 	"sf probe;" \
158 	"sf read ${loadaddr} swu-kernel;" \
159 	"sf read ${loadaddr_swu_initramfs} swu-initramfs;" \
160 	"bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;"
161 
162 #define SETUP_BOOTARGS \
163 	"run set_rootfs_part;" \
164 	"setenv bootargs ${bootargs} console=${console} "	  \
165 		      "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \
166 		      "rootwait rootfstype=ext4 rw; " \
167 	"run set_kernel_part;" \
168 	"part start mmc ${mmcdev} ${kernel_part} lba_start; " \
169 	"mmc read ${loadaddr} ${lba_start} 0x2000; " \
170 	"setenv fdt_conf imx6q-${board}-${display}.dtb; "
171 
172 /* All the numbers are in LBAs */
173 #define __TFTP_UPDATE_KERNEL \
174 	"tftp_mmc_fitImg=" \
175 	   "if test ! -n ${kernel_part}; then " \
176 	       "setenv kernel_part ${kernel_part_active};" \
177 	   "fi;" \
178 	   "if tftp ${loadaddr} ${kernel_file}; then " \
179 	       "setexpr fw_sz ${filesize} / 0x200; " \
180 	       "setexpr fw_sz ${fw_sz} + 1; "  \
181 	       "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
182 	       "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
183 	   "; fi\0" \
184 
185 #define TFTP_UPDATE_KERNEL \
186 	"setenv kernel_part ${kernel_part_active};" \
187 	"run tftp_mmc_fitImg;" \
188 	"setenv kernel_part ${kernel_part_backup};" \
189 	"run tftp_mmc_fitImg;" \
190 
191 #define __TFTP_UPDATE_ROOTFS \
192 	"tftp_mmc_rootfs=" \
193 	   "if test ! -n ${rootfs_part}; then " \
194 	       "setenv rootfs_part ${rootfs_part_active};" \
195 	   "fi;" \
196 	   "if tftp ${loadaddr} ${rootfs_file}; then " \
197 	       "setexpr fw_sz ${filesize} / 0x200; " \
198 	       "setexpr fw_sz ${fw_sz} + 1; "  \
199 	       "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \
200 	       "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \
201 	   "; fi\0" \
202 
203 #define TFTP_UPDATE_ROOTFS \
204 	"setenv rootfs_part ${rootfs_part_active};" \
205 	"run tftp_mmc_rootfs;" \
206 	"run tftp_mmc_rootfs_bkp;" \
207 
208 
209 #define TFTP_UPDATE_RECOVERY_SWU_KERNEL \
210 	"tftp_sf_fitImg_SWU=" \
211 	    "if tftp ${loadaddr} ${kernel_file}; then " \
212 		"sf probe;" \
213 		"sf erase swu-kernel +${filesize};" \
214 		"sf write ${loadaddr} swu-kernel ${filesize};" \
215 	"; fi\0"	  \
216 
217 #define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
218 	"swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \
219 	"tftp_sf_initramfs_SWU=" \
220 	    "if tftp ${loadaddr} ${swu_initramfs_file}; then " \
221 		"sf probe;" \
222 		"sf erase swu-initramfs +${filesize};" \
223 		"sf write ${loadaddr} swu-initramfs ${filesize};" \
224 	"; fi\0"	  \
225 
226 #define TFTP_UPDATE_BOOTLOADER \
227 	"ubootfile=u-boot.img\0" \
228 	"ubootfileSPL=SPL\0" \
229 	"tftp_sf_uboot=" \
230 	    "if tftp ${loadaddr} ${ubootfile}; then " \
231 		"sf probe;" \
232 		"sf erase u-boot +${filesize};" \
233 		"sf write ${loadaddr} u-boot ${filesize}" \
234 	"; fi\0"	  \
235 	"tftp_sf_SPL="	  \
236 	    "if tftp ${loadaddr} ${ubootfileSPL}; then " \
237 		"sf probe;" \
238 		"setexpr uboot_SPL_size ${filesize} + 0x400;" \
239 		"sf erase 0x0 +${uboot_SPL_size};" \
240 		"sf write ${loadaddr} 0x400 ${filesize};" \
241 	"fi\0" \
242 
243 #define TFTP_UPDATE_SPINOR \
244 	"spinorfile=core-image-lwn-display5.spinor\0" \
245 	"spinorsize=0x2000000\0" \
246 	"tftp_sf_img=" \
247 	    "if tftp ${loadaddr} ${spinorfile}; then " \
248 		"sf probe;" \
249 		"sf erase 0x0 ${spinorsize};" \
250 		"sf write ${loadaddr} 0x0 ${filesize};" \
251 	"fi\0" \
252 
253 #define CONFIG_EXTRA_ENV_SETTINGS	  \
254 	PARTS_DEFAULT \
255 	"gpio_recovery=93\0" \
256 	"check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
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 	"ethact=FEC\0" \
266 	"netdev=eth0\0" \
267 	"boot_os=y\0" \
268 	"hostname=display5\0" \
269 	"loadaddr=0x12000000\0" \
270 	"fdtaddr=0x12800000\0" \
271 	"console=ttymxc4,115200 quiet cma=256M\0" \
272 	"fdtfile=imx6q-display5.dtb\0" \
273 	"fdt_high=0xffffffff\0" \
274 	"initrd_high=0xffffffff\0" \
275 	"kernel_file=fitImage\0" \
276 	"up=run tftp_sf_SPL; run tftp_sf_uboot\0" \
277 	"download_kernel=" \
278 		"tftpboot ${loadaddr} ${kernel_file};\0" \
279 	"factory_nfs=" \
280 	     "setenv ipaddr 192.168.1.102;" \
281 	     "setenv gatewayip 192.168.1.1;" \
282 	     "setenv netmask 255.255.255.0;" \
283 	     "setenv serverip 192.168.1.2;" \
284 	     "echo BOOT: FACTORY (LEG);" \
285 	     "run boot_nfs\0" \
286 	"boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \
287 	"recovery=" \
288 	     "echo BOOT: RECOVERY: SWU;" \
289 	     "run boot_swu_recovery\0" \
290 	"boot_tftp=" \
291 	"if run download_kernel; then "	  \
292 	     "setenv bootargs console=${console} " \
293 	     "root=/dev/mmcblk0p2 rootwait;" \
294 	     "bootm ${loadaddr} - ${fdtaddr};reset;" \
295 	"fi\0" \
296 	"addip=setenv bootargs ${bootargs} " \
297 	"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \
298 	    "${hostname}:eth0:on"	  \
299 	"\0"	  \
300 	"nfsargs=setenv bootargs " \
301 	"root=/dev/nfs rw "	  \
302 	"nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \
303 	"\0" \
304 	"rootpath=/srv/tftp/DISP5/rootfs\0" \
305 	"boot_nfs=" \
306 	"if run download_kernel; then "	  \
307 	     "run nfsargs;"	  \
308 	     "run addip;"	  \
309 	     "setenv bootargs ${bootargs} console=${console};"	  \
310 	     "setenv fdt_conf imx6q-${board}-${display}.dtb; " \
311 	     "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
312 	"fi\0" \
313 	"falcon_setup=" \
314 	"if mmc dev ${mmcdev}; then "	  \
315 	     SETUP_BOOTARGS \
316 	     "spl export fdt ${loadaddr}#conf@${fdt_conf};" \
317 	     "setexpr fw_sz ${fdtargslen} / 0x200; " \
318 	     "setexpr fw_sz ${fw_sz} + 1; "  \
319 	     "mmc write ${fdtargsaddr} " \
320 	     __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \
321 	"fi\0" \
322 	"boot_mmc=" \
323 	"if mmc dev ${mmcdev}; then "	  \
324 	     SETUP_BOOTARGS \
325 	     "bootm ${loadaddr}#conf@${fdt_conf};reset;" \
326 	"fi\0" \
327 	"set_kernel_part=" \
328 	"if test ${BOOT_FROM} = ACTIVE; then " \
329 	     "setenv kernel_part ${kernel_part_active};" \
330 	     "echo BOOT: ACTIVE;" \
331 	"else if test ${BOOT_FROM} = BACKUP; then " \
332 	     "setenv kernel_part ${kernel_part_backup};" \
333 	     "echo BOOT: BACKUP;" \
334 	"else " \
335 	     "run recovery;" \
336 	"fi;fi\0" \
337 	"set_rootfs_part=" \
338 	"if test ${BOOT_FROM} = ACTIVE; then " \
339 	     "setenv rootfs_part ${rootfs_part_active};" \
340 	"else if test ${BOOT_FROM} = BACKUP; then " \
341 	     "setenv rootfs_part ${rootfs_part_backup};" \
342 	"else " \
343 	     "run recovery;" \
344 	"fi;fi\0" \
345 	"BOOT_FROM=ACTIVE\0" \
346 	TFTP_UPDATE_BOOTLOADER \
347 	TFTP_UPDATE_SPINOR \
348 	"kernel_part_active=1\0" \
349 	"kernel_part_backup=3\0" \
350 	__TFTP_UPDATE_KERNEL \
351 	"rootfs_part_active=2\0" \
352 	"rootfs_part_backup=4\0" \
353 	"rootfs_file=core-image-lwn-display5.ext4\0" \
354 	"rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \
355 	__TFTP_UPDATE_ROOTFS \
356 	"tftp_mmc_rootfs_bkp=" \
357 	   "setenv rootfs_part ${rootfs_part_backup};" \
358 	   "setenv rootfs_file ${rootfs_file_backup};" \
359 	   "run tftp_mmc_rootfs\0" \
360 	TFTP_UPDATE_RECOVERY_SWU_KERNEL \
361 	TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \
362 	"\0" \
363 
364 /* Miscellaneous configurable options */
365 #undef CONFIG_SYS_CBSIZE
366 #define CONFIG_SYS_CBSIZE		2048
367 
368 /* Print Buffer Size */
369 #define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
370 					 sizeof(CONFIG_SYS_PROMPT) + 16)
371 #define CONFIG_SYS_MAXARGS		32
372 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
373 
374 #define CONFIG_STANDALONE_LOAD_ADDR	0x10001000
375 #define CONFIG_SYS_HZ			1000
376 
377 /* Physical Memory Map */
378 #define PHYS_SDRAM			MMDC0_ARB_BASE_ADDR
379 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM
380 
381 #define CONFIG_SYS_INIT_RAM_ADDR	IRAM_BASE_ADDR
382 #define CONFIG_SYS_INIT_RAM_SIZE	IRAM_SIZE
383 
384 #define CONFIG_SYS_INIT_SP_OFFSET \
385 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
386 #define CONFIG_SYS_INIT_SP_ADDR \
387 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
388 
389 /* Commands */
390 
391 /* Watchdog */
392 #define CONFIG_HW_WATCHDOG
393 #define CONFIG_IMX_WATCHDOG
394 #define CONFIG_WATCHDOG_TIMEOUT_MSECS   15000
395 
396 /* ENV config */
397 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
398 #define CONFIG_ENV_SIZE		(SZ_64K)
399 /* The 0x120000 value corresponds to above SPI-NOR memory MAP */
400 #define CONFIG_ENV_OFFSET		(0x120000)
401 #define CONFIG_ENV_SECT_SIZE		(SZ_64K)
402 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
403 #define CONFIG_ENV_OFFSET_REDUND	(CONFIG_ENV_OFFSET + \
404 						CONFIG_ENV_SECT_SIZE)
405 #define CONFIG_ENV_SIZE_REDUND		CONFIG_ENV_SIZE
406 
407 #define CONFIG_ENV_SPI_BUS		CONFIG_SF_DEFAULT_BUS
408 #define CONFIG_ENV_SPI_CS		CONFIG_SF_DEFAULT_CS
409 #define CONFIG_ENV_SPI_MODE		CONFIG_SF_DEFAULT_MODE
410 #define CONFIG_ENV_SPI_MAX_HZ		CONFIG_SF_DEFAULT_SPEED
411 #endif
412 
413 #define CONFIG_MXC_USB_PORTSC           (PORT_PTS_UTMI | PORT_PTS_PTW)
414 #endif /* __CONFIG_H */
415