xref: /rk3399_ARM-atf/plat/rpi/rpi4/include/platform_def.h (revision 5e6d821cb3b32fc6eadb38c25a96f8efe217efba)
1f5cb15b0SAndre Przywara /*
2f5cb15b0SAndre Przywara  * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
3f5cb15b0SAndre Przywara  *
4f5cb15b0SAndre Przywara  * SPDX-License-Identifier: BSD-3-Clause
5f5cb15b0SAndre Przywara  */
6f5cb15b0SAndre Przywara 
7f5cb15b0SAndre Przywara #ifndef PLATFORM_DEF_H
8f5cb15b0SAndre Przywara #define PLATFORM_DEF_H
9f5cb15b0SAndre Przywara 
10f5cb15b0SAndre Przywara #include <arch.h>
11f5cb15b0SAndre Przywara #include <common/tbbr/tbbr_img_def.h>
12f5cb15b0SAndre Przywara #include <lib/utils_def.h>
13f5cb15b0SAndre Przywara #include <plat/common/common_def.h>
14f5cb15b0SAndre Przywara 
15f5cb15b0SAndre Przywara #include "rpi_hw.h"
16f5cb15b0SAndre Przywara 
17f5cb15b0SAndre Przywara /* Special value used to verify platform parameters from BL2 to BL31 */
18f5cb15b0SAndre Przywara #define RPI3_BL31_PLAT_PARAM_VAL	ULL(0x0F1E2D3C4B5A6978)
19f5cb15b0SAndre Przywara 
20f5cb15b0SAndre Przywara #define PLATFORM_STACK_SIZE		ULL(0x1000)
21f5cb15b0SAndre Przywara 
22f5cb15b0SAndre Przywara #define PLATFORM_MAX_CPUS_PER_CLUSTER	U(4)
23f5cb15b0SAndre Przywara #define PLATFORM_CLUSTER_COUNT		U(1)
24f5cb15b0SAndre Przywara #define PLATFORM_CLUSTER0_CORE_COUNT	PLATFORM_MAX_CPUS_PER_CLUSTER
25f5cb15b0SAndre Przywara #define PLATFORM_CORE_COUNT		PLATFORM_CLUSTER0_CORE_COUNT
26f5cb15b0SAndre Przywara 
27f5cb15b0SAndre Przywara #define RPI4_PRIMARY_CPU		U(0)
28f5cb15b0SAndre Przywara 
29f5cb15b0SAndre Przywara #define PLAT_MAX_PWR_LVL		MPIDR_AFFLVL1
30f5cb15b0SAndre Przywara #define PLAT_NUM_PWR_DOMAINS		(PLATFORM_CLUSTER_COUNT + \
31f5cb15b0SAndre Przywara 					 PLATFORM_CORE_COUNT)
32f5cb15b0SAndre Przywara 
33f5cb15b0SAndre Przywara #define PLAT_MAX_RET_STATE		U(1)
34f5cb15b0SAndre Przywara #define PLAT_MAX_OFF_STATE		U(2)
35f5cb15b0SAndre Przywara 
36f5cb15b0SAndre Przywara /* Local power state for power domains in Run state. */
37f5cb15b0SAndre Przywara #define PLAT_LOCAL_STATE_RUN		U(0)
38f5cb15b0SAndre Przywara /* Local power state for retention. Valid only for CPU power domains */
39f5cb15b0SAndre Przywara #define PLAT_LOCAL_STATE_RET		U(1)
40f5cb15b0SAndre Przywara /*
41f5cb15b0SAndre Przywara  * Local power state for OFF/power-down. Valid for CPU and cluster power
42f5cb15b0SAndre Przywara  * domains.
43f5cb15b0SAndre Przywara  */
44f5cb15b0SAndre Przywara #define PLAT_LOCAL_STATE_OFF		U(2)
45f5cb15b0SAndre Przywara 
46f5cb15b0SAndre Przywara /*
47f5cb15b0SAndre Przywara  * Macros used to parse state information from State-ID if it is using the
48f5cb15b0SAndre Przywara  * recommended encoding for State-ID.
49f5cb15b0SAndre Przywara  */
50f5cb15b0SAndre Przywara #define PLAT_LOCAL_PSTATE_WIDTH		U(4)
51f5cb15b0SAndre Przywara #define PLAT_LOCAL_PSTATE_MASK		((U(1) << PLAT_LOCAL_PSTATE_WIDTH) - 1)
52f5cb15b0SAndre Przywara 
53f5cb15b0SAndre Przywara /*
54f5cb15b0SAndre Przywara  * Some data must be aligned on the biggest cache line size in the platform.
55f5cb15b0SAndre Przywara  * This is known only to the platform as it might have a combination of
56f5cb15b0SAndre Przywara  * integrated and external caches.
57f5cb15b0SAndre Przywara  */
58f5cb15b0SAndre Przywara #define CACHE_WRITEBACK_SHIFT		U(6)
59f5cb15b0SAndre Przywara #define CACHE_WRITEBACK_GRANULE		(U(1) << CACHE_WRITEBACK_SHIFT)
60f5cb15b0SAndre Przywara 
61f5cb15b0SAndre Przywara /*
62f5cb15b0SAndre Przywara  * I/O registers.
63f5cb15b0SAndre Przywara  */
64f5cb15b0SAndre Przywara #define DEVICE0_BASE			RPI_IO_BASE
65f5cb15b0SAndre Przywara #define DEVICE0_SIZE			RPI_IO_SIZE
66f5cb15b0SAndre Przywara 
67f5cb15b0SAndre Przywara /*
68f5cb15b0SAndre Przywara  * Mailbox to control the secondary cores. All secondary cores are held in a
69f5cb15b0SAndre Przywara  * wait loop in cold boot. To release them perform the following steps (plus
70f5cb15b0SAndre Przywara  * any additional barriers that may be needed):
71f5cb15b0SAndre Przywara  *
72f5cb15b0SAndre Przywara  *     uint64_t *entrypoint = (uint64_t *)PLAT_RPI3_TM_ENTRYPOINT;
73f5cb15b0SAndre Przywara  *     *entrypoint = ADDRESS_TO_JUMP_TO;
74f5cb15b0SAndre Przywara  *
75f5cb15b0SAndre Przywara  *     uint64_t *mbox_entry = (uint64_t *)PLAT_RPI3_TM_HOLD_BASE;
76f5cb15b0SAndre Przywara  *     mbox_entry[cpu_id] = PLAT_RPI3_TM_HOLD_STATE_GO;
77f5cb15b0SAndre Przywara  *
78f5cb15b0SAndre Przywara  *     sev();
79f5cb15b0SAndre Przywara  */
80f5cb15b0SAndre Przywara /* The secure entry point to be used on warm reset by all CPUs. */
81882c0ff6SAndre Przywara #define PLAT_RPI3_TM_ENTRYPOINT		0x100
82f5cb15b0SAndre Przywara #define PLAT_RPI3_TM_ENTRYPOINT_SIZE	ULL(8)
83f5cb15b0SAndre Przywara 
84f5cb15b0SAndre Przywara /* Hold entries for each CPU. */
85f5cb15b0SAndre Przywara #define PLAT_RPI3_TM_HOLD_BASE		(PLAT_RPI3_TM_ENTRYPOINT + \
86f5cb15b0SAndre Przywara 					 PLAT_RPI3_TM_ENTRYPOINT_SIZE)
87f5cb15b0SAndre Przywara #define PLAT_RPI3_TM_HOLD_ENTRY_SIZE	ULL(8)
88f5cb15b0SAndre Przywara #define PLAT_RPI3_TM_HOLD_SIZE		(PLAT_RPI3_TM_HOLD_ENTRY_SIZE * \
89f5cb15b0SAndre Przywara 					 PLATFORM_CORE_COUNT)
90f5cb15b0SAndre Przywara 
91f5cb15b0SAndre Przywara #define PLAT_RPI3_TRUSTED_MAILBOX_SIZE	(PLAT_RPI3_TM_ENTRYPOINT_SIZE + \
92f5cb15b0SAndre Przywara 					 PLAT_RPI3_TM_HOLD_SIZE)
93f5cb15b0SAndre Przywara 
94f5cb15b0SAndre Przywara #define PLAT_RPI3_TM_HOLD_STATE_WAIT	ULL(0)
95f5cb15b0SAndre Przywara #define PLAT_RPI3_TM_HOLD_STATE_GO	ULL(1)
96f5cb15b0SAndre Przywara 
97f5cb15b0SAndre Przywara /*
98f5cb15b0SAndre Przywara  * BL31 specific defines.
99f5cb15b0SAndre Przywara  *
100f5cb15b0SAndre Przywara  * Put BL31 at the top of the Trusted SRAM. BL31_BASE is calculated using the
101f5cb15b0SAndre Przywara  * current BL31 debug size plus a little space for growth.
102f5cb15b0SAndre Przywara  */
103882c0ff6SAndre Przywara #define PLAT_MAX_BL31_SIZE		ULL(0x80000)
104f5cb15b0SAndre Przywara 
105f5cb15b0SAndre Przywara #define BL31_BASE			ULL(0x1000)
106882c0ff6SAndre Przywara #define BL31_LIMIT			ULL(0x80000)
107882c0ff6SAndre Przywara #define BL31_PROGBITS_LIMIT		ULL(0x80000)
108f5cb15b0SAndre Przywara 
109f5cb15b0SAndre Przywara #define SEC_SRAM_ID			0
110f5cb15b0SAndre Przywara #define SEC_DRAM_ID			1
111f5cb15b0SAndre Przywara 
112f5cb15b0SAndre Przywara /*
113f5cb15b0SAndre Przywara  * Other memory-related defines.
114f5cb15b0SAndre Przywara  */
115f5cb15b0SAndre Przywara #define PLAT_PHY_ADDR_SPACE_SIZE	(ULL(1) << 32)
116f5cb15b0SAndre Przywara #define PLAT_VIRT_ADDR_SPACE_SIZE	(ULL(1) << 32)
117f5cb15b0SAndre Przywara 
118f5cb15b0SAndre Przywara #define MAX_MMAP_REGIONS		8
119f5cb15b0SAndre Przywara #define MAX_XLAT_TABLES			4
120f5cb15b0SAndre Przywara 
121f5cb15b0SAndre Przywara #define MAX_IO_DEVICES			U(3)
122f5cb15b0SAndre Przywara #define MAX_IO_HANDLES			U(4)
123f5cb15b0SAndre Przywara 
124f5cb15b0SAndre Przywara #define MAX_IO_BLOCK_DEVICES		U(1)
125f5cb15b0SAndre Przywara 
126f5cb15b0SAndre Przywara /*
127f5cb15b0SAndre Przywara  * Serial-related constants.
128f5cb15b0SAndre Przywara  */
129795aefe5SAndre Przywara #define PLAT_RPI_MINI_UART_BASE		RPI4_MINI_UART_BASE
130*5e6d821cSAndre Przywara #define PLAT_RPI_PL011_UART_BASE	RPI4_PL011_UART_BASE
131*5e6d821cSAndre Przywara #define PLAT_RPI_PL011_UART_CLOCK       RPI4_PL011_UART_CLOCK
132795aefe5SAndre Przywara #define PLAT_RPI_UART_BAUDRATE          ULL(115200)
133f5cb15b0SAndre Przywara 
134f5cb15b0SAndre Przywara /*
135f5cb15b0SAndre Przywara  * System counter
136f5cb15b0SAndre Przywara  */
137f5cb15b0SAndre Przywara #define SYS_COUNTER_FREQ_IN_TICKS	ULL(54000000)
138f5cb15b0SAndre Przywara 
139f5cb15b0SAndre Przywara #endif /* PLATFORM_DEF_H */
140