blob: ccabced9ec34f8b55424ca1dfd64ec71c7614648 [file] [log] [blame]
Usama Arifbec5afd2020-04-17 16:13:39 +01001/*
Usama Ariffdfd2502021-03-30 16:39:19 +01002 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Usama Arifbec5afd2020-04-17 16:13:39 +01003 *
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#include <plat/arm/board/common/board_css_def.h>
13#include <plat/arm/board/common/v2m_def.h>
14#include <plat/arm/common/arm_def.h>
15#include <plat/arm/common/arm_spm_def.h>
16#include <plat/arm/css/common/css_def.h>
17#include <plat/arm/soc/common/soc_css_def.h>
18#include <plat/common/common_def.h>
19
Avinash Mehtaf68a0842020-10-28 16:43:28 +000020#define PLATFORM_CORE_COUNT 8
Usama Arifbec5afd2020-04-17 16:13:39 +010021
22#define PLAT_ARM_TRUSTED_SRAM_SIZE 0x00080000 /* 512 KB */
23
24/*
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010025 * The top 16MB of ARM_DRAM1 is configured as secure access only using the TZC,
26 * its base is ARM_AP_TZC_DRAM1_BASE.
27 *
28 * Reserve 32MB below ARM_AP_TZC_DRAM1_BASE for:
29 * - BL32_BASE when SPD_spmd is enabled
30 * - Region to load Trusted OS
31 */
Usama Ariff1513622021-04-09 17:07:41 +010032#define TC_TZC_DRAM1_BASE (ARM_AP_TZC_DRAM1_BASE - \
33 TC_TZC_DRAM1_SIZE)
34#define TC_TZC_DRAM1_SIZE UL(0x02000000) /* 32 MB */
35#define TC_TZC_DRAM1_END (TC_TZC_DRAM1_BASE + \
36 TC_TZC_DRAM1_SIZE - 1)
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010037
Usama Ariff1513622021-04-09 17:07:41 +010038#define TC_NS_DRAM1_BASE ARM_DRAM1_BASE
39#define TC_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010040 ARM_TZC_DRAM1_SIZE - \
Usama Ariff1513622021-04-09 17:07:41 +010041 TC_TZC_DRAM1_SIZE)
42#define TC_NS_DRAM1_END (TC_NS_DRAM1_BASE + \
43 TC_NS_DRAM1_SIZE - 1)
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010044
45/*
Usama Ariff1513622021-04-09 17:07:41 +010046 * Mappings for TC DRAM1 (non-secure) and TC TZC DRAM1 (secure)
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010047 */
Usama Ariff1513622021-04-09 17:07:41 +010048#define TC_MAP_NS_DRAM1 MAP_REGION_FLAT( \
49 TC_NS_DRAM1_BASE, \
50 TC_NS_DRAM1_SIZE, \
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010051 MT_MEMORY | MT_RW | MT_NS)
52
53
Usama Ariff1513622021-04-09 17:07:41 +010054#define TC_MAP_TZC_DRAM1 MAP_REGION_FLAT( \
55 TC_TZC_DRAM1_BASE, \
56 TC_TZC_DRAM1_SIZE, \
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010057 MT_MEMORY | MT_RW | MT_SECURE)
Usama Arifa49bd492021-08-17 17:57:10 +010058
59#define PLAT_HW_CONFIG_DTB_BASE ULL(0x83000000)
60#define PLAT_HW_CONFIG_DTB_SIZE ULL(0x8000)
61
62#define PLAT_DTB_DRAM_NS MAP_REGION_FLAT( \
63 PLAT_HW_CONFIG_DTB_BASE, \
64 PLAT_HW_CONFIG_DTB_SIZE, \
65 MT_MEMORY | MT_RO | MT_NS)
Arunachalam Ganapathyade4a202020-09-22 12:50:45 +010066/*
Usama Ariff1513622021-04-09 17:07:41 +010067 * Max size of SPMC is 2MB for tc. With SPMD enabled this value corresponds to
Arunachalam Ganapathyade4a202020-09-22 12:50:45 +010068 * max size of BL32 image.
69 */
70#if defined(SPD_spmd)
Usama Ariff1513622021-04-09 17:07:41 +010071#define PLAT_ARM_SPMC_BASE TC_TZC_DRAM1_BASE
Arunachalam Ganapathyade4a202020-09-22 12:50:45 +010072#define PLAT_ARM_SPMC_SIZE UL(0x200000) /* 2 MB */
73#endif
Arunachalam Ganapathy81da5582020-09-22 12:47:33 +010074
75/*
Usama Arifbec5afd2020-04-17 16:13:39 +010076 * PLAT_ARM_MMAP_ENTRIES depends on the number of entries in the
77 * plat_arm_mmap array defined for each BL stage.
78 */
79#if defined(IMAGE_BL31)
80# if SPM_MM
81# define PLAT_ARM_MMAP_ENTRIES 9
82# define MAX_XLAT_TABLES 7
83# define PLAT_SP_IMAGE_MMAP_REGIONS 7
84# define PLAT_SP_IMAGE_MAX_XLAT_TABLES 10
85# else
86# define PLAT_ARM_MMAP_ENTRIES 8
87# define MAX_XLAT_TABLES 8
88# endif
89#elif defined(IMAGE_BL32)
90# define PLAT_ARM_MMAP_ENTRIES 8
91# define MAX_XLAT_TABLES 5
92#elif !USE_ROMLIB
93# define PLAT_ARM_MMAP_ENTRIES 11
94# define MAX_XLAT_TABLES 7
95#else
96# define PLAT_ARM_MMAP_ENTRIES 12
97# define MAX_XLAT_TABLES 6
98#endif
99
100/*
101 * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
102 * plus a little space for growth.
103 */
104#define PLAT_ARM_MAX_BL1_RW_SIZE 0xC000
105
106/*
107 * PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
108 */
109
110#if USE_ROMLIB
111#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
112#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0xe000
113#else
114#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
115#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
116#endif
117
118/*
119 * PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
120 * little space for growth.
121 */
122#if TRUSTED_BOARD_BOOT
Arunachalam Ganapathyc44e43d2020-11-17 15:05:01 +0000123# define PLAT_ARM_MAX_BL2_SIZE 0x20000
Usama Arifbec5afd2020-04-17 16:13:39 +0100124#else
Arunachalam Ganapathyade4a202020-09-22 12:50:45 +0100125# define PLAT_ARM_MAX_BL2_SIZE 0x14000
Usama Arifbec5afd2020-04-17 16:13:39 +0100126#endif
127
128/*
129 * Since BL31 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL31_SIZE is
130 * calculated using the current BL31 PROGBITS debug size plus the sizes of
131 * BL2 and BL1-RW
132 */
Usama Arifa49bd492021-08-17 17:57:10 +0100133#define PLAT_ARM_MAX_BL31_SIZE 0x3F000
Usama Arifbec5afd2020-04-17 16:13:39 +0100134
135/*
136 * Size of cacheable stacks
137 */
138#if defined(IMAGE_BL1)
139# if TRUSTED_BOARD_BOOT
140# define PLATFORM_STACK_SIZE 0x1000
141# else
142# define PLATFORM_STACK_SIZE 0x440
143# endif
144#elif defined(IMAGE_BL2)
145# if TRUSTED_BOARD_BOOT
146# define PLATFORM_STACK_SIZE 0x1000
147# else
148# define PLATFORM_STACK_SIZE 0x400
149# endif
150#elif defined(IMAGE_BL2U)
151# define PLATFORM_STACK_SIZE 0x400
152#elif defined(IMAGE_BL31)
153# if SPM_MM
154# define PLATFORM_STACK_SIZE 0x500
155# else
156# define PLATFORM_STACK_SIZE 0x400
157# endif
158#elif defined(IMAGE_BL32)
159# define PLATFORM_STACK_SIZE 0x440
160#endif
161
162
Usama Ariff1513622021-04-09 17:07:41 +0100163#define TC_DEVICE_BASE 0x21000000
164#define TC_DEVICE_SIZE 0x5f000000
Usama Arifbec5afd2020-04-17 16:13:39 +0100165
Usama Ariff1513622021-04-09 17:07:41 +0100166// TC_MAP_DEVICE covers different peripherals
Usama Arifbec5afd2020-04-17 16:13:39 +0100167// available to the platform
Usama Ariff1513622021-04-09 17:07:41 +0100168#define TC_MAP_DEVICE MAP_REGION_FLAT( \
169 TC_DEVICE_BASE, \
170 TC_DEVICE_SIZE, \
Usama Arifbec5afd2020-04-17 16:13:39 +0100171 MT_DEVICE | MT_RW | MT_SECURE)
172
173
Usama Ariff1513622021-04-09 17:07:41 +0100174#define TC_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
Usama Arifbec5afd2020-04-17 16:13:39 +0100175 V2M_FLASH0_SIZE, \
176 MT_DEVICE | MT_RO | MT_SECURE)
177
178#define PLAT_ARM_NSTIMER_FRAME_ID 0
179
180#define PLAT_ARM_TRUSTED_ROM_BASE 0x0
181#define PLAT_ARM_TRUSTED_ROM_SIZE 0x00080000 /* 512KB */
182
183#define PLAT_ARM_NSRAM_BASE 0x06000000
184#define PLAT_ARM_NSRAM_SIZE 0x00080000 /* 512KB */
185
186#define PLAT_ARM_DRAM2_BASE ULL(0x8080000000)
187#define PLAT_ARM_DRAM2_SIZE ULL(0x180000000)
188
189#define PLAT_ARM_G1S_IRQ_PROPS(grp) CSS_G1S_IRQ_PROPS(grp)
190#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
191
192#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
193 PLAT_SP_IMAGE_NS_BUF_SIZE)
194
195/*******************************************************************************
196 * Memprotect definitions
197 ******************************************************************************/
198/* PSCI memory protect definitions:
199 * This variable is stored in a non-secure flash because some ARM reference
200 * platforms do not have secure NVRAM. Real systems that provided MEM_PROTECT
201 * support must use a secure NVRAM to store the PSCI MEM_PROTECT definitions.
202 */
203#define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \
204 V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
205
206/*Secure Watchdog Constants */
207#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
208#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
209
210#define PLAT_ARM_SCMI_CHANNEL_COUNT 1
211
212#define PLAT_ARM_CLUSTER_COUNT U(1)
Avinash Mehtaf68a0842020-10-28 16:43:28 +0000213#define PLAT_MAX_CPUS_PER_CLUSTER U(8)
Usama Arifbec5afd2020-04-17 16:13:39 +0100214#define PLAT_MAX_PE_PER_CPU U(1)
215
216#define PLAT_CSS_MHU_BASE UL(0x45400000)
217#define PLAT_MHUV2_BASE PLAT_CSS_MHU_BASE
218
219#define CSS_SYSTEM_PWR_DMN_LVL ARM_PWR_LVL2
220#define PLAT_MAX_PWR_LVL ARM_PWR_LVL1
221
222/*
223 * Physical and virtual address space limits for MMU in AARCH64
224 */
225#define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 36)
226#define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 36)
227
228/* GIC related constants */
229#define PLAT_ARM_GICD_BASE UL(0x30000000)
230#define PLAT_ARM_GICC_BASE UL(0x2C000000)
Usama Ariffdfd2502021-03-30 16:39:19 +0100231#define PLAT_ARM_GICR_BASE UL(0x30080000)
Usama Arifbec5afd2020-04-17 16:13:39 +0100232
233/*
234 * PLAT_CSS_MAX_SCP_BL2_SIZE is calculated using the current
235 * SCP_BL2 size plus a little space for growth.
236 */
Usama Arif82d931e2020-09-07 18:11:22 +0100237#define PLAT_CSS_MAX_SCP_BL2_SIZE 0x20000
Usama Arifbec5afd2020-04-17 16:13:39 +0100238
239/*
240 * PLAT_CSS_MAX_SCP_BL2U_SIZE is calculated using the current
241 * SCP_BL2U size plus a little space for growth.
242 */
Usama Arif82d931e2020-09-07 18:11:22 +0100243#define PLAT_CSS_MAX_SCP_BL2U_SIZE 0x20000
Usama Arifbec5afd2020-04-17 16:13:39 +0100244
Usama Arife445ff82020-08-18 12:30:37 +0100245/* TZC Related Constants */
246#define PLAT_ARM_TZC_BASE UL(0x25000000)
247#define PLAT_ARM_TZC_FILTERS TZC_400_REGION_ATTR_FILTER_BIT(0)
248
249#define TZC400_OFFSET UL(0x1000000)
250#define TZC400_COUNT 4
251
252#define TZC400_BASE(n) (PLAT_ARM_TZC_BASE + \
253 (n * TZC400_OFFSET))
254
255#define TZC_NSAID_DEFAULT U(0)
256
257#define PLAT_ARM_TZC_NS_DEV_ACCESS \
258 (TZC_REGION_ACCESS_RDWR(TZC_NSAID_DEFAULT))
259
Usama Arif9bbebe72020-08-26 14:04:31 +0100260/*
Usama Ariff1513622021-04-09 17:07:41 +0100261 * The first region below, TC_TZC_DRAM1_BASE (0xfd000000) to
Usama Arif9bbebe72020-08-26 14:04:31 +0100262 * ARM_SCP_TZC_DRAM1_END (0xffffffff) will mark the last 48 MB of DRAM as
263 * secure. The second region gives non secure access to rest of DRAM.
264 */
Usama Ariff1513622021-04-09 17:07:41 +0100265#define TC_TZC_REGIONS_DEF \
266 {TC_TZC_DRAM1_BASE, ARM_SCP_TZC_DRAM1_END, \
Usama Arif9bbebe72020-08-26 14:04:31 +0100267 TZC_REGION_S_RDWR, PLAT_ARM_TZC_NS_DEV_ACCESS}, \
Usama Ariff1513622021-04-09 17:07:41 +0100268 {TC_NS_DRAM1_BASE, TC_NS_DRAM1_END, ARM_TZC_NS_DRAM_S_ACCESS, \
Usama Arif9bbebe72020-08-26 14:04:31 +0100269 PLAT_ARM_TZC_NS_DEV_ACCESS}
270
Arunachalam Ganapathyade4a202020-09-22 12:50:45 +0100271/* virtual address used by dynamic mem_protect for chunk_base */
272#define PLAT_ARM_MEM_PROTEC_VA_FRAME UL(0xc0000000)
273
Usama Arifbec5afd2020-04-17 16:13:39 +0100274#endif /* PLATFORM_DEF_H */