xref: /arm-trusted-firmware/plat/arm/css/sgi/include/sgi_soc_css_def_v2.h (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2021-2022, ARM Limited and Contributors. All rights reserved.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  */
6*91f16700Schasinglulu 
7*91f16700Schasinglulu #ifndef SGI_SOC_CSS_DEF_V2_H
8*91f16700Schasinglulu #define SGI_SOC_CSS_DEF_V2_H
9*91f16700Schasinglulu 
10*91f16700Schasinglulu #include <lib/utils_def.h>
11*91f16700Schasinglulu #include <plat/common/common_def.h>
12*91f16700Schasinglulu 
13*91f16700Schasinglulu /*
14*91f16700Schasinglulu  * Definitions common to all ARM CSS SoCs
15*91f16700Schasinglulu  */
16*91f16700Schasinglulu 
17*91f16700Schasinglulu /* Following covers ARM CSS SoC Peripherals */
18*91f16700Schasinglulu 
19*91f16700Schasinglulu #define SOC_SYSTEM_PERIPH_BASE		UL(0x0C000000)
20*91f16700Schasinglulu #define SOC_SYSTEM_PERIPH_SIZE		UL(0x02000000)
21*91f16700Schasinglulu 
22*91f16700Schasinglulu #define SOC_PLATFORM_PERIPH_BASE	UL(0x0E000000)
23*91f16700Schasinglulu #define SOC_PLATFORM_PERIPH_SIZE	UL(0x02000000)
24*91f16700Schasinglulu 
25*91f16700Schasinglulu #define SOC_CSS_PCIE_CONTROL_BASE	UL(0x0ef20000)
26*91f16700Schasinglulu 
27*91f16700Schasinglulu /* Memory controller */
28*91f16700Schasinglulu #define SOC_MEMCNTRL_BASE		UL(0x10000000)
29*91f16700Schasinglulu #define SOC_MEMCNTRL_SIZE		UL(0x10000000)
30*91f16700Schasinglulu 
31*91f16700Schasinglulu /* SoC NIC-400 Global Programmers View (GPV) */
32*91f16700Schasinglulu #define SOC_CSS_NIC400_BASE		UL(0x0ED00000)
33*91f16700Schasinglulu 
34*91f16700Schasinglulu #define SOC_CSS_NIC400_USB_EHCI		U(0)
35*91f16700Schasinglulu #define SOC_CSS_NIC400_TLX_MASTER	U(1)
36*91f16700Schasinglulu #define SOC_CSS_NIC400_USB_OHCI		U(2)
37*91f16700Schasinglulu #define SOC_CSS_NIC400_PL354_SMC	U(3)
38*91f16700Schasinglulu /*
39*91f16700Schasinglulu  * The apb4_bridge controls access to:
40*91f16700Schasinglulu  *   - the PCIe configuration registers
41*91f16700Schasinglulu  *   - the MMU units for USB, HDLCD and DMA
42*91f16700Schasinglulu  */
43*91f16700Schasinglulu #define SOC_CSS_NIC400_APB4_BRIDGE	U(4)
44*91f16700Schasinglulu 
45*91f16700Schasinglulu /* Non-volatile counters */
46*91f16700Schasinglulu #define SOC_TRUSTED_NVCTR_BASE		UL(0x0EE70000)
47*91f16700Schasinglulu #define TFW_NVCTR_BASE			(SOC_TRUSTED_NVCTR_BASE + 0x0000)
48*91f16700Schasinglulu #define TFW_NVCTR_SIZE			U(4)
49*91f16700Schasinglulu #define NTFW_CTR_BASE			(SOC_TRUSTED_NVCTR_BASE + 0x0004)
50*91f16700Schasinglulu #define NTFW_CTR_SIZE			U(4)
51*91f16700Schasinglulu 
52*91f16700Schasinglulu /* Keys */
53*91f16700Schasinglulu #define SOC_KEYS_BASE			UL(0x0EE80000)
54*91f16700Schasinglulu #define TZ_PUB_KEY_HASH_BASE		(SOC_KEYS_BASE + 0x0000)
55*91f16700Schasinglulu #define TZ_PUB_KEY_HASH_SIZE		U(32)
56*91f16700Schasinglulu #define HU_KEY_BASE			(SOC_KEYS_BASE + 0x0020)
57*91f16700Schasinglulu #define HU_KEY_SIZE			U(16)
58*91f16700Schasinglulu #define END_KEY_BASE			(SOC_KEYS_BASE + 0x0044)
59*91f16700Schasinglulu #define END_KEY_SIZE			U(32)
60*91f16700Schasinglulu 
61*91f16700Schasinglulu /* Base Element RAM error definitions */
62*91f16700Schasinglulu #define SOC_NS_RAM_ERR_REC_BASE		UL(0x2A4C0000)
63*91f16700Schasinglulu #define NS_RAM_ECC_CE_INT		U(87)
64*91f16700Schasinglulu #define NS_RAM_ECC_UE_INT		U(88)
65*91f16700Schasinglulu 
66*91f16700Schasinglulu #define SOC_PLATFORM_PERIPH_MAP_DEVICE	MAP_REGION_FLAT(			\
67*91f16700Schasinglulu 						SOC_PLATFORM_PERIPH_BASE, 	\
68*91f16700Schasinglulu 						SOC_PLATFORM_PERIPH_SIZE, 	\
69*91f16700Schasinglulu 						MT_DEVICE | MT_RW | MT_SECURE)
70*91f16700Schasinglulu 
71*91f16700Schasinglulu #if SPM_MM
72*91f16700Schasinglulu /*
73*91f16700Schasinglulu  * Memory map definition for the platform peripheral memory region that is
74*91f16700Schasinglulu  * accessible from S-EL0 (with secure user mode access).
75*91f16700Schasinglulu  */
76*91f16700Schasinglulu #define SOC_PLATFORM_PERIPH_MAP_DEVICE_USER				       \
77*91f16700Schasinglulu 		MAP_REGION_FLAT(					       \
78*91f16700Schasinglulu 			SOC_PLATFORM_PERIPH_BASE,			       \
79*91f16700Schasinglulu 			SOC_PLATFORM_PERIPH_SIZE,			       \
80*91f16700Schasinglulu 			MT_DEVICE | MT_RW | MT_SECURE | MT_USER)
81*91f16700Schasinglulu #endif
82*91f16700Schasinglulu 
83*91f16700Schasinglulu #define SOC_SYSTEM_PERIPH_MAP_DEVICE	MAP_REGION_FLAT(			\
84*91f16700Schasinglulu 						SOC_SYSTEM_PERIPH_BASE,		\
85*91f16700Schasinglulu 						SOC_SYSTEM_PERIPH_SIZE,		\
86*91f16700Schasinglulu 						MT_DEVICE | MT_RW | MT_SECURE)
87*91f16700Schasinglulu 
88*91f16700Schasinglulu #define SOC_MEMCNTRL_MAP_DEVICE		MAP_REGION_FLAT(			\
89*91f16700Schasinglulu 						SOC_MEMCNTRL_BASE,		\
90*91f16700Schasinglulu 						SOC_MEMCNTRL_SIZE,		\
91*91f16700Schasinglulu 						MT_DEVICE | MT_RW | MT_SECURE)
92*91f16700Schasinglulu 
93*91f16700Schasinglulu #define SOC_MEMCNTRL_MAP_DEVICE_REMOTE_CHIP(n)					\
94*91f16700Schasinglulu 		MAP_REGION_FLAT(						\
95*91f16700Schasinglulu 			CSS_SGI_REMOTE_CHIP_MEM_OFFSET(n) + SOC_MEMCNTRL_BASE,	\
96*91f16700Schasinglulu 			SOC_MEMCNTRL_SIZE,					\
97*91f16700Schasinglulu 			MT_DEVICE | MT_RW | MT_SECURE)
98*91f16700Schasinglulu 
99*91f16700Schasinglulu /*
100*91f16700Schasinglulu  * The bootsec_bridge controls access to a bunch of peripherals, e.g. the UARTs.
101*91f16700Schasinglulu  */
102*91f16700Schasinglulu #define SOC_CSS_NIC400_BOOTSEC_BRIDGE		U(5)
103*91f16700Schasinglulu #define SOC_CSS_NIC400_BOOTSEC_BRIDGE_UART1	UL(1 << 12)
104*91f16700Schasinglulu 
105*91f16700Schasinglulu /*
106*91f16700Schasinglulu  * Required platform porting definitions common to all ARM CSS SoCs
107*91f16700Schasinglulu  */
108*91f16700Schasinglulu /* 2MB used for SCP DDR retraining */
109*91f16700Schasinglulu #define PLAT_ARM_SCP_TZC_DRAM1_SIZE	UL(0x00200000)
110*91f16700Schasinglulu 
111*91f16700Schasinglulu /* V2M motherboard system registers & offsets */
112*91f16700Schasinglulu #define V2M_SYSREGS_BASE		UL(0x0C010000)
113*91f16700Schasinglulu #define V2M_SYS_LED			U(0x8)
114*91f16700Schasinglulu 
115*91f16700Schasinglulu /*
116*91f16700Schasinglulu  * V2M sysled bit definitions. The values written to this
117*91f16700Schasinglulu  * register are defined in arch.h & runtime_svc.h. Only
118*91f16700Schasinglulu  * used by the primary cpu to diagnose any cold boot issues.
119*91f16700Schasinglulu  *
120*91f16700Schasinglulu  * SYS_LED[0]   - Security state (S=0/NS=1)
121*91f16700Schasinglulu  * SYS_LED[2:1] - Exception Level (EL3-EL0)
122*91f16700Schasinglulu  * SYS_LED[7:3] - Exception Class (Sync/Async & origin)
123*91f16700Schasinglulu  *
124*91f16700Schasinglulu  */
125*91f16700Schasinglulu #define V2M_SYS_LED_SS_SHIFT		U(0)
126*91f16700Schasinglulu #define V2M_SYS_LED_EL_SHIFT		U(1)
127*91f16700Schasinglulu #define V2M_SYS_LED_EC_SHIFT		U(3)
128*91f16700Schasinglulu 
129*91f16700Schasinglulu #define V2M_SYS_LED_SS_MASK		U(0x01)
130*91f16700Schasinglulu #define V2M_SYS_LED_EL_MASK		U(0x03)
131*91f16700Schasinglulu #define V2M_SYS_LED_EC_MASK		U(0x1f)
132*91f16700Schasinglulu 
133*91f16700Schasinglulu /* NOR Flash */
134*91f16700Schasinglulu #define V2M_FLASH0_BASE			UL(0x08000000)
135*91f16700Schasinglulu #define V2M_FLASH0_SIZE			UL(0x04000000)
136*91f16700Schasinglulu #define V2M_FLASH_BLOCK_SIZE		UL(0x00040000)	/* 256 KB */
137*91f16700Schasinglulu 
138*91f16700Schasinglulu /*
139*91f16700Schasinglulu  * The flash can be mapped either as read-only or read-write.
140*91f16700Schasinglulu  *
141*91f16700Schasinglulu  * If it is read-write then it should also be mapped as device memory because
142*91f16700Schasinglulu  * NOR flash programming involves sending a fixed, ordered sequence of commands.
143*91f16700Schasinglulu  *
144*91f16700Schasinglulu  * If it is read-only then it should also be mapped as:
145*91f16700Schasinglulu  * - Normal memory, because reading from NOR flash is transparent, it is like
146*91f16700Schasinglulu  *   reading from RAM.
147*91f16700Schasinglulu  * - Non-executable by default. If some parts of the flash need to be executable
148*91f16700Schasinglulu  *   then platform code is responsible for re-mapping the appropriate portion
149*91f16700Schasinglulu  *   of it as executable.
150*91f16700Schasinglulu  */
151*91f16700Schasinglulu #define V2M_MAP_FLASH0_RW		MAP_REGION_FLAT(V2M_FLASH0_BASE,\
152*91f16700Schasinglulu 						V2M_FLASH0_SIZE,	\
153*91f16700Schasinglulu 						MT_DEVICE | MT_RW | MT_SECURE)
154*91f16700Schasinglulu 
155*91f16700Schasinglulu #define V2M_MAP_FLASH0_RO		MAP_REGION_FLAT(V2M_FLASH0_BASE,\
156*91f16700Schasinglulu 						V2M_FLASH0_SIZE,	\
157*91f16700Schasinglulu 						MT_RO_DATA | MT_SECURE)
158*91f16700Schasinglulu 
159*91f16700Schasinglulu #define SGI_MAP_FLASH0_RO		MAP_REGION_FLAT(V2M_FLASH0_BASE,\
160*91f16700Schasinglulu 						V2M_FLASH0_SIZE,	\
161*91f16700Schasinglulu 						MT_DEVICE | MT_RO | MT_SECURE)
162*91f16700Schasinglulu 
163*91f16700Schasinglulu /* Platform ID address */
164*91f16700Schasinglulu #define BOARD_CSS_PLAT_ID_REG_ADDR		UL(0x0EFE00E0)
165*91f16700Schasinglulu 
166*91f16700Schasinglulu /* Platform ID related accessors */
167*91f16700Schasinglulu #define BOARD_CSS_PLAT_ID_REG_ID_MASK		U(0x0F)
168*91f16700Schasinglulu #define BOARD_CSS_PLAT_ID_REG_ID_SHIFT		U(0x00)
169*91f16700Schasinglulu #define BOARD_CSS_PLAT_ID_REG_VERSION_MASK	U(0xF00)
170*91f16700Schasinglulu #define BOARD_CSS_PLAT_ID_REG_VERSION_SHIFT	U(0x08)
171*91f16700Schasinglulu #define BOARD_CSS_PLAT_TYPE_RTL			U(0x00)
172*91f16700Schasinglulu #define BOARD_CSS_PLAT_TYPE_FPGA		U(0x01)
173*91f16700Schasinglulu #define BOARD_CSS_PLAT_TYPE_EMULATOR		U(0x02)
174*91f16700Schasinglulu #define BOARD_CSS_PLAT_TYPE_FVP			U(0x03)
175*91f16700Schasinglulu 
176*91f16700Schasinglulu #ifndef __ASSEMBLER__
177*91f16700Schasinglulu 
178*91f16700Schasinglulu #include <lib/mmio.h>
179*91f16700Schasinglulu 
180*91f16700Schasinglulu #define BOARD_CSS_GET_PLAT_TYPE(addr)					\
181*91f16700Schasinglulu 	((mmio_read_32(addr) & BOARD_CSS_PLAT_ID_REG_ID_MASK)		\
182*91f16700Schasinglulu 	>> BOARD_CSS_PLAT_ID_REG_ID_SHIFT)
183*91f16700Schasinglulu 
184*91f16700Schasinglulu #endif /* __ASSEMBLER__ */
185*91f16700Schasinglulu 
186*91f16700Schasinglulu 
187*91f16700Schasinglulu #define MAX_IO_DEVICES			U(3)
188*91f16700Schasinglulu #define MAX_IO_HANDLES			U(4)
189*91f16700Schasinglulu 
190*91f16700Schasinglulu /* Reserve the last block of flash for PSCI MEM PROTECT flag */
191*91f16700Schasinglulu #define PLAT_ARM_FLASH_IMAGE_BASE	V2M_FLASH0_BASE
192*91f16700Schasinglulu #define PLAT_ARM_FLASH_IMAGE_MAX_SIZE	(V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
193*91f16700Schasinglulu 
194*91f16700Schasinglulu #if ARM_GPT_SUPPORT
195*91f16700Schasinglulu /*
196*91f16700Schasinglulu  * Offset of the FIP in the GPT image. BL1 component uses this option
197*91f16700Schasinglulu  * as it does not load the partition table to get the FIP base
198*91f16700Schasinglulu  * address. At sector 34 by default (i.e. after reserved sectors 0-33)
199*91f16700Schasinglulu  * Offset = 34 * 512(sector size) = 17408 i.e. 0x4400
200*91f16700Schasinglulu  */
201*91f16700Schasinglulu #define PLAT_ARM_FIP_OFFSET_IN_GPT		0x4400
202*91f16700Schasinglulu #endif /* ARM_GPT_SUPPORT */
203*91f16700Schasinglulu 
204*91f16700Schasinglulu #define PLAT_ARM_NVM_BASE		V2M_FLASH0_BASE
205*91f16700Schasinglulu #define PLAT_ARM_NVM_SIZE		(V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
206*91f16700Schasinglulu 
207*91f16700Schasinglulu #endif /* SGI_SOC_CSS_DEF_V2_H */
208