xref: /rk3399_ARM-atf/plat/arm/board/automotive_rd/platform/rdaspen/include/platform_def.h (revision 7b2567911b53a4739607721d16ae15d88681e1ae)
1 /*
2  * Copyright (c) 2025, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef PLATFORM_DEF_H
8 #define PLATFORM_DEF_H
9 
10 #include <lib/utils_def.h>
11 #include <lib/xlat_tables/xlat_tables_defs.h>
12 
13 #define PLAT_ARM_TRUSTED_SRAM_BASE		UL(0x0)
14 #define PLAT_ARM_TRUSTED_SRAM_SIZE		UL(0x00100000)
15 
16 /*
17  * SMD region assignment
18  * AP accesses devices located in SMD via AP SMD region starting from
19  * 0x4000_0000.
20  */
21 /* CNTControl frame 64KB */
22 #define PLAT_ARM_SYS_CNTCTL_BASE		UL(0x40000000)
23 /* CNTRead frame 64KB */
24 #define PLAT_ARM_SYS_CNTREAD_BASE		UL(0x40010000)
25 /* SI MHU regions 6MB in total */
26 #define SI_MHU_REGION_BASE			UL(0x40020000)
27 /* AP MHU regions 768KB in total */
28 #define RDASPEN_CSS_AP_RSE_SECURE_MHU_BASE	UL(0x40680000)
29 
30 /* AP access AP_REFLCK generic timers via Peripheral Block */
31 #define PLAT_ARM_SYS_TIMCTL_BASE		UL(0x1A810000)
32 #define PLAT_ARM_SYS_CNT_BASE_S			UL(0x1A820000)
33 #define PLAT_ARM_SYS_CNT_BASE_NS		UL(0x1A830000)
34 #define PLAT_ARM_NSTIMER_FRAME_ID		U(1)
35 
36 #include <plat/arm/common/arm_def.h>
37 #include <plat/arm/css/common/css_def.h>
38 #include <plat/common/common_def.h>
39 
40 /* Set default topology value if not passed from platform's makefile */
41 #ifndef PLATFORM_CORE_COUNT
42 #define PLATFORM_CORE_COUNT			U(16)
43 #endif /* PLATFORM_CORE_COUNT */
44 
45 #if (PLATFORM_CORE_COUNT > 16) || (PLATFORM_CORE_COUNT < 1)
46 #error "Invalid number of platform's cores was passed."
47 #endif /* 1 <= PLATFORM_CORE_COUNT <= 16 */
48 
49 #if (PLATFORM_CORE_COUNT <= 4)
50 #define PLATFORM_CLUSTER_0_CORE_COUNT		U(PLATFORM_CORE_COUNT)
51 #define PLATFORM_CLUSTER_1_CORE_COUNT		U(0)
52 #define PLATFORM_CLUSTER_2_CORE_COUNT		U(0)
53 #define PLATFORM_CLUSTER_3_CORE_COUNT		U(0)
54 
55 #else /* PLATFORM_CORE_COUNT <= 4 */
56 #define PLATFORM_CLUSTER_0_CORE_COUNT		U(4)
57 
58 #if (PLATFORM_CORE_COUNT <= 8)
59 #define PLATFORM_CLUSTER_1_CORE_COUNT		U(PLATFORM_CORE_COUNT - 4)
60 #define PLATFORM_CLUSTER_2_CORE_COUNT		U(0)
61 #define PLATFORM_CLUSTER_3_CORE_COUNT		U(0)
62 
63 #else /* PLATFORM_CORE_COUNT <= 8 */
64 #define PLATFORM_CLUSTER_1_CORE_COUNT		U(4)
65 
66 #if (PLATFORM_CORE_COUNT <= 12)
67 #define PLATFORM_CLUSTER_2_CORE_COUNT		U(PLATFORM_CORE_COUNT - 8)
68 #define PLATFORM_CLUSTER_3_CORE_COUNT		U(0)
69 
70 #else /* PLATFORM_CORE_COUNT <= 12 */
71 #define PLATFORM_CLUSTER_2_CORE_COUNT		U(4)
72 #define PLATFORM_CLUSTER_3_CORE_COUNT		U(PLATFORM_CORE_COUNT - 12)
73 
74 #endif /* PLATFORM_CORE_COUNT <= 12 */
75 #endif /* PLATFORM_CORE_COUNT <= 8 */
76 #endif /* PLATFORM_CORE_COUNT <= 4 */
77 
78 #define PLAT_MAX_CPUS_PER_CLUSTER		U(4)
79 #define PLAT_MAX_PE_PER_CPU			U(1)
80 #define PLAT_ARM_CLUSTER_COUNT			((PLATFORM_CORE_COUNT + \
81 						  PLAT_MAX_CPUS_PER_CLUSTER - 1) / \
82 						  PLAT_MAX_CPUS_PER_CLUSTER)
83 
84 #define PLATFORM_STACK_SIZE			UL(0x1000)
85 
86 /* BL1 is not supported */
87 #define PLAT_ARM_TRUSTED_ROM_BASE		UL(0x0)
88 #define PLAT_ARM_TRUSTED_ROM_SIZE		UL(0x0)
89 #define PLAT_ARM_MAX_BL1_RW_SIZE		UL(0x0)
90 
91 /* USE_ROMLIB is not supported */
92 #define PLAT_ARM_MAX_ROMLIB_RW_SIZE		U(0)
93 #define PLAT_ARM_MAX_ROMLIB_RO_SIZE		U(0)
94 
95 #define PLAT_ARM_MAX_BL31_SIZE			UL(0xED000)
96 
97 #undef ARM_DRAM2_BASE
98 #define ARM_DRAM2_BASE				ULL(0x20000000000)
99 #undef ARM_DRAM2_SIZE
100 #define ARM_DRAM2_SIZE				SZ_2G
101 
102 /*
103  * MHU for SCMI communication with SCP on Safety Island CL0
104  * Offset to SI_MHU_REGION_BASE: 0x0008_0000.
105  */
106 #define PLAT_CSS_MHU_BASE			UL(0x400A0000)
107 
108 /* UART Related Constants */
109 #define SOC_CSS_SEC_UART_BASE			UL(0x1A410000)
110 #define SOC_CSS_UART_SIZE			SZ_64K
111 #define SOC_CSS_UART_CLK_IN_HZ			UL(24000000)
112 #define PLAT_ARM_BOOT_UART_BASE			SOC_CSS_SEC_UART_BASE
113 #define PLAT_ARM_BOOT_UART_CLK_IN_HZ		SOC_CSS_UART_CLK_IN_HZ
114 #define PLAT_ARM_RUN_UART_BASE			SOC_CSS_SEC_UART_BASE
115 #define PLAT_ARM_RUN_UART_CLK_IN_HZ		SOC_CSS_UART_CLK_IN_HZ
116 #define PLAT_ARM_CRASH_UART_BASE		SOC_CSS_SEC_UART_BASE
117 #define PLAT_ARM_CRASH_UART_CLK_IN_HZ		SOC_CSS_UART_CLK_IN_HZ
118 
119 /* 256 TB */
120 #define SZ_256T					(1ULL << 48)
121 /* Physical and virtual address space limits for MMU */
122 #define PLAT_PHY_ADDR_SPACE_SIZE		SZ_256T
123 #define PLAT_VIRT_ADDR_SPACE_SIZE		SZ_256T
124 
125 #define PLAT_ARM_GICD_BASE			UL(0x20000000)
126 #define PLAT_ARM_GICR_BASE			UL(0x200C0000)
127 #define PLAT_ARM_G1S_IRQ_PROPS(grp)		CSS_G1S_IRQ_PROPS(grp)
128 #define PLAT_ARM_G0_IRQ_PROPS(grp)		ARM_G0_IRQ_PROPS(grp)
129 
130 /* Secure Watchdog Constants */
131 #define SBSA_SECURE_WDOG_BASE			UL(0x1A460000)
132 #define SBSA_SECURE_WDOG_TIMEOUT		UL(100)
133 
134 /* Virtual address used by dynamic mem_protect for chunk_base */
135 #define PLAT_ARM_MEM_PROTEC_VA_FRAME		UL(0xC0000000)
136 
137 /* SCMI Related Constants */
138 #define PLAT_ARM_SCMI_CHANNEL_COUNT		U(1)
139 #define CSS_SYSTEM_PWR_DMN_LVL			ARM_PWR_LVL2
140 #define PLAT_MAX_PWR_LVL			ARM_PWR_LVL1
141 
142 #define MAX_IO_DEVICES				U(3)
143 #define MAX_IO_HANDLES				U(4)
144 
145 #define RDASPEN_CPER_BUF_BASE			UL(0xFFA00000)
146 #define RDASPEN_CPER_BUF_SIZE			UL(0x00100000)
147 
148 #define RDASPEN_MAP_CPER_BUF			MAP_REGION_FLAT(RDASPEN_CPER_BUF_BASE, \
149 						RDASPEN_CPER_BUF_SIZE, \
150 						MT_MEMORY | MT_RW | MT_NS)
151 
152 #if IMAGE_BL2
153 #define PLAT_ARM_MMAP_ENTRIES			U(9)
154 #elif IMAGE_BL31
155 #define PLAT_ARM_MMAP_ENTRIES			(U(9))
156 #endif
157 #define MAX_XLAT_TABLES				(U(10))
158 
159 /*
160  * Map peripherals till GIC regions and devices in Rest of System
161  */
162 #define RDASPEN_DEVICE_BASE		UL(0x10000000)
163 #define RDASPEN_DEVICE_SIZE		UL(0x28000000)
164 #define RDASPEN_MAP_DEVICE		MAP_REGION_FLAT(RDASPEN_DEVICE_BASE, \
165 							RDASPEN_DEVICE_SIZE, \
166 							MT_DEVICE | MT_RW | \
167 							MT_SECURE)
168 
169 /* Flash in Rest of the System */
170 #define EXT_FLASH_BASE			UL(0x38000000)
171 #define EXT_FLASH_SIZE			SZ_128M
172 #define EXT_FLASH_BLOCK_SIZE		SZ_256K
173 #define PLAT_ARM_FLASH_IMAGE_BASE	EXT_FLASH_BASE
174 #define PLAT_ARM_FLASH_IMAGE_MAX_SIZE	(EXT_FLASH_SIZE - \
175 					 EXT_FLASH_BLOCK_SIZE)
176 
177 #define RDASPEN_MAP_EXTERNAL_FLASH	MAP_REGION_FLAT(EXT_FLASH_BASE, \
178 							PLAT_ARM_FLASH_IMAGE_MAX_SIZE, \
179 							MT_DEVICE | MT_RO | \
180 							MT_SECURE)
181 
182 /* SMD region */
183 #define RDASPEN_SMD_REGION_BASE		UL(0x40000000)
184 #define RDASPEN_SMD_REGION_SIZE		UL(0x10000000)
185 #define RDASPEN_MAP_SMD_REGION		MAP_REGION_FLAT(RDASPEN_SMD_REGION_BASE, \
186 							RDASPEN_SMD_REGION_SIZE, \
187 							MT_DEVICE | MT_RW | \
188 							MT_SECURE)
189 
190 /* Trusted OS Config region */
191 #define PLAT_TOS_FW_CONFIG_BASE		UL(0x1800)
192 #define PLAT_TOS_FW_CONFIG_SIZE		UL(0x1000)
193 
194 /* SPMC region */
195 #define PLAT_ARM_SPMC_BASE		UL(0xFFC00000)
196 #define PLAT_ARM_SPMC_SIZE		UL(0x00400000)
197 
198 /*
199  * NS DRAM
200  * DRAM1 consists of Non-secure partition and SPMC Secure partition.
201  */
202 #define NS_DRAM_SIZE			(ARM_DRAM1_SIZE - PLAT_ARM_SPMC_SIZE)
203 
204 #define RDASPEN_MAP_NS_DRAM1		MAP_REGION_FLAT(ARM_DRAM1_BASE, \
205 							NS_DRAM_SIZE, \
206 							MT_MEMORY | MT_RW | \
207 							MT_NS)
208 
209 #define RDASPEN_MAP_NS_DRAM2		MAP_REGION_FLAT(ARM_DRAM2_BASE, \
210 							ARM_DRAM2_SIZE,	\
211 							MT_MEMORY | MT_RW | \
212 							MT_NS)
213 
214 /* Secure DRAM */
215 #define RDASPEN_MAP_S_DRAM		MAP_REGION_FLAT(PLAT_ARM_SPMC_BASE, \
216 							PLAT_ARM_SPMC_SIZE, \
217 							MT_MEMORY | MT_RW | \
218 							MT_SECURE)
219 
220 /* load address of DTB */
221 #define PLAT_HW_CONFIG_DTB_BASE		ARM_DRAM1_BASE
222 #define PLAT_ARM_HW_CONFIG_SIZE		UL(0x8000)
223 
224 /*
225  * PSCI memory protect definitions:
226  * This variable is stored in a non-secure flash because some ARM reference
227  * platforms do not have secure NVRAM. Real systems that provided MEM_PROTECT
228  * support must use a secure NVRAM to store the PSCI MEM_PROTECT definitions.
229  */
230 #define PLAT_ARM_MEM_PROT_ADDR		(EXT_FLASH_BASE + \
231 					 EXT_FLASH_SIZE - \
232 					 EXT_FLASH_BLOCK_SIZE)
233 
234 /* Map mem_protect flash region with read and write permissions */
235 #define RDASPEN_MAP_MEM_PROTECT		MAP_REGION_FLAT(PLAT_ARM_MEM_PROT_ADDR,	\
236 							EXT_FLASH_BLOCK_SIZE,	\
237 							MT_DEVICE | MT_RW | \
238 							MT_SECURE)
239 
240 /* Non-volatile counters */
241 #define RDASPEN_TRUSTED_NVCTR_BASE	UL(0x32030000)
242 #define RDASPEN_TRUSTED_NVCTR_SIZE	UL(0x10000)
243 #define TFW_NVCTR_BASE			RDASPEN_TRUSTED_NVCTR_BASE
244 #define TFW_NVCTR_SIZE			4
245 #define NTFW_CTR_BASE			(RDASPEN_TRUSTED_NVCTR_BASE + 0x0004)
246 #define NTFW_CTR_SIZE			4
247 
248 #define RDASPEN_MAP_TRUSTED_NVCTR	MAP_REGION_FLAT(RDASPEN_TRUSTED_NVCTR_BASE,	\
249 							RDASPEN_TRUSTED_NVCTR_SIZE,	\
250 							MT_DEVICE | MT_RO | \
251 							MT_SECURE)
252 
253 /* 125 MHz REFCLK to System Counter */
254 #define SYS_COUNTER_FREQ_IN_TICKS	UL(125000000)
255 
256 /* The index of the primary CPU */
257 #define RDASPEN_PRIMARY_CPU		0x0
258 
259 /*
260  * In the current implementation, the RoT Service request that requires the
261  * biggest message buffer is the RSE_DELEGATED_ATTEST_GET_PLATFORM_TOKEN. The
262  * maximum required buffer size is calculated based on the platform-specific
263  * needs of this request.
264  */
265  #define PLAT_RSE_COMMS_PAYLOAD_MAX_SIZE	UL(0x1000)
266 
267 /*******************************************************************************
268  * MHUv3 related definitions
269  ******************************************************************************/
270 
271 /* AP - RSE MHUv3 */
272 #define MHU_V3_MBX_FRAME_OFFSET		UL(0x30000)
273 
274 /* MHUv3 Postbox and Mailbox register frame base */
275 #define AP_RSE_SECURE_MHU_V3_PBX	RDASPEN_CSS_AP_RSE_SECURE_MHU_BASE
276 #define AP_RSE_SECURE_MHU_V3_MBX	RDASPEN_CSS_AP_RSE_SECURE_MHU_BASE + \
277 						MHU_V3_MBX_FRAME_OFFSET
278 
279 /*
280  * In the current implementation, the RoT Service request that requires the
281  * biggest message buffer is the RSE_DELEGATED_ATTEST_GET_PLATFORM_TOKEN. The
282  * maximum required buffer size is calculated based on the platform-specific
283  * needs of this request.
284  */
285  #define PLAT_RSE_COMMS_PAYLOAD_MAX_SIZE	UL(0x1000)
286 
287 /*******************************************************************************
288  * MHUv3 related definitions
289  ******************************************************************************/
290 
291 /* AP - RSE MHUv3 */
292 #define MHU_V3_MBX_FRAME_OFFSET		UL(0x30000)
293 
294 /* MHUv3 Postbox and Mailbox register frame base */
295 #define AP_RSE_SECURE_MHU_V3_PBX	RDASPEN_CSS_AP_RSE_SECURE_MHU_BASE
296 #define AP_RSE_SECURE_MHU_V3_MBX	RDASPEN_CSS_AP_RSE_SECURE_MHU_BASE + \
297 						MHU_V3_MBX_FRAME_OFFSET
298 
299 #endif  /* PLATFORM_DEF_H */
300