1 /*
2  * Copyright (C) 2016 Timesys Corporation
3  * Copyright (C) 2016 Advantech Corporation
4  * Copyright (C) 2012 Freescale Semiconductor, Inc.
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #ifndef __ADVANTECH_DMSBA16_CONFIG_H
10 #define __ADVANTECH_DMSBA16_CONFIG_H
11 
12 #include <asm/arch/imx-regs.h>
13 #include <asm/imx-common/gpio.h>
14 
15 #define CONFIG_BOARD_NAME	"Advantech DMS-BA16"
16 
17 #define CONFIG_MXC_UART_BASE	UART4_BASE
18 #define CONSOLE_DEV	"ttymxc3"
19 #define CONFIG_EXTRA_BOOTARGS	"panic=10"
20 
21 #define CONFIG_BOOT_DIR	""
22 #define CONFIG_LOADCMD "fatload"
23 #define CONFIG_RFSPART "2"
24 
25 #define CONFIG_SUPPORT_EMMC_BOOT
26 
27 #include "mx6_common.h"
28 #include <linux/sizes.h>
29 
30 #define CONFIG_CMDLINE_TAG
31 #define CONFIG_SETUP_MEMORY_TAGS
32 #define CONFIG_INITRD_TAG
33 #define CONFIG_REVISION_TAG
34 #define CONFIG_SYS_MALLOC_LEN		(10 * SZ_1M)
35 
36 #define CONFIG_MXC_GPIO
37 #define CONFIG_MXC_UART
38 
39 #define CONFIG_CMD_FUSE
40 #define CONFIG_MXC_OCOTP
41 
42 /* SATA Configs */
43 #define CONFIG_CMD_SATA
44 #define CONFIG_DWC_AHSATA
45 #define CONFIG_SYS_SATA_MAX_DEVICE	1
46 #define CONFIG_DWC_AHSATA_PORT_ID	0
47 #define CONFIG_DWC_AHSATA_BASE_ADDR	SATA_ARB_BASE_ADDR
48 #define CONFIG_LBA48
49 #define CONFIG_LIBATA
50 
51 /* MMC Configs */
52 #define CONFIG_FSL_ESDHC
53 #define CONFIG_FSL_USDHC
54 #define CONFIG_SYS_FSL_ESDHC_ADDR      0
55 #define CONFIG_BOUNCE_BUFFER
56 
57 /* USB Configs */
58 #define CONFIG_USB_STORAGE
59 #define CONFIG_USB_MAX_CONTROLLER_COUNT 2
60 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
61 #define CONFIG_MXC_USB_PORTSC	(PORT_PTS_UTMI | PORT_PTS_PTW)
62 #define CONFIG_MXC_USB_FLAGS	0
63 #define CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP
64 
65 #define CONFIG_USBD_HS
66 #define CONFIG_USB_FUNCTION_MASS_STORAGE
67 #define CONFIG_USB_GADGET_VBUS_DRAW 2
68 
69 /* Networking Configs */
70 #define CONFIG_FEC_MXC
71 #define CONFIG_MII
72 #define IMX_FEC_BASE			ENET_BASE_ADDR
73 #define CONFIG_FEC_XCV_TYPE		RGMII
74 #define CONFIG_ETHPRIME		"FEC"
75 #define CONFIG_FEC_MXC_PHYADDR		4
76 #define CONFIG_PHYLIB
77 #define CONFIG_PHY_ATHEROS
78 
79 /* Serial Flash */
80 #ifdef CONFIG_CMD_SF
81 #define CONFIG_MXC_SPI
82 #define CONFIG_SF_DEFAULT_BUS		0
83 #define CONFIG_SF_DEFAULT_CS		0
84 #define CONFIG_SF_DEFAULT_SPEED	20000000
85 #define CONFIG_SF_DEFAULT_MODE		SPI_MODE_0
86 #endif
87 
88 /* allow to overwrite serial and ethaddr */
89 #define CONFIG_ENV_OVERWRITE
90 #define CONFIG_CONS_INDEX	1
91 
92 #define CONFIG_LOADADDR	0x12000000
93 #define CONFIG_SYS_TEXT_BASE	0x17800000
94 
95 #define CONFIG_EXTRA_ENV_SETTINGS \
96 	"script=boot.scr\0" \
97 	"image=" CONFIG_BOOT_DIR "/uImage\0" \
98 	"uboot=u-boot.imx\0" \
99 	"fdt_file=" CONFIG_BOOT_DIR "/" CONFIG_DEFAULT_FDT_FILE "\0" \
100 	"fdt_addr=0x18000000\0" \
101 	"boot_fdt=yes\0" \
102 	"ip_dyn=yes\0" \
103 	"console=" CONSOLE_DEV "\0" \
104 	"fdt_high=0xffffffff\0"	  \
105 	"initrd_high=0xffffffff\0" \
106 	"sddev=0\0" \
107 	"emmcdev=1\0" \
108 	"partnum=1\0" \
109 	"loadcmd=" CONFIG_LOADCMD "\0" \
110 	"rfspart=" CONFIG_RFSPART "\0" \
111 	"update_sd_firmware=" \
112 		"if test ${ip_dyn} = yes; then " \
113 			"setenv get_cmd dhcp; " \
114 		"else " \
115 			"setenv get_cmd tftp; " \
116 		"fi; " \
117 		"if mmc dev ${mmcdev}; then "	\
118 			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
119 				"setexpr fw_sz ${filesize} / 0x200; " \
120 				"setexpr fw_sz ${fw_sz} + 1; "	\
121 				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
122 			"fi; "	\
123 		"fi\0" \
124 	"update_sf_uboot=" \
125 		"if tftp $loadaddr $uboot; then " \
126 			"sf probe; " \
127 			"sf erase 0 0xC0000; " \
128 			"sf write $loadaddr 0x400 $filesize; " \
129 			"echo 'U-Boot upgraded. Please reset'; " \
130 		"fi\0" \
131 	"setargs=setenv bootargs console=${console},${baudrate} " \
132 		"root=/dev/${rootdev} rw rootwait " CONFIG_EXTRA_BOOTARGS "\0" \
133 	"loadbootscript=" \
134 		"${loadcmd} ${dev} ${devnum}:${partnum} ${loadaddr} ${script};\0" \
135 	"bootscript=echo Running bootscript from ${dev}:${devnum}:${partnum};" \
136 		" source\0" \
137 	"loadimage=" \
138 		"${loadcmd} ${dev} ${devnum}:${partnum} ${loadaddr} ${image}\0" \
139 	"loadfdt=${loadcmd} ${dev} ${devnum}:${partnum} ${fdt_addr} ${fdt_file}\0" \
140 	"tryboot=" \
141 		"if run loadbootscript; then " \
142 			"run bootscript; " \
143 		"else " \
144 			"if run loadimage; then " \
145 				"run doboot; " \
146 			"fi; " \
147 		"fi;\0" \
148 	"doboot=echo Booting from ${dev}:${devnum}:${partnum} ...; " \
149 		"run setargs; " \
150 		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
151 			"if run loadfdt; then " \
152 				"bootm ${loadaddr} - ${fdt_addr}; " \
153 			"else " \
154 				"if test ${boot_fdt} = try; then " \
155 					"bootm; " \
156 				"else " \
157 					"echo WARN: Cannot load the DT; " \
158 				"fi; " \
159 			"fi; " \
160 		"else " \
161 			"bootm; " \
162 		"fi;\0" \
163 	"netargs=setenv bootargs console=${console},${baudrate} " \
164 		"root=/dev/nfs " \
165 		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
166 	"netboot=echo Booting from net ...; " \
167 		"run netargs; " \
168 		"if test ${ip_dyn} = yes; then " \
169 			"setenv get_cmd dhcp; " \
170 		"else " \
171 			"setenv get_cmd tftp; " \
172 		"fi; " \
173 		"${get_cmd} ${image}; " \
174 		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
175 			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
176 				"bootm ${loadaddr} - ${fdt_addr}; " \
177 			"else " \
178 				"if test ${boot_fdt} = try; then " \
179 					"bootm; " \
180 				"else " \
181 					"echo WARN: Cannot load the DT; " \
182 				"fi; " \
183 			"fi; " \
184 		"else " \
185 			"bootm; " \
186 		"fi;\0" \
187 
188 #define CONFIG_BOOTCOMMAND \
189 	"usb start; " \
190 	"setenv dev usb; " \
191 	"setenv devnum 0; " \
192 	"setenv rootdev sda${rfspart}; " \
193 	"run tryboot; " \
194 	\
195 	"setenv dev mmc; " \
196 	"setenv rootdev mmcblk0p${rfspart}; " \
197 	\
198 	"setenv devnum ${sddev}; " \
199 	"if mmc dev ${devnum}; then " \
200 		"run tryboot; " \
201 	"fi; " \
202 	\
203 	"setenv devnum ${emmcdev}; " \
204 	"setenv rootdev mmcblk${emmcdev}p${rfspart}; " \
205 	"if mmc dev ${devnum}; then " \
206 		"run tryboot; " \
207 	"fi; " \
208 	\
209 	"bmode usb; " \
210 
211 #define CONFIG_ARP_TIMEOUT     200UL
212 
213 /* Miscellaneous configurable options */
214 #define CONFIG_SYS_LONGHELP
215 #define CONFIG_AUTO_COMPLETE
216 
217 /* Print Buffer Size */
218 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
219 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
220 
221 #define CONFIG_SYS_MEMTEST_START       0x10000000
222 #define CONFIG_SYS_MEMTEST_END         0x10010000
223 #define CONFIG_SYS_MEMTEST_SCRATCH     0x10800000
224 
225 #define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
226 
227 #define CONFIG_CMDLINE_EDITING
228 
229 /* Physical Memory Map */
230 #define CONFIG_NR_DRAM_BANKS           1
231 #define PHYS_SDRAM                     MMDC0_ARB_BASE_ADDR
232 
233 #define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM
234 #define CONFIG_SYS_INIT_RAM_ADDR       IRAM_BASE_ADDR
235 #define CONFIG_SYS_INIT_RAM_SIZE       IRAM_SIZE
236 
237 #define CONFIG_SYS_INIT_SP_OFFSET \
238 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
239 #define CONFIG_SYS_INIT_SP_ADDR \
240 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
241 
242 /* FLASH and environment organization */
243 
244 #define CONFIG_ENV_IS_IN_SPI_FLASH
245 #define CONFIG_ENV_SIZE                 (8 * 1024)
246 #define CONFIG_ENV_OFFSET               (768 * 1024)
247 #define CONFIG_ENV_SECT_SIZE            (64 * 1024)
248 #define CONFIG_ENV_SPI_BUS              CONFIG_SF_DEFAULT_BUS
249 #define CONFIG_ENV_SPI_CS               CONFIG_SF_DEFAULT_CS
250 #define CONFIG_ENV_SPI_MODE             CONFIG_SF_DEFAULT_MODE
251 #define CONFIG_ENV_SPI_MAX_HZ           CONFIG_SF_DEFAULT_SPEED
252 
253 #ifndef CONFIG_SYS_DCACHE_OFF
254 #endif
255 
256 #define CONFIG_SYS_FSL_USDHC_NUM        3
257 
258 /* Framebuffer */
259 #ifdef CONFIG_VIDEO
260 #define CONFIG_VIDEO_IPUV3
261 #define CONFIG_VIDEO_BMP_RLE8
262 #define CONFIG_SPLASH_SCREEN
263 #define CONFIG_SPLASH_SCREEN_ALIGN
264 #define CONFIG_BMP_16BPP
265 #define CONFIG_VIDEO_LOGO
266 #define CONFIG_VIDEO_BMP_LOGO
267 #define CONFIG_IPUV3_CLK                260000000
268 #define CONFIG_IMX_HDMI
269 #define CONFIG_IMX_VIDEO_SKIP
270 #endif
271 
272 #define CONFIG_PWM_IMX
273 #define CONFIG_IMX6_PWM_PER_CLK         66000000
274 
275 #undef CONFIG_CMD_PCI
276 #ifdef CONFIG_CMD_PCI
277 #define CONFIG_PCI_SCAN_SHOW
278 #define CONFIG_PCIE_IMX
279 #define CONFIG_PCIE_IMX_PERST_GPIO      IMX_GPIO_NR(7, 12)
280 #define CONFIG_PCIE_IMX_POWER_GPIO      IMX_GPIO_NR(1, 5)
281 #endif
282 
283 /* I2C Configs */
284 #define CONFIG_SYS_I2C
285 #define CONFIG_SYS_I2C_MXC
286 #define CONFIG_SYS_I2C_SPEED            100000
287 #define CONFIG_SYS_I2C_MXC_I2C1
288 #define CONFIG_SYS_I2C_MXC_I2C2
289 #define CONFIG_SYS_I2C_MXC_I2C3
290 
291 #endif	/* __ADVANTECH_DMSBA16_CONFIG_H */
292