1 /* 2 * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved. 3 * Copyright (c) 2019-2023, Intel Corporation. All rights reserved. 4 * Copyright (c) 2024-2025, Altera Corporation. All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef PLAT_SOCFPGA_DEF_H 10 #define PLAT_SOCFPGA_DEF_H 11 12 #include "agilex5_memory_controller.h" 13 #include "agilex5_system_manager.h" 14 15 #include <platform_def.h> 16 17 /* Platform Setting */ 18 #define PLATFORM_MODEL PLAT_SOCFPGA_AGILEX5 19 /* 1 = Flush cache, 0 = No cache flush. 20 * Default for Agilex5 is Cache flush. 21 */ 22 #define CACHE_FLUSH 1 23 #define MMC_DEVICE_TYPE 1 /* MMC = 0, SD = 1 */ 24 #define XLAT_TABLES_V2 U(1) 25 #define PLAT_PRIMARY_CPU_A55 0x000 26 #define PLAT_PRIMARY_CPU_A76 0x200 27 #define PLAT_CLUSTER_ID_MPIDR_AFF_SHIFT MPIDR_AFF2_SHIFT 28 #define PLAT_CPU_ID_MPIDR_AFF_SHIFT MPIDR_AFF1_SHIFT 29 #define PLAT_L2_RESET_REQ 0xB007C0DE 30 #define PLAT_HANDOFF_OFFSET 0x0007F000 31 #define PLAT_TIMER_BASE_ADDR 0x10D01000 32 #define SOCFPGA_DTB_BASE 0x80020000 33 #define DT_COMPATIBLE_STR "arm,altera socfpga-agilex5" 34 35 /* System Counter */ 36 /* TODO: Update back to 400MHz. 37 * This shall be updated to read from L4 clock instead of hardcoded. 38 */ 39 #define PLAT_SYS_COUNTER_FREQ_IN_TICKS U(400000000) 40 #define PLAT_SYS_COUNTER_FREQ_IN_MHZ U(400) 41 42 /* FPGA config helpers */ 43 #define INTEL_SIP_SMC_FPGA_CONFIG_ADDR 0x80400000 44 #define INTEL_SIP_SMC_FPGA_CONFIG_SIZE 0x82000000 45 46 /* QSPI Setting */ 47 #define CAD_QSPIDATA_OFST 0x10900000 48 #define CAD_QSPI_OFFSET 0x108d2000 49 50 /* FIP Setting */ 51 #define PLAT_FIP_BASE (0) 52 #if ARM_LINUX_KERNEL_AS_BL33 53 #define PLAT_FIP_MAX_SIZE (0x8000000) 54 #else 55 #define PLAT_FIP_MAX_SIZE (0x1000000) 56 #endif 57 58 /* SDMMC Setting */ 59 #if ARM_LINUX_KERNEL_AS_BL33 60 #define PLAT_MMC_DATA_BASE (0x90000000) 61 #define PLAT_MMC_DATA_SIZE (0x100000) 62 #define SOCFPGA_MMC_BLOCK_SIZE U(32768) 63 #else 64 #define PLAT_MMC_DATA_BASE (0x0007D000) 65 #define PLAT_MMC_DATA_SIZE (0x2000) 66 #define SOCFPGA_MMC_BLOCK_SIZE U(8192) 67 #endif 68 69 #define PLAT_NAND_SCRATCH_BUFF (0x96400000) 70 71 /* Register Mapping */ 72 #define SOCFPGA_CCU_NOC_REG_BASE 0x1c000000 73 #define SOCFPGA_F2SDRAMMGR_REG_BASE 0x18001000 74 75 #define SOCFPGA_MMC_REG_BASE 0x10808000 76 #define SOCFPGA_MEMCTRL_REG_BASE 0x108CC000 77 #define SOCFPGA_RSTMGR_REG_BASE 0x10d11000 78 #define SOCFPGA_SYSMGR_REG_BASE 0x10d12000 79 #define SOCFPGA_PINMUX_REG_BASE 0x10d13000 80 #define SOCFPGA_NAND_REG_BASE 0x10B80000 81 #define SOCFPGA_ECC_QSPI_REG_BASE 0x10A22000 82 83 #define SOCFPGA_L4_PER_SCR_REG_BASE 0x10d21000 84 #define SOCFPGA_L4_SYS_SCR_REG_BASE 0x10d21100 85 #define SOCFPGA_SOC2FPGA_SCR_REG_BASE 0x10d21200 86 #define SOCFPGA_LWSOC2FPGA_SCR_REG_BASE 0x10d21300 87 #define SOCFPGA_SDMMC_SECU_BIT 0x40 88 #define SOCFPGA_LWSOC2FPGA_ENABLE 0xffe0301 89 #define SOCFPGA_SDMMC_SECU_BIT_ENABLE 0x1010001 90 91 92 /* Define maximum page size for NAND flash devices */ 93 #define PLATFORM_MTD_MAX_PAGE_SIZE U(0x2000) 94 95 /* OCRAM Register*/ 96 97 #define OCRAM_REG_BASE 0x108CC400 98 #define OCRAM_REGION_0_OFFSET 0x18 99 #define OCRAM_REGION_0_REG_BASE (OCRAM_REG_BASE + \ 100 OCRAM_REGION_0_OFFSET) 101 #define OCRAM_NON_SECURE_ENABLE 0x0 102 103 104 /* 105 * Magic key bits: 4 bits[5:2] from boot scratch register COLD3 are used to 106 * indicate the below requests/status 107 * 0x0 : Default value on reset, not used 108 * 0x1 : L2/warm reset is completed 109 * 0x2 : SMP secondary core boot requests 110 * 0x3 - 0xF : Reserved for future use 111 */ 112 #define BS_REG_MAGIC_KEYS_MASK 0x3C 113 #define BS_REG_MAGIC_KEYS_POS 0x02 114 #define L2_RESET_DONE_STATUS (0x01 << BS_REG_MAGIC_KEYS_POS) 115 #define SMP_SEC_CORE_BOOT_REQ (0x02 << BS_REG_MAGIC_KEYS_POS) 116 #define ALIGN_CHECK_64BIT_MASK 0x07 117 118 /******************************************************************************* 119 * Platform memory map related constants 120 ******************************************************************************/ 121 #define DRAM_BASE (0x80000000) 122 #define DRAM_SIZE (0x80000000) 123 124 #define OCRAM_BASE (0x00000000) 125 #define OCRAM_SIZE (0x00080000) 126 127 #define MEM64_BASE (0x0080000000) 128 #define MEM64_SIZE (0x0080000000) 129 130 //128MB PSS 131 #define PSS_BASE (0x10000000) 132 #define PSS_SIZE (0x08000000) 133 134 //64MB MPFE 135 #define MPFE_BASE (0x18000000) 136 #define MPFE_SIZE (0x04000000) 137 138 //16MB CCU 139 #define CCU_BASE (0x1C000000) 140 #define CCU_SIZE (0x01000000) 141 142 //1MB GIC 143 #define GIC_BASE (0x1D000000) 144 #define GIC_SIZE (0x00100000) 145 146 #define BL2_BASE (0x00000000) 147 #define BL2_LIMIT (0x0007E000) 148 149 #define BL31_BASE (0x80000000) 150 #define BL31_LIMIT (0x82000000) 151 /******************************************************************************* 152 * UART related constants 153 ******************************************************************************/ 154 #define PLAT_UART0_BASE (0x10C02000) 155 #define PLAT_UART1_BASE (0x10C02100) 156 157 /******************************************************************************* 158 * WDT related constants 159 ******************************************************************************/ 160 #define WDT_BASE (0x10D00200) 161 162 /******************************************************************************* 163 * GIC related constants 164 ******************************************************************************/ 165 #define PLAT_GIC_BASE (0x1D000000) 166 #define PLAT_GICC_BASE (PLAT_GIC_BASE + 0x20000) 167 #define PLAT_GICD_BASE (PLAT_GIC_BASE + 0x00000) 168 #define PLAT_GICR_BASE (PLAT_GIC_BASE + 0x60000) 169 170 #define PLAT_INTEL_SOCFPGA_GICR_BASE PLAT_GICR_BASE 171 172 /******************************************************************************* 173 * SDMMC related pointer function 174 ******************************************************************************/ 175 #define SDMMC_READ_BLOCKS sdmmc_read_blocks 176 #define SDMMC_WRITE_BLOCKS sdmmc_write_blocks 177 178 /******************************************************************************* 179 * sysmgr.boot_scratch_cold3 bits[5:2] are used to indicate L2 reset 180 * is done, or SMP secondary cores boot request status. 181 ******************************************************************************/ 182 #define L2_RESET_DONE_REG SOCFPGA_SYSMGR(BOOT_SCRATCH_COLD_3) 183 184 #endif /* PLAT_SOCFPGA_DEF_H */ 185