1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2011 Freescale Semiconductor, Inc.
4  * Author: Fabio Estevam <fabio.estevam@freescale.com>
5  *
6  * Based on m28evk.h:
7  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
8  * on behalf of DENX Software Engineering GmbH
9  */
10 #ifndef __CONFIGS_MX28EVK_H__
11 #define __CONFIGS_MX28EVK_H__
12 
13 /* System configurations */
14 #define CONFIG_MACH_TYPE	MACH_TYPE_MX28EVK
15 
16 /* Memory configuration */
17 #define PHYS_SDRAM_1			0x40000000	/* Base address */
18 #define PHYS_SDRAM_1_SIZE		0x40000000	/* Max 1 GB RAM */
19 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
20 
21 /* Environment */
22 
23 /* Environment is in MMC */
24 
25 /* Environment is in NAND */
26 #if defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_IN_NAND)
27 #define CONFIG_ENV_RANGE		(512 * 1024)
28 #endif
29 
30 /* Environment is in SPI flash */
31 
32 /* UBI and NAND partitioning */
33 
34 /* FEC Ethernet on SoC */
35 #ifdef	CONFIG_CMD_NET
36 #define CONFIG_FEC_MXC
37 #define CONFIG_FEC_MXC_MDIO_BASE MXS_ENET0_BASE
38 #define CONFIG_MX28_FEC_MAC_IN_OCOTP
39 #endif
40 
41 /* RTC */
42 #ifdef	CONFIG_CMD_DATE
43 #define	CONFIG_RTC_MXS
44 #endif
45 
46 /* USB */
47 #ifdef	CONFIG_CMD_USB
48 #define CONFIG_EHCI_MXS_PORT1
49 #define CONFIG_USB_MAX_CONTROLLER_COUNT	1
50 #endif
51 
52 /* Framebuffer support */
53 #ifdef CONFIG_VIDEO
54 #define CONFIG_VIDEO_LOGO
55 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE	(512 << 10)
56 #endif
57 
58 /* Boot Linux */
59 #define CONFIG_BOOTFILE		"uImage"
60 #define CONFIG_LOADADDR		0x42000000
61 #define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
62 
63 /* Extra Environment */
64 #define CONFIG_EXTRA_ENV_SETTINGS \
65 	"ubifs_file=filesystem.ubifs\0" \
66 	"update_nand_full_filename=u-boot.nand\0" \
67 	"update_nand_firmware_filename=u-boot.sb\0"	\
68 	"update_nand_firmware_maxsz=0x100000\0"	\
69 	"update_nand_stride=0x40\0"	/* MX28 datasheet ch. 12.12 */ \
70 	"update_nand_count=0x4\0"	/* MX28 datasheet ch. 12.12 */ \
71 	"update_nand_get_fcb_size="	/* Get size of FCB blocks */ \
72 		"nand device 0 ; " \
73 		"nand info ; " \
74 		"setexpr fcb_sz ${update_nand_stride} * ${update_nand_count};" \
75 		"setexpr update_nand_fcb ${fcb_sz} * ${nand_writesize}\0" \
76 	"update_nand_firmware_full=" /* Update FCB, DBBT and FW */ \
77 		"if tftp ${update_nand_full_filename} ; then " \
78 		"run update_nand_get_fcb_size ; " \
79 		"nand scrub -y 0x0 ${filesize} ; " \
80 		"nand write.raw ${loadaddr} 0x0 ${fcb_sz} ; " \
81 		"setexpr update_off ${loadaddr} + ${update_nand_fcb} ; " \
82 		"setexpr update_sz ${filesize} - ${update_nand_fcb} ; " \
83 		"nand write ${update_off} ${update_nand_fcb} ${update_sz} ; " \
84 		"fi\0" \
85 	"update_nand_firmware="		/* Update only firmware */ \
86 		"if tftp ${update_nand_firmware_filename} ; then " \
87 		"run update_nand_get_fcb_size ; " \
88 		"setexpr fcb_sz ${update_nand_fcb} * 2 ; " /* FCB + DBBT */ \
89 		"setexpr fw_sz ${update_nand_firmware_maxsz} * 2 ; " \
90 		"setexpr fw_off ${fcb_sz} + ${update_nand_firmware_maxsz};" \
91 		"nand erase ${fcb_sz} ${fw_sz} ; " \
92 		"nand write ${loadaddr} ${fcb_sz} ${filesize} ; " \
93 		"nand write ${loadaddr} ${fw_off} ${filesize} ; " \
94 		"fi\0" \
95 	"update_nand_kernel="		/* Update kernel */ \
96 		"mtdparts default; " \
97 		"nand erase.part kernel; " \
98 		"if test ${ip_dyn} = yes; then " \
99 			"setenv get_cmd dhcp; " \
100 		"else " \
101 			"setenv get_cmd tftp; " \
102 		"fi; " \
103 		"${get_cmd} ${image}; " \
104 		"nand write ${loadaddr} kernel ${filesize}\0" \
105 	"update_nand_fdt="		/* Update fdt */ \
106 		"mtdparts default; " \
107 		"nand erase.part fdt; " \
108 		"if test ${ip_dyn} = yes; then " \
109 			"setenv get_cmd dhcp; " \
110 		"else " \
111 			"setenv get_cmd tftp; " \
112 		"fi; " \
113 		"${get_cmd} ${fdt_file}; " \
114 		"nand write ${loadaddr} fdt ${filesize}\0" \
115 	"update_nand_filesystem="		/* Update filesystem */ \
116 		"mtdparts default; " \
117 		"nand erase.part filesystem; " \
118 		"if test ${ip_dyn} = yes; then " \
119 			"setenv get_cmd dhcp; " \
120 		"else " \
121 			"setenv get_cmd tftp; " \
122 		"fi; " \
123 		"${get_cmd} ${ubifs_file}; " \
124 		"ubi part filesystem; " \
125 		"ubi create filesystem; " \
126 		"ubi write ${loadaddr} filesystem ${filesize}\0" \
127 	"nandargs=setenv bootargs console=${console_mainline},${baudrate} " \
128 		"rootfstype=ubifs ubi.mtd=6 root=ubi0_0 ${mtdparts}\0" \
129 	"nandboot="		/* Boot from NAND */ \
130 		"mtdparts default; " \
131 		"run nandargs; " \
132 		"nand read ${loadaddr} kernel 0x00400000; " \
133 		"if test ${boot_fdt} = yes; then " \
134 			"nand read ${fdt_addr} fdt 0x00080000; " \
135 			"bootz ${loadaddr} - ${fdt_addr}; " \
136 		"else " \
137 			"if test ${boot_fdt} = no; then " \
138 				"bootz; " \
139 			"else " \
140 				"echo \"ERROR: Set boot_fdt to yes or no.\"; " \
141 			"fi; " \
142 		"fi\0" \
143 	"update_sd_firmware_filename=u-boot.sd\0" \
144 	"update_sd_firmware="		/* Update the SD firmware partition */ \
145 		"if mmc rescan ; then "	\
146 		"if tftp ${update_sd_firmware_filename} ; then " \
147 		"setexpr fw_sz ${filesize} / 0x200 ; "	/* SD block size */ \
148 		"setexpr fw_sz ${fw_sz} + 1 ; "	\
149 		"mmc write ${loadaddr} 0x800 ${fw_sz} ; " \
150 		"fi ; "	\
151 		"fi\0" \
152 	"script=boot.scr\0"	\
153 	"image=zImage\0" \
154 	"console_fsl=ttyAM0\0" \
155 	"console_mainline=ttyAMA0\0" \
156 	"fdt_file=imx28-evk.dtb\0" \
157 	"fdt_addr=0x41000000\0" \
158 	"boot_fdt=try\0" \
159 	"ip_dyn=yes\0" \
160 	"mmcdev=0\0" \
161 	"mmcpart=2\0" \
162 	"mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
163 	"mmcargs=setenv bootargs console=${console_mainline},${baudrate} " \
164 		"root=${mmcroot}\0" \
165 	"loadbootscript="  \
166 		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
167 	"bootscript=echo Running bootscript from mmc ...; "	\
168 		"source\0" \
169 	"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
170 	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
171 	"mmcboot=echo Booting from mmc ...; " \
172 		"run mmcargs; " \
173 		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
174 			"if run loadfdt; then " \
175 				"bootz ${loadaddr} - ${fdt_addr}; " \
176 			"else " \
177 				"if test ${boot_fdt} = try; then " \
178 					"bootz; " \
179 				"else " \
180 					"echo WARN: Cannot load the DT; " \
181 				"fi; " \
182 			"fi; " \
183 		"else " \
184 			"bootz; " \
185 		"fi;\0" \
186 	"netargs=setenv bootargs console=${console_mainline},${baudrate} " \
187 		"root=/dev/nfs " \
188 		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
189 	"netboot=echo Booting from net ...; " \
190 		"run netargs; "	\
191 		"if test ${ip_dyn} = yes; then " \
192 			"setenv get_cmd dhcp; " \
193 		"else " \
194 			"setenv get_cmd tftp; " \
195 		"fi; " \
196 		"${get_cmd} ${image}; " \
197 		"if test ${boot_fdt} = yes; then " \
198 			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
199 				"bootz ${loadaddr} - ${fdt_addr}; " \
200 			"else " \
201 				"if test ${boot_fdt} = try; then " \
202 					"bootz; " \
203 				"else " \
204 					"echo WARN: Cannot load the DT; " \
205 				"fi;" \
206 			"fi; " \
207 		"else " \
208 			"bootz; " \
209 		"fi;\0"
210 
211 #define CONFIG_BOOTCOMMAND \
212 	"mmc dev ${mmcdev}; if mmc rescan; then " \
213 		"if run loadbootscript; then " \
214 			"run bootscript; " \
215 		"else " \
216 			"if run loadimage; then " \
217 				"run mmcboot; " \
218 			"else run netboot; " \
219 			"fi; " \
220 		"fi; " \
221 	"else run netboot; fi"
222 
223 /* The rest of the configuration is shared */
224 #include <configs/mxs.h>
225 
226 #endif /* __CONFIGS_MX28EVK_H__ */
227