1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2007-2010 Michal Simek
4  *
5  * Michal SIMEK <monstr@monstr.eu>
6  */
7 
8 #ifndef __CONFIG_H
9 #define __CONFIG_H
10 
11 #include "../board/xilinx/microblaze-generic/xparameters.h"
12 
13 /* MicroBlaze CPU */
14 #define	MICROBLAZE_V5		1
15 
16 /* linear and spi flash memory */
17 #ifdef XILINX_FLASH_START
18 #define	FLASH
19 #undef	SPIFLASH
20 #undef	RAMENV	/* hold environment in flash */
21 #else
22 #ifdef XILINX_SPI_FLASH_BASEADDR
23 #undef	FLASH
24 #define	SPIFLASH
25 #undef	RAMENV	/* hold environment in flash */
26 #else
27 #undef	FLASH
28 #undef	SPIFLASH
29 #define	RAMENV	/* hold environment in RAM */
30 #endif
31 #endif
32 
33 /* uart */
34 /* The following table includes the supported baudrates */
35 # define CONFIG_SYS_BAUDRATE_TABLE \
36 	{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
37 
38 /* setting reset address */
39 /*#define	CONFIG_SYS_RESET_ADDRESS	CONFIG_SYS_TEXT_BASE*/
40 
41 #define CONFIG_SYS_MALLOC_LEN	0xC0000
42 
43 /* Stack location before relocation */
44 #define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_TEXT_BASE - \
45 					 CONFIG_SYS_MALLOC_F_LEN)
46 
47 /*
48  * CFI flash memory layout - Example
49  * CONFIG_SYS_FLASH_BASE = 0x2200_0000;
50  * CONFIG_SYS_FLASH_SIZE = 0x0080_0000;	  8MB
51  *
52  * SECT_SIZE = 0x20000;			128kB is one sector
53  * CONFIG_ENV_SIZE = SECT_SIZE;		128kB environment store
54  *
55  * 0x2200_0000	CONFIG_SYS_FLASH_BASE
56  *					FREE		256kB
57  * 0x2204_0000	CONFIG_ENV_ADDR
58  *					ENV_AREA	128kB
59  * 0x2206_0000
60  *					FREE
61  * 0x2280_0000	CONFIG_SYS_FLASH_BASE + CONFIG_SYS_FLASH_SIZE
62  *
63  */
64 
65 #ifdef FLASH
66 # define CONFIG_SYS_FLASH_BASE		XILINX_FLASH_START
67 # define CONFIG_SYS_FLASH_SIZE		XILINX_FLASH_SIZE
68 # define CONFIG_SYS_FLASH_CFI		1
69 # define CONFIG_FLASH_CFI_DRIVER	1
70 /* ?empty sector */
71 # define CONFIG_SYS_FLASH_EMPTY_INFO	1
72 /* max number of memory banks */
73 # define CONFIG_SYS_MAX_FLASH_BANKS	1
74 /* max number of sectors on one chip */
75 # define CONFIG_SYS_MAX_FLASH_SECT	512
76 /* hardware flash protection */
77 # define CONFIG_SYS_FLASH_PROTECTION
78 /* use buffered writes (20x faster) */
79 # define	CONFIG_SYS_FLASH_USE_BUFFER_WRITE	1
80 # ifdef	RAMENV
81 #  define CONFIG_ENV_SIZE	0x1000
82 #  define CONFIG_ENV_ADDR	(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
83 
84 # else	/* FLASH && !RAMENV */
85 /* 128K(one sector) for env */
86 #  define CONFIG_ENV_SECT_SIZE	0x20000
87 #  define CONFIG_ENV_ADDR \
88 			(CONFIG_SYS_FLASH_BASE + (2 * CONFIG_ENV_SECT_SIZE))
89 #  define CONFIG_ENV_SIZE	0x20000
90 # endif /* FLASH && !RAMBOOT */
91 #else /* !FLASH */
92 
93 #ifdef SPIFLASH
94 # define CONFIG_SYS_SPI_BASE		XILINX_SPI_FLASH_BASEADDR
95 # define CONFIG_SF_DEFAULT_MODE		SPI_MODE_3
96 # define CONFIG_SF_DEFAULT_SPEED	XILINX_SPI_FLASH_MAX_FREQ
97 # define CONFIG_SF_DEFAULT_CS		XILINX_SPI_FLASH_CS
98 
99 # ifdef	RAMENV
100 #  define CONFIG_ENV_SIZE	0x1000
101 #  define CONFIG_ENV_ADDR	(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
102 
103 # else	/* SPIFLASH && !RAMENV */
104 #  define CONFIG_ENV_SPI_MODE		SPI_MODE_3
105 #  define CONFIG_ENV_SPI_MAX_HZ		CONFIG_SF_DEFAULT_SPEED
106 #  define CONFIG_ENV_SPI_CS		CONFIG_SF_DEFAULT_CS
107 /* 128K(two sectors) for env */
108 #  define CONFIG_ENV_SECT_SIZE	0x10000
109 #  define CONFIG_ENV_SIZE	(2 * CONFIG_ENV_SECT_SIZE)
110 /* Warning: adjust the offset in respect of other flash content and size */
111 #  define CONFIG_ENV_OFFSET	(128 * CONFIG_ENV_SECT_SIZE) /* at 8MB */
112 # endif /* SPIFLASH && !RAMBOOT */
113 #else /* !SPIFLASH */
114 
115 /* ENV in RAM */
116 # define CONFIG_ENV_SIZE	0x1000
117 # define CONFIG_ENV_ADDR	(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
118 #endif /* !SPIFLASH */
119 #endif /* !FLASH */
120 
121 #if defined(XILINX_USE_ICACHE)
122 # define CONFIG_ICACHE
123 #else
124 # undef CONFIG_ICACHE
125 #endif
126 
127 #if defined(XILINX_USE_DCACHE)
128 # define CONFIG_DCACHE
129 #else
130 # undef CONFIG_DCACHE
131 #endif
132 
133 #ifndef XILINX_DCACHE_BYTE_SIZE
134 #define XILINX_DCACHE_BYTE_SIZE	32768
135 #endif
136 
137 /*
138  * BOOTP options
139  */
140 #define CONFIG_BOOTP_BOOTFILESIZE
141 
142 #if defined(CONFIG_CMD_JFFS2)
143 # define CONFIG_MTD_PARTITIONS
144 #endif
145 
146 #if defined(CONFIG_CMD_UBI)
147 # define CONFIG_MTD_PARTITIONS
148 #endif
149 
150 #if defined(CONFIG_MTD_PARTITIONS)
151 /* MTD partitions */
152 #define CONFIG_MTD_DEVICE	/* needed for mtdparts commands */
153 #define CONFIG_FLASH_CFI_MTD
154 
155 /* default mtd partition table */
156 #endif
157 
158 /* size of console buffer */
159 #define	CONFIG_SYS_CBSIZE	512
160 /* max number of command args */
161 #define	CONFIG_SYS_MAXARGS	15
162 /* default load address */
163 #define	CONFIG_SYS_LOAD_ADDR	0
164 
165 #define	CONFIG_HOSTNAME		"microblaze-generic"
166 #define	CONFIG_BOOTCOMMAND	"base 0;tftp 11000000 image.img;bootm"
167 
168 /* architecture dependent code */
169 #define	CONFIG_SYS_USR_EXCEP	/* user exception */
170 
171 #define	CONFIG_PREBOOT	"echo U-BOOT for ${hostname};setenv preboot;echo"
172 
173 #ifndef CONFIG_EXTRA_ENV_SETTINGS
174 #define	CONFIG_EXTRA_ENV_SETTINGS	"unlock=yes\0" \
175 					"nor0=flash-0\0"\
176 					"mtdparts=mtdparts=flash-0:"\
177 					"256k(u-boot),256k(env),3m(kernel),"\
178 					"1m(romfs),1m(cramfs),-(jffs2)\0"\
179 					"nc=setenv stdout nc;"\
180 					"setenv stdin nc\0" \
181 					"serial=setenv stdout serial;"\
182 					"setenv stdin serial\0"
183 #endif
184 
185 /* Enable flat device tree support */
186 #define CONFIG_LMB		1
187 
188 #if defined(CONFIG_XILINX_AXIEMAC)
189 # define CONFIG_MII		1
190 # define CONFIG_SYS_FAULT_ECHO_LINK_DOWN	1
191 #else
192 # undef CONFIG_MII
193 #endif
194 
195 /* SPL part */
196 
197 #ifdef CONFIG_SYS_FLASH_BASE
198 # define CONFIG_SYS_UBOOT_BASE		CONFIG_SYS_FLASH_BASE
199 #endif
200 
201 /* for booting directly linux */
202 
203 #define CONFIG_SYS_FDT_BASE		(CONFIG_SYS_FLASH_BASE + \
204 					 0x40000)
205 #define CONFIG_SYS_FDT_SIZE		(16 << 10)
206 #define CONFIG_SYS_SPL_ARGS_ADDR	(CONFIG_SYS_TEXT_BASE + \
207 					 0x1000000)
208 
209 /* SP location before relocation, must use scratch RAM */
210 /* BRAM start */
211 #define CONFIG_SYS_INIT_RAM_ADDR	0x0
212 /* BRAM size - will be generated */
213 #define CONFIG_SYS_INIT_RAM_SIZE	0x100000
214 
215 # define CONFIG_SPL_STACK_ADDR		(CONFIG_SYS_INIT_RAM_ADDR + \
216 					 CONFIG_SYS_INIT_RAM_SIZE - \
217 					 CONFIG_SYS_MALLOC_F_LEN)
218 
219 /* Just for sure that there is a space for stack */
220 #define CONFIG_SPL_STACK_SIZE		0x100
221 
222 #define CONFIG_SYS_UBOOT_START		CONFIG_SYS_TEXT_BASE
223 
224 #define CONFIG_SPL_MAX_FOOTPRINT	(CONFIG_SYS_INIT_RAM_SIZE - \
225 					 CONFIG_SYS_INIT_RAM_ADDR - \
226 					 CONFIG_SYS_MALLOC_F_LEN - \
227 					 CONFIG_SPL_STACK_SIZE)
228 
229 #endif	/* __CONFIG_H */
230