blob: 81b3944e5827eb6b1ba591c140c1f2298791bc53 [file] [log] [blame]
Usama Arifbec5afd2020-04-17 16:13:39 +01001/*
Usama Arife445ff82020-08-18 12:30:37 +01002 * Copyright (c) 2020, 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
20#define PLATFORM_CORE_COUNT 4
21
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 */
32#define TC0_TZC_DRAM1_BASE (ARM_AP_TZC_DRAM1_BASE - \
33 TC0_TZC_DRAM1_SIZE)
34#define TC0_TZC_DRAM1_SIZE UL(0x02000000) /* 32 MB */
35#define TC0_TZC_DRAM1_END (TC0_TZC_DRAM1_BASE + \
36 TC0_TZC_DRAM1_SIZE - 1)
37
38#define TC0_NS_DRAM1_BASE ARM_DRAM1_BASE
39#define TC0_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
40 ARM_TZC_DRAM1_SIZE - \
41 TC0_TZC_DRAM1_SIZE)
42#define TC0_NS_DRAM1_END (TC0_NS_DRAM1_BASE + \
43 TC0_NS_DRAM1_SIZE - 1)
44
45/*
46 * Mappings for TC0 DRAM1 (non-secure) and TC0 TZC DRAM1 (secure)
47 */
48#define TC0_MAP_NS_DRAM1 MAP_REGION_FLAT( \
49 TC0_NS_DRAM1_BASE, \
50 TC0_NS_DRAM1_SIZE, \
51 MT_MEMORY | MT_RW | MT_NS)
52
53
54#define TC0_MAP_TZC_DRAM1 MAP_REGION_FLAT( \
55 TC0_TZC_DRAM1_BASE, \
56 TC0_TZC_DRAM1_SIZE, \
57 MT_MEMORY | MT_RW | MT_SECURE)
58
59/*
Usama Arifbec5afd2020-04-17 16:13:39 +010060 * PLAT_ARM_MMAP_ENTRIES depends on the number of entries in the
61 * plat_arm_mmap array defined for each BL stage.
62 */
63#if defined(IMAGE_BL31)
64# if SPM_MM
65# define PLAT_ARM_MMAP_ENTRIES 9
66# define MAX_XLAT_TABLES 7
67# define PLAT_SP_IMAGE_MMAP_REGIONS 7
68# define PLAT_SP_IMAGE_MAX_XLAT_TABLES 10
69# else
70# define PLAT_ARM_MMAP_ENTRIES 8
71# define MAX_XLAT_TABLES 8
72# endif
73#elif defined(IMAGE_BL32)
74# define PLAT_ARM_MMAP_ENTRIES 8
75# define MAX_XLAT_TABLES 5
76#elif !USE_ROMLIB
77# define PLAT_ARM_MMAP_ENTRIES 11
78# define MAX_XLAT_TABLES 7
79#else
80# define PLAT_ARM_MMAP_ENTRIES 12
81# define MAX_XLAT_TABLES 6
82#endif
83
84/*
85 * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
86 * plus a little space for growth.
87 */
88#define PLAT_ARM_MAX_BL1_RW_SIZE 0xC000
89
90/*
91 * PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
92 */
93
94#if USE_ROMLIB
95#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
96#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0xe000
97#else
98#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
99#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
100#endif
101
102/*
103 * PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
104 * little space for growth.
105 */
106#if TRUSTED_BOARD_BOOT
107# define PLAT_ARM_MAX_BL2_SIZE 0x1E000
108#else
109# define PLAT_ARM_MAX_BL2_SIZE 0x11000
110#endif
111
112/*
113 * Since BL31 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL31_SIZE is
114 * calculated using the current BL31 PROGBITS debug size plus the sizes of
115 * BL2 and BL1-RW
116 */
117#define PLAT_ARM_MAX_BL31_SIZE 0x3B000
118
119/*
120 * Size of cacheable stacks
121 */
122#if defined(IMAGE_BL1)
123# if TRUSTED_BOARD_BOOT
124# define PLATFORM_STACK_SIZE 0x1000
125# else
126# define PLATFORM_STACK_SIZE 0x440
127# endif
128#elif defined(IMAGE_BL2)
129# if TRUSTED_BOARD_BOOT
130# define PLATFORM_STACK_SIZE 0x1000
131# else
132# define PLATFORM_STACK_SIZE 0x400
133# endif
134#elif defined(IMAGE_BL2U)
135# define PLATFORM_STACK_SIZE 0x400
136#elif defined(IMAGE_BL31)
137# if SPM_MM
138# define PLATFORM_STACK_SIZE 0x500
139# else
140# define PLATFORM_STACK_SIZE 0x400
141# endif
142#elif defined(IMAGE_BL32)
143# define PLATFORM_STACK_SIZE 0x440
144#endif
145
146
147#define TC0_DEVICE_BASE 0x21000000
148#define TC0_DEVICE_SIZE 0x5f000000
149
150// TC0_MAP_DEVICE covers different peripherals
151// available to the platform
152#define TC0_MAP_DEVICE MAP_REGION_FLAT( \
153 TC0_DEVICE_BASE, \
154 TC0_DEVICE_SIZE, \
155 MT_DEVICE | MT_RW | MT_SECURE)
156
157
158#define TC0_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
159 V2M_FLASH0_SIZE, \
160 MT_DEVICE | MT_RO | MT_SECURE)
161
162#define PLAT_ARM_NSTIMER_FRAME_ID 0
163
164#define PLAT_ARM_TRUSTED_ROM_BASE 0x0
165#define PLAT_ARM_TRUSTED_ROM_SIZE 0x00080000 /* 512KB */
166
167#define PLAT_ARM_NSRAM_BASE 0x06000000
168#define PLAT_ARM_NSRAM_SIZE 0x00080000 /* 512KB */
169
170#define PLAT_ARM_DRAM2_BASE ULL(0x8080000000)
171#define PLAT_ARM_DRAM2_SIZE ULL(0x180000000)
172
173#define PLAT_ARM_G1S_IRQ_PROPS(grp) CSS_G1S_IRQ_PROPS(grp)
174#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
175
176#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
177 PLAT_SP_IMAGE_NS_BUF_SIZE)
178
179/*******************************************************************************
180 * Memprotect definitions
181 ******************************************************************************/
182/* PSCI memory protect definitions:
183 * This variable is stored in a non-secure flash because some ARM reference
184 * platforms do not have secure NVRAM. Real systems that provided MEM_PROTECT
185 * support must use a secure NVRAM to store the PSCI MEM_PROTECT definitions.
186 */
187#define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \
188 V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
189
190/*Secure Watchdog Constants */
191#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
192#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
193
194#define PLAT_ARM_SCMI_CHANNEL_COUNT 1
195
196#define PLAT_ARM_CLUSTER_COUNT U(1)
197#define PLAT_MAX_CPUS_PER_CLUSTER U(4)
198#define PLAT_MAX_PE_PER_CPU U(1)
199
200#define PLAT_CSS_MHU_BASE UL(0x45400000)
201#define PLAT_MHUV2_BASE PLAT_CSS_MHU_BASE
202
203#define CSS_SYSTEM_PWR_DMN_LVL ARM_PWR_LVL2
204#define PLAT_MAX_PWR_LVL ARM_PWR_LVL1
205
206/*
207 * Physical and virtual address space limits for MMU in AARCH64
208 */
209#define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 36)
210#define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 36)
211
212/* GIC related constants */
213#define PLAT_ARM_GICD_BASE UL(0x30000000)
214#define PLAT_ARM_GICC_BASE UL(0x2C000000)
215#define PLAT_ARM_GICR_BASE UL(0x30140000)
216
217/*
218 * PLAT_CSS_MAX_SCP_BL2_SIZE is calculated using the current
219 * SCP_BL2 size plus a little space for growth.
220 */
Usama Arif82d931e2020-09-07 18:11:22 +0100221#define PLAT_CSS_MAX_SCP_BL2_SIZE 0x20000
Usama Arifbec5afd2020-04-17 16:13:39 +0100222
223/*
224 * PLAT_CSS_MAX_SCP_BL2U_SIZE is calculated using the current
225 * SCP_BL2U size plus a little space for growth.
226 */
Usama Arif82d931e2020-09-07 18:11:22 +0100227#define PLAT_CSS_MAX_SCP_BL2U_SIZE 0x20000
Usama Arifbec5afd2020-04-17 16:13:39 +0100228
Usama Arife445ff82020-08-18 12:30:37 +0100229/* TZC Related Constants */
230#define PLAT_ARM_TZC_BASE UL(0x25000000)
231#define PLAT_ARM_TZC_FILTERS TZC_400_REGION_ATTR_FILTER_BIT(0)
232
233#define TZC400_OFFSET UL(0x1000000)
234#define TZC400_COUNT 4
235
236#define TZC400_BASE(n) (PLAT_ARM_TZC_BASE + \
237 (n * TZC400_OFFSET))
238
239#define TZC_NSAID_DEFAULT U(0)
240
241#define PLAT_ARM_TZC_NS_DEV_ACCESS \
242 (TZC_REGION_ACCESS_RDWR(TZC_NSAID_DEFAULT))
243
Usama Arifbec5afd2020-04-17 16:13:39 +0100244#endif /* PLATFORM_DEF_H */