blob: de99b06ad85aa22d9552a35902ebd649daa1acaa [file] [log] [blame]
Manish Pandey52990ae2018-11-28 11:20:37 +00001/*
2 * Copyright (c) 2019, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef PLATFORM_DEF_H
8#define PLATFORM_DEF_H
9
10#include <lib/utils_def.h>
11#include <lib/xlat_tables/xlat_tables_defs.h>
12#include <plat/arm/board/common/v2m_def.h>
13#include <plat/arm/common/arm_spm_def.h>
14#include <plat/common/common_def.h>
15
16/* Core/Cluster/Thread counts for Corstone700 */
17#define CORSTONE700_CLUSTER_COUNT 1
18#define CORSTONE700_MAX_CPUS_PER_CLUSTER 4
19#define CORSTONE700_MAX_PE_PER_CPU 1
20#define CORSTONE700_CORE_COUNT (CORSTONE700_CLUSTER_COUNT * \
21 CORSTONE700_MAX_CPUS_PER_CLUSTER * \
22 CORSTONE700_MAX_PE_PER_CPU)
23#define PLATFORM_CORE_COUNT CORSTONE700_CORE_COUNT
24#define PLAT_ARM_CLUSTER_COUNT CORSTONE700_CLUSTER_COUNT
25
26/* UART related constants */
27#define PLAT_ARM_BOOT_UART_BASE 0x1a510000
28#define PLAT_ARM_BOOT_UART_CLK_IN_HZ V2M_IOFPGA_UART0_CLK_IN_HZ
29#define PLAT_ARM_RUN_UART_BASE 0x1a520000
30#define PLAT_ARM_RUN_UART_CLK_IN_HZ V2M_IOFPGA_UART1_CLK_IN_HZ
31#define ARM_CONSOLE_BAUDRATE 115200
32#define PLAT_ARM_CRASH_UART_BASE PLAT_ARM_RUN_UART_BASE
33#define PLAT_ARM_CRASH_UART_CLK_IN_HZ PLAT_ARM_RUN_UART_CLK_IN_HZ
34
35/* Memory related constants */
36#define ARM_DRAM1_BASE UL(0x80000000)
37#define ARM_DRAM1_SIZE UL(0x80000000)
38#define ARM_DRAM1_END (ARM_DRAM1_BASE + \
39 ARM_DRAM1_SIZE - 1)
40#define ARM_NS_DRAM1_BASE ARM_DRAM1_BASE
41#define ARM_NS_DRAM1_SIZE ARM_DRAM1_SIZE
42#define ARM_NS_DRAM1_END (ARM_NS_DRAM1_BASE + \
43 ARM_NS_DRAM1_SIZE - 1)
44#define ARM_TRUSTED_SRAM_BASE UL(0x02000000)
45#define ARM_SHARED_RAM_BASE ARM_TRUSTED_SRAM_BASE
46#define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */
47#define PLAT_ARM_TRUSTED_SRAM_SIZE 0x00040000 /* 256 KB */
48
49/* The remaining Trusted SRAM is used to load the BL images */
50#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + \
51 ARM_SHARED_RAM_SIZE)
52#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - \
53 ARM_SHARED_RAM_SIZE)
54
55/*
56 * SP_MIN is the only BL image in SRAM. Allocate the whole of SRAM (excluding
57 * the page reserved for fw_configs) to BL32
58 */
59#define BL32_BASE (ARM_BL_RAM_BASE + PAGE_SIZE)
60#define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
61
62/*
63 * Some data must be aligned on the biggest cache line size in the platform.
64 * This is known only to the platform as it might have a combination of
65 * integrated and external caches.
66 */
67#define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT)
68#define ARM_CACHE_WRITEBACK_SHIFT 6
69
70/*
71 * To enable TB_FW_CONFIG to be loaded by BL1, define the corresponding base
72 * and limit. Leave enough space for BL2 meminfo.
73 */
74#define ARM_TB_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t))
75#define ARM_TB_FW_CONFIG_LIMIT (ARM_BL_RAM_BASE + (PAGE_SIZE / 2U))
76
77/*
78 * The max number of regions like RO(code), coherent and data required by
79 * different BL stages which need to be mapped in the MMU.
80 */
81#define ARM_BL_REGIONS 2
82#define PLAT_ARM_MMAP_ENTRIES 8
83#define MAX_XLAT_TABLES 5
84#define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
85 ARM_BL_REGIONS)
86
87/* GIC related constants */
88#define PLAT_ARM_GICD_BASE 0x1C010000
89#define PLAT_ARM_GICC_BASE 0x1C02F000
90
91/* Timer/watchdog related constants */
92#define ARM_SYS_CNTCTL_BASE UL(0x1a200000)
93#define ARM_SYS_CNTREAD_BASE UL(0x1a210000)
94#define ARM_SYS_TIMCTL_BASE UL(0x1a220000)
95#define CORSTONE700_TIMER_BASE_FREQUENCY UL(24000000)
96#define CORSTONE700_IRQ_TZ_WDOG 32
97#define CORSTONE700_IRQ_SEC_SYS_TIMER 34
98
99#define PLAT_MAX_PWR_LVL 2
100/*
101 * Macros mapping the MPIDR Affinity levels to ARM Platform Power levels. The
102 * power levels have a 1:1 mapping with the MPIDR affinity levels.
103 */
104#define ARM_PWR_LVL0 MPIDR_AFFLVL0
105#define ARM_PWR_LVL1 MPIDR_AFFLVL1
106#define ARM_PWR_LVL2 MPIDR_AFFLVL2
107
108/*
109 * Macros for local power states in ARM platforms encoded by State-ID field
110 * within the power-state parameter.
111 */
112/* Local power state for power domains in Run state. */
113#define ARM_LOCAL_STATE_RUN U(0)
114/* Local power state for retention. Valid only for CPU power domains */
115#define ARM_LOCAL_STATE_RET U(1)
116/* Local power state for OFF/power-down. Valid for CPU and cluster
117 * power domains
118 */
119#define ARM_LOCAL_STATE_OFF U(2)
120
121#define PLAT_ARM_TRUSTED_MAILBOX_BASE ARM_TRUSTED_SRAM_BASE
122#define PLAT_ARM_NSTIMER_FRAME_ID U(1)
123
124#define PLAT_ARM_NS_IMAGE_OFFSET (ARM_DRAM1_BASE + UL(0x8000000))
125
126#define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32)
127#define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32)
128
129/*
130 * This macro defines the deepest retention state possible. A higher state
131 * ID will represent an invalid or a power down state.
132 */
133#define PLAT_MAX_RET_STATE 1
134
135/*
136 * This macro defines the deepest power down states possible. Any state ID
137 * higher than this is invalid.
138 */
139#define PLAT_MAX_OFF_STATE 2
140
141#define PLATFORM_STACK_SIZE UL(0x440)
142
143#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
144 ARM_SHARED_RAM_BASE, \
145 ARM_SHARED_RAM_SIZE, \
146 MT_DEVICE | MT_RW | MT_SECURE)
147
148#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
149 ARM_NS_DRAM1_BASE, \
150 ARM_NS_DRAM1_SIZE, \
151 MT_MEMORY | MT_RW | MT_NS)
152
153#define ARM_MAP_BL_RO MAP_REGION_FLAT( \
154 BL_CODE_BASE, \
155 BL_CODE_END \
156 - BL_CODE_BASE, \
157 MT_CODE | MT_SECURE), \
158 MAP_REGION_FLAT( \
159 BL_RO_DATA_BASE, \
160 BL_RO_DATA_END \
161 - BL_RO_DATA_BASE, \
162 MT_RO_DATA | MT_SECURE)
163#if USE_COHERENT_MEM
164#define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
165 BL_COHERENT_RAM_BASE, \
166 BL_COHERENT_RAM_END \
167 - BL_COHERENT_RAM_BASE, \
168 MT_DEVICE | MT_RW | MT_SECURE)
169#endif
170
171#define CORSTONE700_DEVICE_BASE (0x1A000000)
172#define CORSTONE700_DEVICE_SIZE (0x26000000)
173#define CORSTONE700_MAP_DEVICE MAP_REGION_FLAT( \
174 CORSTONE700_DEVICE_BASE, \
175 CORSTONE700_DEVICE_SIZE, \
176 MT_DEVICE | MT_RW | MT_SECURE)
177
178#define ARM_IRQ_SEC_PHY_TIMER 29
179
180#define ARM_IRQ_SEC_SGI_0 8
181#define ARM_IRQ_SEC_SGI_1 9
182#define ARM_IRQ_SEC_SGI_2 10
183#define ARM_IRQ_SEC_SGI_3 11
184#define ARM_IRQ_SEC_SGI_4 12
185#define ARM_IRQ_SEC_SGI_5 13
186#define ARM_IRQ_SEC_SGI_6 14
187#define ARM_IRQ_SEC_SGI_7 15
188
189/*
190 * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3
191 * terminology. On a GICv2 system or mode, the lists will be merged and treated
192 * as Group 0 interrupts.
193 */
194#define ARM_G1S_IRQ_PROPS(grp) \
195 INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, \
196 (grp), GIC_INTR_CFG_LEVEL), \
197 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, \
198 (grp), GIC_INTR_CFG_EDGE), \
199 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, \
200 (grp), GIC_INTR_CFG_EDGE), \
201 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, \
202 (grp), GIC_INTR_CFG_EDGE), \
203 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, \
204 (grp), GIC_INTR_CFG_EDGE), \
205 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, \
206 (grp), GIC_INTR_CFG_EDGE), \
207 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, \
208 (grp), GIC_INTR_CFG_EDGE)
209
210#define ARM_G0_IRQ_PROPS(grp) \
211 INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \
212 GIC_INTR_CFG_EDGE)
213
214/*
215 * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
216 * terminology. On a GICv2 system or mode, the lists will be merged and treated
217 * as Group 0 interrupts.
218 */
219#define PLAT_ARM_G1S_IRQ_PROPS(grp) \
220 ARM_G1S_IRQ_PROPS(grp), \
221 INTR_PROP_DESC(CORSTONE700_IRQ_TZ_WDOG, \
222 GIC_HIGHEST_SEC_PRIORITY, (grp), GIC_INTR_CFG_LEVEL), \
223 INTR_PROP_DESC(CORSTONE700_IRQ_SEC_SYS_TIMER, \
224 GIC_HIGHEST_SEC_PRIORITY, (grp), GIC_INTR_CFG_LEVEL) \
225
226#define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
227
228#endif /* PLATFORM_DEF_H */