xref: /rk3399_ARM-atf/plat/arm/board/fvp/include/fvp_pas_def.h (revision 843bc862d729b5c9f19503691d0e47384f1d2455)
186e4859aSRohit Mathew /*
2*aeec55c8SAlexeiFedorov  * Copyright (c) 2021-2025, ARM Limited and Contributors. All rights reserved.
386e4859aSRohit Mathew  *
486e4859aSRohit Mathew  * SPDX-License-Identifier: BSD-3-Clause
586e4859aSRohit Mathew  */
686e4859aSRohit Mathew #ifndef FVP_PAS_DEF_H
786e4859aSRohit Mathew #define FVP_PAS_DEF_H
886e4859aSRohit Mathew 
986e4859aSRohit Mathew #include <lib/gpt_rme/gpt_rme.h>
1086e4859aSRohit Mathew #include <platform_def.h>
1186e4859aSRohit Mathew 
1286e4859aSRohit Mathew /*****************************************************************************
1386e4859aSRohit Mathew  * PAS regions used to initialize the Granule Protection Table (GPT)
1486e4859aSRohit Mathew  ****************************************************************************/
1586e4859aSRohit Mathew 
1686e4859aSRohit Mathew /*
1786e4859aSRohit Mathew  * The PA space is initially mapped in the GPT as follows:
1886e4859aSRohit Mathew  *
1986e4859aSRohit Mathew  * ============================================================================
2086e4859aSRohit Mathew  * Base Addr | Size        |L? GPT|PAS   |Content                 |Comment
2186e4859aSRohit Mathew  * ============================================================================
2286e4859aSRohit Mathew  * 0GB       | 1GB         |L0 GPT|ANY   |TBROM (EL3 code)        |Fixed mapping
2386e4859aSRohit Mathew  *           |             |      |      |TSRAM (EL3 data)        |
24665a8fdfSAlexeiFedorov  * 00000000  | 40000000    |      |      |IO (incl.UARTs & GIC)   |
2586e4859aSRohit Mathew  * ----------------------------------------------------------------------------
2686e4859aSRohit Mathew  * 1GB       | 1GB         |L0 GPT|ANY   |IO                      |Fixed mapping
27665a8fdfSAlexeiFedorov  * 40000000  | 40000000    |      |      |                        |
2886e4859aSRohit Mathew  * ----------------------------------------------------------------------------
29*aeec55c8SAlexeiFedorov  * 1GB+256MB | 256MB       |L1 GPT|NS    |PCI Memory Region 1     |Use T.Descrip
30*aeec55c8SAlexeiFedorov  * 50000000  | 10000000    |      |      |                        |
31*aeec55c8SAlexeiFedorov  * ----------------------------------------------------------------------------
3286e4859aSRohit Mathew  * 2GB       | 2GB-64MB    |L1 GPT|NS    |DRAM (NS Kernel)        |Use T.Descrip
33665a8fdfSAlexeiFedorov  * 80000000  | 7C000000    |      |      |                        |
3486e4859aSRohit Mathew  * ----------------------------------------------------------------------------
3586e4859aSRohit Mathew  * 4GB-64MB  |64MB-32MB-4MB|L1 GPT|SECURE|DRAM TZC                |Use T.Descrip
36665a8fdfSAlexeiFedorov  * FC000000  | 1C00000     |      |      |                        |
3786e4859aSRohit Mathew  * ----------------------------------------------------------------------------
3886e4859aSRohit Mathew  * 4GB-32MB  |             |      |      |                        |
3986e4859aSRohit Mathew  * -3MB-1MB  | 32MB        |L1 GPT|REALM |RMM                     |Use T.Descrip
40665a8fdfSAlexeiFedorov  * FDC00000  | 2000000     |      |      |                        |
4186e4859aSRohit Mathew  * ----------------------------------------------------------------------------
4286e4859aSRohit Mathew  * 4GB-3MB   |             |      |      |                        |
43665a8fdfSAlexeiFedorov  * -1MB      | 4MB         |L1 GPT|ROOT  |EL3 DRAM data, L1 GPTs, |Use T.Descrip
44665a8fdfSAlexeiFedorov  * FFC00000  | 400000      |      |      |SCP TZC                 |
4586e4859aSRohit Mathew  * ----------------------------------------------------------------------------
4686e4859aSRohit Mathew  * 34GB      | 2GB         |L1 GPT|NS    |DRAM (NS Kernel)        |Use T.Descrip
47665a8fdfSAlexeiFedorov  * 880000000 | 80000000    |      |      |                        |
48*aeec55c8SAlexeiFedorov  * ----------------------------------------------------------------------------
49*aeec55c8SAlexeiFedorov  * 256GB     | 3GB         |L1 GPT|NS    |PCI Memory Region 2     |Use T.Descrip
50*aeec55c8SAlexeiFedorov  * 4000000000| C0000000    |      |      |(first 3GB only)        |
5186e4859aSRohit Mathew  * ============================================================================
5286e4859aSRohit Mathew  *
5386e4859aSRohit Mathew  * - 4KB of L0 GPT reside in TSRAM, on top of the CONFIG section.
5486e4859aSRohit Mathew  * - ~1MB of L1 GPTs reside at the top of DRAM1 (TZC area).
5586e4859aSRohit Mathew  * - The first 1GB region has GPT_GPI_ANY and, therefore, is not protected by
5686e4859aSRohit Mathew  *   the GPT.
5786e4859aSRohit Mathew  * - The DRAM TZC area is split into three regions: the L1 GPT region and
5886e4859aSRohit Mathew  *   3MB of region below that are defined as GPT_GPI_ROOT, 32MB Realm region
5986e4859aSRohit Mathew  *   below that is defined as GPT_GPI_REALM and the rest of it is defined as
6086e4859aSRohit Mathew  *   GPT_GPI_SECURE.
6186e4859aSRohit Mathew  */
6286e4859aSRohit Mathew 
6386e4859aSRohit Mathew /* TODO: This might not be the best way to map the PAS */
6486e4859aSRohit Mathew 
6586e4859aSRohit Mathew /* Device memory 0 to 2GB */
6686e4859aSRohit Mathew #define ARM_PAS_1_BASE			(U(0))
67665a8fdfSAlexeiFedorov #define ARM_PAS_1_SIZE			(SZ_2G) /* 2GB */
6886e4859aSRohit Mathew 
6986e4859aSRohit Mathew /* NS memory 2GB to (end - 64MB) */
7086e4859aSRohit Mathew #define ARM_PAS_2_BASE			(ARM_PAS_1_BASE + ARM_PAS_1_SIZE)
7186e4859aSRohit Mathew #define ARM_PAS_2_SIZE			(ARM_NS_DRAM1_SIZE)
7286e4859aSRohit Mathew 
7386e4859aSRohit Mathew /* Shared area between EL3 and RMM */
7486e4859aSRohit Mathew #define ARM_PAS_SHARED_BASE		(ARM_EL3_RMM_SHARED_BASE)
7586e4859aSRohit Mathew #define ARM_PAS_SHARED_SIZE		(ARM_EL3_RMM_SHARED_SIZE)
7686e4859aSRohit Mathew 
7786e4859aSRohit Mathew /* Secure TZC region */
7886e4859aSRohit Mathew #define ARM_PAS_3_BASE			(ARM_AP_TZC_DRAM1_BASE)
7986e4859aSRohit Mathew #define ARM_PAS_3_SIZE			(ARM_AP_TZC_DRAM1_SIZE)
8086e4859aSRohit Mathew 
8186e4859aSRohit Mathew /* NS memory 2GB */
8286e4859aSRohit Mathew #define	ARM_PAS_4_BASE			ARM_DRAM2_BASE
83665a8fdfSAlexeiFedorov #define	ARM_PAS_4_SIZE			(SZ_2G)	/* 2GB */
8486e4859aSRohit Mathew 
8586e4859aSRohit Mathew #define	ARM_PAS_KERNEL			GPT_MAP_REGION_GRANULE(ARM_PAS_2_BASE, \
8686e4859aSRohit Mathew 							       ARM_PAS_2_SIZE, \
8786e4859aSRohit Mathew 							       GPT_GPI_NS)
8886e4859aSRohit Mathew 
8986e4859aSRohit Mathew #define ARM_PAS_SECURE			GPT_MAP_REGION_GRANULE(ARM_PAS_3_BASE, \
9086e4859aSRohit Mathew 							       ARM_PAS_3_SIZE, \
9186e4859aSRohit Mathew 							       GPT_GPI_SECURE)
9286e4859aSRohit Mathew 
9386e4859aSRohit Mathew #define	ARM_PAS_KERNEL_1		GPT_MAP_REGION_GRANULE(ARM_PAS_4_BASE, \
9486e4859aSRohit Mathew 							       ARM_PAS_4_SIZE, \
9586e4859aSRohit Mathew 							       GPT_GPI_NS)
96*aeec55c8SAlexeiFedorov 
97*aeec55c8SAlexeiFedorov #define ARM_PAS_PCI_MEM_1		GPT_MAP_REGION_GRANULE(PLAT_ARM_PCI_MEM_1_BASE, \
98*aeec55c8SAlexeiFedorov 							       PLAT_ARM_PCI_MEM_1_SIZE, \
99*aeec55c8SAlexeiFedorov 							       GPT_GPI_NS)
100*aeec55c8SAlexeiFedorov 
101*aeec55c8SAlexeiFedorov #define	ARM_PAS_PCI_MEM_2		GPT_MAP_REGION_GRANULE(PLAT_ARM_PCI_MEM_2_BASE, \
102*aeec55c8SAlexeiFedorov 							       PLAT_ARM_PCI_MEM_2_SIZE, \
103*aeec55c8SAlexeiFedorov 							       GPT_GPI_NS)
10486e4859aSRohit Mathew /*
10586e4859aSRohit Mathew  * REALM and Shared area share the same PAS, so consider them a single
10686e4859aSRohit Mathew  * PAS region to configure in GPT.
10786e4859aSRohit Mathew  */
10886e4859aSRohit Mathew #define ARM_PAS_REALM			GPT_MAP_REGION_GRANULE(ARM_REALM_BASE, \
10986e4859aSRohit Mathew 							       (ARM_PAS_SHARED_SIZE + \
11086e4859aSRohit Mathew 								ARM_REALM_SIZE), \
11186e4859aSRohit Mathew 							       GPT_GPI_REALM)
112665a8fdfSAlexeiFedorov /* Check if the EL3 TZC DRAM is contiguous with L1 GPT region. */
113665a8fdfSAlexeiFedorov #if (ARM_L1_GPT_BASE != (ARM_EL3_TZC_DRAM1_BASE + ARM_EL3_TZC_DRAM1_SIZE))
11486e4859aSRohit Mathew #define ARM_PAS_EL3_DRAM		GPT_MAP_REGION_GRANULE(ARM_EL3_TZC_DRAM1_BASE, \
11586e4859aSRohit Mathew 							       ARM_EL3_TZC_DRAM1_SIZE, \
11686e4859aSRohit Mathew 							       GPT_GPI_ROOT)
11786e4859aSRohit Mathew 
11886e4859aSRohit Mathew #define	ARM_PAS_GPTS			GPT_MAP_REGION_GRANULE(ARM_L1_GPT_BASE, \
11986e4859aSRohit Mathew 							       ARM_L1_GPT_SIZE, \
12086e4859aSRohit Mathew 							       GPT_GPI_ROOT)
121665a8fdfSAlexeiFedorov #else
122665a8fdfSAlexeiFedorov /* Contiguous ROOT region */
123665a8fdfSAlexeiFedorov #define ARM_PAS_EL3_DRAM		GPT_MAP_REGION_GRANULE(ARM_EL3_TZC_DRAM1_BASE,	\
124665a8fdfSAlexeiFedorov 							       ARM_EL3_TZC_DRAM1_SIZE +	\
125665a8fdfSAlexeiFedorov 							       ARM_L1_GPT_SIZE, \
126665a8fdfSAlexeiFedorov 							       GPT_GPI_ROOT)
127665a8fdfSAlexeiFedorov #endif
12886e4859aSRohit Mathew 
12986e4859aSRohit Mathew /* GPT Configuration options */
13086e4859aSRohit Mathew #define PLATFORM_L0GPTSZ		GPCCR_L0GPTSZ_30BITS
13186e4859aSRohit Mathew 
13286e4859aSRohit Mathew #endif /* FVP_PAS_DEF_H */
133