xref: /openbmc/u-boot/include/configs/km/keymile-common.h (revision 92c91080e41b36146985fc6d5bf9d35bb162d034)
1 /*
2  * (C) Copyright 2008-2011
3  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 
24 #ifndef __CONFIG_KEYMILE_H
25 #define __CONFIG_KEYMILE_H
26 
27 /* Do boardspecific init for all boards */
28 #define CONFIG_BOARD_EARLY_INIT_R
29 #define CONFIG_LAST_STAGE_INIT
30 
31 #define CONFIG_BOOTCOUNT_LIMIT
32 
33 /*
34  * By default kwbimage.cfg from board specific folder is used
35  * If for some board, different configuration file need to be used,
36  * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file
37  */
38 #ifndef CONFIG_SYS_KWD_CONFIG
39 #define	CONFIG_SYS_KWD_CONFIG	$(SRCTREE)/$(CONFIG_BOARDDIR)/kwbimage.cfg
40 #endif /* CONFIG_SYS_KWD_CONFIG */
41 
42 /*
43  * Command line configuration.
44  */
45 #include <config_cmd_default.h>
46 
47 #define CONFIG_CMD_ASKENV
48 #define CONFIG_CMD_DHCP
49 #define CONFIG_CMD_ECHO
50 #define CONFIG_CMD_IMMAP
51 #define CONFIG_CMD_MII
52 #define CONFIG_CMD_PING
53 #define CONFIG_CMD_EEPROM
54 #define CONFIG_CMD_I2C
55 #define CONFIG_CMD_JFFS2
56 #define CONFIG_CMD_MTDPARTS
57 #define CONFIG_CMD_SETEXPR
58 
59 #undef	CONFIG_WATCHDOG		/* disable platform specific watchdog */
60 
61 #define CONFIG_BOOTDELAY	2 /* autoboot after 2 seconds */
62 #undef	CONFIG_BOOTARGS		/* the boot command will set bootargs */
63 
64 /*
65  * Miscellaneous configurable options
66  */
67 #define CONFIG_SYS_HUSH_PARSER
68 #define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
69 #define CONFIG_SYS_LONGHELP			/* undef to save memory	  */
70 #define CONFIG_SYS_PROMPT		"=> "	/* Monitor Command Prompt */
71 #if defined(CONFIG_CMD_KGDB)
72 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
73 #else
74 #define CONFIG_SYS_CBSIZE		512	/* Console I/O Buffer Size  */
75 #endif
76 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
77 #define CONFIG_SYS_MAXARGS		32 /* max number of command args */
78 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
79 #define CONFIG_CMDLINE_EDITING
80 #define CONFIG_AUTO_COMPLETE
81 
82 #define CONFIG_HUSH_INIT_VAR
83 
84 #define CONFIG_SYS_ALT_MEMTEST		/* memory test, takes time */
85 
86 #define CONFIG_SYS_HZ			1000	/* decr. freq: 1 ms ticks */
87 
88 #define CONFIG_BAUDRATE			115200
89 #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400 }
90 
91 #define CONFIG_LOADS_ECHO
92 #define CONFIG_SYS_LOADS_BAUD_CHANGE
93 #define CONFIG_SYS_BOARD_DRAM_INIT	/* Used board specific dram_init */
94 
95 /*
96  * How to get access to the slot ID.  Put this here to make it easy
97  * to modify in a centralized location.  This is used in the HDLC
98  * driver to set the MAC.
99 */
100 #define CONFIG_CHECK_ETHERNET_PRESENT
101 #define CONFIG_SYS_SLOT_ID_BASE		CONFIG_SYS_KMBEC_FPGA_BASE
102 #define CONFIG_SYS_SLOT_ID_OFF		(0x07)	/* register offset */
103 #define CONFIG_SYS_SLOT_ID_MASK		(0x3f)	/* mask for slot ID bits */
104 
105 #define CONFIG_I2C_MULTI_BUS
106 #define CONFIG_SYS_MAX_I2C_BUS		1
107 #define CONFIG_SYS_I2C_INIT_BOARD
108 #define CONFIG_I2C_MUX
109 
110 /* EEprom support */
111 #define CONFIG_SYS_I2C_MULTI_EEPROMS
112 #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
113 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
114 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
115 
116 /* Support the IVM EEprom */
117 #define	CONFIG_SYS_IVM_EEPROM_ADR	0x50
118 #define CONFIG_SYS_IVM_EEPROM_MAX_LEN	0x400
119 #define CONFIG_SYS_IVM_EEPROM_PAGE_LEN	0x100
120 
121 #define	CONFIG_SYS_FLASH_PROTECTION
122 
123 /*
124  * BOOTP options
125  */
126 #define CONFIG_BOOTP_BOOTFILESIZE
127 #define CONFIG_BOOTP_BOOTPATH
128 #define CONFIG_BOOTP_GATEWAY
129 #define CONFIG_BOOTP_HOSTNAME
130 
131 #define CONFIG_SYS_MALLOC_LEN		(4 * 1024 * 1024)
132 
133 /* UBI Support for all Keymile boards */
134 #define CONFIG_CMD_UBI
135 #define CONFIG_RBTREE
136 #define CONFIG_MTD_PARTITIONS
137 #define CONFIG_MTD_DEVICE
138 #define CONFIG_MTD_CONCAT
139 
140 /* common powerpc specific env settings */
141 #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
142 #define CONFIG_KM_DEF_ENV_BOOTPARAMS \
143 	"bootparams=empty\0"	\
144 	"initial_boot_bank=0\0"
145 #endif
146 
147 #ifndef CONFIG_KM_DEF_NETDEV
148 #define CONFIG_KM_DEF_NETDEV	\
149 	"netdev=eth0\0"
150 #endif
151 
152 #ifndef CONFIG_KM_UBI_PARTITION_NAME
153 #define CONFIG_KM_UBI_PARTITION_NAME	"ubi0"
154 #endif
155 #ifndef CONFIG_KM_UBI_LINUX_MTD_NAME
156 #define CONFIG_KM_UBI_LINUX_MTD_NAME	"ubi0"
157 #endif
158 
159 #define xstr(s)	str(s)
160 #define str(s)	#s
161 
162 /*
163  * bootrunner
164  * - run all commands in 'subbootcmds'
165  * - on error, stop running the remaing commands
166  */
167 #define CONFIG_KM_DEF_ENV_BOOTRUNNER					\
168 	"bootrunner="							\
169 		"break=0; "						\
170 		"for subbootcmd in ${subbootcmds}; do "			\
171 		"if test ${break} -eq 0; then; "			\
172 		"echo \"[INFO] running \\c\"; "				\
173 		"print ${subbootcmd}; "					\
174 		"run ${subbootcmd} || break=1; "			\
175 		"if test ${break} -eq 1; then; "			\
176 		"echo \"[ERR] failed \\c\"; "				\
177 		"print ${subbootcmd}; "					\
178 		"fi; "							\
179 		"fi; "							\
180 		"done\0"						\
181 	""
182 
183 /*
184  * boottargets
185  * - set 'subbootcmds' for the bootrunner
186  * - set 'bootcmd' and 'altbootcmd'
187  * available targets:
188  * - 'release': for a standalone system		kernel/rootfs from flash
189  * - 'develop': for development			kernel(tftp)/rootfs(NFS)
190  * - 'ramfs': rootfilesystem in RAM		kernel(tftp)/rootfs(RAM)
191  *
192  * - 'commonargs': bootargs common to all targets
193  */
194 #define CONFIG_KM_DEF_ENV_BOOTTARGETS					\
195 	"commonargs="							\
196 		"addip "						\
197 		"addtty "						\
198 		"addmem "						\
199 		"addinit "						\
200 		"addvar "						\
201 		"addmtdparts "						\
202 		"addbootcount "						\
203 		"\0"							\
204 	"develop="							\
205 		"setenv subbootcmds \""					\
206 		"tftpfdt tftpkernel "					\
207 		"nfsargs ${commonargs} "				\
208 		"printbootargs boot "					\
209 		"\" && "						\
210 		"setenv bootcmd \'"					\
211 		"run bootrunner"					\
212 		"\' && "						\
213 		"setenv altbootcmd \'"					\
214 		"run bootcmd"						\
215 		"\' && "						\
216 		"run setboardid && "					\
217 		"saveenv && "						\
218 		"reset\0"						\
219 	"ramfs="							\
220 		"setenv actual_bank -1 && "				\
221 		"setenv subbootcmds \""					\
222 		"tftpfdt tftpkernel "					\
223 		"setrootfsaddr tftpramfs "				\
224 		"flashargs ${commonargs} "				\
225 		"addpanic addramfs "					\
226 		"printbootargs boot "					\
227 		"\" && "						\
228 		"setenv bootcmd \'"					\
229 		"run bootrunner"					\
230 		"\' && "						\
231 		"setenv altbootcmd \'"					\
232 		"run bootcmd"						\
233 		"\' && "						\
234 		"run setboardid && "					\
235 		"run setramfspram && "					\
236 		"saveenv && "						\
237 		"reset\0"						\
238 	"release="							\
239 		"setenv actual_bank ${initial_boot_bank} && "		\
240 		"setenv subbootcmds \""					\
241 		"checkboardid "						\
242 		"ubiattach ubicopy "					\
243 		"cramfsloadfdt cramfsloadkernel "			\
244 		"flashargs ${commonargs} "				\
245 		"addpanic "						\
246 		"printbootargs boot "					\
247 		"\" && "						\
248 		"setenv bootcmd \'"					\
249 		"run actual bootrunner; reset"				\
250 		"\' && "						\
251 		"setenv altbootcmd \'"					\
252 		"run backup bootrunner; reset"				\
253 		"\' && "						\
254 		"saveenv && "						\
255 		"reset\0"						\
256 	""
257 
258 /*
259  * bootargs
260  * - modify 'bootargs'
261  *
262  * - 'addip': add ip configuration
263  * - 'addmem': limit kernel memory mem=
264  * - 'addpanic': add kernel panic options
265  * - 'addramfs': add phram device for the rootfilesysten in ram
266  * - 'addtty': add console=...
267  * - 'addvar': add phram device for /var
268  * - 'nfsargs': default arguments for nfs boot
269  * - 'flashargs': defaults arguments for flash base boot
270  *
271  * processor specific settings
272  * - 'addbootcount': add boot counter
273  * - 'addmtdparts': add mtd partition information
274  */
275 #define CONFIG_KM_DEF_ENV_BOOTARGS					\
276 	"addinit="							\
277 		"setenv bootargs ${bootargs} init=${init}\0"		\
278 	"addip="							\
279 		"setenv bootargs ${bootargs} "				\
280 		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"	\
281 		":${hostname}:${netdev}:off\0"				\
282 	"addmem="							\
283 		"setenv bootargs ${bootargs} mem=0x${pnvramaddr}\0"	\
284 	"addpanic="							\
285 		"setenv bootargs ${bootargs} "				\
286 		"panic=1 panic_on_oops=1\0"				\
287 	"addramfs="							\
288 		"setenv bootargs \""					\
289 		"${bootargs} phram.phram="				\
290 		"rootfs${boot_bank},${rootfsaddr},${rootfssize}\"\0"	\
291 	"addtty="							\
292 		"setenv bootargs ${bootargs}"				\
293 		" console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}\0"	\
294 	"addvar="							\
295 		"setenv bootargs ${bootargs} phram.phram=phvar,"	\
296 		"${varaddr},0x" xstr(CONFIG_KM_PHRAM) "\0"		\
297 	"nfsargs="							\
298 		"setenv bootargs "					\
299 		"ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " "		\
300 		"root=/dev/nfs rw "					\
301 		"nfsroot=${serverip}:${rootpath}\0"			\
302 	"flashargs="							\
303 		"setenv bootargs "					\
304 		"ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " "		\
305 		"root=mtdblock:rootfs${boot_bank} "			\
306 		"rootfstype=squashfs ro\0"				\
307 	""
308 
309 /*
310  * compute_addr
311  * - compute addresses and sizes
312  * - addresses are calculated form the end of memory 'memsize'
313  *
314  * - 'setramfspram': compute PRAM size for ramfs target
315  * - 'setrootfsaddr': compute rootfilesystem address for phram
316  */
317 #define CONFIG_KM_DEF_ENV_COMPUTE_ADDR					\
318 	"setboardid="							\
319 		"if test \"x${boardId}\" = \"x\"; then; "		\
320 		"setenv boardId ${IVM_BoardId} && "			\
321 		"setenv hwKey ${IVM_HWKey}; "				\
322 		"else; "						\
323 		"echo \\\\c; "						\
324 		"fi\0"							\
325 	"setramfspram="							\
326 		"setexpr value ${rootfssize} / 0x400 && "		\
327 		"setexpr value 0x${value} + ${pram} && "		\
328 		"setenv pram 0x${value}\0"				\
329 	"setrootfsaddr="						\
330 		"setexpr value ${pnvramaddr} - ${rootfssize} && "	\
331 		"setenv rootfsaddr 0x${value}\0"			\
332 	""
333 
334 /*
335  * flash_boot
336  * - commands for booting from flash
337  *
338  * - 'cramfsaddr': address to the cramfs (in ram)
339  * - 'cramfsloadkernel': copy kernel from a cramfs to ram
340  * - 'ubiattach': attach ubi partition
341  * - 'ubicopy': copy ubi volume to ram
342  *              - volume names: bootfs0, bootfs1, bootfs2, ...
343  * - 'ubiparition': mtd parition name for ubi
344  *
345  * processor specific settings
346  * - 'cramfsloadfdt': copy fdt from a cramfs to ram
347  */
348 #define CONFIG_KM_DEF_ENV_FLASH_BOOT					\
349 	"cramfsaddr="xstr(CONFIG_KM_CRAMFS_ADDR) "\0"			\
350 	"cramfsloadkernel="						\
351 		"cramfsload ${kernel_addr_r} uImage && "		\
352 		"setenv actual_kernel_addr ${kernel_addr_r}\0"		\
353 	"ubiattach=ubi part ${ubipartition}\0"				\
354 	"ubicopy=ubi read ${cramfsaddr} bootfs${boot_bank}\0"		\
355 	"ubipartition=" CONFIG_KM_UBI_PARTITION_NAME "\0"		\
356 	""
357 
358 /*
359  * net_boot
360  * - commands for booting over the network
361  *
362  * - 'tftpkernel': load a kernel with tftp into ram
363  * - 'tftpramfs': load rootfs with tftp into ram
364  *
365  * processor specific settings
366  * - 'tftpfdt': load fdt with tftp into ram
367  */
368 #define CONFIG_KM_DEF_ENV_NET_BOOT					\
369 	"tftpkernel="							\
370 		"tftpboot ${kernel_addr_r} ${kernel_file} && "		\
371 		"setenv actual_kernel_addr ${kernel_addr_r}\0"		\
372 	"tftpramfs="							\
373 		"tftpboot ${rootfsaddr} \"\\\"${rootfsfile}\\\"\" && "	\
374 		"setenv loadaddr\0"					\
375 	""
376 
377 /*
378  * constants
379  * - KM specific constants and commands
380  *
381  * - 'default': setup default environment
382  */
383 #define CONFIG_KM_DEF_ENV_CONSTANTS					\
384 	"actual=setenv boot_bank ${actual_bank}\0"			\
385 	"backup=setenv boot_bank ${backup_bank}\0"			\
386 	"actual_bank=${initial_boot_bank}\0"				\
387 	"backup_bank=0\0"						\
388 	"default="							\
389 		"setenv default 'run newenv; reset' &&  "		\
390 		"run release && saveenv; reset\0"			\
391 	"printbootargs=print bootargs\0"				\
392 	"rootfsfile="xstr(CONFIG_HOSTNAME) "/rootfsImage\0"		\
393 	"checkboardid=km_checkbidhwk\0"					\
394 	""
395 
396 #ifndef CONFIG_KM_DEF_ENV
397 #define CONFIG_KM_DEF_ENV	\
398 	CONFIG_KM_DEF_ENV_BOOTPARAMS					\
399 	CONFIG_KM_DEF_NETDEV						\
400 	CONFIG_KM_DEF_ENV_CPU						\
401 	CONFIG_KM_DEF_ENV_BOOTRUNNER					\
402 	CONFIG_KM_DEF_ENV_BOOTTARGETS					\
403 	CONFIG_KM_DEF_ENV_BOOTARGS					\
404 	CONFIG_KM_DEF_ENV_COMPUTE_ADDR					\
405 	CONFIG_KM_DEF_ENV_FLASH_BOOT					\
406 	CONFIG_KM_DEF_ENV_NET_BOOT					\
407 	CONFIG_KM_DEF_ENV_CONSTANTS					\
408 	"altbootcmd=run bootcmd\0"					\
409 	"bootcmd=run default\0"						\
410 	"bootlimit=2\0"							\
411 	"init=/sbin/init-overlay.sh\0"					\
412 	"kernel_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0"		\
413 	"kernel_file="xstr(CONFIG_HOSTNAME) "/uImage\0"			\
414 	"kernel_name=uImage\0"						\
415 	"load=tftpboot ${u-boot_addr_r} ${u-boot}\0"			\
416 	"mtdids=" MTDIDS_DEFAULT "\0"					\
417 	"mtdparts=" MTDPARTS_DEFAULT "\0"				\
418 	"stderr=serial\0"						\
419 	"stdin=serial\0"						\
420 	"stdout=serial\0"						\
421 	"u-boot="xstr(CONFIG_HOSTNAME) "/u-boot.bin\0"			\
422 	"u-boot_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0"		\
423 	""
424 #endif /* CONFIG_KM_DEF_ENV */
425 
426 #define CONFIG_VERSION_VARIABLE	/* include version env variable */
427 
428 #endif /* __CONFIG_KEYMILE_H */
429