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