blob: d44e27837d349f907577281ddef449f7f4d7526a [file] [log] [blame]
Dan Handleyb4315302015-03-19 18:58:55 +00001/*
David Cunado9edac042017-01-19 10:26:16 +00002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Dan Handleyb4315302015-03-19 18:58:55 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handleyb4315302015-03-19 18:58:55 +00005 */
6#ifndef __ARM_DEF_H__
7#define __ARM_DEF_H__
8
Soby Mathew38dce702015-07-01 16:16:20 +01009#include <arch.h>
Dan Handleyb4315302015-03-19 18:58:55 +000010#include <common_def.h>
11#include <platform_def.h>
Juan Castillodff93c82015-05-07 14:52:44 +010012#include <tbbr_img_def.h>
Scott Branden53d9c9c2017-04-10 11:45:52 -070013#include <utils_def.h>
Antonio Nino Diazbf75a372017-02-23 17:22:58 +000014#include <xlat_tables_defs.h>
Dan Handleyb4315302015-03-19 18:58:55 +000015
16
17/******************************************************************************
18 * Definitions common to all ARM standard platforms
19 *****************************************************************************/
20
Juan Castillod1786372015-12-14 09:35:25 +000021/* Special value used to verify platform parameters from BL2 to BL31 */
Dan Handleyb4315302015-03-19 18:58:55 +000022#define ARM_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL
23
Soby Mathew5f3a6032015-05-08 10:18:59 +010024#define ARM_SYSTEM_COUNT 1
Dan Handleyb4315302015-03-19 18:58:55 +000025
26#define ARM_CACHE_WRITEBACK_SHIFT 6
27
Soby Mathew38dce702015-07-01 16:16:20 +010028/*
29 * Macros mapping the MPIDR Affinity levels to ARM Platform Power levels. The
30 * power levels have a 1:1 mapping with the MPIDR affinity levels.
31 */
32#define ARM_PWR_LVL0 MPIDR_AFFLVL0
33#define ARM_PWR_LVL1 MPIDR_AFFLVL1
Soby Mathew5f3a6032015-05-08 10:18:59 +010034#define ARM_PWR_LVL2 MPIDR_AFFLVL2
Soby Mathew38dce702015-07-01 16:16:20 +010035
36/*
37 * Macros for local power states in ARM platforms encoded by State-ID field
38 * within the power-state parameter.
39 */
40/* Local power state for power domains in Run state. */
41#define ARM_LOCAL_STATE_RUN 0
42/* Local power state for retention. Valid only for CPU power domains */
43#define ARM_LOCAL_STATE_RET 1
44/* Local power state for OFF/power-down. Valid for CPU and cluster power
45 domains */
46#define ARM_LOCAL_STATE_OFF 2
47
Dan Handleyb4315302015-03-19 18:58:55 +000048/* Memory location options for TSP */
49#define ARM_TRUSTED_SRAM_ID 0
50#define ARM_TRUSTED_DRAM_ID 1
51#define ARM_DRAM_ID 2
52
53/* The first 4KB of Trusted SRAM are used as shared memory */
54#define ARM_TRUSTED_SRAM_BASE 0x04000000
55#define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE
56#define ARM_SHARED_RAM_SIZE 0x00001000 /* 4 KB */
57
58/* The remaining Trusted SRAM is used to load the BL images */
59#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
60 ARM_SHARED_RAM_SIZE)
61#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
62 ARM_SHARED_RAM_SIZE)
63
64/*
65 * The top 16MB of DRAM1 is configured as secure access only using the TZC
66 * - SCP TZC DRAM: If present, DRAM reserved for SCP use
67 * - AP TZC DRAM: The remaining TZC secured DRAM reserved for AP use
68 */
David Cunado9edac042017-01-19 10:26:16 +000069#define ARM_TZC_DRAM1_SIZE ULL(0x01000000)
Dan Handleyb4315302015-03-19 18:58:55 +000070
71#define ARM_SCP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
72 ARM_DRAM1_SIZE - \
73 ARM_SCP_TZC_DRAM1_SIZE)
74#define ARM_SCP_TZC_DRAM1_SIZE PLAT_ARM_SCP_TZC_DRAM1_SIZE
75#define ARM_SCP_TZC_DRAM1_END (ARM_SCP_TZC_DRAM1_BASE + \
76 ARM_SCP_TZC_DRAM1_SIZE - 1)
77
78#define ARM_AP_TZC_DRAM1_BASE (ARM_DRAM1_BASE + \
79 ARM_DRAM1_SIZE - \
80 ARM_TZC_DRAM1_SIZE)
81#define ARM_AP_TZC_DRAM1_SIZE (ARM_TZC_DRAM1_SIZE - \
82 ARM_SCP_TZC_DRAM1_SIZE)
83#define ARM_AP_TZC_DRAM1_END (ARM_AP_TZC_DRAM1_BASE + \
84 ARM_AP_TZC_DRAM1_SIZE - 1)
85
Soby Mathewe60f2af2017-05-10 11:50:30 +010086/* Define the Access permissions for Secure peripherals to NS_DRAM */
87#if ARM_CRYPTOCELL_INTEG
88/*
89 * Allow Secure peripheral to read NS DRAM when integrated with CryptoCell.
90 * This is required by CryptoCell to authenticate BL33 which is loaded
91 * into the Non Secure DDR.
92 */
93#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_RD
94#else
95#define ARM_TZC_NS_DRAM_S_ACCESS TZC_REGION_S_NONE
96#endif
97
Summer Qin54661cd2017-04-24 16:49:28 +010098#ifdef SPD_opteed
99/*
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200100 * BL2 needs to map 4MB at the end of TZC_DRAM1 in order to
101 * load/authenticate the trusted os extra image. The first 512KB of
102 * TZC_DRAM1 are reserved for trusted os (OPTEE). The extra image loading
103 * for OPTEE is paged image which only include the paging part using
104 * virtual memory but without "init" data. OPTEE will copy the "init" data
105 * (from pager image) to the first 512KB of TZC_DRAM, and then copy the
106 * extra image behind the "init" data.
Summer Qin54661cd2017-04-24 16:49:28 +0100107 */
Jens Wiklander04f72ba2017-08-24 15:39:09 +0200108#define ARM_OPTEE_PAGEABLE_LOAD_BASE (ARM_AP_TZC_DRAM1_BASE + \
109 ARM_AP_TZC_DRAM1_SIZE - \
110 ARM_OPTEE_PAGEABLE_LOAD_SIZE)
111#define ARM_OPTEE_PAGEABLE_LOAD_SIZE 0x400000
Summer Qin54661cd2017-04-24 16:49:28 +0100112#define ARM_OPTEE_PAGEABLE_LOAD_MEM MAP_REGION_FLAT( \
113 ARM_OPTEE_PAGEABLE_LOAD_BASE, \
114 ARM_OPTEE_PAGEABLE_LOAD_SIZE, \
115 MT_MEMORY | MT_RW | MT_SECURE)
116#endif /* SPD_opteed */
Dan Handleyb4315302015-03-19 18:58:55 +0000117
118#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
119#define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
120 ARM_TZC_DRAM1_SIZE)
121#define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \
122 ARM_NS_DRAM1_SIZE - 1)
123
David Cunado9edac042017-01-19 10:26:16 +0000124#define ARM_DRAM1_BASE ULL(0x80000000)
125#define ARM_DRAM1_SIZE ULL(0x80000000)
Dan Handleyb4315302015-03-19 18:58:55 +0000126#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
127 ARM_DRAM1_SIZE - 1)
128
David Cunado9edac042017-01-19 10:26:16 +0000129#define ARM_DRAM2_BASE ULL(0x880000000)
Dan Handleyb4315302015-03-19 18:58:55 +0000130#define ARM_DRAM2_SIZE PLAT_ARM_DRAM2_SIZE
131#define ARM_DRAM2_END (ARM_DRAM2_BASE + \
132 ARM_DRAM2_SIZE - 1)
133
134#define ARM_IRQ_SEC_PHY_TIMER 29
135
136#define ARM_IRQ_SEC_SGI_0 8
137#define ARM_IRQ_SEC_SGI_1 9
138#define ARM_IRQ_SEC_SGI_2 10
139#define ARM_IRQ_SEC_SGI_3 11
140#define ARM_IRQ_SEC_SGI_4 12
141#define ARM_IRQ_SEC_SGI_5 13
142#define ARM_IRQ_SEC_SGI_6 14
143#define ARM_IRQ_SEC_SGI_7 15
144
Achin Gupta27573c52015-11-03 14:18:34 +0000145/*
146 * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
147 * terminology. On a GICv2 system or mode, the lists will be merged and treated
148 * as Group 0 interrupts.
149 */
150#define ARM_G1S_IRQS ARM_IRQ_SEC_PHY_TIMER, \
151 ARM_IRQ_SEC_SGI_1, \
152 ARM_IRQ_SEC_SGI_2, \
153 ARM_IRQ_SEC_SGI_3, \
154 ARM_IRQ_SEC_SGI_4, \
155 ARM_IRQ_SEC_SGI_5, \
156 ARM_IRQ_SEC_SGI_7
157
158#define ARM_G0_IRQS ARM_IRQ_SEC_SGI_0, \
159 ARM_IRQ_SEC_SGI_6
160
Dan Handleyb4315302015-03-19 18:58:55 +0000161#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
162 ARM_SHARED_RAM_BASE, \
163 ARM_SHARED_RAM_SIZE, \
Juan Castillo74eb26e2016-01-13 15:01:09 +0000164 MT_DEVICE | MT_RW | MT_SECURE)
Dan Handleyb4315302015-03-19 18:58:55 +0000165
166#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
167 ARM_NS_DRAM1_BASE, \
168 ARM_NS_DRAM1_SIZE, \
169 MT_MEMORY | MT_RW | MT_NS)
170
Sandrine Bailleux3eb2d672017-08-30 10:59:22 +0100171#ifdef SPD_tspd
Dan Handleyb4315302015-03-19 18:58:55 +0000172#define ARM_MAP_TSP_SEC_MEM MAP_REGION_FLAT( \
173 TSP_SEC_MEM_BASE, \
174 TSP_SEC_MEM_SIZE, \
175 MT_MEMORY | MT_RW | MT_SECURE)
Sandrine Bailleux3eb2d672017-08-30 10:59:22 +0100176#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000177
David Wang4518dd92016-03-07 11:02:57 +0800178#if ARM_BL31_IN_DRAM
179#define ARM_MAP_BL31_SEC_DRAM MAP_REGION_FLAT( \
180 BL31_BASE, \
181 PLAT_ARM_MAX_BL31_SIZE, \
182 MT_MEMORY | MT_RW | MT_SECURE)
183#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000184
185/*
186 * The number of regions like RO(code), coherent and data required by
187 * different BL stages which need to be mapped in the MMU.
188 */
189#if USE_COHERENT_MEM
190#define ARM_BL_REGIONS 3
191#else
192#define ARM_BL_REGIONS 2
193#endif
194
195#define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
196 ARM_BL_REGIONS)
197
198/* Memory mapped Generic timer interfaces */
199#define ARM_SYS_CNTCTL_BASE 0x2a430000
200#define ARM_SYS_CNTREAD_BASE 0x2a800000
201#define ARM_SYS_TIMCTL_BASE 0x2a810000
202
203#define ARM_CONSOLE_BAUDRATE 115200
204
Juan Castillo7b4c1402015-10-06 14:01:35 +0100205/* Trusted Watchdog constants */
206#define ARM_SP805_TWDG_BASE 0x2a490000
207#define ARM_SP805_TWDG_CLK_HZ 32768
208/* The TBBR document specifies a watchdog timeout of 256 seconds. SP805
209 * asserts reset after two consecutive countdowns (2 x 128 = 256 sec) */
210#define ARM_TWDG_TIMEOUT_SEC 128
211#define ARM_TWDG_LOAD_VAL (ARM_SP805_TWDG_CLK_HZ * \
212 ARM_TWDG_TIMEOUT_SEC)
213
Dan Handleyb4315302015-03-19 18:58:55 +0000214/******************************************************************************
215 * Required platform porting definitions common to all ARM standard platforms
216 *****************************************************************************/
217
Antonio Nino Diaze60e74b2016-12-13 13:48:31 +0000218#define PLAT_PHY_ADDR_SPACE_SIZE (1ull << 32)
219#define PLAT_VIRT_ADDR_SPACE_SIZE (1ull << 32)
Dan Handleyb4315302015-03-19 18:58:55 +0000220
Soby Mathew38dce702015-07-01 16:16:20 +0100221/*
222 * This macro defines the deepest retention state possible. A higher state
223 * id will represent an invalid or a power down state.
224 */
225#define PLAT_MAX_RET_STATE ARM_LOCAL_STATE_RET
226
227/*
228 * This macro defines the deepest power down states possible. Any state ID
229 * higher than this is invalid.
230 */
231#define PLAT_MAX_OFF_STATE ARM_LOCAL_STATE_OFF
232
Dan Handleyb4315302015-03-19 18:58:55 +0000233/*
234 * Some data must be aligned on the biggest cache line size in the platform.
235 * This is known only to the platform as it might have a combination of
236 * integrated and external caches.
237 */
238#define CACHE_WRITEBACK_GRANULE (1 << ARM_CACHE_WRITEBACK_SHIFT)
239
Dan Handleyb4315302015-03-19 18:58:55 +0000240
241/*******************************************************************************
242 * BL1 specific defines.
243 * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of
244 * addresses.
245 ******************************************************************************/
246#define BL1_RO_BASE PLAT_ARM_TRUSTED_ROM_BASE
247#define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \
248 + PLAT_ARM_TRUSTED_ROM_SIZE)
249/*
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000250 * Put BL1 RW at the top of the Trusted SRAM.
Dan Handleyb4315302015-03-19 18:58:55 +0000251 */
Dan Handleyb4315302015-03-19 18:58:55 +0000252#define BL1_RW_BASE (ARM_BL_RAM_BASE + \
253 ARM_BL_RAM_SIZE - \
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000254 PLAT_ARM_MAX_BL1_RW_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000255#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
256
257/*******************************************************************************
258 * BL2 specific defines.
259 ******************************************************************************/
dp-arma4409002017-02-15 11:07:55 +0000260#if ARM_BL31_IN_DRAM || defined(AARCH32)
David Wang4518dd92016-03-07 11:02:57 +0800261/*
dp-arma4409002017-02-15 11:07:55 +0000262 * For AArch32 BL31 is not applicable.
263 * For AArch64 BL31 is loaded in the DRAM.
David Wang4518dd92016-03-07 11:02:57 +0800264 * Put BL2 just below BL1.
265 */
266#define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE)
267#define BL2_LIMIT BL1_RW_BASE
268#else
Dan Handleyb4315302015-03-19 18:58:55 +0000269/*
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000270 * Put BL2 just below BL31.
Dan Handleyb4315302015-03-19 18:58:55 +0000271 */
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000272#define BL2_BASE (BL31_BASE - PLAT_ARM_MAX_BL2_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000273#define BL2_LIMIT BL31_BASE
David Wang4518dd92016-03-07 11:02:57 +0800274#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000275
276/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000277 * BL31 specific defines.
Dan Handleyb4315302015-03-19 18:58:55 +0000278 ******************************************************************************/
David Wang4518dd92016-03-07 11:02:57 +0800279#if ARM_BL31_IN_DRAM
280/*
281 * Put BL31 at the bottom of TZC secured DRAM
282 */
283#define BL31_BASE ARM_AP_TZC_DRAM1_BASE
284#define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
285 PLAT_ARM_MAX_BL31_SIZE)
286#else
Dan Handleyb4315302015-03-19 18:58:55 +0000287/*
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000288 * Put BL31 at the top of the Trusted SRAM.
Dan Handleyb4315302015-03-19 18:58:55 +0000289 */
290#define BL31_BASE (ARM_BL_RAM_BASE + \
291 ARM_BL_RAM_SIZE - \
Vikram Kanigiriecf70f72016-01-21 14:08:15 +0000292 PLAT_ARM_MAX_BL31_SIZE)
Dan Handleyb4315302015-03-19 18:58:55 +0000293#define BL31_PROGBITS_LIMIT BL1_RW_BASE
294#define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
David Wang4518dd92016-03-07 11:02:57 +0800295#endif
Dan Handleyb4315302015-03-19 18:58:55 +0000296
297/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000298 * BL32 specific defines.
Dan Handleyb4315302015-03-19 18:58:55 +0000299 ******************************************************************************/
300/*
301 * On ARM standard platforms, the TSP can execute from Trusted SRAM,
302 * Trusted DRAM (if available) or the DRAM region secured by the TrustZone
303 * controller.
304 */
David Wang4518dd92016-03-07 11:02:57 +0800305#if ARM_BL31_IN_DRAM
306# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \
307 PLAT_ARM_MAX_BL31_SIZE)
308# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - \
309 PLAT_ARM_MAX_BL31_SIZE)
310# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + \
311 PLAT_ARM_MAX_BL31_SIZE)
312# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
313 ARM_AP_TZC_DRAM1_SIZE)
314#elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_SRAM_ID
Dan Handleyb4315302015-03-19 18:58:55 +0000315# define TSP_SEC_MEM_BASE ARM_BL_RAM_BASE
316# define TSP_SEC_MEM_SIZE ARM_BL_RAM_SIZE
317# define TSP_PROGBITS_LIMIT BL2_BASE
318# define BL32_BASE ARM_BL_RAM_BASE
319# define BL32_LIMIT BL31_BASE
320#elif ARM_TSP_RAM_LOCATION_ID == ARM_TRUSTED_DRAM_ID
321# define TSP_SEC_MEM_BASE PLAT_ARM_TRUSTED_DRAM_BASE
322# define TSP_SEC_MEM_SIZE PLAT_ARM_TRUSTED_DRAM_SIZE
323# define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE
324# define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \
325 + (1 << 21))
326#elif ARM_TSP_RAM_LOCATION_ID == ARM_DRAM_ID
327# define TSP_SEC_MEM_BASE ARM_AP_TZC_DRAM1_BASE
328# define TSP_SEC_MEM_SIZE ARM_AP_TZC_DRAM1_SIZE
329# define BL32_BASE ARM_AP_TZC_DRAM1_BASE
330# define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
331 ARM_AP_TZC_DRAM1_SIZE)
332#else
333# error "Unsupported ARM_TSP_RAM_LOCATION_ID value"
334#endif
335
Soby Mathew877cf3f2016-07-11 14:13:56 +0100336/* BL32 is mandatory in AArch32 */
337#ifndef AARCH32
Antonio Nino Diaz81d139d2016-04-05 11:38:49 +0100338#ifdef SPD_none
339#undef BL32_BASE
340#endif /* SPD_none */
Soby Mathew877cf3f2016-07-11 14:13:56 +0100341#endif
Antonio Nino Diaz81d139d2016-04-05 11:38:49 +0100342
Yatharth Kochar436223d2015-10-11 14:14:55 +0100343/*******************************************************************************
344 * FWU Images: NS_BL1U, BL2U & NS_BL2U defines.
345 ******************************************************************************/
346#define BL2U_BASE BL2_BASE
Yatharth Kochar1bd61d02016-11-22 11:06:03 +0000347#if ARM_BL31_IN_DRAM || defined(AARCH32)
348/*
349 * For AArch32 BL31 is not applicable.
350 * For AArch64 BL31 is loaded in the DRAM.
351 * BL2U extends up to BL1.
352 */
David Wang4518dd92016-03-07 11:02:57 +0800353#define BL2U_LIMIT BL1_RW_BASE
354#else
Yatharth Kochar1bd61d02016-11-22 11:06:03 +0000355/* BL2U extends up to BL31. */
Yatharth Kochar436223d2015-10-11 14:14:55 +0100356#define BL2U_LIMIT BL31_BASE
David Wang4518dd92016-03-07 11:02:57 +0800357#endif
Yatharth Kochar436223d2015-10-11 14:14:55 +0100358#define NS_BL2U_BASE ARM_NS_DRAM1_BASE
Yatharth Kochar843ddee2016-02-01 11:04:46 +0000359#define NS_BL1U_BASE (PLAT_ARM_NVM_BASE + 0x03EB8000)
Yatharth Kochar436223d2015-10-11 14:14:55 +0100360
Dan Handleyb4315302015-03-19 18:58:55 +0000361/*
362 * ID of the secure physical generic timer interrupt used by the TSP.
363 */
364#define TSP_IRQ_SEC_PHY_TIMER ARM_IRQ_SEC_PHY_TIMER
365
366
Vikram Kanigirie25e6f42015-09-09 10:52:13 +0100367/*
368 * One cache line needed for bakery locks on ARM platforms
369 */
370#define PLAT_PERCPU_BAKERY_LOCK_SIZE (1 * CACHE_WRITEBACK_GRANULE)
371
372
Dan Handleyb4315302015-03-19 18:58:55 +0000373#endif /* __ARM_DEF_H__ */