1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2013-2019 Toradex, Inc.
4  *
5  * Configuration settings for the Toradex Apalis iMX6
6  */
7 
8 #ifndef __CONFIG_H
9 #define __CONFIG_H
10 
11 #include <linux/stringify.h>
12 
13 #include "mx6_common.h"
14 
15 #undef CONFIG_DISPLAY_BOARDINFO
16 
17 #define CONFIG_MACH_TYPE		4886
18 
19 #include <asm/arch/imx-regs.h>
20 #include <asm/mach-imx/gpio.h>
21 
22 #ifdef CONFIG_SPL
23 #include "imx6_spl.h"
24 #endif
25 
26 #define CONFIG_CMDLINE_TAG
27 #define CONFIG_SETUP_MEMORY_TAGS
28 #define CONFIG_INITRD_TAG
29 #define CONFIG_REVISION_TAG
30 #define CONFIG_SERIAL_TAG
31 
32 /* Size of malloc() pool */
33 #define CONFIG_SYS_MALLOC_LEN		(32 * 1024 * 1024)
34 
35 #define CONFIG_MXC_UART_BASE		UART1_BASE
36 
37 /* I2C Configs */
38 #define CONFIG_SYS_I2C_MXC
39 #define CONFIG_SYS_I2C_MXC_I2C1		/* enable I2C bus 1 */
40 #define CONFIG_SYS_I2C_MXC_I2C2		/* enable I2C bus 2 */
41 #define CONFIG_SYS_I2C_MXC_I2C3		/* enable I2C bus 3 */
42 #define CONFIG_SYS_I2C_SPEED		100000
43 #define CONFIG_SYS_MXC_I2C3_SPEED	400000
44 
45 /* MMC Configs */
46 #define CONFIG_SYS_FSL_ESDHC_ADDR	0
47 #define CONFIG_SYS_FSL_USDHC_NUM	3
48 
49 /*
50  * SATA Configs
51  */
52 #ifdef CONFIG_CMD_SATA
53 #define CONFIG_LBA48
54 #endif
55 
56 /* Network */
57 #define PHY_ANEG_TIMEOUT		15000 /* PHY needs longer aneg time */
58 
59 /* USB Configs */
60 /* Host */
61 #define CONFIG_USB_MAX_CONTROLLER_COUNT		2
62 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET	/* For OTG port */
63 #define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
64 #define CONFIG_MXC_USB_FLAGS		0
65 /* Client */
66 #define CONFIG_USBD_HS
67 
68 /* Framebuffer and LCD */
69 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
70 #define CONFIG_VIDEO_LOGO
71 #define CONFIG_VIDEO_BMP_LOGO
72 #define CONFIG_IMX_HDMI
73 #define CONFIG_IMX_VIDEO_SKIP
74 
75 /* Command definition */
76 
77 #undef CONFIG_IPADDR
78 #define CONFIG_IPADDR			192.168.10.2
79 #define CONFIG_NETMASK			255.255.255.0
80 #undef CONFIG_SERVERIP
81 #define CONFIG_SERVERIP			192.168.10.1
82 
83 #define CONFIG_LOADADDR			0x12000000
84 
85 #ifndef CONFIG_SPL_BUILD
86 #define BOOT_TARGET_DEVICES(func) \
87 	func(MMC, mmc, 1) \
88 	func(MMC, mmc, 2) \
89 	func(MMC, mmc, 0) \
90 	func(USB, usb, 0) \
91 	func(DHCP, dhcp, na)
92 #include <config_distro_bootcmd.h>
93 #undef BOOTENV_RUN_NET_USB_START
94 #define BOOTENV_RUN_NET_USB_START ""
95 #else /* CONFIG_SPL_BUILD */
96 #define BOOTENV
97 #endif /* CONFIG_SPL_BUILD */
98 
99 #define UBOOT_UPDATE \
100 	"uboot_hwpart=1\0" \
101 	"uboot_blk=8a\0" \
102 	"uboot_spl_blk=2\0" \
103 	"set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && " \
104 		"setexpr blkcnt ${blkcnt} / 0x200\0" \
105 	"update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
106 		"mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0" \
107 	"update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
108 		"mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
109 
110 #define MEM_LAYOUT_ENV_SETTINGS \
111 	"bootm_size=0x20000000\0" \
112 	"fdt_addr_r=0x12100000\0" \
113 	"kernel_addr_r=0x11000000\0" \
114 	"pxefile_addr_r=0x17100000\0" \
115 	"ramdisk_addr_r=0x12200000\0" \
116 	"scriptaddr=0x17000000\0"
117 
118 #define NFS_BOOTCMD \
119 	"nfsargs=ip=:::::eth0:on root=/dev/nfs ro\0" \
120 	"nfsboot=run setup; " \
121 		"setenv bootargs ${defargs} ${nfsargs} ${setupargs} " \
122 		"${vidargs}; echo Booting via DHCP/TFTP/NFS...; " \
123 		"run nfsdtbload; dhcp ${kernel_addr_r} " \
124 		"&& run fdt_fixup && bootz ${kernel_addr_r} ${dtbparam}\0" \
125 	"nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r} ${fdt_file} " \
126 		"&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
127 
128 #ifndef CONFIG_TDX_APALIS_IMX6_V1_0
129 #define FDT_FILE "imx6q-apalis-eval.dtb"
130 #define FDT_FILE_V1_0 "imx6q-apalis_v1_0-eval.dtb"
131 #else
132 #define FDT_FILE "imx6q-apalis_v1_0-eval.dtb"
133 #endif
134 #define CONFIG_EXTRA_ENV_SETTINGS \
135 	BOOTENV \
136 	"bootcmd=run distro_bootcmd ; " \
137 		"usb start ; " \
138 		"setenv stdout serial,vidconsole; " \
139 		"setenv stdin serial,usbkbd\0" \
140 	"boot_file=zImage\0" \
141 	"console=ttymxc0\0" \
142 	"defargs=enable_wait_mode=off vmalloc=400M\0" \
143 	"fdt_file=" FDT_FILE "\0" \
144 	"fdtfile=" FDT_FILE "\0" \
145 	"fdt_fixup=;\0" \
146 	MEM_LAYOUT_ENV_SETTINGS \
147 	NFS_BOOTCMD \
148 	UBOOT_UPDATE \
149 	"setethupdate=if env exists ethaddr; then; else setenv ethaddr " \
150 		"00:14:2d:00:00:00; fi; tftpboot ${loadaddr} " \
151 		"flash_eth.img && source ${loadaddr}\0" \
152 	"setsdupdate=setenv interface mmc; setenv drive 1; mmc rescan; " \
153 		"load ${interface} ${drive}:1 ${loadaddr} flash_blk.img " \
154 		"|| setenv drive 2; mmc rescan; load ${interface} ${drive}:1" \
155 		" ${loadaddr} flash_blk.img && " \
156 		"source ${loadaddr}\0" \
157 	"setup=setenv setupargs fec_mac=${ethaddr} " \
158 		"consoleblank=0 no_console_suspend=1 console=tty1 " \
159 		"console=${console},${baudrate}n8\0 " \
160 	"setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
161 	"setusbupdate=usb start && setenv interface usb; setenv drive 0; " \
162 		"load ${interface} ${drive}:1 ${loadaddr} flash_blk.img && " \
163 		"source ${loadaddr}\0" \
164 	"splashpos=m,m\0" \
165 	"splashimage=" __stringify(CONFIG_LOADADDR) "\0" \
166 	"vidargs=mxc_hdmi.only_cea=1 " \
167 		"video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24 " \
168 		"video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off " \
169 		"fbmem=32M\0 "
170 
171 /* Miscellaneous configurable options */
172 #undef CONFIG_SYS_CBSIZE
173 #define CONFIG_SYS_CBSIZE		1024
174 #undef CONFIG_SYS_MAXARGS
175 #define CONFIG_SYS_MAXARGS		48
176 
177 #define CONFIG_SYS_LOAD_ADDR		CONFIG_LOADADDR
178 
179 /* Physical Memory Map */
180 #define PHYS_SDRAM			MMDC0_ARB_BASE_ADDR
181 
182 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM
183 #define CONFIG_SYS_INIT_RAM_ADDR	IRAM_BASE_ADDR
184 #define CONFIG_SYS_INIT_RAM_SIZE	IRAM_SIZE
185 
186 #define CONFIG_SYS_INIT_SP_OFFSET \
187 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
188 #define CONFIG_SYS_INIT_SP_ADDR \
189 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
190 
191 #endif	/* __CONFIG_H */
192