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