blob: f6c56e8f01219e674a06eb2870e891f33d8aedd7 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
Thomas Abraham09641592021-02-16 12:23:56 +05302 * Copyright (c) 2018-2021, 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/common/arm_def.h>
13#include <plat/arm/common/arm_spm_def.h>
14#include <plat/arm/css/common/css_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000015#include <plat/common/common_def.h>
16
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053017#define PLATFORM_CORE_COUNT (CSS_SGI_CHIP_COUNT * \
18 PLAT_ARM_CLUSTER_COUNT * \
19 CSS_SGI_MAX_CPUS_PER_CLUSTER * \
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053020 CSS_SGI_MAX_PE_PER_CPU)
Nariman Poushin0ece80f2018-02-26 06:52:04 +000021
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +010022#define PLAT_ARM_TRUSTED_SRAM_SIZE 0x00040000 /* 256 KB */
23
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +053024/* Remote chip address offset (4TB per chip) */
25#define CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) ((ULL(1) << 42) * (n))
26
Antonio Nino Diaz92029262018-09-28 16:39:26 +010027/*
28 * PLAT_ARM_MMAP_ENTRIES depends on the number of entries in the
29 * plat_arm_mmap array defined for each BL stage.
30 */
31#if defined(IMAGE_BL31)
Paul Beesleydb4e25a2019-10-14 15:27:12 +000032# if SPM_MM
Antonio Nino Diaz92029262018-09-28 16:39:26 +010033# define PLAT_ARM_MMAP_ENTRIES 9
34# define MAX_XLAT_TABLES 7
35# define PLAT_SP_IMAGE_MMAP_REGIONS 7
36# define PLAT_SP_IMAGE_MAX_XLAT_TABLES 10
37# else
Aditya Angadid1608f12020-04-08 14:17:08 +053038# define PLAT_ARM_MMAP_ENTRIES (5 + ((CSS_SGI_CHIP_COUNT - 1) * 3))
Sami Mujawara4f315c2020-04-30 15:50:34 +010039# define MAX_XLAT_TABLES (6 + ((CSS_SGI_CHIP_COUNT - 1) * 3))
Antonio Nino Diaz92029262018-09-28 16:39:26 +010040# endif
41#elif defined(IMAGE_BL32)
42# define PLAT_ARM_MMAP_ENTRIES 8
Nariman Poushin0ece80f2018-02-26 06:52:04 +000043# define MAX_XLAT_TABLES 5
Antonio Nino Diaz92029262018-09-28 16:39:26 +010044#elif !USE_ROMLIB
45# define PLAT_ARM_MMAP_ENTRIES 11
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053046# define MAX_XLAT_TABLES 7
Antonio Nino Diaz92029262018-09-28 16:39:26 +010047#else
48# define PLAT_ARM_MMAP_ENTRIES 12
49# define MAX_XLAT_TABLES 6
Nariman Poushin0ece80f2018-02-26 06:52:04 +000050#endif
51
Antonio Nino Diaz92029262018-09-28 16:39:26 +010052/*
53 * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
54 * plus a little space for growth.
55 */
Louis Mayencourtc8d110d2020-03-02 14:56:58 +000056#define PLAT_ARM_MAX_BL1_RW_SIZE 0xC000
Antonio Nino Diaz92029262018-09-28 16:39:26 +010057
58/*
59 * PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
60 */
61
62#if USE_ROMLIB
63#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
64#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0xe000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000065#else
Antonio Nino Diaz92029262018-09-28 16:39:26 +010066#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
67#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
Nariman Poushin0ece80f2018-02-26 06:52:04 +000068#endif
69
Antonio Nino Diaz92029262018-09-28 16:39:26 +010070/*
71 * PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
72 * little space for growth.
73 */
Nariman Poushin0ece80f2018-02-26 06:52:04 +000074#if TRUSTED_BOARD_BOOT
75# define PLAT_ARM_MAX_BL2_SIZE 0x1D000
76#else
Manish V Badarkhec48eb862020-04-02 13:23:45 +010077# define PLAT_ARM_MAX_BL2_SIZE 0x14000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000078#endif
79
Antonio Nino Diaz92029262018-09-28 16:39:26 +010080/*
81 * Since BL31 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL31_SIZE is
82 * calculated using the current BL31 PROGBITS debug size plus the sizes of
83 * BL2 and BL1-RW
84 */
85#define PLAT_ARM_MAX_BL31_SIZE 0x3B000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000086
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +010087/*
88 * Size of cacheable stacks
89 */
90#if defined(IMAGE_BL1)
91# if TRUSTED_BOARD_BOOT
92# define PLATFORM_STACK_SIZE 0x1000
93# else
94# define PLATFORM_STACK_SIZE 0x440
95# endif
96#elif defined(IMAGE_BL2)
97# if TRUSTED_BOARD_BOOT
98# define PLATFORM_STACK_SIZE 0x1000
99# else
100# define PLATFORM_STACK_SIZE 0x400
101# endif
102#elif defined(IMAGE_BL2U)
103# define PLATFORM_STACK_SIZE 0x400
104#elif defined(IMAGE_BL31)
Paul Beesleydb4e25a2019-10-14 15:27:12 +0000105# if SPM_MM
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +0100106# define PLATFORM_STACK_SIZE 0x500
107# else
108# define PLATFORM_STACK_SIZE 0x400
109# endif
110#elif defined(IMAGE_BL32)
111# define PLATFORM_STACK_SIZE 0x440
112#endif
113
114
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000115#define PLAT_ARM_NSTIMER_FRAME_ID 0
116
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000117#define PLAT_ARM_TRUSTED_ROM_BASE 0x0
118#define PLAT_ARM_TRUSTED_ROM_SIZE 0x00080000 /* 512KB */
119
Chris Kay42fbdfc2018-05-10 14:27:45 +0100120#define PLAT_ARM_NSRAM_BASE 0x06000000
121#define PLAT_ARM_NSRAM_SIZE 0x00080000 /* 512KB */
122
Suyash Pathak00b99832020-02-12 10:36:20 +0530123#define PLAT_ARM_DRAM2_BASE ULL(0x8080000000)
124#define PLAT_ARM_DRAM2_SIZE ULL(0x180000000)
125
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000126#define PLAT_ARM_G1S_IRQ_PROPS(grp) CSS_G1S_IRQ_PROPS(grp)
127#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
128
129#define CSS_SGI_DEVICE_BASE (0x20000000)
130#define CSS_SGI_DEVICE_SIZE (0x20000000)
131#define CSS_SGI_MAP_DEVICE MAP_REGION_FLAT( \
132 CSS_SGI_DEVICE_BASE, \
133 CSS_SGI_DEVICE_SIZE, \
134 MT_DEVICE | MT_RW | MT_SECURE)
135
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +0530136#define ARM_MAP_SHARED_RAM_REMOTE_CHIP(n) \
137 MAP_REGION_FLAT( \
138 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
139 ARM_SHARED_RAM_BASE, \
140 ARM_SHARED_RAM_SIZE, \
Vijayenthiran Subramaniambaa930c2020-03-11 15:05:49 +0530141 MT_NON_CACHEABLE | MT_RW | MT_SECURE \
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +0530142 )
143
144#define CSS_SGI_MAP_DEVICE_REMOTE_CHIP(n) \
145 MAP_REGION_FLAT( \
146 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
147 CSS_SGI_DEVICE_BASE, \
148 CSS_SGI_DEVICE_SIZE, \
149 MT_DEVICE | MT_RW | MT_SECURE \
150 )
151
152#define SOC_CSS_MAP_DEVICE_REMOTE_CHIP(n) \
153 MAP_REGION_FLAT( \
154 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
155 SOC_CSS_DEVICE_BASE, \
156 SOC_CSS_DEVICE_SIZE, \
157 MT_DEVICE | MT_RW | MT_SECURE \
158 )
159
Sughosh Ganue1579e02018-05-16 17:19:56 +0530160/* Map the secure region for access from S-EL0 */
161#define PLAT_ARM_SECURE_MAP_DEVICE MAP_REGION_FLAT( \
162 SOC_CSS_DEVICE_BASE, \
163 SOC_CSS_DEVICE_SIZE, \
164 MT_DEVICE | MT_RW | MT_SECURE | MT_USER)
165
Sughosh Ganud284b572018-11-14 10:42:46 +0530166#define PLAT_SP_PRI PLAT_RAS_PRI
167
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530168#if SPM_MM && RAS_EXTENSION
169/*
170 * CPER buffer memory of 128KB is reserved and it is placed adjacent to the
171 * memory shared between EL3 and S-EL0.
172 */
173#define CSS_SGI_SP_CPER_BUF_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
174 PLAT_SP_IMAGE_NS_BUF_SIZE)
175#define CSS_SGI_SP_CPER_BUF_SIZE ULL(0x20000)
176#define CSS_SGI_SP_CPER_BUF_MMAP MAP_REGION2( \
177 CSS_SGI_SP_CPER_BUF_BASE, \
178 CSS_SGI_SP_CPER_BUF_BASE, \
179 CSS_SGI_SP_CPER_BUF_SIZE, \
180 MT_RW_DATA | MT_NS | MT_USER, \
Sughosh Ganu70661cf2018-05-16 17:26:40 +0530181 PAGE_SIZE)
Sughosh Ganu5f212942018-05-16 15:35:25 +0530182
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530183/*
184 * Secure partition stack follows right after the memory space reserved for
185 * CPER buffer memory.
186 */
187#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
188 PLAT_SP_IMAGE_NS_BUF_SIZE + \
189 CSS_SGI_SP_CPER_BUF_SIZE)
190#elif SPM_MM
191/*
192 * Secure partition stack follows right after the memory region that is shared
193 * between EL3 and S-EL0.
194 */
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100195#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
196 PLAT_SP_IMAGE_NS_BUF_SIZE)
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530197#endif /* SPM_MM && RAS_EXTENSION */
Sughosh Ganu5f212942018-05-16 15:35:25 +0530198
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000199/* Platform ID address */
200#define SSC_VERSION (SSC_REG_BASE + SSC_VERSION_OFFSET)
Julius Werner53456fc2019-07-09 13:49:11 -0700201#ifndef __ASSEMBLER__
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000202/* SSC_VERSION related accessors */
203/* Returns the part number of the platform */
204#define GET_SGI_PART_NUM \
205 GET_SSC_VERSION_PART_NUM(mmio_read_32(SSC_VERSION))
206/* Returns the configuration number of the platform */
207#define GET_SGI_CONFIG_NUM \
208 GET_SSC_VERSION_CONFIG(mmio_read_32(SSC_VERSION))
Julius Werner53456fc2019-07-09 13:49:11 -0700209#endif /* __ASSEMBLER__ */
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000210
Roberto Vargasbcca6c62018-06-11 16:15:35 +0100211/*******************************************************************************
212 * Memprotect definitions
213 ******************************************************************************/
214/* PSCI memory protect definitions:
215 * This variable is stored in a non-secure flash because some ARM reference
216 * platforms do not have secure NVRAM. Real systems that provided MEM_PROTECT
217 * support must use a secure NVRAM to store the PSCI MEM_PROTECT definitions.
218 */
219#define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \
220 V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
221
Aditya Angadi20b48412019-04-16 11:29:14 +0530222/*Secure Watchdog Constants */
223#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
224#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
Roberto Vargasbcca6c62018-06-11 16:15:35 +0100225
Aditya Angadi7f8837b2019-12-31 14:23:53 +0530226/* Number of SCMI channels on the platform */
227#define PLAT_ARM_SCMI_CHANNEL_COUNT CSS_SGI_CHIP_COUNT
228
Chandni Cherukuria3f66132018-08-10 11:17:58 +0530229#endif /* SGI_BASE_PLATFORM_DEF_H */