1 /*
2  * Copyright (C) 2013 Marek Vasut <marex@denx.de>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 #ifndef __MX23_OLINUXINO_CONFIG_H__
7 #define __MX23_OLINUXINO_CONFIG_H__
8 
9 #include <asm/arch/iomux-mx23.h>
10 
11 /*
12  * SoC configurations
13  */
14 #define CONFIG_MX23				/* i.MX23 SoC */
15 #define CONFIG_MXS_GPIO				/* GPIO control */
16 #define CONFIG_SYS_HZ		1000		/* Ticks per second */
17 
18 #define CONFIG_MACH_TYPE	4105
19 
20 #include <asm/arch/regs-base.h>
21 
22 #define CONFIG_SYS_NO_FLASH
23 #define CONFIG_BOARD_EARLY_INIT_F
24 #define CONFIG_ARCH_MISC_INIT
25 
26 /*
27  * SPL
28  */
29 #define CONFIG_SPL
30 #define CONFIG_SPL_NO_CPU_SUPPORT_CODE
31 #define CONFIG_SPL_START_S_PATH		"arch/arm/cpu/arm926ejs/mxs"
32 #define CONFIG_SPL_LDSCRIPT	"arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds"
33 #define CONFIG_SPL_LIBCOMMON_SUPPORT
34 #define CONFIG_SPL_LIBGENERIC_SUPPORT
35 #define CONFIG_SPL_GPIO_SUPPORT
36 
37 /*
38  * U-Boot Commands
39  */
40 #include <config_cmd_default.h>
41 #define CONFIG_DISPLAY_CPUINFO
42 #define CONFIG_DOS_PARTITION
43 
44 #define CONFIG_CMD_CACHE
45 #define CONFIG_CMD_DHCP
46 #define CONFIG_CMD_EXT2
47 #define CONFIG_CMD_FAT
48 #define CONFIG_CMD_GPIO
49 #define CONFIG_CMD_LED
50 #define CONFIG_CMD_MMC
51 #define CONFIG_CMD_NET
52 #define CONFIG_CMD_USB
53 
54 /*
55  * Memory configurations
56  */
57 #define CONFIG_NR_DRAM_BANKS		1		/* 1 bank of DRAM */
58 #define PHYS_SDRAM_1			0x40000000	/* Base address */
59 #define PHYS_SDRAM_1_SIZE		0x08000000	/* Max 128 MB RAM */
60 #define CONFIG_SYS_MALLOC_LEN		0x00400000	/* 4 MB for malloc */
61 #define CONFIG_SYS_GBL_DATA_SIZE	128		/* Initial data */
62 #define CONFIG_SYS_MEMTEST_START	0x40000000	/* Memtest start adr */
63 #define CONFIG_SYS_MEMTEST_END		0x40400000	/* 4 MB RAM test */
64 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
65 /* Point initial SP in SRAM so SPL can use it too. */
66 
67 #define CONFIG_SYS_INIT_RAM_ADDR	0x00000000
68 #define CONFIG_SYS_INIT_RAM_SIZE	(128 * 1024)
69 
70 #define CONFIG_SYS_INIT_SP_OFFSET \
71 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
72 #define CONFIG_SYS_INIT_SP_ADDR \
73 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
74 /*
75  * We need to sacrifice first 4 bytes of RAM here to avoid triggering some
76  * strange BUG in ROM corrupting first 4 bytes of RAM when loading U-Boot
77  * binary. In case there was more of this mess, 0x100 bytes are skipped.
78  */
79 #define CONFIG_SYS_TEXT_BASE		0x40000100
80 
81 /*
82  * U-Boot general configurations
83  */
84 #define CONFIG_SYS_LONGHELP
85 #define CONFIG_SYS_PROMPT	"=> "
86 #define CONFIG_SYS_CBSIZE	1024		/* Console I/O buffer size */
87 #define CONFIG_SYS_PBSIZE	\
88 	(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
89 						/* Print buffer size */
90 #define CONFIG_SYS_MAXARGS	32		/* Max number of command args */
91 #define CONFIG_SYS_BARGSIZE	CONFIG_SYS_CBSIZE
92 						/* Boot argument buffer size */
93 #define CONFIG_VERSION_VARIABLE			/* U-BOOT version */
94 #define CONFIG_AUTO_COMPLETE			/* Command auto complete */
95 #define CONFIG_CMDLINE_EDITING			/* Command history etc */
96 #define CONFIG_SYS_HUSH_PARSER
97 
98 /*
99  * Serial Driver
100  */
101 #define CONFIG_PL011_SERIAL
102 #define CONFIG_PL011_CLOCK		24000000
103 #define CONFIG_PL01x_PORTS		{ (void *)MXS_UARTDBG_BASE }
104 #define CONFIG_CONS_INDEX		0
105 #define CONFIG_BAUDRATE			115200	/* Default baud rate */
106 
107 /*
108  * Status LED
109  */
110 #define CONFIG_STATUS_LED
111 #define CONFIG_GPIO_LED
112 #define CONFIG_BOARD_SPECIFIC_LED
113 #define STATUS_LED_BOOT	0
114 #define STATUS_LED_BIT	MX23_PAD_SSP1_DETECT__GPIO_2_1
115 #define STATUS_LED_STATE	STATUS_LED_ON
116 #define STATUS_LED_PERIOD	(CONFIG_SYS_HZ / 2)
117 
118 /*
119  * MMC Driver
120  */
121 #ifdef CONFIG_CMD_MMC
122 #define CONFIG_MMC
123 #define CONFIG_BOUNCE_BUFFER
124 #define CONFIG_GENERIC_MMC
125 #define CONFIG_MXS_MMC
126 #endif
127 
128 /*
129  * APBH DMA
130  */
131 #define CONFIG_APBH_DMA
132 
133 /* USB */
134 #ifdef CONFIG_CMD_USB
135 #define CONFIG_USB_EHCI
136 #define CONFIG_USB_EHCI_MXS
137 #define CONFIG_EHCI_MXS_PORT0
138 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
139 #define CONFIG_EHCI_IS_TDI
140 #define CONFIG_USB_STORAGE
141 #endif
142 
143 /* Ethernet */
144 #ifdef CONFIG_CMD_NET
145 #define CONFIG_USB_HOST_ETHER
146 #define CONFIG_USB_ETHER_SMSC95XX
147 #endif
148 
149 /*
150  * Boot Linux
151  */
152 #define CONFIG_CMDLINE_TAG
153 #define CONFIG_SETUP_MEMORY_TAGS
154 #define CONFIG_BOOTDELAY	3
155 #define CONFIG_BOOTFILE		"uImage"
156 #define CONFIG_LOADADDR		0x42000000
157 #define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
158 #define CONFIG_OF_LIBFDT
159 
160 /*
161  * Environment
162  */
163 #define CONFIG_ENV_IS_IN_MMC
164 #define CONFIG_ENV_OVERWRITE
165 #ifdef CONFIG_ENV_IS_IN_MMC
166 #define CONFIG_ENV_OFFSET	(256 * 1024)
167 #define CONFIG_ENV_SIZE	(16 * 1024)
168 #define CONFIG_SYS_MMC_ENV_DEV 0
169 #endif
170 
171 /*
172  * Extra Environments
173  */
174 #define CONFIG_EXTRA_ENV_SETTINGS \
175 	"update_sd_firmware_filename=u-boot.sd\0" \
176 	"update_sd_firmware="		/* Update the SD firmware partition */ \
177 		"if mmc rescan ; then "	\
178 		"if tftp ${update_sd_firmware_filename} ; then " \
179 		"setexpr fw_sz ${filesize} / 0x200 ; "	/* SD block size */ \
180 		"setexpr fw_sz ${fw_sz} + 1 ; "	\
181 		"mmc write ${loadaddr} 0x800 ${fw_sz} ; " \
182 		"fi ; "	\
183 		"fi\0" \
184 	"script=boot.scr\0"	\
185 	"uimage=uImage\0" \
186 	"console=ttyAMA0\0" \
187 	"fdt_file=imx23-olinuxino.dtb\0" \
188 	"fdt_addr=0x41000000\0" \
189 	"boot_fdt=try\0" \
190 	"ip_dyn=yes\0" \
191 	"mmcdev=0\0" \
192 	"mmcpart=2\0" \
193 	"mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
194 	"mmcargs=setenv bootargs console=${console},${baudrate} " \
195 		"root=${mmcroot}\0" \
196 	"loadbootscript="  \
197 		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
198 	"bootscript=echo Running bootscript from mmc ...; "	\
199 		"source\0" \
200 	"loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \
201 	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
202 	"mmcboot=echo Booting from mmc ...; " \
203 		"run mmcargs; " \
204 		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
205 			"if run loadfdt; then " \
206 				"bootm ${loadaddr} - ${fdt_addr}; " \
207 			"else " \
208 				"if test ${boot_fdt} = try; then " \
209 					"bootm; " \
210 				"else " \
211 					"echo WARN: Cannot load the DT; " \
212 				"fi; " \
213 			"fi; " \
214 		"else " \
215 			"bootm; " \
216 		"fi;\0" \
217 	"netargs=setenv bootargs console=${console},${baudrate} " \
218 		"root=/dev/nfs " \
219 		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
220 	"netboot=echo Booting from net ...; " \
221 		"usb start; " \
222 		"run netargs; "	\
223 		"if test ${ip_dyn} = yes; then " \
224 			"setenv get_cmd dhcp; " \
225 		"else " \
226 			"setenv get_cmd tftp; " \
227 		"fi; " \
228 		"${get_cmd} ${uimage}; " \
229 		"if test ${boot_fdt} = yes; then " \
230 			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
231 				"bootm ${loadaddr} - ${fdt_addr}; " \
232 			"else " \
233 				"if test ${boot_fdt} = try; then " \
234 					"bootm; " \
235 				"else " \
236 					"echo WARN: Cannot load the DT; " \
237 				"fi;" \
238 			"fi; " \
239 		"else " \
240 			"bootm; " \
241 		"fi;\0"
242 
243 #define CONFIG_BOOTCOMMAND \
244 	"mmc dev ${mmcdev}; if mmc rescan; then " \
245 		"if run loadbootscript; then " \
246 			"run bootscript; " \
247 		"else " \
248 			"if run loaduimage; then " \
249 				"run mmcboot; " \
250 			"else run netboot; " \
251 			"fi; " \
252 		"fi; " \
253 	"else run netboot; fi"
254 
255 #endif /* __MX23_OLINUXINO_CONFIG_H__ */
256