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