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