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