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