1 /*
2  * (C) Copyright 2009
3  * Vipin Kumar, STMicroelectronics, <vipin.kumar@st.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef _SPEAR_COMMON_H
9 #define _SPEAR_COMMON_H
10 /*
11  * Common configurations used for both spear3xx as well as spear6xx
12  */
13 
14 /* U-boot Load Address */
15 #define CONFIG_SYS_TEXT_BASE			0x00700000
16 
17 /* Ethernet driver configuration */
18 #define CONFIG_MII
19 #define CONFIG_DESIGNWARE_ETH
20 #define CONFIG_DW_SEARCH_PHY
21 #define CONFIG_DW0_PHY				1
22 #define CONFIG_NET_MULTI
23 #define CONFIG_PHY_RESET_DELAY			10000		/* in usec */
24 #define CONFIG_DW_AUTONEG
25 #define CONFIG_PHY_GIGE			/* Include GbE speed/duplex detection */
26 
27 /* USBD driver configuration */
28 #if defined(CONFIG_SPEAR_USBTTY)
29 #define CONFIG_DW_UDC
30 #define CONFIG_USB_DEVICE
31 #define CONFIG_USBD_HS
32 #define CONFIG_USB_TTY
33 
34 #define CONFIG_USBD_PRODUCT_NAME		"SPEAr SoC"
35 #define CONFIG_USBD_MANUFACTURER		"ST Microelectronics"
36 
37 #endif
38 
39 #define CONFIG_EXTRA_ENV_USBTTY			"usbtty=cdc_acm\0"
40 
41 /* I2C driver configuration */
42 #define CONFIG_HARD_I2C
43 #define CONFIG_DW_I2C
44 #define CONFIG_SYS_I2C_SPEED			400000
45 #define CONFIG_SYS_I2C_SLAVE			0x02
46 
47 #define CONFIG_I2C_CHIPADDRESS			0x50
48 
49 /* Timer, HZ specific defines */
50 
51 /* Flash configuration */
52 #if defined(CONFIG_FLASH_PNOR)
53 #define CONFIG_SPEAR_EMI
54 #else
55 #define CONFIG_ST_SMI
56 #endif
57 
58 #if defined(CONFIG_ST_SMI)
59 
60 #define CONFIG_SYS_MAX_FLASH_BANKS		2
61 #define CONFIG_SYS_FLASH_BASE			0xF8000000
62 #define CONFIG_SYS_CS1_FLASH_BASE		0xF9000000
63 #define CONFIG_SYS_FLASH_BANK_SIZE		0x01000000
64 #define CONFIG_SYS_FLASH_ADDR_BASE		{CONFIG_SYS_FLASH_BASE, \
65 						CONFIG_SYS_CS1_FLASH_BASE}
66 #define CONFIG_SYS_MAX_FLASH_SECT		128
67 
68 #define CONFIG_SYS_FLASH_ERASE_TOUT		(3 * CONFIG_SYS_HZ)
69 #define CONFIG_SYS_FLASH_WRITE_TOUT		(3 * CONFIG_SYS_HZ)
70 
71 #endif
72 
73 /*
74  * Serial Configuration (PL011)
75  * CONFIG_PL01x_PORTS is defined in specific files
76  */
77 #define CONFIG_PL011_SERIAL
78 #define CONFIG_PL011_CLOCK			(48 * 1000 * 1000)
79 #define CONFIG_CONS_INDEX			0
80 #define CONFIG_BAUDRATE				115200
81 #define CONFIG_SYS_BAUDRATE_TABLE		{ 9600, 19200, 38400, \
82 						57600, 115200 }
83 
84 #define CONFIG_SYS_LOADS_BAUD_CHANGE
85 
86 /* NAND FLASH Configuration */
87 #define CONFIG_SYS_NAND_SELF_INIT
88 #define CONFIG_MTD_DEVICE
89 #define CONFIG_MTD_PARTITIONS
90 #define CONFIG_NAND_FSMC
91 #define CONFIG_SYS_MAX_NAND_DEVICE		1
92 #define CONFIG_SYS_NAND_ONFI_DETECTION
93 #define CONFIG_SYS_NAND_QUIET_TEST
94 
95 /*
96  * Command support defines
97  */
98 #define CONFIG_CMD_I2C
99 #define CONFIG_CMD_NAND
100 #define CONFIG_CMD_ENV
101 #define CONFIG_CMD_MEMORY
102 #define CONFIG_CMD_RUN
103 #define CONFIG_CMD_SAVES
104 #define CONFIG_CMD_NET
105 #define CONFIG_CMD_MII
106 #define CONFIG_CMD_PING
107 #define CONFIG_CMD_DHCP
108 
109 /* This must be included AFTER the definition of CONFIG_COMMANDS (if any) */
110 #include <config_cmd_default.h>
111 
112 /*
113  * Default Environment Varible definitions
114  */
115 #if defined(CONFIG_SPEAR_USBTTY)
116 #define CONFIG_BOOTDELAY			-1
117 #else
118 #define CONFIG_BOOTDELAY			1
119 #endif
120 
121 #define CONFIG_ENV_OVERWRITE
122 
123 /*
124  * U-Boot Environment placing definitions.
125  */
126 #if defined(CONFIG_ENV_IS_IN_FLASH)
127 #ifdef CONFIG_ST_SMI
128 /*
129  * Environment is in serial NOR flash
130  */
131 #define CONFIG_SYS_MONITOR_LEN			0x00040000
132 #define CONFIG_ENV_SECT_SIZE			0x00010000
133 #define CONFIG_FSMTDBLK				"/dev/mtdblock3 "
134 
135 #define CONFIG_BOOTCOMMAND			"bootm 0xf8050000"
136 
137 #elif defined(CONFIG_SPEAR_EMI)
138 /*
139  * Environment is in parallel NOR flash
140  */
141 #define CONFIG_SYS_MONITOR_LEN			0x00060000
142 #define CONFIG_ENV_SECT_SIZE			0x00020000
143 #define CONFIG_FSMTDBLK				"/dev/mtdblock3 "
144 
145 #define CONFIG_BOOTCOMMAND			"cp.b 0x50080000 0x1600000 " \
146 						"0x4C0000; bootm 0x1600000"
147 #endif
148 
149 #define CONFIG_ENV_ADDR				(CONFIG_SYS_FLASH_BASE + \
150 						CONFIG_SYS_MONITOR_LEN)
151 #elif defined(CONFIG_ENV_IS_IN_NAND)
152 /*
153  * Environment is in NAND
154  */
155 
156 #define CONFIG_ENV_OFFSET			0x60000
157 #define CONFIG_ENV_RANGE			0x10000
158 #define CONFIG_FSMTDBLK				"/dev/mtdblock7 "
159 
160 #define CONFIG_BOOTCOMMAND			"nand read.jffs2 0x1600000 " \
161 						"0x80000 0x4C0000; " \
162 						"bootm 0x1600000"
163 #endif
164 
165 #define CONFIG_BOOTARGS				"console=ttyAMA0,115200 " \
166 						"mem=128M " \
167 						"root="CONFIG_FSMTDBLK \
168 						"rootfstype=jffs2"
169 
170 #define CONFIG_NFSBOOTCOMMAND						\
171 	"bootp; "							\
172 	"setenv bootargs root=/dev/nfs rw "				\
173 	"nfsroot=$(serverip):$(rootpath) "				\
174 	"ip=$(ipaddr):$(serverip):$(gatewayip):"			\
175 			"$(netmask):$(hostname):$(netdev):off "		\
176 			"console=ttyAMA0,115200 $(othbootargs);"	\
177 	"bootm; "
178 
179 #define CONFIG_RAMBOOTCOMMAND						\
180 	"setenv bootargs root=/dev/ram rw "				\
181 		"console=ttyAMA0,115200 $(othbootargs);"		\
182 	CONFIG_BOOTCOMMAND
183 
184 
185 #define CONFIG_ENV_SIZE				0x02000
186 #define CONFIG_SYS_MONITOR_BASE			CONFIG_SYS_TEXT_BASE
187 
188 /* Miscellaneous configurable options */
189 #define CONFIG_ARCH_CPU_INIT
190 #define CONFIG_BOARD_EARLY_INIT_F
191 #define CONFIG_DISPLAY_CPUINFO
192 #define CONFIG_BOOT_PARAMS_ADDR			0x00000100
193 #define CONFIG_CMDLINE_TAG
194 #define CONFIG_SETUP_MEMORY_TAGS
195 #define CONFIG_MISC_INIT_R
196 #define CONFIG_ZERO_BOOTDELAY_CHECK
197 #define CONFIG_AUTOBOOT_KEYED
198 #define CONFIG_AUTOBOOT_STOP_STR		" "
199 #define CONFIG_AUTOBOOT_PROMPT			\
200 		"Hit SPACE in %d seconds to stop autoboot.\n", bootdelay
201 
202 #define CONFIG_SYS_MEMTEST_START		0x00800000
203 #define CONFIG_SYS_MEMTEST_END			0x04000000
204 #define CONFIG_SYS_MALLOC_LEN			(1024*1024)
205 #define CONFIG_IDENT_STRING			"-SPEAr"
206 #define CONFIG_SYS_LONGHELP
207 #define CONFIG_SYS_PROMPT			"u-boot> "
208 #define CONFIG_CMDLINE_EDITING
209 #define CONFIG_SYS_CBSIZE			256
210 #define CONFIG_SYS_PBSIZE			(CONFIG_SYS_CBSIZE + \
211 						sizeof(CONFIG_SYS_PROMPT) + 16)
212 #define CONFIG_SYS_MAXARGS			16
213 #define CONFIG_SYS_BARGSIZE			CONFIG_SYS_CBSIZE
214 #define CONFIG_SYS_LOAD_ADDR			0x00800000
215 #define CONFIG_SYS_CONSOLE_INFO_QUIET
216 
217 #define CONFIG_SYS_FLASH_EMPTY_INFO
218 
219 /* Physical Memory Map */
220 #define CONFIG_NR_DRAM_BANKS			1
221 #define PHYS_SDRAM_1				0x00000000
222 #define PHYS_SDRAM_1_MAXSIZE			0x40000000
223 
224 #define CONFIG_SYS_SDRAM_BASE			PHYS_SDRAM_1
225 #define CONFIG_SYS_INIT_RAM_ADDR		0xD2800000
226 #define CONFIG_SYS_INIT_RAM_SIZE		0x2000
227 
228 #define CONFIG_SYS_INIT_SP_OFFSET		\
229 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
230 
231 #define CONFIG_SYS_INIT_SP_ADDR			\
232 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
233 
234 #endif
235