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