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