Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 |
| 2 | * |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 3 | * Copyright (C) 2017-2024 Intel Corporation <www.intel.com> |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 4 | * |
| 5 | */ |
| 6 | |
| 7 | #ifndef __CONFIG_SOCFPGA_SOC64_COMMON_H__ |
| 8 | #define __CONFIG_SOCFPGA_SOC64_COMMON_H__ |
| 9 | |
Siew Chin Lim | 142d9c0 | 2021-08-10 11:26:27 +0800 | [diff] [blame] | 10 | #include <asm/arch/base_addr_soc64.h> |
Siew Chin Lim | 954d599 | 2021-03-24 13:11:34 +0800 | [diff] [blame] | 11 | #include <asm/arch/handoff_soc64.h> |
Simon Glass | fb64e36 | 2020-05-10 11:40:09 -0600 | [diff] [blame] | 12 | #include <linux/stringify.h> |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * U-Boot general configurations |
| 16 | */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 17 | /* sysmgr.boot_scratch_cold4 & 5 (64bit) will be used for PSCI_CPU_ON call */ |
| 18 | #define CPU_RELEASE_ADDR 0xFFD12210 |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * U-Boot console configurations |
| 22 | */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 23 | |
| 24 | /* Extend size of kernel image for uncompression */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * U-Boot run time memory configurations |
| 28 | */ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 29 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 30 | #define CFG_SYS_INIT_RAM_ADDR 0x0 |
| 31 | #define CFG_SYS_INIT_RAM_SIZE 0x80000 |
| 32 | #else |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 33 | #define CFG_SYS_INIT_RAM_ADDR 0xFFE00000 |
| 34 | #define CFG_SYS_INIT_RAM_SIZE 0x40000 |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 35 | #endif |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * U-Boot environment configurations |
| 39 | */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 40 | |
| 41 | /* |
Siew Chin Lim | 14b8a48 | 2021-03-01 20:04:14 +0800 | [diff] [blame] | 42 | * Environment variable |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 43 | */ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 44 | #if IS_ENABLED(CONFIG_DISTRO_DEFAULTS) |
| 45 | #if IS_ENABLED(CONFIG_CMD_MMC) |
| 46 | #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) |
| 47 | #else |
| 48 | #define BOOT_TARGET_DEVICES_MMC(func) |
| 49 | #endif |
| 50 | |
| 51 | #if IS_ENABLED(CONFIG_CMD_SF) |
| 52 | #define BOOT_TARGET_DEVICES_QSPI(func) func(QSPI, qspi, na) |
| 53 | #else |
| 54 | #define BOOT_TARGET_DEVICES_QSPI(func) |
| 55 | #endif |
| 56 | |
| 57 | #define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \ |
| 58 | "bootcmd_qspi=ubi detach; sf probe && " \ |
| 59 | "if ubi part root && ubi readvol ${scriptaddr} script; " \ |
| 60 | "then echo QSPI: Running script from UBIFS; " \ |
| 61 | "elif sf read ${scriptaddr} ${qspiscriptaddr} ${scriptsize}; " \ |
| 62 | "then echo QSPI: Running script from JFFS2; fi; " \ |
| 63 | "echo QSPI: Trying to boot script at ${scriptaddr} && " \ |
| 64 | "source ${scriptaddr}; " \ |
| 65 | "echo QSPI: SCRIPT FAILED: continuing...; ubi detach;\0" |
| 66 | |
| 67 | #define BOOTENV_DEV_NAME_QSPI(devtypeu, devtypel, instance) \ |
| 68 | "qspi " |
| 69 | |
| 70 | #define BOOT_TARGET_DEVICES(func) \ |
| 71 | BOOT_TARGET_DEVICES_MMC(func) \ |
| 72 | BOOT_TARGET_DEVICES_QSPI(func) |
| 73 | |
| 74 | #include <config_distro_bootcmd.h> |
| 75 | |
| 76 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 77 | |
Tom Rini | c9edebe | 2022-12-04 10:03:50 -0500 | [diff] [blame] | 78 | #define CFG_EXTRA_ENV_SETTINGS \ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 79 | "kernel_addr_r=0x82000000\0" \ |
| 80 | "fdt_addr_r=0x86000000\0" \ |
| 81 | "qspiscriptaddr=0x02110000\0" \ |
| 82 | "scriptsize=0x00010000\0" \ |
| 83 | "qspibootimageaddr=0x02120000\0" \ |
| 84 | "bootimagesize=0x03200000\0" \ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 85 | "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ |
Chee Hong Ang | f28875c | 2020-12-24 18:20:57 +0800 | [diff] [blame] | 86 | "bootfile=" CONFIG_BOOTFILE "\0" \ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 87 | "mmcroot=/dev/mmcblk0p2\0" \ |
| 88 | "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \ |
| 89 | "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \ |
| 90 | "linux_qspi_enable=if sf probe; then " \ |
| 91 | "echo Enabling QSPI at Linux DTB...;" \ |
| 92 | "fdt addr ${fdt_addr}; fdt resize;" \ |
| 93 | "fdt set /soc/spi@108d2000 status okay;" \ |
| 94 | "if fdt set /clocks/qspi-clk clock-frequency" \ |
| 95 | " ${qspi_clock}; then echo QSPI clock frequency updated;" \ |
| 96 | " elif fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency" \ |
| 97 | " ${qspi_clock}; then echo QSPI clock frequency updated;" \ |
| 98 | " else fdt set /clocks/qspi-clk clock-frequency" \ |
| 99 | " ${qspi_clock}; echo QSPI clock frequency updated; fi; fi\0" \ |
| 100 | "scriptaddr=0x81000000\0" \ |
| 101 | "scriptfile=boot.scr\0" \ |
| 102 | "socfpga_legacy_reset_compat=1\0" \ |
| 103 | "smc_fid_rd=0xC2000007\0" \ |
| 104 | "smc_fid_wr=0xC2000008\0" \ |
| 105 | "smc_fid_upd=0xC2000009\0 " \ |
| 106 | BOOTENV |
| 107 | |
| 108 | #else |
| 109 | |
| 110 | #define CFG_EXTRA_ENV_SETTINGS \ |
| 111 | "kernel_addr_r=0x2000000\0" \ |
| 112 | "fdt_addr_r=0x6000000\0" \ |
| 113 | "qspiscriptaddr=0x02110000\0" \ |
| 114 | "scriptsize=0x00010000\0" \ |
| 115 | "qspibootimageaddr=0x02120000\0" \ |
| 116 | "bootimagesize=0x03200000\0" \ |
| 117 | "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ |
| 118 | "bootfile=" CONFIG_BOOTFILE "\0" \ |
| 119 | "mmcroot=/dev/mmcblk0p2\0" \ |
| 120 | "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \ |
| 121 | "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \ |
| 122 | "linux_qspi_enable=if sf probe; then " \ |
| 123 | "echo Enabling QSPI at Linux DTB...;" \ |
| 124 | "fdt addr ${fdt_addr}; fdt resize;" \ |
| 125 | "fdt set /soc/spi@ff8d2000 status okay;" \ |
| 126 | "if fdt set /soc/clocks/qspi-clk clock-frequency" \ |
| 127 | " ${qspi_clock}; then echo QSPI clock frequency updated;" \ |
| 128 | " elif fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency" \ |
| 129 | " ${qspi_clock}; then echo QSPI clock frequency updated;" \ |
| 130 | " else fdt set /clocks/qspi-clk clock-frequency" \ |
| 131 | " ${qspi_clock}; echo QSPI clock frequency updated; fi; fi\0" \ |
| 132 | "scriptaddr=0x05FF0000\0" \ |
| 133 | "scriptfile=boot.scr\0" \ |
| 134 | "socfpga_legacy_reset_compat=1\0" \ |
| 135 | "smc_fid_rd=0xC2000007\0" \ |
| 136 | "smc_fid_wr=0xC2000008\0" \ |
| 137 | "smc_fid_upd=0xC2000009\0 " \ |
| 138 | BOOTENV |
| 139 | #endif /*#IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5)*/ |
| 140 | |
| 141 | #else |
| 142 | |
| 143 | #define CFG_EXTRA_ENV_SETTINGS \ |
| 144 | "kernel_comp_addr_r=0x9000000\0" \ |
| 145 | "kernel_comp_size=0x01000000\0" \ |
| 146 | "qspibootimageaddr=0x020E0000\0" \ |
| 147 | "qspifdtaddr=0x020D0000\0" \ |
| 148 | "bootimagesize=0x01F00000\0" \ |
| 149 | "fdtimagesize=0x00010000\0" \ |
| 150 | "qspiload=sf read ${loadaddr} ${qspibootimageaddr} ${bootimagesize};" \ |
| 151 | "sf read ${fdt_addr} ${qspifdtaddr} ${fdtimagesize}\0" \ |
| 152 | "qspiboot=setenv bootargs earlycon root=/dev/mtdblock1 rw " \ |
| 153 | "rootfstype=jffs2 rootwait;booti ${loadaddr} - ${fdt_addr}\0" \ |
| 154 | "qspifitload=sf read ${loadaddr} ${qspibootimageaddr} ${bootimagesize}\0" \ |
| 155 | "qspifitboot=setenv bootargs earlycon root=/dev/mtdblock1 rw " \ |
| 156 | "rootfstype=jffs2 rootwait;bootm ${loadaddr}\0" \ |
| 157 | "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ |
| 158 | "bootfile=" CONFIG_BOOTFILE "\0" \ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 159 | "fdt_addr=8000000\0" \ |
Ley Foon Tan | 461d298 | 2019-11-27 15:55:32 +0800 | [diff] [blame] | 160 | "fdtimage=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 161 | "mmcroot=/dev/mmcblk0p2\0" \ |
| 162 | "mmcboot=setenv bootargs " CONFIG_BOOTARGS \ |
| 163 | " root=${mmcroot} rw rootwait;" \ |
| 164 | "booti ${loadaddr} - ${fdt_addr}\0" \ |
| 165 | "mmcload=mmc rescan;" \ |
| 166 | "load mmc 0:1 ${loadaddr} ${bootfile};" \ |
| 167 | "load mmc 0:1 ${fdt_addr} ${fdtimage}\0" \ |
Chee Hong Ang | f28875c | 2020-12-24 18:20:57 +0800 | [diff] [blame] | 168 | "mmcfitboot=setenv bootargs " CONFIG_BOOTARGS \ |
| 169 | " root=${mmcroot} rw rootwait;" \ |
| 170 | "bootm ${loadaddr}\0" \ |
| 171 | "mmcfitload=mmc rescan;" \ |
| 172 | "load mmc 0:1 ${loadaddr} ${bootfile}\0" \ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 173 | "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \ |
| 174 | "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 175 | "linux_qspi_enable=if sf probe; then " \ |
| 176 | "echo Enabling QSPI at Linux DTB...;" \ |
| 177 | "fdt addr ${fdt_addr}; fdt resize;" \ |
| 178 | "fdt set /soc/spi@ff8d2000 status okay;" \ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 179 | "if fdt set /soc/clocks/qspi-clk clock-frequency" \ |
| 180 | " ${qspi_clock}; then echo QSPI clock frequency updated;" \ |
| 181 | " elif fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency" \ |
| 182 | " ${qspi_clock}; then echo QSPI clock frequency updated;" \ |
| 183 | " else fdt set /clocks/qspi-clk clock-frequency" \ |
| 184 | " ${qspi_clock}; echo QSPI clock frequency updated; fi; fi\0" \ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 185 | "scriptaddr=0x02100000\0" \ |
| 186 | "scriptfile=u-boot.scr\0" \ |
| 187 | "fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 188 | "then source ${scriptaddr}:script; fi\0" \ |
| 189 | "socfpga_legacy_reset_compat=1\0" \ |
| 190 | "smc_fid_rd=0xC2000007\0" \ |
| 191 | "smc_fid_wr=0xC2000008\0" \ |
| 192 | "smc_fid_upd=0xC2000009\0 " |
| 193 | #endif /*#if IS_ENABLED(CONFIG_DISTRO_DEFAULTS)*/ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 194 | |
| 195 | /* |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 196 | * External memory configurations |
| 197 | */ |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 198 | #if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) |
| 199 | #define PHYS_SDRAM_1 0x80000000 |
| 200 | #define PHYS_SDRAM_1_SIZE (1 * 1024 * 1024 * 1024) |
| 201 | #define CFG_SYS_SDRAM_BASE 0x80000000 |
| 202 | #else |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 203 | #define PHYS_SDRAM_1 0x0 |
| 204 | #define PHYS_SDRAM_1_SIZE (1 * 1024 * 1024 * 1024) |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 205 | #define CFG_SYS_SDRAM_BASE 0 |
Jit Loon Lim | 977071e | 2024-03-12 22:01:03 +0800 | [diff] [blame] | 206 | #endif |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 207 | |
| 208 | /* |
| 209 | * Serial / UART configurations |
| 210 | */ |
Tom Rini | df6a215 | 2022-11-16 13:10:28 -0500 | [diff] [blame] | 211 | #define CFG_SYS_NS16550_CLK 100000000 |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 212 | |
| 213 | /* |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 214 | * SDMMC configurations |
| 215 | */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 216 | /* |
| 217 | * Flash configurations |
| 218 | */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 219 | |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 220 | /* |
| 221 | * L4 Watchdog |
| 222 | */ |
Ley Foon Tan | 461d298 | 2019-11-27 15:55:32 +0800 | [diff] [blame] | 223 | #ifdef CONFIG_TARGET_SOCFPGA_STRATIX10 |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 224 | #ifndef __ASSEMBLY__ |
| 225 | unsigned int cm_get_l4_sys_free_clk_hz(void); |
Tom Rini | 79088cf | 2022-12-04 10:03:39 -0500 | [diff] [blame] | 226 | #define CFG_DW_WDT_CLOCK_KHZ (cm_get_l4_sys_free_clk_hz() / 1000) |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 227 | #endif |
Ley Foon Tan | 461d298 | 2019-11-27 15:55:32 +0800 | [diff] [blame] | 228 | #else |
Tom Rini | 79088cf | 2022-12-04 10:03:39 -0500 | [diff] [blame] | 229 | #define CFG_DW_WDT_CLOCK_KHZ 100000 |
Ley Foon Tan | 461d298 | 2019-11-27 15:55:32 +0800 | [diff] [blame] | 230 | #endif |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 231 | |
| 232 | /* |
| 233 | * SPL memory layout |
| 234 | * |
| 235 | * On chip RAM |
| 236 | * 0xFFE0_0000 ...... Start of OCRAM |
| 237 | * SPL code, rwdata |
| 238 | * empty space |
| 239 | * 0xFFEx_xxxx ...... Top of stack (grows down) |
| 240 | * 0xFFEy_yyyy ...... Global Data |
| 241 | * 0xFFEz_zzzz ...... Malloc prior relocation (size CONFIG_SYS_MALLOC_F_LEN) |
| 242 | * 0xFFE3_F000 ...... Hardware handdoff blob (size 4KB) |
| 243 | * 0xFFE3_FFFF ...... End of OCRAM |
| 244 | * |
| 245 | * SDRAM |
| 246 | * 0x0000_0000 ...... Start of SDRAM_1 |
| 247 | * unused / empty space for image loading |
Simon Glass | 67e3fca | 2023-09-26 08:14:16 -0600 | [diff] [blame] | 248 | * Size 64MB ...... MALLOC (size CONFIG_SPL_SYS_MALLOC_SIZE) |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 249 | * Size 1MB ...... BSS (size CONFIG_SPL_BSS_MAX_SIZE) |
| 250 | * 0x8000_0000 ...... End of SDRAM_1 (assume 2GB) |
| 251 | * |
| 252 | */ |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 253 | |
Ley Foon Tan | c46f6a6 | 2019-11-27 15:55:31 +0800 | [diff] [blame] | 254 | #endif /* __CONFIG_SOCFPGA_SOC64_COMMON_H__ */ |