xref: /openbmc/u-boot/include/configs/am335x_shc.h (revision 5c8fd32b)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2016
4  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5  *
6  * Based on:
7  * am335x_evm.h
8  *
9  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
10  */
11 
12 #ifndef __CONFIG_AM335X_SHC_H
13 #define __CONFIG_AM335X_SHC_H
14 
15 #include <configs/ti_am335x_common.h>
16 
17 /* settings we don;t want on this board */
18 #undef CONFIG_CMD_SPI
19 
20 #define CONFIG_CMD_CACHE
21 
22 #ifndef CONFIG_SPL_BUILD
23 # define CONFIG_TIMESTAMP
24 #endif
25 
26 #define CONFIG_SYS_BOOTM_LEN		(16 << 20)
27 
28 /* Clock Defines */
29 #define V_OSCK				24000000  /* Clock output from T2 */
30 #define V_SCLK				(V_OSCK)
31 
32 /*
33  * in case of SD Card or Network boot we want to have a possibility to
34  * debrick the shc, therefore do not read environment from eMMC
35  */
36 #if defined(CONFIG_SHC_SDBOOT) || defined(CONFIG_SHC_NETBOOT)
37 #define CONFIG_SYS_MMC_ENV_DEV		0
38 #else
39 #define CONFIG_SYS_MMC_ENV_DEV		1
40 #endif
41 
42 /*
43  * Info when using boot partitions: As environment resides within first
44  * 128 kB, MLO must start at 128 kB == 0x20000
45  * ENV at MMC Boot0 Partition - 0/Undefined=user, 1=boot0, 2=boot1,
46  * 4..7=general0..3
47  */
48 #define CONFIG_ENV_SIZE				0x1000 /* 4 KB */
49 #define CONFIG_ENV_OFFSET			0x7000 /* 28 kB */
50 
51 #define CONFIG_HSMMC2_8BIT
52 
53 #define CONFIG_ENV_OFFSET_REDUND    0x9000 /* 36 kB */
54 #define CONFIG_ENV_SIZE_REDUND      CONFIG_ENV_SIZE
55 
56 #ifndef CONFIG_SHC_ICT
57 /*
58  * In builds other than ICT, reset to retry after timeout
59  * Define a timeout after which a stopped bootloader continues autoboot
60  * (only works with CONFIG_RESET_TO_RETRY)
61  */
62 # define CONFIG_BOOT_RETRY_TIME 30
63 # define CONFIG_RESET_TO_RETRY
64 #endif
65 
66 #ifndef CONFIG_SPL_BUILD
67 #define CONFIG_EXTRA_ENV_SETTINGS \
68 	"loadaddr=0x80200000\0" \
69 	"kloadaddr=0x84000000\0" \
70 	"fdtaddr=0x85000000\0" \
71 	"fdt_high=0xffffffff\0" \
72 	"rdaddr=0x81000000\0" \
73 	"bootfile=uImage\0" \
74 	"fdtfile=am335x-shc.dtb\0" \
75 	"verify=no\0" \
76 	"serverip=10.55.152.184\0" \
77 	"rootpath=/srv/nfs/shc-rootfs\0" \
78 	"console=ttyO0,115200n8\0" \
79 	"optargs=quiet\0" \
80 	"mmcdev=1\0" \
81 	"harakiri=0\0" \
82 	"mmcpart=2\0" \
83 	"active_root=root1\0" \
84 	"inactive_root=root2\0" \
85 	"mmcrootfstype=ext4 rootwait\0" \
86 	"nfsopts=nolock\0" \
87 	"static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}" \
88 		"::off\0" \
89 	"ip_method=none\0" \
90 	"bootargs_defaults=setenv bootargs " \
91 		"console=${console} " \
92 		"${optargs}\0" \
93 	"mmcargs=run bootargs_defaults;" \
94 		"setenv bootargs ${bootargs} " \
95 		"root=${mmcroot} " \
96 		"rootfstype=${mmcrootfstype} ip=${ip_method}\0" \
97 	"netargs=setenv bootargs console=${console} " \
98 		"${optargs} " \
99 		"root=/dev/nfs " \
100 		"nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
101 		"ip=dhcp\0" \
102 	"bootenv=uEnv.txt\0" \
103 	"loadbootenv=if fatload mmc ${mmcdev} ${loadaddr} ${bootenv}; then " \
104 			"echo Loaded environment from ${bootenv}; " \
105 			"run importbootenv; " \
106 		"fi;\0" \
107 	"importbootenv=echo Importing environment variables from uEnv.txt ...; " \
108 		"env import -t $loadaddr $filesize\0" \
109 	"loaduimagefat=fatload mmc ${mmcdev} ${kloadaddr} ${bootfile}\0" \
110 	"loaduimage=ext2load mmc ${mmcdev}:${mmcpart} ${kloadaddr} /boot/${bootfile}\0" \
111 	"loadfdt=ext2load mmc ${mmcdev}:${mmcpart} ${fdtaddr} /boot/${fdtfile}\0" \
112 	"netloaduimage=tftp ${loadaddr} ${bootfile}\0" \
113 	"netloadfdt=tftp ${fdtaddr} ${fdtfile}\0" \
114 	"mmcboot=echo Booting Linux from ${mmcdevice} ...; " \
115 		"run mmcargs; " \
116 		"if run loadfdt; then " \
117 			"echo device tree detected; " \
118 			"bootm ${kloadaddr} - ${fdtaddr}; " \
119 		"else " \
120 			"bootm ${kloadaddr}; " \
121 		"fi; \0" \
122 	"netboot=echo Booting from network ...; " \
123 		"setenv autoload no; " \
124 		"dhcp; " \
125 		"run netloaduimage; " \
126 		"run netargs; " \
127 		"echo NFS path: ${serverip}:${rootpath};" \
128 		"if run netloadfdt; then " \
129 			"echo device tree detected; " \
130 			"bootm ${loadaddr} - ${fdtaddr}; " \
131 		"else " \
132 			"bootm ${loadaddr}; " \
133 		"fi; \0" \
134 	"emmc_erase=if test ${harakiri} = 1 ; then echo erase emmc ...; setenv mmcdev 1; mmc erase 0 200; reset; fi; \0" \
135 	"mmcpart_gp=mmcpart gp 1 40; \0" \
136 	"mmcpart_enhance=mmcpart enhance 0 64; \0" \
137 	"mmcpart_rel_write=mmcpart rel_write 1f; \0" \
138 	"mmcpart_commit=mmcpart commit 1; \0" \
139 	"mmc_hw_part=run mmcpart_gp; run mmcpart_enhance; run mmcpart_rel_write; run mmcpart_commit; \0" \
140 	"led_success=gpio set 22; \0" \
141 	"fusecmd=mmc dev 1; if mmcpart iscommitted; then echo HW Partitioning already committed; mmcpart list; else run mmc_hw_part; fi; run led_success; \0" \
142 	"uenv_exec=if test -n $uenvcmd; then " \
143 			"echo Running uenvcmd ...; " \
144 			"run uenvcmd; " \
145 		"fi;\0" \
146 	"sd_setup=echo SD/MMC-Card detected on device 0; " \
147 		"setenv mmcdevice SD; " \
148 		"setenv mmcdev 0; " \
149 		"setenv mmcpart 2; " \
150 		"setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart};\0" \
151 	"emmc_setup=echo eMMC detected on device 1; " \
152 		"setenv mmcdevice eMMC; " \
153 		"setenv mmcdev 1; " \
154 		"run emmc_erase; " \
155 		"if test ${active_root} = root2; then " \
156 			"echo Active root is partition 6 (root2); " \
157 			"setenv mmcpart 6; " \
158 		"else " \
159 			"echo Active root is partition 5 (root1); " \
160 			"setenv mmcpart 5; " \
161 		"fi; " \
162 		"setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart};\0"
163 #endif /* #ifndef CONFIG_SPL_BUILD */
164 
165 #if defined CONFIG_SHC_NETBOOT
166 /* Network Boot */
167 # define CONFIG_BOOTCOMMAND \
168 	"run fusecmd; " \
169 	"if run netboot; then " \
170 		"echo Booting from network; " \
171 	"else " \
172 		"echo ERROR: Cannot boot from network!; " \
173 		"panic; " \
174 	"fi; "
175 
176 #elif defined CONFIG_SHC_SDBOOT /* !defined CONFIG_SHC_NETBOOT */
177 /* SD-Card Boot */
178 # define CONFIG_BOOTCOMMAND \
179 	"if mmc dev 0; mmc rescan; then " \
180 		"run sd_setup; " \
181 	"else " \
182 		"echo ERROR: SD/MMC-Card not detected!; " \
183 		"panic; " \
184 	"fi; " \
185 	"if run loaduimage; then " \
186 		"echo Bootable SD/MMC-Card inserted, booting from it!; " \
187 		"run mmcboot; " \
188 	"else " \
189 		"echo ERROR: Unable to load uImage from SD/MMC-Card!; " \
190 		"panic; " \
191 	"fi; "
192 
193 #elif defined CONFIG_SHC_ICT
194 /* ICT adapter boots only u-boot and does HW partitioning */
195 # define CONFIG_BOOTCOMMAND \
196 	"if mmc dev 0; mmc rescan; then " \
197 		"run sd_setup; " \
198 	"else " \
199 		"echo ERROR: SD/MMC-Card not detected!; " \
200 		"panic; " \
201 	"fi; " \
202 	"run fusecmd; "
203 
204 #else /* !defined CONFIG_SHC_NETBOOT, !defined CONFIG_SHC_SDBOOT */
205 /* Regular Boot from internal eMMC */
206 # define CONFIG_BOOTCOMMAND \
207 	"if mmc dev 1; mmc rescan; then " \
208 		"run emmc_setup; " \
209 	"else " \
210 		"echo ERROR: eMMC device not detected!; " \
211 		"panic; " \
212 	"fi; " \
213 	"if run loaduimage; then " \
214 		"run mmcboot; " \
215 	"else " \
216 		"echo ERROR Unable to load uImage from eMMC!; " \
217 		"echo Performing Rollback!; " \
218 		"setenv _active_ ${active_root}; " \
219 		"setenv _inactive_ ${inactive_root}; " \
220 		"setenv active_root ${_inactive_}; " \
221 		"setenv inactive_root ${_active_}; " \
222 		"saveenv; " \
223 		"reset; " \
224 	"fi; "
225 
226 #endif /* Regular Boot */
227 
228 /* NS16550 Configuration */
229 #define CONFIG_SYS_NS16550_COM1		0x44e09000	/* UART0 */
230 #define CONFIG_SYS_NS16550_COM2		0x48022000	/* UART1 */
231 #define CONFIG_SYS_NS16550_COM3		0x48024000	/* UART2 */
232 #define CONFIG_SYS_NS16550_COM4		0x481a6000	/* UART3 */
233 #define CONFIG_SYS_NS16550_COM5		0x481a8000	/* UART4 */
234 #define CONFIG_SYS_NS16550_COM6		0x481aa000	/* UART5 */
235 
236 /* PMIC support */
237 #define CONFIG_POWER_TPS65217
238 
239 /* SPL */
240 
241 /*
242  * Disable MMC DM for SPL build and can be re-enabled after adding
243  * DM support in SPL
244  */
245 #ifdef CONFIG_SPL_BUILD
246 #undef CONFIG_DM_MMC
247 #undef CONFIG_TIMER
248 #endif
249 
250 #define CONFIG_BOOTP_DEFAULT
251 #define CONFIG_BOOTP_DNS2
252 #define CONFIG_BOOTP_SEND_HOSTNAME
253 #define CONFIG_NET_RETRY_COUNT         10
254 #define CONFIG_PHY_SMSC
255 
256 /* I2C configuration */
257 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
258 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
259 #define CONFIG_SYS_I2C_SPEED		400000
260 #define CONFIG_SYS_I2C_SLAVE		1
261 
262 #define CONFIG_SHOW_BOOT_PROGRESS
263 #endif	/* ! __CONFIG_AM335X_SHC_H */
264