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