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