blob: b7ee1dbf201cb188c1a81da3e1f061de4410ec48 [file] [log] [blame]
Ley Foon Tanc46f6a62019-11-27 15:55:31 +08001/* SPDX-License-Identifier: GPL-2.0
2 *
Jit Loon Lim977071e2024-03-12 22:01:03 +08003 * Copyright (C) 2017-2024 Intel Corporation <www.intel.com>
Ley Foon Tanc46f6a62019-11-27 15:55:31 +08004 *
5 */
6
7#ifndef __CONFIG_SOCFPGA_SOC64_COMMON_H__
8#define __CONFIG_SOCFPGA_SOC64_COMMON_H__
9
Siew Chin Lim142d9c02021-08-10 11:26:27 +080010#include <asm/arch/base_addr_soc64.h>
Siew Chin Lim954d5992021-03-24 13:11:34 +080011#include <asm/arch/handoff_soc64.h>
Simon Glassfb64e362020-05-10 11:40:09 -060012#include <linux/stringify.h>
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080013
14/*
15 * U-Boot general configurations
16 */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080017/* sysmgr.boot_scratch_cold4 & 5 (64bit) will be used for PSCI_CPU_ON call */
18#define CPU_RELEASE_ADDR 0xFFD12210
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080019
20/*
21 * U-Boot console configurations
22 */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080023
24/* Extend size of kernel image for uncompression */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080025
26/*
27 * U-Boot run time memory configurations
28 */
Jit Loon Lim977071e2024-03-12 22:01:03 +080029#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 Rini6a5dccc2022-11-16 13:10:41 -050033#define CFG_SYS_INIT_RAM_ADDR 0xFFE00000
34#define CFG_SYS_INIT_RAM_SIZE 0x40000
Jit Loon Lim977071e2024-03-12 22:01:03 +080035#endif
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080036
37/*
38 * U-Boot environment configurations
39 */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080040
41/*
Siew Chin Lim14b8a482021-03-01 20:04:14 +080042 * Environment variable
Ley Foon Tanc46f6a62019-11-27 15:55:31 +080043 */
Jit Loon Lim977071e2024-03-12 22:01:03 +080044#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 Rinic9edebe2022-12-04 10:03:50 -050078#define CFG_EXTRA_ENV_SETTINGS \
Jit Loon Lim977071e2024-03-12 22:01:03 +080079 "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 Tanc46f6a62019-11-27 15:55:31 +080085 "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
Chee Hong Angf28875c2020-12-24 18:20:57 +080086 "bootfile=" CONFIG_BOOTFILE "\0" \
Jit Loon Lim977071e2024-03-12 22:01:03 +080087 "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 Tanc46f6a62019-11-27 15:55:31 +0800159 "fdt_addr=8000000\0" \
Ley Foon Tan461d2982019-11-27 15:55:32 +0800160 "fdtimage=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800161 "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 Angf28875c2020-12-24 18:20:57 +0800168 "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 Lim977071e2024-03-12 22:01:03 +0800173 "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
174 "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800175 "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 Lim977071e2024-03-12 22:01:03 +0800179 "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 Tanc46f6a62019-11-27 15:55:31 +0800185 "scriptaddr=0x02100000\0" \
186 "scriptfile=u-boot.scr\0" \
187 "fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \
Jit Loon Lim977071e2024-03-12 22:01:03 +0800188 "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 Tanc46f6a62019-11-27 15:55:31 +0800194
195/*
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800196 * External memory configurations
197 */
Jit Loon Lim977071e2024-03-12 22:01:03 +0800198#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 Tanc46f6a62019-11-27 15:55:31 +0800203#define PHYS_SDRAM_1 0x0
204#define PHYS_SDRAM_1_SIZE (1 * 1024 * 1024 * 1024)
Tom Rinibb4dd962022-11-16 13:10:37 -0500205#define CFG_SYS_SDRAM_BASE 0
Jit Loon Lim977071e2024-03-12 22:01:03 +0800206#endif
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800207
208/*
209 * Serial / UART configurations
210 */
Tom Rinidf6a2152022-11-16 13:10:28 -0500211#define CFG_SYS_NS16550_CLK 100000000
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800212
213/*
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800214 * SDMMC configurations
215 */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800216/*
217 * Flash configurations
218 */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800219
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800220/*
221 * L4 Watchdog
222 */
Ley Foon Tan461d2982019-11-27 15:55:32 +0800223#ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800224#ifndef __ASSEMBLY__
225unsigned int cm_get_l4_sys_free_clk_hz(void);
Tom Rini79088cf2022-12-04 10:03:39 -0500226#define CFG_DW_WDT_CLOCK_KHZ (cm_get_l4_sys_free_clk_hz() / 1000)
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800227#endif
Ley Foon Tan461d2982019-11-27 15:55:32 +0800228#else
Tom Rini79088cf2022-12-04 10:03:39 -0500229#define CFG_DW_WDT_CLOCK_KHZ 100000
Ley Foon Tan461d2982019-11-27 15:55:32 +0800230#endif
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800231
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 Glass67e3fca2023-09-26 08:14:16 -0600248 * Size 64MB ...... MALLOC (size CONFIG_SPL_SYS_MALLOC_SIZE)
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800249 * Size 1MB ...... BSS (size CONFIG_SPL_BSS_MAX_SIZE)
250 * 0x8000_0000 ...... End of SDRAM_1 (assume 2GB)
251 *
252 */
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800253
Ley Foon Tanc46f6a62019-11-27 15:55:31 +0800254#endif /* __CONFIG_SOCFPGA_SOC64_COMMON_H__ */