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