1 /*
2  * Copyright (C) 2015 Marek Vasut <marex@denx.de>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 #ifndef __CONFIG_SAMTEC_VINING_FPGA_H__
7 #define __CONFIG_SAMTEC_VINING_FPGA_H__
8 
9 #include <asm/arch/base_addr_ac5.h>
10 
11 #define CONFIG_HW_WATCHDOG
12 
13 /* Memory configurations */
14 #define PHYS_SDRAM_1_SIZE		0x40000000	/* 1GiB on VINING_FPGA */
15 
16 /* Booting Linux */
17 #define CONFIG_BOOTFILE		"openwrt-socfpga-socfpga_cyclone5_vining_fpga-fit-uImage.itb"
18 #define CONFIG_BOOTCOMMAND	"run selboot"
19 #define CONFIG_LOADADDR		0x01000000
20 #define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
21 
22 /* I2C EEPROM */
23 #ifdef CONFIG_CMD_EEPROM
24 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x50
25 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
26 #define CONFIG_SYS_I2C_EEPROM_BUS		0
27 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
28 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	70
29 #endif
30 
31 /*
32  * Status LEDs:
33  *   0 ... Top Green
34  *   1 ... Top Red
35  *   2 ... Bottom Green
36  *   3 ... Bottom Red
37  */
38 
39 /* Ethernet on SoC (EMAC) */
40 #if defined(CONFIG_CMD_NET)
41 #define CONFIG_BOOTP_SEND_HOSTNAME
42 /* PHY */
43 #endif
44 
45 /* Extra Environment */
46 #define CONFIG_HOSTNAME			socfpga_vining_fpga
47 
48 /*
49  * Active LOW GPIO buttons:
50  * A: GPIO 77 ... the button between USB B and ethernet
51  * B: GPIO 78 ... the button between USB A ports
52  *
53  * The logic:
54  *  if button B is not pressed, boot normal Linux system immediatelly
55  *  if button B is pressed, wait $bootdelay and boot recovery system
56  */
57 #define CONFIG_PREBOOT						\
58 	"setenv hostname vining-${unit_serial} ; "		\
59 	"setenv PS1 \"${unit_ident} (${unit_serial}) => \" ; "	\
60 	"if gpio input 78 ; then "			\
61 		"setenv bootdelay 10 ; "		\
62 		"setenv boottype rcvr ; "		\
63 	"else "						\
64 		"setenv bootdelay 5 ; "			\
65 		"setenv boottype norm ; "		\
66 	"fi"
67 
68 #define CONFIG_EXTRA_ENV_SETTINGS \
69 	"verify=n\0" \
70 	"consdev=ttyS0\0"						\
71 	"baudrate=115200\0"						\
72 	"bootscript=boot.scr\0"						\
73 	"ubimtdnr=5\0"							\
74 	"ubimtd=rootfs\0"						\
75 	"ubipart=ubi0:rootfs\0"						\
76 	"ubisfcs=1\0"		/* Default is flash at CS#1 */		\
77 	"netdev=eth0\0"							\
78 	"hostname=vining_fpga\0"						\
79 	"kernel_addr_r=0x10000000\0"					\
80 	"mtdparts_0=ff705000.spi.0:"					\
81 		"1m(u-boot),"						\
82 		"64k(env1),"						\
83 		"64k(env2),"						\
84 		"256k(samtec1),"					\
85 		"256k(samtec2),"					\
86 		"-(rcvrfs)\0"	/* Recovery */				\
87 	"mtdparts_1=ff705000.spi.1:"					\
88 		"32m(rootfs),"						\
89 		"-(userfs)\0"						\
90 	"update_filename=u-boot-with-spl-dtb.sfp\0"			\
91 	"update_qspi_offset=0x0\0"					\
92 	"update_qspi="		/* Update the QSPI firmware */		\
93 		"if sf probe ; then "					\
94 		"if tftp ${update_filename} ; then "			\
95 		"sf update ${loadaddr} ${update_qspi_offset} ${filesize} ; " \
96 		"fi ; "							\
97 		"fi\0"							\
98 	"fpga_filename=output_file.rbf\0"				\
99 	"load_fpga="		/* Load FPGA bitstream */		\
100 		"if tftp ${fpga_filename} ; then "			\
101 		"fpga load 0 $loadaddr $filesize ; "			\
102 		"bridge enable ; "					\
103 		"fi\0"							\
104 	"addcons="							\
105 		"setenv bootargs ${bootargs} "				\
106 		"console=${consdev},${baudrate}\0"			\
107 	"addip="							\
108 		"setenv bootargs ${bootargs} "				\
109 		"ip=${ipaddr}:${serverip}:${gatewayip}:"		\
110 			"${netmask}:${hostname}:${netdev}:off\0"	\
111 	"addmisc="							\
112 		"setenv bootargs ${bootargs} ${miscargs}\0"		\
113 	"addmtd="							\
114 		"setenv mtdparts \"${mtdparts_0};${mtdparts_1}\" ; "	\
115 		"setenv bootargs ${bootargs} mtdparts=${mtdparts}\0"	\
116 	"addargs=run addcons addmtd addmisc\0"				\
117 	"ubiload="							\
118 		"ubi part ${ubimtd} ; ubifsmount ${ubipart} ; "		\
119 		"ubifsload ${kernel_addr_r} /boot/${bootfile}\0"	\
120 	"netload="							\
121 		"tftp ${kernel_addr_r} ${hostname}/${bootfile}\0"	\
122 	"miscargs=nohlt panic=1\0"					\
123 	"ubiargs="							\
124 		"setenv bootargs ubi.mtd=${ubimtdnr} "			\
125 		"root=${ubipart} rootfstype=ubifs\0"			\
126 	"nfsargs="							\
127 		"setenv bootargs root=/dev/nfs rw "			\
128 			"nfsroot=${serverip}:${rootpath},v3,tcp\0"	\
129 	"ubi_sfsel="							\
130 		"if test \"${boottype}\" = \"rcvr\" ; then "		\
131 			"setenv ubisfcs 0 ; "				\
132 			"setenv ubimtd rcvrfs ; "			\
133 			"setenv ubimtdnr 5 ; "				\
134 			"setenv mtdparts mtdparts=${mtdparts_0} ; "	\
135 			"setenv mtdids nor0=ff705000.spi.0 ; "		\
136 			"setenv ubipart ubi0:rootfs ; "			\
137 		"else "							\
138 			"setenv ubisfcs 1 ; "				\
139 			"setenv ubimtd rootfs ; "			\
140 			"setenv ubimtdnr 6 ; "				\
141 			"setenv mtdparts mtdparts=${mtdparts_1} ; "	\
142 			"setenv mtdids nor0=ff705000.spi.1 ; "		\
143 			"setenv ubipart ubi0:rootfs ; "			\
144 		"fi ; "							\
145 		"sf probe 0:${ubisfcs}\0"				\
146 	"ubi_ubi="							\
147 		"run ubi_sfsel ubiload ubiargs addargs ; "		\
148 		"bootm ${kernel_addr_r}\0"				\
149 	"ubi_nfs="							\
150 		"run ubiload nfsargs addip addargs ; "			\
151 		"bootm ${kernel_addr_r}\0"				\
152 	"net_ubi="							\
153 		"run netload ubiargs addargs ; "			\
154 		"bootm ${kernel_addr_r}\0"				\
155 	"net_nfs="							\
156 		"run netload nfsargs addip addargs ; "			\
157 		"bootm ${kernel_addr_r}\0"				\
158 	"selboot="	/* Select from where to boot. */		\
159 		"if test \"${bootmode}\" = \"qspi\" ; then "		\
160 			"led all off ; "				\
161 			"if test \"${boottype}\" = \"rcvr\" ; then "	\
162 				"echo \"Booting recovery system\" ; "	\
163 				"led 3 on ; "	/* Bottom RED */	\
164 			"fi ; "						\
165 			"led 1 on ; "		/* Top RED */		\
166 			"run ubi_ubi ; "				\
167 		"else echo \"Unsupported boot mode: \"${bootmode} ; "	\
168 		"fi\0"							\
169 
170 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
171 #define CONFIG_ENV_SIZE_REDUND		CONFIG_ENV_SIZE
172 #define CONFIG_ENV_SECT_SIZE		(64 * 1024)
173 #define CONFIG_ENV_OFFSET		0x100000
174 #define CONFIG_ENV_OFFSET_REDUND	\
175 	(CONFIG_ENV_OFFSET + CONFIG_ENV_SECT_SIZE)
176 
177 #define CONFIG_MISC_INIT_R
178 
179 /* Support changing the prompt string */
180 #define CONFIG_CMDLINE_PS_SUPPORT
181 
182 /* The rest of the configuration is shared */
183 #include <configs/socfpga_common.h>
184 
185 #endif	/* __CONFIG_SAMTEC_VINING_FPGA_H__ */
186