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