1 /*
2  * (C) Copyright 2008-2011
3  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef __CONFIG_KEYMILE_H
9 #define __CONFIG_KEYMILE_H
10 
11 #define CONFIG_BOOTCOUNT_LIMIT
12 
13 /*
14  * Command line configuration.
15  */
16 #define CONFIG_CMD_ASKENV
17 #define CONFIG_CMD_DHCP
18 #define CONFIG_CMD_DEFAULTENV_VARS
19 #define CONFIG_CMD_GREPENV
20 #define CONFIG_CMD_IMMAP
21 #define CONFIG_CMD_MII
22 #define CONFIG_CMD_PING
23 #define CONFIG_CMD_EEPROM
24 #define CONFIG_CMD_I2C
25 #define CONFIG_CMD_JFFS2
26 #define CONFIG_CMD_MTDPARTS
27 
28 #undef	CONFIG_WATCHDOG		/* disable platform specific watchdog */
29 
30 #define CONFIG_BOOTDELAY	2 /* autoboot after 2 seconds */
31 #undef	CONFIG_BOOTARGS		/* the boot command will set bootargs */
32 
33 /*
34  * Miscellaneous configurable options
35  */
36 #define CONFIG_SYS_HUSH_PARSER
37 #define CONFIG_SYS_LONGHELP			/* undef to save memory	  */
38 #if defined(CONFIG_CMD_KGDB)
39 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
40 #else
41 #define CONFIG_SYS_CBSIZE		512	/* Console I/O Buffer Size  */
42 #endif
43 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
44 #define CONFIG_SYS_MAXARGS		32 /* max number of command args */
45 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
46 #define CONFIG_CMDLINE_EDITING
47 #define CONFIG_AUTO_COMPLETE
48 
49 #define CONFIG_HUSH_INIT_VAR
50 
51 #define CONFIG_SYS_ALT_MEMTEST		/* memory test, takes time */
52 
53 #define CONFIG_BAUDRATE			115200
54 #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400 }
55 
56 #define CONFIG_LOADS_ECHO
57 #define CONFIG_SYS_LOADS_BAUD_CHANGE
58 
59 #define CONFIG_AUTOBOOT_KEYED
60 #define CONFIG_AUTOBOOT_PROMPT "Hit <SPACE> key to stop autoboot in %2ds\n"
61 #define CONFIG_AUTOBOOT_STOP_STR        " "
62 
63 /* Support the IVM EEprom */
64 #define	CONFIG_SYS_IVM_EEPROM_ADR	0x50
65 #define CONFIG_SYS_IVM_EEPROM_MAX_LEN	0x400
66 #define CONFIG_SYS_IVM_EEPROM_PAGE_LEN	0x100
67 
68 #define	CONFIG_SYS_FLASH_PROTECTION
69 
70 /*
71  * BOOTP options
72  */
73 #define CONFIG_BOOTP_BOOTFILESIZE
74 #define CONFIG_BOOTP_BOOTPATH
75 #define CONFIG_BOOTP_GATEWAY
76 #define CONFIG_BOOTP_HOSTNAME
77 
78 /* UBI Support for all Keymile boards */
79 #define CONFIG_CMD_UBI
80 #define CONFIG_RBTREE
81 #define CONFIG_MTD_PARTITIONS
82 #define CONFIG_MTD_DEVICE
83 #define CONFIG_MTD_CONCAT
84 
85 #define CONFIG_CMD_CRAMFS
86 #define CONFIG_CRAMFS_CMDLINE
87 
88 #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
89 #define CONFIG_KM_DEF_ENV_BOOTPARAMS \
90 	"actual_bank=0\0"
91 #endif
92 
93 #ifndef CONFIG_KM_DEF_NETDEV
94 #define CONFIG_KM_DEF_NETDEV	\
95 	"netdev=eth0\0"
96 #endif
97 
98 #ifndef CONFIG_KM_UBI_PARTITION_NAME_BOOT
99 #define CONFIG_KM_UBI_PARTITION_NAME_BOOT	"ubi0"
100 #endif /* CONFIG_KM_UBI_PARTITION_NAME_BOOT */
101 
102 #ifndef CONFIG_KM_UBI_PART_BOOT_OPTS
103 #define CONFIG_KM_UBI_PART_BOOT_OPTS		""
104 #endif /* CONFIG_KM_UBI_PART_BOOT_OPTS */
105 
106 #ifndef CONFIG_KM_UBI_PARTITION_NAME_APP
107 /* one flash chip only called boot */
108 /* boot: CONFIG_KM_UBI_PARTITION_NAME_BOOT */
109 # define CONFIG_KM_UBI_LINUX_MTD					\
110 	"ubi.mtd=" CONFIG_KM_UBI_PARTITION_NAME_BOOT			\
111 	CONFIG_KM_UBI_PART_BOOT_OPTS
112 # define CONFIG_KM_DEV_ENV_FLASH_BOOT_UBI				\
113 	"ubiattach=ubi part " CONFIG_KM_UBI_PARTITION_NAME_BOOT "\0"
114 #else /* CONFIG_KM_UBI_PARTITION_NAME_APP */
115 /* two flash chips called boot and app */
116 /* boot: CONFIG_KM_UBI_PARTITION_NAME_BOOT */
117 /* app:  CONFIG_KM_UBI_PARTITION_NAME_APP */
118 # define CONFIG_KM_UBI_LINUX_MTD					\
119 	"ubi.mtd=" CONFIG_KM_UBI_PARTITION_NAME_BOOT			\
120 	CONFIG_KM_UBI_PART_BOOT_OPTS " "				\
121 	"ubi.mtd=" CONFIG_KM_UBI_PARTITION_NAME_APP
122 # define CONFIG_KM_DEV_ENV_FLASH_BOOT_UBI				\
123 	"ubiattach=if test ${boot_bank} -eq 0; then; "			\
124 	"ubi part " CONFIG_KM_UBI_PARTITION_NAME_BOOT "; else; "	\
125 	"ubi part " CONFIG_KM_UBI_PARTITION_NAME_APP "; fi\0"
126 #endif /* CONFIG_KM_UBI_PARTITION_NAME_APP */
127 
128 #ifdef CONFIG_NAND_ECC_BCH
129 #define CONFIG_KM_UIMAGE_NAME "ecc_bch_uImage\0"
130 #define CONFIG_KM_ECC_MODE    " eccmode=bch"
131 #else
132 #define CONFIG_KM_UIMAGE_NAME "uImage\0"
133 #define CONFIG_KM_ECC_MODE
134 #endif
135 
136 /*
137  * boottargets
138  * - set 'subbootcmds'
139  * - set 'bootcmd' and 'altbootcmd'
140  * available targets:
141  * - 'release': for a standalone system		kernel/rootfs from flash
142  */
143 #define CONFIG_KM_DEF_ENV_BOOTTARGETS					\
144 	"subbootcmds=ubiattach ubicopy checkfdt cramfsloadfdt "		\
145 		"set_fdthigh cramfsloadkernel flashargs add_default "	\
146 		"addpanic boot\0"					\
147 	"develop="							\
148 		"tftp 200000 scripts/develop-${arch}.txt && "		\
149 		"env import -t 200000 ${filesize} && "			\
150 		"run setup_debug_env\0"					\
151 	"ramfs="							\
152 		"tftp 200000 scripts/ramfs-${arch}.txt && "		\
153 		"env import -t 200000 ${filesize} && "			\
154 		"run setup_debug_env\0"					\
155 	""
156 
157 /*
158  * bootargs
159  * - modify 'bootargs'
160  *
161  * - 'add_default': default bootargs common for all arm/ppc boards
162  * - 'addpanic': add kernel panic options
163  * - 'flashargs': defaults arguments for flash base boot
164  *
165  */
166 #define CONFIG_KM_DEF_ENV_BOOTARGS					\
167 	"add_default="							\
168 		"setenv bootargs ${bootargs} "				\
169 		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"	\
170 		":${hostname}:${netdev}:off:"				\
171 		" console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}"	\
172 		" mem=${kernelmem} init=${init}"			\
173 		CONFIG_KM_ECC_MODE					\
174 		" phram.phram=phvar,${varaddr}," __stringify(CONFIG_KM_PHRAM)\
175 		" " CONFIG_KM_UBI_LINUX_MTD " "				\
176 		CONFIG_KM_DEF_BOOT_ARGS_CPU				\
177 		"\0"							\
178 	"addpanic="							\
179 		"setenv bootargs ${bootargs} panic=1 panic_on_oops=1\0"	\
180 	"flashargs="							\
181 		"setenv bootargs "					\
182 		"root=mtdblock:rootfs${boot_bank} "			\
183 		"rootfstype=squashfs ro\0"				\
184 	""
185 
186 /*
187  * flash_boot
188  * - commands for booting from flash
189  *
190  * - 'cramfsloadkernel': copy kernel from a cramfs to ram
191  * - 'ubiattach': attach ubi partition
192  * - 'ubicopy': copy ubi volume to ram
193  *              - volume names: bootfs0, bootfs1, bootfs2, ...
194  *
195  * processor specific settings
196  * - 'cramfsloadfdt': copy fdt from a cramfs to ram
197  */
198 #define CONFIG_KM_DEF_ENV_FLASH_BOOT					\
199 	"cramfsaddr=" __stringify(CONFIG_KM_CRAMFS_ADDR) "\0"		\
200 	"cramfsloadkernel=cramfsload ${load_addr_r} ${uimage}\0"	\
201 	"ubicopy=ubi read "__stringify(CONFIG_KM_CRAMFS_ADDR)		\
202 			" bootfs${boot_bank}\0"				\
203 	"uimage=" CONFIG_KM_UIMAGE_NAME					\
204 	CONFIG_KM_DEV_ENV_FLASH_BOOT_UBI
205 
206 /*
207  * constants
208  * - KM specific constants and commands
209  *
210  * - 'default': setup default environment
211  */
212 #define CONFIG_KM_DEF_ENV_CONSTANTS					\
213 	"backup_bank=0\0"						\
214 	"release=run newenv; reset\0"					\
215 	"pnvramsize=" __stringify(CONFIG_KM_PNVRAM) "\0"		\
216 	"testbootcmd=setenv boot_bank ${test_bank}; "			\
217 		"run ${subbootcmds}; reset\0"				\
218 	""
219 
220 #ifndef CONFIG_KM_DEF_ENV
221 #define CONFIG_KM_DEF_ENV	\
222 	CONFIG_KM_DEF_ENV_BOOTPARAMS					\
223 	CONFIG_KM_DEF_NETDEV						\
224 	CONFIG_KM_DEF_ENV_CPU						\
225 	CONFIG_KM_DEF_ENV_BOOTTARGETS					\
226 	CONFIG_KM_DEF_ENV_BOOTARGS					\
227 	CONFIG_KM_DEF_ENV_FLASH_BOOT					\
228 	CONFIG_KM_DEF_ENV_CONSTANTS					\
229 	"altbootcmd=run bootcmd\0"					\
230 	"boot=bootm ${load_addr_r} - ${fdt_addr_r}\0"			\
231 	"bootcmd=km_checkbidhwk &&  "					\
232 		"setenv bootcmd \'if km_checktestboot; then; "          \
233 				"setenv boot_bank ${test_bank}; else; " \
234 				"setenv boot_bank ${actual_bank}; fi;"  \
235 			"run ${subbootcmds}; reset\' && "		\
236 		"setenv altbootcmd \'setenv boot_bank ${backup_bank}; "	\
237 			"run ${subbootcmds}; reset\' && "		\
238 		"saveenv && saveenv && boot\0"				\
239 	"bootlimit=3\0"							\
240 	"cramfsloadfdt="						\
241 		"cramfsload ${fdt_addr_r} "				\
242 		"fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb\0"		\
243 	"fdt_addr_r="__stringify(CONFIG_KM_FDT_ADDR) "\0"		\
244 	"init=/sbin/init-overlay.sh\0"					\
245 	"load_addr_r="__stringify(CONFIG_KM_KERNEL_ADDR) "\0"		\
246 	"load=tftpboot ${load_addr_r} ${u-boot}\0"			\
247 	"mtdids=" MTDIDS_DEFAULT "\0"					\
248 	"mtdparts=" MTDPARTS_DEFAULT "\0"				\
249 	""
250 #endif /* CONFIG_KM_DEF_ENV */
251 
252 #define CONFIG_VERSION_VARIABLE	/* include version env variable */
253 
254 #endif /* __CONFIG_KEYMILE_H */
255