blob: 3b8d565854a254941d3e0084f713f475087fd26d [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +05302 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
Nariman Poushin0ece80f2018-02-26 06:52:04 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Chandni Cherukuria3f66132018-08-10 11:17:58 +05307#ifndef SGI_BASE_PLATFORM_DEF_H
8#define SGI_BASE_PLATFORM_DEF_H
Nariman Poushin0ece80f2018-02-26 06:52:04 +00009
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <lib/utils_def.h>
11#include <lib/xlat_tables/xlat_tables_defs.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000012#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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000018#include <plat/common/common_def.h>
19
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053020#define PLATFORM_CORE_COUNT (CSS_SGI_CHIP_COUNT * \
21 PLAT_ARM_CLUSTER_COUNT * \
22 CSS_SGI_MAX_CPUS_PER_CLUSTER * \
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053023 CSS_SGI_MAX_PE_PER_CPU)
Nariman Poushin0ece80f2018-02-26 06:52:04 +000024
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +010025#define PLAT_ARM_TRUSTED_SRAM_SIZE 0x00040000 /* 256 KB */
26
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +053027/* Remote chip address offset (4TB per chip) */
28#define CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) ((ULL(1) << 42) * (n))
29
Antonio Nino Diaz92029262018-09-28 16:39:26 +010030/*
31 * PLAT_ARM_MMAP_ENTRIES depends on the number of entries in the
32 * plat_arm_mmap array defined for each BL stage.
33 */
34#if defined(IMAGE_BL31)
Paul Beesleydb4e25a2019-10-14 15:27:12 +000035# if SPM_MM
Antonio Nino Diaz92029262018-09-28 16:39:26 +010036# define PLAT_ARM_MMAP_ENTRIES 9
37# define MAX_XLAT_TABLES 7
38# define PLAT_SP_IMAGE_MMAP_REGIONS 7
39# define PLAT_SP_IMAGE_MAX_XLAT_TABLES 10
40# else
41# define PLAT_ARM_MMAP_ENTRIES 8
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053042# define MAX_XLAT_TABLES 8
Antonio Nino Diaz92029262018-09-28 16:39:26 +010043# endif
44#elif defined(IMAGE_BL32)
45# define PLAT_ARM_MMAP_ENTRIES 8
Nariman Poushin0ece80f2018-02-26 06:52:04 +000046# define MAX_XLAT_TABLES 5
Antonio Nino Diaz92029262018-09-28 16:39:26 +010047#elif !USE_ROMLIB
48# define PLAT_ARM_MMAP_ENTRIES 11
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053049# define MAX_XLAT_TABLES 7
Antonio Nino Diaz92029262018-09-28 16:39:26 +010050#else
51# define PLAT_ARM_MMAP_ENTRIES 12
52# define MAX_XLAT_TABLES 6
Nariman Poushin0ece80f2018-02-26 06:52:04 +000053#endif
54
Antonio Nino Diaz92029262018-09-28 16:39:26 +010055/*
56 * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
57 * plus a little space for growth.
58 */
Louis Mayencourtc8d110d2020-03-02 14:56:58 +000059#define PLAT_ARM_MAX_BL1_RW_SIZE 0xC000
Antonio Nino Diaz92029262018-09-28 16:39:26 +010060
61/*
62 * PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
63 */
64
65#if USE_ROMLIB
66#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
67#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0xe000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000068#else
Antonio Nino Diaz92029262018-09-28 16:39:26 +010069#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
70#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
Nariman Poushin0ece80f2018-02-26 06:52:04 +000071#endif
72
Antonio Nino Diaz92029262018-09-28 16:39:26 +010073/*
74 * PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
75 * little space for growth.
76 */
Nariman Poushin0ece80f2018-02-26 06:52:04 +000077#if TRUSTED_BOARD_BOOT
78# define PLAT_ARM_MAX_BL2_SIZE 0x1D000
79#else
Manish V Badarkhec48eb862020-04-02 13:23:45 +010080# define PLAT_ARM_MAX_BL2_SIZE 0x14000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000081#endif
82
Antonio Nino Diaz92029262018-09-28 16:39:26 +010083/*
84 * Since BL31 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL31_SIZE is
85 * calculated using the current BL31 PROGBITS debug size plus the sizes of
86 * BL2 and BL1-RW
87 */
88#define PLAT_ARM_MAX_BL31_SIZE 0x3B000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000089
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +010090/*
91 * Size of cacheable stacks
92 */
93#if defined(IMAGE_BL1)
94# if TRUSTED_BOARD_BOOT
95# define PLATFORM_STACK_SIZE 0x1000
96# else
97# define PLATFORM_STACK_SIZE 0x440
98# endif
99#elif defined(IMAGE_BL2)
100# if TRUSTED_BOARD_BOOT
101# define PLATFORM_STACK_SIZE 0x1000
102# else
103# define PLATFORM_STACK_SIZE 0x400
104# endif
105#elif defined(IMAGE_BL2U)
106# define PLATFORM_STACK_SIZE 0x400
107#elif defined(IMAGE_BL31)
Paul Beesleydb4e25a2019-10-14 15:27:12 +0000108# if SPM_MM
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +0100109# define PLATFORM_STACK_SIZE 0x500
110# else
111# define PLATFORM_STACK_SIZE 0x400
112# endif
113#elif defined(IMAGE_BL32)
114# define PLATFORM_STACK_SIZE 0x440
115#endif
116
117
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000118#define PLAT_ARM_NSTIMER_FRAME_ID 0
119
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000120#define PLAT_ARM_TRUSTED_ROM_BASE 0x0
121#define PLAT_ARM_TRUSTED_ROM_SIZE 0x00080000 /* 512KB */
122
Chris Kay42fbdfc2018-05-10 14:27:45 +0100123#define PLAT_ARM_NSRAM_BASE 0x06000000
124#define PLAT_ARM_NSRAM_SIZE 0x00080000 /* 512KB */
125
Suyash Pathak00b99832020-02-12 10:36:20 +0530126#define PLAT_ARM_DRAM2_BASE ULL(0x8080000000)
127#define PLAT_ARM_DRAM2_SIZE ULL(0x180000000)
128
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000129#define PLAT_ARM_G1S_IRQ_PROPS(grp) CSS_G1S_IRQ_PROPS(grp)
130#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
131
132#define CSS_SGI_DEVICE_BASE (0x20000000)
133#define CSS_SGI_DEVICE_SIZE (0x20000000)
134#define CSS_SGI_MAP_DEVICE MAP_REGION_FLAT( \
135 CSS_SGI_DEVICE_BASE, \
136 CSS_SGI_DEVICE_SIZE, \
137 MT_DEVICE | MT_RW | MT_SECURE)
138
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +0530139#define ARM_MAP_SHARED_RAM_REMOTE_CHIP(n) \
140 MAP_REGION_FLAT( \
141 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
142 ARM_SHARED_RAM_BASE, \
143 ARM_SHARED_RAM_SIZE, \
Vijayenthiran Subramaniambaa930c2020-03-11 15:05:49 +0530144 MT_NON_CACHEABLE | MT_RW | MT_SECURE \
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +0530145 )
146
147#define CSS_SGI_MAP_DEVICE_REMOTE_CHIP(n) \
148 MAP_REGION_FLAT( \
149 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
150 CSS_SGI_DEVICE_BASE, \
151 CSS_SGI_DEVICE_SIZE, \
152 MT_DEVICE | MT_RW | MT_SECURE \
153 )
154
155#define SOC_CSS_MAP_DEVICE_REMOTE_CHIP(n) \
156 MAP_REGION_FLAT( \
157 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
158 SOC_CSS_DEVICE_BASE, \
159 SOC_CSS_DEVICE_SIZE, \
160 MT_DEVICE | MT_RW | MT_SECURE \
161 )
162
Sughosh Ganue1579e02018-05-16 17:19:56 +0530163/* Map the secure region for access from S-EL0 */
164#define PLAT_ARM_SECURE_MAP_DEVICE MAP_REGION_FLAT( \
165 SOC_CSS_DEVICE_BASE, \
166 SOC_CSS_DEVICE_SIZE, \
167 MT_DEVICE | MT_RW | MT_SECURE | MT_USER)
168
Sughosh Ganud284b572018-11-14 10:42:46 +0530169#define PLAT_SP_PRI PLAT_RAS_PRI
170
Sughosh Ganu5f212942018-05-16 15:35:25 +0530171#if RAS_EXTENSION
172/* Allocate 128KB for CPER buffers */
Sughosh Ganu70661cf2018-05-16 17:26:40 +0530173#define PLAT_SP_BUF_BASE ULL(0x20000)
174
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100175#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
176 PLAT_SP_IMAGE_NS_BUF_SIZE + \
Sughosh Ganu70661cf2018-05-16 17:26:40 +0530177 PLAT_SP_BUF_BASE)
178
179/* Platform specific SMC FID's used for RAS */
180#define SP_DMC_ERROR_INJECT_EVENT_AARCH64 0xC4000042
181#define SP_DMC_ERROR_INJECT_EVENT_AARCH32 0x84000042
182
183#define SP_DMC_ERROR_OVERFLOW_EVENT_AARCH64 0xC4000043
184#define SP_DMC_ERROR_OVERFLOW_EVENT_AARCH32 0x84000043
185
186#define SP_DMC_ERROR_ECC_EVENT_AARCH64 0xC4000044
187#define SP_DMC_ERROR_ECC_EVENT_AARCH32 0x84000044
188
189/* ARM SDEI dynamic shared event numbers */
190#define SGI_SDEI_DS_EVENT_0 804
191#define SGI_SDEI_DS_EVENT_1 805
192
193#define PLAT_ARM_PRIVATE_SDEI_EVENTS \
194 SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI), \
195 SDEI_EXPLICIT_EVENT(SGI_SDEI_DS_EVENT_0, SDEI_MAPF_CRITICAL), \
196 SDEI_EXPLICIT_EVENT(SGI_SDEI_DS_EVENT_1, SDEI_MAPF_CRITICAL),
197#define PLAT_ARM_SHARED_SDEI_EVENTS
198
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100199#define ARM_SP_CPER_BUF_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
200 PLAT_SP_IMAGE_NS_BUF_SIZE)
Sughosh Ganu70661cf2018-05-16 17:26:40 +0530201#define ARM_SP_CPER_BUF_SIZE ULL(0x20000)
202#define ARM_SP_CPER_BUF_MMAP MAP_REGION2( \
203 ARM_SP_CPER_BUF_BASE, \
204 ARM_SP_CPER_BUF_BASE, \
205 ARM_SP_CPER_BUF_SIZE, \
206 MT_RW_DATA | MT_NS | MT_USER, \
207 PAGE_SIZE)
Sughosh Ganu5f212942018-05-16 15:35:25 +0530208
Sughosh Ganu5f212942018-05-16 15:35:25 +0530209#else
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100210#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
211 PLAT_SP_IMAGE_NS_BUF_SIZE)
Sughosh Ganu5f212942018-05-16 15:35:25 +0530212#endif /* RAS_EXTENSION */
213
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000214/* Platform ID address */
215#define SSC_VERSION (SSC_REG_BASE + SSC_VERSION_OFFSET)
Julius Werner53456fc2019-07-09 13:49:11 -0700216#ifndef __ASSEMBLER__
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000217/* SSC_VERSION related accessors */
218/* Returns the part number of the platform */
219#define GET_SGI_PART_NUM \
220 GET_SSC_VERSION_PART_NUM(mmio_read_32(SSC_VERSION))
221/* Returns the configuration number of the platform */
222#define GET_SGI_CONFIG_NUM \
223 GET_SSC_VERSION_CONFIG(mmio_read_32(SSC_VERSION))
Julius Werner53456fc2019-07-09 13:49:11 -0700224#endif /* __ASSEMBLER__ */
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000225
Roberto Vargasbcca6c62018-06-11 16:15:35 +0100226/*******************************************************************************
227 * Memprotect definitions
228 ******************************************************************************/
229/* PSCI memory protect definitions:
230 * This variable is stored in a non-secure flash because some ARM reference
231 * platforms do not have secure NVRAM. Real systems that provided MEM_PROTECT
232 * support must use a secure NVRAM to store the PSCI MEM_PROTECT definitions.
233 */
234#define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \
235 V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
236
Aditya Angadi20b48412019-04-16 11:29:14 +0530237/*Secure Watchdog Constants */
238#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
239#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
Roberto Vargasbcca6c62018-06-11 16:15:35 +0100240
Aditya Angadi7f8837b2019-12-31 14:23:53 +0530241/* Number of SCMI channels on the platform */
242#define PLAT_ARM_SCMI_CHANNEL_COUNT CSS_SGI_CHIP_COUNT
243
Chandni Cherukuria3f66132018-08-10 11:17:58 +0530244#endif /* SGI_BASE_PLATFORM_DEF_H */