env: Remove useless CONFIG_ENV_SIZE_REDUND and fix ENV_IS_REDUND check
[platform/kernel/u-boot.git] / include / configs / am335x_shc.h
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
55 #ifndef CONFIG_SHC_ICT
56 /*
57  * In builds other than ICT, reset to retry after timeout
58  * Define a timeout after which a stopped bootloader continues autoboot
59  * (only works with CONFIG_RESET_TO_RETRY)
60  */
61 # define CONFIG_BOOT_RETRY_TIME 30
62 # define CONFIG_RESET_TO_RETRY
63 #endif
64
65 #ifndef CONFIG_SPL_BUILD
66 #define CONFIG_EXTRA_ENV_SETTINGS \
67         "loadaddr=0x80200000\0" \
68         "kloadaddr=0x84000000\0" \
69         "fdtaddr=0x85000000\0" \
70         "fdt_high=0xffffffff\0" \
71         "rdaddr=0x81000000\0" \
72         "bootfile=uImage\0" \
73         "fdtfile=am335x-shc.dtb\0" \
74         "verify=no\0" \
75         "serverip=10.55.152.184\0" \
76         "rootpath=/srv/nfs/shc-rootfs\0" \
77         "console=ttyO0,115200n8\0" \
78         "optargs=quiet\0" \
79         "mmcdev=1\0" \
80         "harakiri=0\0" \
81         "mmcpart=2\0" \
82         "active_root=root1\0" \
83         "inactive_root=root2\0" \
84         "mmcrootfstype=ext4 rootwait\0" \
85         "nfsopts=nolock\0" \
86         "static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}" \
87                 "::off\0" \
88         "ip_method=none\0" \
89         "bootargs_defaults=setenv bootargs " \
90                 "console=${console} " \
91                 "${optargs}\0" \
92         "mmcargs=run bootargs_defaults;" \
93                 "setenv bootargs ${bootargs} " \
94                 "root=${mmcroot} " \
95                 "rootfstype=${mmcrootfstype} ip=${ip_method}\0" \
96         "netargs=setenv bootargs console=${console} " \
97                 "${optargs} " \
98                 "root=/dev/nfs " \
99                 "nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
100                 "ip=dhcp\0" \
101         "bootenv=uEnv.txt\0" \
102         "loadbootenv=if fatload mmc ${mmcdev} ${loadaddr} ${bootenv}; then " \
103                         "echo Loaded environment from ${bootenv}; " \
104                         "run importbootenv; " \
105                 "fi;\0" \
106         "importbootenv=echo Importing environment variables from uEnv.txt ...; " \
107                 "env import -t $loadaddr $filesize\0" \
108         "loaduimagefat=fatload mmc ${mmcdev} ${kloadaddr} ${bootfile}\0" \
109         "loaduimage=ext2load mmc ${mmcdev}:${mmcpart} ${kloadaddr} /boot/${bootfile}\0" \
110         "loadfdt=ext2load mmc ${mmcdev}:${mmcpart} ${fdtaddr} /boot/${fdtfile}\0" \
111         "netloaduimage=tftp ${loadaddr} ${bootfile}\0" \
112         "netloadfdt=tftp ${fdtaddr} ${fdtfile}\0" \
113         "mmcboot=echo Booting Linux from ${mmcdevice} ...; " \
114                 "run mmcargs; " \
115                 "if run loadfdt; then " \
116                         "echo device tree detected; " \
117                         "bootm ${kloadaddr} - ${fdtaddr}; " \
118                 "else " \
119                         "bootm ${kloadaddr}; " \
120                 "fi; \0" \
121         "netboot=echo Booting from network ...; " \
122                 "setenv autoload no; " \
123                 "dhcp; " \
124                 "run netloaduimage; " \
125                 "run netargs; " \
126                 "echo NFS path: ${serverip}:${rootpath};" \
127                 "if run netloadfdt; then " \
128                         "echo device tree detected; " \
129                         "bootm ${loadaddr} - ${fdtaddr}; " \
130                 "else " \
131                         "bootm ${loadaddr}; " \
132                 "fi; \0" \
133         "emmc_erase=if test ${harakiri} = 1 ; then echo erase emmc ...; setenv mmcdev 1; mmc erase 0 200; reset; fi; \0" \
134         "mmcpart_gp=mmcpart gp 1 40; \0" \
135         "mmcpart_enhance=mmcpart enhance 0 64; \0" \
136         "mmcpart_rel_write=mmcpart rel_write 1f; \0" \
137         "mmcpart_commit=mmcpart commit 1; \0" \
138         "mmc_hw_part=run mmcpart_gp; run mmcpart_enhance; run mmcpart_rel_write; run mmcpart_commit; \0" \
139         "led_success=gpio set 22; \0" \
140         "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" \
141         "uenv_exec=if test -n $uenvcmd; then " \
142                         "echo Running uenvcmd ...; " \
143                         "run uenvcmd; " \
144                 "fi;\0" \
145         "sd_setup=echo SD/MMC-Card detected on device 0; " \
146                 "setenv mmcdevice SD; " \
147                 "setenv mmcdev 0; " \
148                 "setenv mmcpart 2; " \
149                 "setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart};\0" \
150         "emmc_setup=echo eMMC detected on device 1; " \
151                 "setenv mmcdevice eMMC; " \
152                 "setenv mmcdev 1; " \
153                 "run emmc_erase; " \
154                 "if test ${active_root} = root2; then " \
155                         "echo Active root is partition 6 (root2); " \
156                         "setenv mmcpart 6; " \
157                 "else " \
158                         "echo Active root is partition 5 (root1); " \
159                         "setenv mmcpart 5; " \
160                 "fi; " \
161                 "setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart};\0"
162 #endif /* #ifndef CONFIG_SPL_BUILD */
163
164 #if defined CONFIG_SHC_NETBOOT
165 /* Network Boot */
166 # define CONFIG_BOOTCOMMAND \
167         "run fusecmd; " \
168         "if run netboot; then " \
169                 "echo Booting from network; " \
170         "else " \
171                 "echo ERROR: Cannot boot from network!; " \
172                 "panic; " \
173         "fi; "
174
175 #elif defined CONFIG_SHC_SDBOOT /* !defined CONFIG_SHC_NETBOOT */
176 /* SD-Card Boot */
177 # define CONFIG_BOOTCOMMAND \
178         "if mmc dev 0; mmc rescan; then " \
179                 "run sd_setup; " \
180         "else " \
181                 "echo ERROR: SD/MMC-Card not detected!; " \
182                 "panic; " \
183         "fi; " \
184         "if run loaduimage; then " \
185                 "echo Bootable SD/MMC-Card inserted, booting from it!; " \
186                 "run mmcboot; " \
187         "else " \
188                 "echo ERROR: Unable to load uImage from SD/MMC-Card!; " \
189                 "panic; " \
190         "fi; "
191
192 #elif defined CONFIG_SHC_ICT
193 /* ICT adapter boots only u-boot and does HW partitioning */
194 # define CONFIG_BOOTCOMMAND \
195         "if mmc dev 0; mmc rescan; then " \
196                 "run sd_setup; " \
197         "else " \
198                 "echo ERROR: SD/MMC-Card not detected!; " \
199                 "panic; " \
200         "fi; " \
201         "run fusecmd; "
202
203 #else /* !defined CONFIG_SHC_NETBOOT, !defined CONFIG_SHC_SDBOOT */
204 /* Regular Boot from internal eMMC */
205 # define CONFIG_BOOTCOMMAND \
206         "if mmc dev 1; mmc rescan; then " \
207                 "run emmc_setup; " \
208         "else " \
209                 "echo ERROR: eMMC device not detected!; " \
210                 "panic; " \
211         "fi; " \
212         "if run loaduimage; then " \
213                 "run mmcboot; " \
214         "else " \
215                 "echo ERROR Unable to load uImage from eMMC!; " \
216                 "echo Performing Rollback!; " \
217                 "setenv _active_ ${active_root}; " \
218                 "setenv _inactive_ ${inactive_root}; " \
219                 "setenv active_root ${_inactive_}; " \
220                 "setenv inactive_root ${_active_}; " \
221                 "saveenv; " \
222                 "reset; " \
223         "fi; "
224
225 #endif /* Regular Boot */
226
227 /* NS16550 Configuration */
228 #define CONFIG_SYS_NS16550_COM1         0x44e09000      /* UART0 */
229 #define CONFIG_SYS_NS16550_COM2         0x48022000      /* UART1 */
230 #define CONFIG_SYS_NS16550_COM3         0x48024000      /* UART2 */
231 #define CONFIG_SYS_NS16550_COM4         0x481a6000      /* UART3 */
232 #define CONFIG_SYS_NS16550_COM5         0x481a8000      /* UART4 */
233 #define CONFIG_SYS_NS16550_COM6         0x481aa000      /* UART5 */
234
235 /* PMIC support */
236 #define CONFIG_POWER_TPS65217
237
238 /* SPL */
239
240 /*
241  * Disable MMC DM for SPL build and can be re-enabled after adding
242  * DM support in SPL
243  */
244 #ifdef CONFIG_SPL_BUILD
245 #undef CONFIG_DM_MMC
246 #undef CONFIG_TIMER
247 #endif
248
249 #define CONFIG_BOOTP_DEFAULT
250 #define CONFIG_BOOTP_DNS2
251 #define CONFIG_BOOTP_SEND_HOSTNAME
252 #define CONFIG_NET_RETRY_COUNT         10
253 #define CONFIG_PHY_SMSC
254
255 /* I2C configuration */
256 #define CONFIG_SYS_I2C_EEPROM_ADDR      0x50    /* Main EEPROM */
257 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN  2
258 #define CONFIG_SYS_I2C_SPEED            400000
259 #define CONFIG_SYS_I2C_SLAVE            1
260 #endif  /* ! __CONFIG_AM335X_SHC_H */