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