1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
/*
* Copyright (c) 2015-2023, ARM Limited and Contributors. All rights reserved.
*
* Copyright (c) 2017-2023 Nuvoton Technology Corp.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
#include <arch.h>
#include <common/interrupt_props.h>
#include <common/tbbr/tbbr_img_def.h>
#include <drivers/arm/gic_common.h>
#include <lib/utils_def.h>
#include <lib/xlat_tables/xlat_tables_defs.h>
#include <npcm845x_arm_def.h>
#include <plat/arm/common/smccc_def.h>
#include <plat/common/common_def.h>
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
#define PLATFORM_LINKER_ARCH aarch64
#define PLATFORM_STACK_SIZE 0x400
#define PLATFORM_CORE_COUNT NPCM845x_PLATFORM_CORE_COUNT
#define PLATFORM_CLUSTER_COUNT NPCM845x_CLUSTER_COUNT
#define PLATFORM_MAX_CPU_PER_CLUSTER NPCM845x_MAX_CPU_PER_CLUSTER
#define PLAT_PRIMARY_CPU NPCM845x_PLAT_PRIMARY_CPU
#define PLATFORM_SYSTEM_COUNT NPCM845x_SYSTEM_COUNT
/* Local power state for power domains in Run state. */
#define PLAT_LOCAL_STATE_RUN U(0)
/* Local power state for retention. Valid only for CPU power domains */
#define PLAT_LOCAL_STATE_RET U(1)
/*
* Local power state for OFF/power-down. Valid for CPU and cluster power
* domains.
*/
#define PLAT_LOCAL_STATE_OFF U(2)
/*
* This macro defines the deepest power down states possible. Any state ID
* higher than this is invalid.
*/
#define PLAT_MAX_OFF_STATE PLAT_LOCAL_STATE_OFF
#define PLAT_MAX_RET_STATE PLAT_LOCAL_STATE_RET
#define PLAT_NUM_PWR_DOMAINS (PLATFORM_CLUSTER_COUNT + PLATFORM_CORE_COUNT)
#define NPCM845x_MAX_PWR_LVL ARM_PWR_LVL1
/*
* Macros used to parse state information from State-ID if it is using the
* recommended encoding for State-ID.
*/
#define PLAT_LOCAL_PSTATE_WIDTH 4
#define PLAT_LOCAL_PSTATE_MASK ((1 << PLAT_LOCAL_PSTATE_WIDTH) - 1)
/*
* Required ARM standard platform porting definitions
*/
#define PLAT_ARM_CLUSTER_COUNT PLATFORM_CLUSTER_COUNT
#define PLAT_NUM_PWR_DOMAINS (PLATFORM_CLUSTER_COUNT + PLATFORM_CORE_COUNT)
#define PLAT_MAX_PWR_LVL NPCM845x_MAX_PWR_LVL
#define PLAT_LOCAL_PSTATE_WIDTH 4
#define PLAT_LOCAL_PSTATE_MASK ((1 << PLAT_LOCAL_PSTATE_WIDTH) - 1)
#ifdef BL32_BASE
#ifndef CONFIG_TARGET_ARBEL_PALLADIUM
#define PLAT_ARM_TRUSTED_DRAM_BASE BL32_BASE
#else
#define PLAT_ARM_TRUSTED_DRAM_BASE BL32_BASE
#endif /* CONFIG_TARGET_ARBEL_PALLADIUM */
#define PLAT_ARM_TRUSTED_DRAM_SIZE UL(0x02000000) /* 32 MB */
#endif /* BL32_BASE */
#define PWR_DOMAIN_AT_MAX_LVL U(1)
#define PLAT_VIRT_ADDR_SPACE_SIZE (1ull << 32)
#define PLAT_PHY_ADDR_SPACE_SIZE (1ull << 32)
#define MAX_XLAT_TABLES 16
#define PLAT_ARM_MMAP_ENTRIES 17
#ifdef NPCM845X_DEBUG
#define MAX_MMAP_REGIONS 8
#define NPCM845X_TZ1_BASE 0xFFFB0000
#endif /* NPCM845X_DEBUG */
#define FIQ_SMP_CALL_SGI 10
/* (0x00040000) 128 KB, the rest 128K if it is non secured */
#define PLAT_ARM_TRUSTED_SRAM_SIZE UL(0x00020000)
#define ARM_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */
/* UL(0xfffCE000) add calc ARM_TRUSTED_SRAM_BASE */
#define ARM_SHARED_RAM_BASE (BL31_BASE + 0x00020000 - ARM_SHARED_RAM_SIZE)
/* The remaining Trusted SRAM is used to load the BL images */
#define ARM_BL_RAM_BASE (ARM_SHARED_RAM_BASE + ARM_SHARED_RAM_SIZE)
/*
* PLAT_ARM_TRUSTED_SRAM_SIZE is taken from platform_def.h 0x20000
* because only half is secured in this specific implementation
*/
#define ARM_BL_RAM_SIZE (PLAT_ARM_TRUSTED_SRAM_SIZE - ARM_SHARED_RAM_SIZE)
#if RESET_TO_BL31
/* Size of Trusted SRAM - the first 4KB of shared memory */
#define PLAT_ARM_MAX_BL31_SIZE \
(PLAT_ARM_TRUSTED_SRAM_SIZE - ARM_SHARED_RAM_SIZE)
#else
/*
* Since BL31 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL31_SIZE
* is calculated using the current BL31 PROGBITS debug size plus the sizes
* of BL2 and BL1-RW
*/
#define PLAT_ARM_MAX_BL31_SIZE \
(PLAT_ARM_TRUSTED_SRAM_SIZE - ARM_SHARED_RAM_SIZE)
#endif /* RESET_TO_BL31 */
/*
* Load address of BL33 for this platform port
*/
#define PLAT_ARM_NS_IMAGE_BASE (ARM_DRAM1_BASE + UL(0x6208000))
#ifdef NPCM845X_DEBUG
#define COUNTER_FREQUENCY 0x07735940 /* f/4 = 125MHz */
#endif /* NPCM845X_DEBUG */
#define COUNTER_FREQUENCY 0x0EE6B280 /* f/2 = 250MHz */
#define PLAT_ARM_NSTIMER_FRAME_ID U(1)
/* GIC parameters */
/* Base compatible GIC memory map */
#define NT_GIC_BASE (0xDFFF8000)
#define BASE_GICD_BASE (NT_GIC_BASE + 0x1000)
#define BASE_GICC_BASE (NT_GIC_BASE + 0x2000)
#define BASE_GICR_BASE (NT_GIC_BASE + 0x200000)
#define BASE_GICH_BASE (NT_GIC_BASE + 0x4000)
#define BASE_GICV_BASE (NT_GIC_BASE + 0x6000)
#define DEVICE1_BASE BASE_GICD_BASE
#define DEVICE1_SIZE 0x7000
#ifdef NPCM845X_DEBUG
/* ((BASE_GICR_BASE - BASE_GICD_BASE) + (PLATFORM_CORE_COUNT * 0x20000)) */
#define ARM_CPU_START_ADDRESS(m) UL(0xf0800e00 + 0x10 + m * 4)
#endif /* NPCM845X_DEBUG */
#define PLAT_REG_BASE NPCM845x_REG_BASE
#define PLAT_REG_SIZE NPCM845x_REG_SIZE
/* MMU entry for internal (register) space access */
#define MAP_DEVICE0 \
MAP_REGION_FLAT(PLAT_REG_BASE, PLAT_REG_SIZE, MT_DEVICE | MT_RW | MT_NS)
#define MAP_DEVICE1 \
MAP_REGION_FLAT(DEVICE1_BASE, DEVICE1_SIZE, \
MT_DEVICE | MT_RW | MT_SECURE)
/*
* Define a list of Group 1 Secure and Group 0 interrupt properties
* as per GICv3 terminology. On a GICv2 system or mode,
* the lists will be merged and treated as Group 0 interrupts.
*/
#define PLAT_ARM_GICD_BASE BASE_GICD_BASE
#define PLAT_ARM_GICC_BASE BASE_GICC_BASE
#define PLAT_ARM_G1S_IRQ_PROPS(grp) \
INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, grp, \
GIC_INTR_CFG_LEVEL), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE), \
INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, \
grp, GIC_INTR_CFG_EDGE)
#define PLAT_ARM_G0_IRQ_PROPS(grp)
/* Required for compilation: */
/*
* PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
* plus a little space for growth.
*/
#define PLAT_ARM_MAX_BL1_RW_SIZE 0 /* UL(0xB000) */
#if USE_ROMLIB
#define PLAT_ARM_MAX_ROMLIB_RW_SIZE UL(0x1000)
#define PLAT_ARM_MAX_ROMLIB_RO_SIZE UL(0xe000)
#define FVP_BL2_ROMLIB_OPTIMIZATION UL(0x6000)
#else
#define PLAT_ARM_MAX_ROMLIB_RW_SIZE UL(0)
#define PLAT_ARM_MAX_ROMLIB_RO_SIZE UL(0)
#define FVP_BL2_ROMLIB_OPTIMIZATION UL(0)
#endif /* USE_ROMLIB */
/*
* PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size
* plus a little space for growth.
*/
#if TRUSTED_BOARD_BOOT
#define PLAT_ARM_MAX_BL2_SIZE (UL(0x1D000) * FVP_BL2_ROMLIB_OPTIMIZATION)
#else
/* (UL(0x13000) - FVP_BL2_ROMLIB_OPTIMIZATION) */
#define PLAT_ARM_MAX_BL2_SIZE 0
#endif /* TRUSTED_BOARD_BOOT */
#undef NPCM_PRINT_ONCE
#ifdef NPCM_PRINT_ONCE
#define PRINT_ONLY_ONCE
#pragma message(VAR_NAME_VALUE(ARM_AP_TZC_DRAM1_BASE))
#pragma message(VAR_NAME_VALUE(BL31_BASE))
#pragma message(VAR_NAME_VALUE(BL31_LIMIT))
#pragma message(VAR_NAME_VALUE(PLAT_ARM_MAX_BL31_SIZE))
#pragma message(VAR_NAME_VALUE(BL32_BASE))
#pragma message(VAR_NAME_VALUE(BL32_LIMIT))
#pragma message(VAR_NAME_VALUE(PLAT_ARM_MAX_BL32_SIZE)
#pragma message(VAR_NAME_VALUE(SPMD_SPM_AT_SEL2_KKO))
#endif /* NPCM_PRINT_ONCE */
#define MAX_IO_DEVICES 4
#define MAX_IO_HANDLES 4
#define PLAT_ARM_FIP_BASE 0x0
#define PLAT_ARM_FIP_MAX_SIZE PLAT_ARM_MAX_BL31_SIZE
#define PLAT_ARM_BOOT_UART_BASE 0xF0000000
#define PLAT_ARM_BOOT_UART_CLK_IN_HZ 115200
#define PLAT_ARM_RUN_UART_BASE 0xF0000000
#define PLAT_ARM_RUN_UART_CLK_IN_HZ 115200
#define PLAT_ARM_CRASH_UART_BASE 0xF0000000
#define PLAT_ARM_CRASH_UART_CLK_IN_HZ 115200
/*
* Mailbox to control the secondary cores.All secondary cores are held in a wait
* loop in cold boot. To release them perform the following steps (plus any
* additional barriers that may be needed):
*
* uint64_t *entrypoint = (uint64_t *)PLAT_NPCM_TM_ENTRYPOINT;
* *entrypoint = ADDRESS_TO_JUMP_TO;
*
* uint64_t *mbox_entry = (uint64_t *)PLAT_NPCM_TM_HOLD_BASE;
* mbox_entry[cpu_id] = PLAT_NPCM_TM_HOLD_BASE;
*
* sev();
*/
#define PLAT_NPCM_TRUSTED_MAILBOX_BASE ARM_SHARED_RAM_BASE
/* The secure entry point to be used on warm reset by all CPUs. */
#define PLAT_NPCM_TM_ENTRYPOINT PLAT_NPCM_TRUSTED_MAILBOX_BASE
#define PLAT_NPCM_TM_ENTRYPOINT_SIZE ULL(8)
/* Hold entries for each CPU. */
#define PLAT_NPCM_TM_HOLD_BASE \
(PLAT_NPCM_TM_ENTRYPOINT + PLAT_NPCM_TM_ENTRYPOINT_SIZE)
#define PLAT_NPCM_TM_HOLD_ENTRY_SIZE ULL(8)
#define PLAT_NPCM_TM_HOLD_SIZE \
(PLAT_NPCM_TM_HOLD_ENTRY_SIZE * PLATFORM_CORE_COUNT)
#define PLAT_NPCM_TRUSTED_NOTIFICATION_BASE \
(PLAT_NPCM_TM_ENTRYPOINT_SIZE + PLAT_NPCM_TM_HOLD_SIZE)
#define PLAT_NPCM_TRUSTED_NOTIFICATION_ENTRY_SIZE ULL(8)
#define PLAT_NPCM_TRUSTED_NOTIFICATION_SIZE \
(PLAT_NPCM_TRUSTED_NOTIFICATION_ENTRY_SIZE * PLATFORM_CORE_COUNT)
#define PLAT_NPCM_TRUSTED_MAILBOX_SIZE \
(PLAT_NPCM_TM_ENTRYPOINT_SIZE + PLAT_NPCM_TM_HOLD_SIZE + \
PLAT_NPCM_TRUSTED_NOTIFICATION_ENTRY_SIZE)
#define PLAT_NPCM_TM_HOLD_STATE_WAIT ULL(0)
#define PLAT_NPCM_TM_HOLD_STATE_GO ULL(1)
#define PLAT_NPCM_TM_HOLD_STATE_BSP_OFF ULL(2)
#define PLAT_NPCM_TM_NOTIFICATION_START ULL(0xAA)
#define PLAT_NPCM_TM_NOTIFICATION_BR ULL(0xCC)
#ifdef NPCM845X_DEBUG
#define PLAT_ARM_TRUSTED_MAILBOX_BASE 0xfffB0000
#endif /* NPCM845X_DEBUG */
#endif /* PLATFORM_DEF_H */
|