1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2013, 2014, 2017 Markus Niebel <Markus.Niebel@tq-group.com>
4  *
5  * Configuration settings for the TQ Systems TQMa6<Q,D,DL,S> module.
6  */
7 
8 #ifndef __CONFIG_H
9 #define __CONFIG_H
10 
11 #include <linux/kconfig.h>
12 #include <linux/stringify.h>
13 
14 /* SPL */
15 /* #if defined(CONFIG_SPL_BUILD) */
16 /* common IMX6 SPL configuration */
17 #include "imx6_spl.h"
18 
19 /* #endif */
20 
21 /* place code in last 4 MiB of RAM */
22 
23 #include "mx6_common.h"
24 
25 #if defined(CONFIG_TQMA6S)
26 #define PHYS_SDRAM_SIZE			(512u * SZ_1M)
27 #elif defined(CONFIG_TQMA6DL)
28 #define PHYS_SDRAM_SIZE			(SZ_1G)
29 #elif defined(CONFIG_TQMA6Q)
30 #define PHYS_SDRAM_SIZE			(SZ_1G)
31 #endif
32 
33 /* SPI Flash */
34 
35 #define TQMA6_SPI_FLASH_SECTOR_SIZE	SZ_64K
36 
37 /* I2C Configs */
38 #define CONFIG_I2C_MULTI_BUS
39 #define CONFIG_SYS_I2C_SPEED		100000
40 
41 /* I2C EEPROM (M24C64) */
42 #define CONFIG_SYS_I2C_EEPROM_ADDR			0x50
43 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN			2
44 #define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_BITS		5 /* 32 Bytes */
45 #define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_DELAY_MS	20
46 
47 #if !defined(CONFIG_DM_PMIC)
48 #define CONFIG_POWER
49 #define CONFIG_POWER_I2C
50 #define CONFIG_POWER_PFUZE100
51 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
52 #define TQMA6_PFUZE100_I2C_BUS		2
53 #endif
54 
55 /* MMC Configs */
56 #define CONFIG_SYS_FSL_ESDHC_ADDR	0
57 
58 /* USB Configs */
59 #define CONFIG_MXC_USB_PORTSC	(PORT_PTS_UTMI | PORT_PTS_PTW)
60 #define CONFIG_USB_MAX_CONTROLLER_COUNT	2
61 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET	/* For OTG port */
62 
63 #define CONFIG_FEC_MXC
64 #define IMX_FEC_BASE			ENET_BASE_ADDR
65 
66 #define CONFIG_ARP_TIMEOUT		200UL
67 
68 /* Size of malloc() pool */
69 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 2 * SZ_1M)
70 
71 #if defined(CONFIG_TQMA6X_MMC_BOOT)
72 
73 #define TQMA6_UBOOT_OFFSET		SZ_1K
74 #define TQMA6_UBOOT_SECTOR_START	0x2
75 #define TQMA6_UBOOT_SECTOR_COUNT	0x7fe
76 
77 #define TQMA6_FDT_OFFSET		(2 * SZ_1M)
78 #define TQMA6_FDT_SECTOR_START		0x1000
79 #define TQMA6_FDT_SECTOR_COUNT		0x800
80 
81 #define TQMA6_KERNEL_SECTOR_START	0x2000
82 #define TQMA6_KERNEL_SECTOR_COUNT	0x2000
83 
84 #define TQMA6_EXTRA_BOOTDEV_ENV_SETTINGS                                       \
85 	"uboot_start="__stringify(TQMA6_UBOOT_SECTOR_START)"\0"                \
86 	"uboot_size="__stringify(TQMA6_UBOOT_SECTOR_COUNT)"\0"                 \
87 	"fdt_start="__stringify(TQMA6_FDT_SECTOR_START)"\0"                    \
88 	"fdt_size="__stringify(TQMA6_FDT_SECTOR_COUNT)"\0"                     \
89 	"kernel_start="__stringify(TQMA6_KERNEL_SECTOR_START)"\0"              \
90 	"kernel_size="__stringify(TQMA6_KERNEL_SECTOR_COUNT)"\0"               \
91 	"mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0"                       \
92 	"loadimage=mmc dev ${mmcdev}; "                                        \
93 		"mmc read ${loadaddr} ${kernel_start} ${kernel_size};\0"       \
94 	"loadfdt=mmc dev ${mmcdev}; "                                          \
95 		"mmc read ${fdt_addr} ${fdt_start} ${fdt_size};\0"             \
96 	"update_uboot=if tftp ${uboot}; then "                                 \
97 		"if itest ${filesize} > 0; then "                              \
98 			"mmc dev ${mmcdev}; mmc rescan; "                      \
99 			"setexpr blkc ${filesize} + 0x1ff; "                   \
100 			"setexpr blkc ${blkc} / 0x200; "                       \
101 			"if itest ${blkc} <= ${uboot_size}; then "             \
102 				"mmc write ${loadaddr} ${uboot_start} "        \
103 					"${blkc}; "                            \
104 			"fi; "                                                 \
105 		"fi; fi; "                                                     \
106 		"setenv filesize; setenv blkc \0"                              \
107 	"update_kernel=run kernel_name; "                                      \
108 		"if tftp ${kernel}; then "                                     \
109 			"if itest ${filesize} > 0; then "                      \
110 				"mmc dev ${mmcdev}; mmc rescan; "              \
111 				"setexpr blkc ${filesize} + 0x1ff; "           \
112 				"setexpr blkc ${blkc} / 0x200; "               \
113 				"if itest ${blkc} <= ${kernel_size}; then "    \
114 					"mmc write ${loadaddr} "               \
115 						"${kernel_start} ${blkc}; "    \
116 				"fi; "                                         \
117 			"fi; "                                                 \
118 		"fi; "                                                         \
119 		"setenv filesize; setenv blkc \0"                              \
120 	"update_fdt=if tftp ${fdt_file}; then "                                \
121 		"if itest ${filesize} > 0; then "                              \
122 			"mmc dev ${mmcdev}; mmc rescan; "                      \
123 			"setexpr blkc ${filesize} + 0x1ff; "                   \
124 			"setexpr blkc ${blkc} / 0x200; "                       \
125 			"if itest ${blkc} <= ${fdt_size}; then "               \
126 				"mmc write ${loadaddr} ${fdt_start} ${blkc}; " \
127 			"fi; "                                                 \
128 		"fi; fi; "                                                     \
129 		"setenv filesize; setenv blkc \0"                              \
130 
131 #define CONFIG_BOOTCOMMAND \
132 	"run mmcboot; run netboot; run panicboot"
133 
134 #elif defined(CONFIG_TQMA6X_SPI_BOOT)
135 
136 #define TQMA6_UBOOT_OFFSET		0x400
137 #define TQMA6_UBOOT_SECTOR_START	0x0
138 /* max u-boot size: 512k */
139 #define TQMA6_UBOOT_SECTOR_SIZE		TQMA6_SPI_FLASH_SECTOR_SIZE
140 #define TQMA6_UBOOT_SECTOR_COUNT	0x8
141 #define TQMA6_UBOOT_SIZE		(TQMA6_UBOOT_SECTOR_SIZE * \
142 					 TQMA6_UBOOT_SECTOR_COUNT)
143 
144 #define TQMA6_FDT_OFFSET		(CONFIG_ENV_OFFSET_REDUND + \
145 					 CONFIG_ENV_SECT_SIZE)
146 #define TQMA6_FDT_SECT_SIZE		(TQMA6_SPI_FLASH_SECTOR_SIZE)
147 
148 #define TQMA6_FDT_SECTOR_START		0x0a /* 8 Sector u-boot, 2 Sector env */
149 #define TQMA6_FDT_SECTOR_COUNT		0x01
150 
151 #define TQMA6_KERNEL_SECTOR_START	0x10
152 #define TQMA6_KERNEL_SECTOR_COUNT	0x60
153 
154 #define TQMA6_EXTRA_BOOTDEV_ENV_SETTINGS                                       \
155 	"mmcblkdev=0\0"                                                        \
156 	"uboot_offset="__stringify(TQMA6_UBOOT_OFFSET)"\0"                     \
157 	"uboot_sectors="__stringify(TQMA6_UBOOT_SECTOR_COUNT)"\0"              \
158 	"fdt_start="__stringify(TQMA6_FDT_SECTOR_START)"\0"                    \
159 	"fdt_sectors="__stringify(TQMA6_FDT_SECTOR_COUNT)"\0"                  \
160 	"kernel_start="__stringify(TQMA6_KERNEL_SECTOR_START)"\0"              \
161 	"kernel_sectors="__stringify(TQMA6_KERNEL_SECTOR_COUNT)"\0"            \
162 	"update_uboot=if tftp ${uboot}; then "                                 \
163 		"if itest ${filesize} > 0; then "                              \
164 			"setexpr blkc ${filesize} + "                          \
165 				__stringify(TQMA6_UBOOT_OFFSET) "; "           \
166 			"setexpr size ${uboot_sectors} * "                     \
167 				__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
168 			"if itest ${blkc} <= ${size}; then "                   \
169 				"sf probe; "                                   \
170 				"sf erase 0 ${size}; "                         \
171 				"sf write ${loadaddr} ${uboot_offset} "        \
172 					"${filesize}; "                        \
173 			"fi; "                                                 \
174 		"fi; fi; "                                                     \
175 		"setenv filesize 0; setenv blkc; setenv size \0"               \
176 	"update_kernel=run kernel_name; if tftp ${kernel}; then "              \
177 		"if itest ${filesize} > 0; then "                              \
178 			"setexpr size ${kernel_sectors} * "                    \
179 				__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
180 			"setexpr offset ${kernel_start} * "                    \
181 				__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
182 			"if itest ${filesize} <= ${size}; then "               \
183 				"sf probe; "                                   \
184 				"sf erase ${offset} ${size}; "                 \
185 				"sf write ${loadaddr} ${offset} "              \
186 					"${filesize}; "                        \
187 			"fi; "                                                 \
188 		"fi; fi; "                                                     \
189 		"setenv filesize 0; setenv size ; setenv offset\0"             \
190 	"update_fdt=if tftp ${fdt_file}; then "                                \
191 		"if itest ${filesize} > 0; then "                              \
192 			"setexpr size ${fdt_sectors} * "                       \
193 				__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
194 			"setexpr offset ${fdt_start} * "                       \
195 				__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
196 			"if itest ${filesize} <= ${size}; then "               \
197 				"sf probe; "                                   \
198 				"sf erase ${offset} ${size}; "                 \
199 				"sf write ${loadaddr} ${offset} "              \
200 					"${filesize}; "                        \
201 			"fi; "                                                 \
202 		"fi; fi; "                                                     \
203 		"setenv filesize 0; setenv size ; setenv offset\0"             \
204 	"loadimage=sf probe; "                                                 \
205 		"setexpr size ${kernel_sectors} * "                            \
206 			__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
207 		"setexpr offset ${kernel_start} * "                            \
208 			__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
209 		"sf read ${loadaddr} ${offset} ${size}; "                      \
210 		"setenv size ; setenv offset\0"                                \
211 	"loadfdt=sf probe; "                                                   \
212 		"setexpr size ${fdt_sectors} * "                               \
213 			__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
214 		"setexpr offset ${fdt_start} * "                               \
215 			__stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
216 		"sf read ${fdt_addr} ${offset} ${size}; "                      \
217 		"setenv size ; setenv offset\0"                                \
218 
219 #define CONFIG_BOOTCOMMAND                                                     \
220 	"sf probe; run mmcboot; run netboot; run panicboot"                    \
221 
222 #else
223 
224 #error "need to define boot source"
225 
226 #endif
227 
228 /* 128 MiB offset as in ARM related docu for linux suggested */
229 #define TQMA6_FDT_ADDRESS		0x18000000
230 
231 /* set to a resonable value, changeable by user */
232 #define TQMA6_CMA_SIZE                 160M
233 
234 #define CONFIG_EXTRA_ENV_SETTINGS                                              \
235 	"board=tqma6\0"                                                        \
236 	"uimage=uImage\0"                                                      \
237 	"zimage=zImage\0"                                                      \
238 	"boot_type=bootz\0"                                                    \
239 	"kernel_name=if test \"${boot_type}\" != bootz; then "                 \
240 		"setenv kernel ${uimage}; "                                    \
241 		"else setenv kernel ${zimage}; fi\0"                           \
242 	"uboot=u-boot.imx\0"                                                   \
243 	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0"                               \
244 	"fdt_addr="__stringify(TQMA6_FDT_ADDRESS)"\0"                          \
245 	"console=" CONSOLE_DEV "\0"                                            \
246 	"cma_size="__stringify(TQMA6_CMA_SIZE)"\0"                             \
247 	"fdt_high=0xffffffff\0"                                                \
248 	"initrd_high=0xffffffff\0"                                             \
249 	"rootfsmode=ro\0"                                                      \
250 	"addcma=setenv bootargs ${bootargs} cma=${cma_size}\0"                 \
251 	"addtty=setenv bootargs ${bootargs} console=${console},${baudrate}\0"  \
252 	"addfb=setenv bootargs ${bootargs} "                                   \
253 		"imx-fbdev.legacyfb_depth=32 consoleblank=0\0"                 \
254 	"mmcpart=2\0"                                                          \
255 	"mmcblkdev=0\0"                                                        \
256 	"mmcargs=run addmmc addtty addfb addcma\0"                             \
257 	"addmmc=setenv bootargs ${bootargs} "                                  \
258 		"root=/dev/mmcblk${mmcblkdev}p${mmcpart} ${rootfsmode} "       \
259 		"rootwait\0"                                                   \
260 	"mmcboot=echo Booting from mmc ...; "                                  \
261 		"setenv bootargs; "                                            \
262 		"run mmcargs; "                                                \
263 		"run loadimage; "                                              \
264 		"if run loadfdt; then "                                        \
265 			"echo boot device tree kernel ...; "                   \
266 			"${boot_type} ${loadaddr} - ${fdt_addr}; "             \
267 		"else "                                                        \
268 			"${boot_type}; "                                       \
269 		"fi;\0"                                                        \
270 		"setenv bootargs \0"                                           \
271 	"netdev=eth0\0"                                                        \
272 	"rootpath=/srv/nfs/tqma6\0"                                            \
273 	"ipmode=static\0"                                                      \
274 	"netargs=run addnfs addip addtty addfb addcma\0"                       \
275 	"addnfs=setenv bootargs ${bootargs} "                                  \
276 		"root=/dev/nfs rw "                                            \
277 		"nfsroot=${serverip}:${rootpath},v3,tcp;\0"                    \
278 	"addip_static=setenv bootargs ${bootargs} "                            \
279 		"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:"            \
280 		"${hostname}:${netdev}:off\0"                                  \
281 	"addip_dynamic=setenv bootargs ${bootargs} ip=dhcp\0"                  \
282 	"addip=if test \"${ipmode}\" != static; then "                         \
283 		"run addip_dynamic; else run addip_static; fi\0"               \
284 	"set_getcmd=if test \"${ipmode}\" != static; then "                    \
285 		"setenv getcmd dhcp; setenv autoload yes; "                    \
286 		"else setenv getcmd tftp; setenv autoload no; fi\0"            \
287 	"netboot=echo Booting from net ...; "                                  \
288 		"run kernel_name; "                                            \
289 		"run set_getcmd; "                                             \
290 		"setenv bootargs; "                                            \
291 		"run netargs; "                                                \
292 		"if ${getcmd} ${kernel}; then "                                \
293 			"if ${getcmd} ${fdt_addr} ${fdt_file}; then "          \
294 				"${boot_type} ${loadaddr} - ${fdt_addr}; "     \
295 			"fi; "                                                 \
296 		"fi; "                                                         \
297 		"echo ... failed\0"                                            \
298 	"panicboot=echo No boot device !!! reset\0"                            \
299 	TQMA6_EXTRA_BOOTDEV_ENV_SETTINGS                                      \
300 
301 /* Physical Memory Map */
302 #define PHYS_SDRAM			MMDC0_ARB_BASE_ADDR
303 
304 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM
305 #define CONFIG_SYS_INIT_RAM_ADDR	IRAM_BASE_ADDR
306 #define CONFIG_SYS_INIT_RAM_SIZE	IRAM_SIZE
307 
308 #define CONFIG_SYS_INIT_SP_OFFSET \
309 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
310 #define CONFIG_SYS_INIT_SP_ADDR \
311 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
312 
313 /*
314  * All the defines above are for the TQMa6 SoM
315  *
316  * Now include the baseboard specific configuration
317  */
318 #ifdef CONFIG_MBA6
319 #include "tqma6_mba6.h"
320 #elif CONFIG_WRU4
321 #include "tqma6_wru4.h"
322 #else
323 #error "No baseboard for the TQMa6 defined!"
324 #endif
325 
326 /* Support at least the sensor on TQMa6 SOM */
327 
328 #endif /* __CONFIG_H */
329