1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2012 Altera Corporation <www.altera.com>
5 #ifndef __CONFIG_SOCFPGA_COMMON_H__
6 #define __CONFIG_SOCFPGA_COMMON_H__
8 #include <linux/stringify.h>
11 * Memory configurations
13 #define PHYS_SDRAM_1 0x0
14 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
15 #define CONFIG_SYS_INIT_RAM_ADDR 0xFFFF0000
16 #define CONFIG_SYS_INIT_RAM_SIZE SOCFPGA_PHYS_OCRAM_SIZE
17 #define CONFIG_SPL_PAD_TO 0x10000
18 #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
19 #define CONFIG_SYS_INIT_RAM_ADDR 0xFFE00000
20 #define CONFIG_SPL_PAD_TO 0x40000
21 /* SPL memory allocation configuration, this is for FAT implementation */
22 #ifndef CONFIG_SYS_SPL_MALLOC_SIZE
23 #define CONFIG_SYS_SPL_MALLOC_SIZE 0x10000
25 #define CONFIG_SYS_INIT_RAM_SIZE (SOCFPGA_PHYS_OCRAM_SIZE - \
26 CONFIG_SYS_SPL_MALLOC_SIZE)
27 #define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SYS_INIT_RAM_ADDR + \
28 CONFIG_SYS_INIT_RAM_SIZE)
32 * Some boards (e.g. socfpga_sr1500) use 8 bytes at the end of the internal
33 * SRAM as bootcounter storage. Make sure to not put the stack directly
34 * at this address to not overwrite the bootcounter by checking, if the
35 * bootcounter address is located in the internal SRAM.
37 #if ((CONFIG_SYS_BOOTCOUNT_ADDR > CONFIG_SYS_INIT_RAM_ADDR) && \
38 (CONFIG_SYS_BOOTCOUNT_ADDR < (CONFIG_SYS_INIT_RAM_ADDR + \
39 CONFIG_SYS_INIT_RAM_SIZE)))
40 #define CONFIG_SPL_STACK CONFIG_SYS_BOOTCOUNT_ADDR
42 #define CONFIG_SPL_STACK \
43 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)
47 * U-Boot stack setup: if SPL post-reloc uses DDR stack, use it in pre-reloc
48 * phase of U-Boot, too. This prevents overwriting SPL data if stack/heap usage
49 * in U-Boot pre-reloc is higher than in SPL.
51 #if defined(CONFIG_SPL_STACK_R_ADDR) && CONFIG_SPL_STACK_R_ADDR
52 #define CONFIG_SYS_INIT_SP_ADDR CONFIG_SPL_STACK_R_ADDR
54 #define CONFIG_SYS_INIT_SP_ADDR CONFIG_SPL_STACK
57 #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
60 * U-Boot general configurations
62 #define CONFIG_SYS_CBSIZE 1024 /* Console I/O buffer size */
63 /* Print buffer size */
64 #define CONFIG_SYS_MAXARGS 32 /* Max number of command args */
65 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
66 /* Boot argument buffer size */
71 #define CONFIG_SYS_L2_PL310
72 #define CONFIG_SYS_PL310_BASE SOCFPGA_MPUL2_ADDRESS
75 * Ethernet on SoC (EMAC)
78 #define CONFIG_DW_ALTDESCRIPTOR
84 #ifdef CONFIG_CMD_FPGA
85 #define CONFIG_FPGA_COUNT 1
92 #define CONFIG_SYS_TIMERBASE SOCFPGA_OSC1TIMER0_ADDRESS
93 #define CONFIG_SYS_TIMER_COUNTS_DOWN
94 #define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4)
95 #ifndef CONFIG_SYS_TIMER_RATE
96 #define CONFIG_SYS_TIMER_RATE 25000000
103 #define CONFIG_DW_WDT_BASE SOCFPGA_L4WD0_ADDRESS
104 #define CONFIG_DW_WDT_CLOCK_KHZ 25000
109 #ifdef CONFIG_CMD_MMC
111 /* using smaller max blk cnt to avoid flooding the limited stack we have */
112 #define CONFIG_SYS_MMC_MAX_BLK_COUNT 256 /* FIXME -- SPL only? */
118 #ifdef CONFIG_NAND_DENALI
119 #define CONFIG_SYS_MAX_NAND_DEVICE 1
120 #define CONFIG_SYS_NAND_REGS_BASE SOCFPGA_NANDREGS_ADDRESS
121 #define CONFIG_SYS_NAND_DATA_BASE SOCFPGA_NANDDATA_ADDRESS
129 * USB Gadget (DFU, UMS)
131 #if defined(CONFIG_CMD_DFU) || defined(CONFIG_CMD_USB_MASS_STORAGE)
132 #define DFU_DEFAULT_POLL_TIMEOUT 300
135 #define CONFIG_G_DNL_UMS_VENDOR_NUM 0x0525
136 #define CONFIG_G_DNL_UMS_PRODUCT_NUM 0xA4A5
143 /* Environment for SDMMC boot */
145 /* Environment for QSPI boot */
150 * SRAM Memory layout for gen 5:
152 * 0xFFFF_0000 ...... Start of SRAM
153 * 0xFFFF_xxxx ...... Top of stack (grows down)
154 * 0xFFFF_yyyy ...... Global Data
155 * 0xFFFF_zzzz ...... Malloc area
156 * 0xFFFF_FFFF ...... End of SRAM
158 * SRAM Memory layout for Arria 10:
159 * 0xFFE0_0000 ...... Start of SRAM (bottom)
160 * 0xFFEx_xxxx ...... Top of stack (grows down to bottom)
161 * 0xFFEy_yyyy ...... Global Data
162 * 0xFFEz_zzzz ...... Malloc area (grows up to top)
163 * 0xFFE3_FFFF ...... End of SRAM (top)
165 #ifndef CONFIG_SPL_TEXT_BASE
166 #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_INIT_RAM_SIZE
169 /* SPL SDMMC boot support */
170 #ifdef CONFIG_SPL_MMC
171 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
172 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img"
176 /* SPL QSPI boot support */
178 /* SPL NAND boot support */
180 /* Extra Environment */
181 #ifndef CONFIG_SPL_BUILD
183 #ifdef CONFIG_CMD_DHCP
184 #define BOOT_TARGET_DEVICES_DHCP(func) func(DHCP, dhcp, na)
186 #define BOOT_TARGET_DEVICES_DHCP(func)
189 #if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
190 #define BOOT_TARGET_DEVICES_PXE(func) func(PXE, pxe, na)
192 #define BOOT_TARGET_DEVICES_PXE(func)
195 #ifdef CONFIG_CMD_MMC
196 #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
198 #define BOOT_TARGET_DEVICES_MMC(func)
201 #define BOOT_TARGET_DEVICES(func) \
202 BOOT_TARGET_DEVICES_MMC(func) \
203 BOOT_TARGET_DEVICES_PXE(func) \
204 BOOT_TARGET_DEVICES_DHCP(func)
206 #include <config_distro_bootcmd.h>
208 #ifndef CONFIG_EXTRA_ENV_SETTINGS
209 #define CONFIG_EXTRA_ENV_SETTINGS \
210 "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
211 "bootm_size=0xa000000\0" \
212 "kernel_addr_r="__stringify(CONFIG_SYS_LOAD_ADDR)"\0" \
213 "fdt_addr_r=0x02000000\0" \
214 "scriptaddr=0x02100000\0" \
215 "pxefile_addr_r=0x02200000\0" \
216 "ramdisk_addr_r=0x02300000\0" \
217 "socfpga_legacy_reset_compat=1\0" \
223 #endif /* __CONFIG_SOCFPGA_COMMON_H__ */