77914438bfa05352ac81c69a033d98623b937db9
[platform/kernel/u-boot.git] / include / configs / socfpga_arria5_secu1.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2017-2020 ABB
4  *
5  */
6 #ifndef __CONFIG_SOCFPGA_SECU1_H__
7 #define __CONFIG_SOCFPGA_SECU1_H__
8
9 #include <asm/arch/base_addr_ac5.h>
10 #include <linux/stringify.h>
11
12 /* Call misc_init_r */
13 #define CONFIG_MISC_INIT_R
14
15 #define CONFIG_HUSH_INIT_VAR
16 /* Eternal oscillator */
17 #define CONFIG_SYS_TIMER_RATE   40000000
18
19 /* Memory configurations */
20 #define PHYS_SDRAM_1_SIZE       0x20000000      /* 512MiB on SECU1 */
21
22 /*
23  * We use bootcounter in i2c nvram of the RTC (0x68)
24  * The offset fopr the bootcounter is 0x9e, which are
25  * the last two bytes of the 128 bytes large NVRAM in the
26  * RTC which begin at address 0x20
27  */
28 #define CONFIG_SYS_I2C_RTC_ADDR         0x68
29
30 /* Booting Linux */
31 #define CONFIG_BOOTDELAY        2
32 #define CONFIG_BOOTFILE         "zImage"
33
34 #define CONFIG_BOOTCOMMAND      \
35         "setenv bootcmd '"      \
36                 "bridge enable; "       \
37                 "if test ${bootnum} = \"b\"; " \
38                       "then run _fpga_loadsafe; " \
39                 "else if test ${bootcount} -eq 4; then echo \"Switching copy...\"; setexpr x $bootnum % 2 && setexpr bootnum $x + 1; saveenv; fi; " \
40                       "run _fpga_loaduser; " \
41                 "fi;" \
42                 "echo \"Booting bank $bootnum\" && run userload && run userboot;" \
43         "' && " \
44         "setenv altbootcmd 'setenv bootnum b && saveenv && boot;' && " \
45         "saveenv && saveenv && boot;"
46
47 #define CONFIG_CMDLINE_TAG
48 #define CONFIG_SYS_BOOTM_LEN            (64 << 20)
49
50 /* Environment settings */
51 #define CONFIG_ENV_OVERWRITE
52
53 /*
54  * Autoboot
55  *
56  * After 45s of inactivity in the prompt, the board will reset.
57  * Set 'bootretry' in the environment to -1 to disable this behavior
58  */
59 #define CONFIG_BOOT_RETRY_TIME 45
60 #define CONFIG_RESET_TO_RETRY
61
62 #define CONFIG_LOADADDR         0x01000000
63 #define CONFIG_SYS_LOAD_ADDR   CONFIG_KM_KERNEL_ADDR
64
65 /*
66  * FPGA Remote Update related environment
67  *
68  * Note that since those commands access the FPGA, the HPS-to-FPGA
69  * bridges MUST have been previously enabled (for example
70  * with 'bridge enable').
71  */
72 #define FPGA_RMTU_ENV \
73         "rmtu_page=0xFF29000C\0" \
74         "rmtu_reconfig=0xFF290018\0" \
75         "fpga_safebase=0x0\0" \
76         "fpga_userbase=0x2000000\0" \
77         "_fpga_loaduser=echo Loading FPGA USER image..." \
78                 " && mw ${rmtu_page} ${fpga_userbase} && mw ${rmtu_reconfig} 1\0" \
79         "_fpga_loadsafe=echo Loading FPGA SAFE image..." \
80                 " && mw ${rmtu_page} ${fpga_safebase} && mw ${rmtu_reconfig} 1\0" \
81
82 #define CONFIG_KM_NEW_ENV \
83         "newenv=" \
84                 "nand erase 0x100000 0x40000\0"
85
86 #define CONFIG_KM_DEF_ENV_BOOTTARGETS \
87         "release=" \
88                 "run newenv; reset\0" \
89         "develop=" \
90                 "tftp 0x200000 scripts/develop-secu.txt && env import -t 0x200000 ${filesize} && saveenv && reset\0"
91
92 #define CONFIG_EXTRA_ENV_SETTINGS \
93         FPGA_RMTU_ENV \
94         CONFIG_KM_DEF_ENV_BOOTTARGETS \
95         CONFIG_KM_NEW_ENV \
96         "socfpga_legacy_reset_compat=1\0"       \
97         "altbootcmd=run bootcmd;\0"     \
98         "bootlimit=6\0" \
99         "bootnum=1\0" \
100         "bootretry=" __stringify(CONFIG_BOOT_RETRY_TIME) "\0" \
101         "fdt_addr=" __stringify(CONFIG_KM_FDT_ADDR) "\0" \
102         "load=tftpboot ${loadaddr} u-boot-with-nand-spl.sfp\0" \
103         "loadaddr=" __stringify(CONFIG_KM_KERNEL_ADDR) "\0" \
104         "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
105         "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
106         "update=nand erase 0x0 0x00100000 && nand write ${loadaddr} 0x0 ${filesize}\0" \
107         "userload=ubi part nand.ubi &&" \
108                 "ubi check rootfs$bootnum &&" \
109                 "ubi read $fdt_addr dtb$bootnum &&" \
110                 "ubi read $loadaddr kernel$bootnum\0" \
111         "userboot=setenv bootargs " CONFIG_BOOTARGS \
112                 " ubi.mtd=1 ubi.block=0,rootfs$bootnum root=/dev/ubiblock0_$ubivolid"   \
113                 " ro rootfstype=squashfs init=sbin/preinit;" \
114                 "bootz ${loadaddr} - ${fdt_addr}\0" \
115         "verify=y\0"
116
117 /* The rest of the configuration is shared */
118 #include <configs/socfpga_common.h>
119
120 #ifdef CONFIG_SPL_NAND_SUPPORT
121 #undef CONFIG_SYS_NAND_U_BOOT_OFFS
122 #define CONFIG_SYS_NAND_U_BOOT_OFFS     0x80000
123 #endif
124
125 #undef CONFIG_WATCHDOG_TIMEOUT_MSECS
126 #define CONFIG_WATCHDOG_TIMEOUT_MSECS   60000
127
128 #endif  /* __CONFIG_SOCFPGA_SECU1_H__ */