blob: 9c3beb5b338ae05f9887a942b82c022742b3bd05 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
Rohit Mathew580daab2021-12-13 15:40:25 +00002 * Copyright (c) 2018-2022, 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
Aditya Angadica14fb82021-02-17 18:39:32 +053029 * plat_arm_mmap array defined for each BL stage. In addition to that, on
30 * multi-chip platforms, address regions on each of the remote chips are
31 * also mapped. In BL31, for instance, three address regions on the remote
32 * chips are accessed - secure ram, css device and soc device regions.
Antonio Nino Diaz92029262018-09-28 16:39:26 +010033 */
34#if defined(IMAGE_BL31)
Paul Beesleydb4e25a2019-10-14 15:27:12 +000035# if SPM_MM
Aditya Angadica14fb82021-02-17 18:39:32 +053036# define PLAT_ARM_MMAP_ENTRIES (9 + ((CSS_SGI_CHIP_COUNT - 1) * 3))
37# define MAX_XLAT_TABLES (7 + ((CSS_SGI_CHIP_COUNT - 1) * 3))
Madhukar Pappireddy01231962022-03-11 20:49:20 +010038# define PLAT_SP_IMAGE_MMAP_REGIONS 9
39# define PLAT_SP_IMAGE_MAX_XLAT_TABLES 11
Antonio Nino Diaz92029262018-09-28 16:39:26 +010040# else
Aditya Angadid1608f12020-04-08 14:17:08 +053041# define PLAT_ARM_MMAP_ENTRIES (5 + ((CSS_SGI_CHIP_COUNT - 1) * 3))
Sami Mujawara4f315c2020-04-30 15:50:34 +010042# define MAX_XLAT_TABLES (6 + ((CSS_SGI_CHIP_COUNT - 1) * 3))
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
Aditya Angadica14fb82021-02-17 18:39:32 +053047#elif defined(IMAGE_BL2)
48# define PLAT_ARM_MMAP_ENTRIES (11 + (CSS_SGI_CHIP_COUNT - 1))
49
50/*
51 * MAX_XLAT_TABLES entries need to be doubled because when the address width
52 * exceeds 40 bits an additional level of translation is required. In case of
53 * multichip platforms peripherals also fall into address space with width
54 * > 40 bits
55 *
56 */
57# define MAX_XLAT_TABLES (7 + ((CSS_SGI_CHIP_COUNT - 1) * 2))
Antonio Nino Diaz92029262018-09-28 16:39:26 +010058#elif !USE_ROMLIB
59# define PLAT_ARM_MMAP_ENTRIES 11
Vijayenthiran Subramaniamc4e68a42019-10-28 14:49:48 +053060# define MAX_XLAT_TABLES 7
Antonio Nino Diaz92029262018-09-28 16:39:26 +010061#else
62# define PLAT_ARM_MMAP_ENTRIES 12
63# define MAX_XLAT_TABLES 6
Nariman Poushin0ece80f2018-02-26 06:52:04 +000064#endif
65
Antonio Nino Diaz92029262018-09-28 16:39:26 +010066/*
67 * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
68 * plus a little space for growth.
69 */
Louis Mayencourtc8d110d2020-03-02 14:56:58 +000070#define PLAT_ARM_MAX_BL1_RW_SIZE 0xC000
Antonio Nino Diaz92029262018-09-28 16:39:26 +010071
72/*
73 * PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
74 */
75
76#if USE_ROMLIB
77#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
78#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0xe000
Nariman Poushin0ece80f2018-02-26 06:52:04 +000079#else
Antonio Nino Diaz92029262018-09-28 16:39:26 +010080#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
81#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
Nariman Poushin0ece80f2018-02-26 06:52:04 +000082#endif
83
Antonio Nino Diaz92029262018-09-28 16:39:26 +010084/*
85 * PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
Aditya Angadica14fb82021-02-17 18:39:32 +053086 * little space for growth. Additional 8KiB space is added per chip in
87 * order to accommodate the additional level of translation required for "TZC"
88 * peripheral access which lies in >4TB address space.
89 *
Antonio Nino Diaz92029262018-09-28 16:39:26 +010090 */
Nariman Poushin0ece80f2018-02-26 06:52:04 +000091#if TRUSTED_BOARD_BOOT
Vijayenthiran Subramaniam0e5ee5e2021-10-06 15:12:25 +053092# define PLAT_ARM_MAX_BL2_SIZE (0x20000 + ((CSS_SGI_CHIP_COUNT - 1) * \
Aditya Angadica14fb82021-02-17 18:39:32 +053093 0x2000))
Nariman Poushin0ece80f2018-02-26 06:52:04 +000094#else
Aditya Angadica14fb82021-02-17 18:39:32 +053095# define PLAT_ARM_MAX_BL2_SIZE (0x14000 + ((CSS_SGI_CHIP_COUNT - 1) * \
96 0x2000))
Nariman Poushin0ece80f2018-02-26 06:52:04 +000097#endif
98
Antonio Nino Diaz92029262018-09-28 16:39:26 +010099/*
100 * Since BL31 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL31_SIZE is
101 * calculated using the current BL31 PROGBITS debug size plus the sizes of
102 * BL2 and BL1-RW
103 */
104#define PLAT_ARM_MAX_BL31_SIZE 0x3B000
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000105
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +0100106/*
107 * Size of cacheable stacks
108 */
109#if defined(IMAGE_BL1)
110# if TRUSTED_BOARD_BOOT
111# define PLATFORM_STACK_SIZE 0x1000
112# else
113# define PLATFORM_STACK_SIZE 0x440
114# endif
115#elif defined(IMAGE_BL2)
116# if TRUSTED_BOARD_BOOT
117# define PLATFORM_STACK_SIZE 0x1000
118# else
119# define PLATFORM_STACK_SIZE 0x400
120# endif
121#elif defined(IMAGE_BL2U)
122# define PLATFORM_STACK_SIZE 0x400
123#elif defined(IMAGE_BL31)
Paul Beesleydb4e25a2019-10-14 15:27:12 +0000124# if SPM_MM
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +0100125# define PLATFORM_STACK_SIZE 0x500
126# else
127# define PLATFORM_STACK_SIZE 0x400
128# endif
129#elif defined(IMAGE_BL32)
130# define PLATFORM_STACK_SIZE 0x440
131#endif
132
Rohit Mathew580daab2021-12-13 15:40:25 +0000133/* PL011 UART related constants */
134#define SOC_CSS_SEC_UART_BASE UL(0x2A410000)
135#define SOC_CSS_NSEC_UART_BASE UL(0x2A400000)
136#define SOC_CSS_UART_SIZE UL(0x10000)
137#define SOC_CSS_UART_CLK_IN_HZ UL(7372800)
138
139/* UART related constants */
140#define PLAT_ARM_BOOT_UART_BASE SOC_CSS_SEC_UART_BASE
141#define PLAT_ARM_BOOT_UART_CLK_IN_HZ SOC_CSS_UART_CLK_IN_HZ
142
143#define PLAT_ARM_RUN_UART_BASE SOC_CSS_SEC_UART_BASE
144#define PLAT_ARM_RUN_UART_CLK_IN_HZ SOC_CSS_UART_CLK_IN_HZ
145
146#define PLAT_ARM_CRASH_UART_BASE SOC_CSS_SEC_UART_BASE
147#define PLAT_ARM_CRASH_UART_CLK_IN_HZ SOC_CSS_UART_CLK_IN_HZ
Antonio Nino Diaz48bfb542018-10-11 13:02:34 +0100148
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000149#define PLAT_ARM_NSTIMER_FRAME_ID 0
150
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000151#define PLAT_ARM_TRUSTED_ROM_BASE 0x0
152#define PLAT_ARM_TRUSTED_ROM_SIZE 0x00080000 /* 512KB */
153
Chris Kay42fbdfc2018-05-10 14:27:45 +0100154#define PLAT_ARM_NSRAM_BASE 0x06000000
155#define PLAT_ARM_NSRAM_SIZE 0x00080000 /* 512KB */
156
Suyash Pathak00b99832020-02-12 10:36:20 +0530157#define PLAT_ARM_DRAM2_BASE ULL(0x8080000000)
158#define PLAT_ARM_DRAM2_SIZE ULL(0x180000000)
159
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000160#define PLAT_ARM_G1S_IRQ_PROPS(grp) CSS_G1S_IRQ_PROPS(grp)
161#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
162
163#define CSS_SGI_DEVICE_BASE (0x20000000)
164#define CSS_SGI_DEVICE_SIZE (0x20000000)
165#define CSS_SGI_MAP_DEVICE MAP_REGION_FLAT( \
166 CSS_SGI_DEVICE_BASE, \
167 CSS_SGI_DEVICE_SIZE, \
168 MT_DEVICE | MT_RW | MT_SECURE)
169
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +0530170#define ARM_MAP_SHARED_RAM_REMOTE_CHIP(n) \
171 MAP_REGION_FLAT( \
172 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
173 ARM_SHARED_RAM_BASE, \
174 ARM_SHARED_RAM_SIZE, \
Vijayenthiran Subramaniambaa930c2020-03-11 15:05:49 +0530175 MT_NON_CACHEABLE | MT_RW | MT_SECURE \
Vijayenthiran Subramaniam2478f8e2019-10-28 14:49:48 +0530176 )
177
178#define CSS_SGI_MAP_DEVICE_REMOTE_CHIP(n) \
179 MAP_REGION_FLAT( \
180 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
181 CSS_SGI_DEVICE_BASE, \
182 CSS_SGI_DEVICE_SIZE, \
183 MT_DEVICE | MT_RW | MT_SECURE \
184 )
185
186#define SOC_CSS_MAP_DEVICE_REMOTE_CHIP(n) \
187 MAP_REGION_FLAT( \
188 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + \
189 SOC_CSS_DEVICE_BASE, \
190 SOC_CSS_DEVICE_SIZE, \
191 MT_DEVICE | MT_RW | MT_SECURE \
192 )
193
Sughosh Ganue1579e02018-05-16 17:19:56 +0530194/* Map the secure region for access from S-EL0 */
195#define PLAT_ARM_SECURE_MAP_DEVICE MAP_REGION_FLAT( \
196 SOC_CSS_DEVICE_BASE, \
197 SOC_CSS_DEVICE_SIZE, \
198 MT_DEVICE | MT_RW | MT_SECURE | MT_USER)
199
Sughosh Ganud284b572018-11-14 10:42:46 +0530200#define PLAT_SP_PRI PLAT_RAS_PRI
201
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530202#if SPM_MM && RAS_EXTENSION
203/*
204 * CPER buffer memory of 128KB is reserved and it is placed adjacent to the
205 * memory shared between EL3 and S-EL0.
206 */
207#define CSS_SGI_SP_CPER_BUF_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
208 PLAT_SP_IMAGE_NS_BUF_SIZE)
209#define CSS_SGI_SP_CPER_BUF_SIZE ULL(0x20000)
210#define CSS_SGI_SP_CPER_BUF_MMAP MAP_REGION2( \
211 CSS_SGI_SP_CPER_BUF_BASE, \
212 CSS_SGI_SP_CPER_BUF_BASE, \
213 CSS_SGI_SP_CPER_BUF_SIZE, \
214 MT_RW_DATA | MT_NS | MT_USER, \
Sughosh Ganu70661cf2018-05-16 17:26:40 +0530215 PAGE_SIZE)
Sughosh Ganu5f212942018-05-16 15:35:25 +0530216
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530217/*
218 * Secure partition stack follows right after the memory space reserved for
219 * CPER buffer memory.
220 */
221#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
222 PLAT_SP_IMAGE_NS_BUF_SIZE + \
223 CSS_SGI_SP_CPER_BUF_SIZE)
224#elif SPM_MM
225/*
226 * Secure partition stack follows right after the memory region that is shared
227 * between EL3 and S-EL0.
228 */
Ard Biesheuvel8b034fc2018-12-29 19:43:21 +0100229#define PLAT_ARM_SP_IMAGE_STACK_BASE (PLAT_SP_IMAGE_NS_BUF_BASE + \
230 PLAT_SP_IMAGE_NS_BUF_SIZE)
Thomas Abrahama0aea1a2021-02-16 11:36:00 +0530231#endif /* SPM_MM && RAS_EXTENSION */
Sughosh Ganu5f212942018-05-16 15:35:25 +0530232
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000233/* Platform ID address */
234#define SSC_VERSION (SSC_REG_BASE + SSC_VERSION_OFFSET)
Julius Werner53456fc2019-07-09 13:49:11 -0700235#ifndef __ASSEMBLER__
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000236/* SSC_VERSION related accessors */
237/* Returns the part number of the platform */
238#define GET_SGI_PART_NUM \
239 GET_SSC_VERSION_PART_NUM(mmio_read_32(SSC_VERSION))
240/* Returns the configuration number of the platform */
241#define GET_SGI_CONFIG_NUM \
242 GET_SSC_VERSION_CONFIG(mmio_read_32(SSC_VERSION))
Julius Werner53456fc2019-07-09 13:49:11 -0700243#endif /* __ASSEMBLER__ */
Nariman Poushin0ece80f2018-02-26 06:52:04 +0000244
Roberto Vargasbcca6c62018-06-11 16:15:35 +0100245/*******************************************************************************
246 * Memprotect definitions
247 ******************************************************************************/
248/* PSCI memory protect definitions:
249 * This variable is stored in a non-secure flash because some ARM reference
250 * platforms do not have secure NVRAM. Real systems that provided MEM_PROTECT
251 * support must use a secure NVRAM to store the PSCI MEM_PROTECT definitions.
252 */
253#define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \
254 V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
255
Aditya Angadi20b48412019-04-16 11:29:14 +0530256/*Secure Watchdog Constants */
257#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
258#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
Roberto Vargasbcca6c62018-06-11 16:15:35 +0100259
Aditya Angadi7f8837b2019-12-31 14:23:53 +0530260/* Number of SCMI channels on the platform */
261#define PLAT_ARM_SCMI_CHANNEL_COUNT CSS_SGI_CHIP_COUNT
262
Aditya Angadi44224bd2020-05-14 17:00:07 +0530263/*
264 * Mapping definition of the TrustZone Controller for ARM SGI/RD platforms
265 * where both the DRAM regions are marked for non-secure access. This applies
266 * to multi-chip platforms.
267 */
268#define SGI_PLAT_TZC_NS_REMOTE_REGIONS_DEF(n) \
269 {CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + ARM_DRAM1_BASE, \
270 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + ARM_DRAM1_END, \
271 ARM_TZC_NS_DRAM_S_ACCESS, PLAT_ARM_TZC_NS_DEV_ACCESS}, \
272 {CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + ARM_DRAM2_BASE, \
273 CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + ARM_DRAM2_END, \
274 ARM_TZC_NS_DRAM_S_ACCESS, PLAT_ARM_TZC_NS_DEV_ACCESS}
275
Chandni Cherukuria3f66132018-08-10 11:17:58 +0530276#endif /* SGI_BASE_PLATFORM_DEF_H */