xref: /rk3399_ARM-atf/plat/amd/versal2/include/def.h (revision d235708c0e449ba31dbd7fb0356155d3c8d17480)
1 /*
2  * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
3  * Copyright (c) 2021-2022, Xilinx, Inc. All rights reserved.
4  * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef DEF_H
10 #define DEF_H
11 
12 #include <plat/arm/common/smccc_def.h>
13 #include <plat/common/common_def.h>
14 
15 #define MAX_INTR_EL3			2U
16 
17 /* List all consoles */
18 #define VERSAL2_CONSOLE_ID_none		0
19 #define VERSAL2_CONSOLE_ID_pl011	1
20 #define VERSAL2_CONSOLE_ID_pl011_0       1
21 #define VERSAL2_CONSOLE_ID_pl011_1       2
22 #define VERSAL2_CONSOLE_ID_dcc           3
23 #define VERSAL2_CONSOLE_ID_dtb           4
24 
25 #define CONSOLE_IS(con) (VERSAL2_CONSOLE_ID_ ## con == VERSAL2_CONSOLE)
26 
27 /* Runtime console */
28 #define RT_CONSOLE_ID_pl011   1
29 #define RT_CONSOLE_ID_pl011_0   1
30 #define RT_CONSOLE_ID_pl011_1   2
31 #define RT_CONSOLE_ID_dcc       3
32 #define RT_CONSOLE_ID_dtb       4
33 
34 #define RT_CONSOLE_IS(con)      (RT_CONSOLE_ID_ ## con == CONSOLE_RUNTIME)
35 
36 /* List all platforms */
37 #define SILICON		U(0)
38 #define SPP			U(1)
39 #define EMU			U(2)
40 #define QEMU			U(3)
41 #define SPP_MMD			U(5)
42 #define EMU_MMD			U(6)
43 #define QEMU_COSIM		U(7)
44 
45 /* For platform detection */
46 #define PMC_TAP				U(0xF11A0000)
47 #define PMC_TAP_VERSION			(PMC_TAP + 0x4U)
48 # define PMC_VERSION			GENMASK(7U, 0U)
49 # define PS_VERSION			GENMASK(15U, 8U)
50 # define RTL_VERSION			GENMASK(23U, 16U)
51 # define PLATFORM_MASK			GENMASK(27U, 24U)
52 # define PLATFORM_VERSION_MASK		GENMASK(31U, 28U)
53 
54 /* Global timer reset */
55 #define PSX_CRF			U(0xEC200000)
56 #define ACPU0_CLK_CTRL		U(0x10C)
57 #define ACPU_CLK_CTRL_CLKACT	BIT(25)
58 
59 #define RST_APU0_OFFSET		U(0x300)
60 #define RST_APU_COLD_RESET	BIT(0)
61 #define RST_APU_WARN_RESET	BIT(4)
62 #define RST_APU_CLUSTER_COLD_RESET	BIT(8)
63 #define RST_APU_CLUSTER_WARM_RESET	BIT(9)
64 
65 #define PSX_CRF_RST_TIMESTAMP_OFFSET	U(0x33C)
66 
67 #define APU_PCLI			(0xECB10000ULL)
68 #define APU_PCLI_CPU_STEP		(0x30ULL)
69 #define APU_PCLI_CLUSTER_CPU_STEP	(4ULL * APU_PCLI_CPU_STEP)
70 #define APU_PCLI_CLUSTER_OFFSET		U(0x8000)
71 #define APU_PCLI_CLUSTER_STEP		U(0x1000)
72 #define PCLI_PREQ_OFFSET		U(0x4)
73 #define PREQ_CHANGE_REQUEST		BIT(0)
74 #define PCLI_PSTATE_OFFSET		U(0x8)
75 #define PCLI_PSTATE_VAL_SET		U(0x48)
76 #define PCLI_PSTATE_VAL_CLEAR		U(0x38)
77 
78 /* Firmware Image Package */
79 #define PRIMARY_CPU		U(0)
80 
81 #define CORE_0_ISR_WAKE_OFFSET			(0x00000020ULL)
82 #define APU_PCIL_CORE_X_ISR_WAKE_REG(cpu_id)	(APU_PCLI + (CORE_0_ISR_WAKE_OFFSET + \
83 						 (APU_PCLI_CPU_STEP * (cpu_id))))
84 #define APU_PCIL_CORE_X_ISR_WAKE_MASK		(0x00000001U)
85 #define CORE_0_IEN_WAKE_OFFSET			(0x00000028ULL)
86 #define APU_PCIL_CORE_X_IEN_WAKE_REG(cpu_id)	(APU_PCLI + (CORE_0_IEN_WAKE_OFFSET + \
87 						 (APU_PCLI_CPU_STEP * (cpu_id))))
88 #define APU_PCIL_CORE_X_IEN_WAKE_MASK		(0x00000001U)
89 #define CORE_0_IDS_WAKE_OFFSET			(0x0000002CULL)
90 #define APU_PCIL_CORE_X_IDS_WAKE_REG(cpu_id)	(APU_PCLI + (CORE_0_IDS_WAKE_OFFSET + \
91 						 (APU_PCLI_CPU_STEP * (cpu_id))))
92 #define APU_PCIL_CORE_X_IDS_WAKE_MASK		(0x00000001U)
93 #define CORE_0_ISR_POWER_OFFSET			(0x00000010ULL)
94 #define APU_PCIL_CORE_X_ISR_POWER_REG(cpu_id)	(APU_PCLI + (CORE_0_ISR_POWER_OFFSET + \
95 						 (APU_PCLI_CPU_STEP * (cpu_id))))
96 #define APU_PCIL_CORE_X_ISR_POWER_MASK		U(0x00000001)
97 #define CORE_0_IEN_POWER_OFFSET			(0x00000018ULL)
98 #define APU_PCIL_CORE_X_IEN_POWER_REG(cpu_id)	(APU_PCLI + (CORE_0_IEN_POWER_OFFSET + \
99 						 (APU_PCLI_CPU_STEP * (cpu_id))))
100 #define APU_PCIL_CORE_X_IEN_POWER_MASK		(0x00000001U)
101 #define CORE_0_IDS_POWER_OFFSET			(0x0000001CULL)
102 #define APU_PCIL_CORE_X_IDS_POWER_REG(cpu_id)	(APU_PCLI + (CORE_0_IDS_POWER_OFFSET + \
103 						 (APU_PCLI_CPU_STEP * (cpu_id))))
104 #define APU_PCIL_CORE_X_IDS_POWER_MASK		(0x00000001U)
105 #define CORE_PWRDN_EN_BIT_MASK			(0x1U)
106 
107 /*******************************************************************************
108  * memory map related constants
109  ******************************************************************************/
110 /* IPP 1.2/SPP 0.9 mapping */
111 #define DEVICE0_BASE		U(0xE8000000) /* psx, crl, iou */
112 #define DEVICE0_SIZE		U(0x08000000)
113 #define DEVICE1_BASE		U(0xE2000000) /* gic */
114 #define DEVICE1_SIZE		U(0x00800000)
115 #define DEVICE2_BASE		U(0xF1000000) /* uart, pmc_tap */
116 #define DEVICE2_SIZE		U(0x01000000)
117 #define CRF_BASE		U(0xFD1A0000)
118 #define CRF_SIZE		U(0x00600000)
119 #define IPI_BASE		U(0xEB300000)
120 #define IPI_SIZE		U(0x00100000)
121 
122 /* CRL */
123 #define CRL					U(0xEB5E0000)
124 #define CRL_TIMESTAMP_REF_CTRL_OFFSET	U(0x14C)
125 #define CRL_RST_TIMESTAMP_OFFSET		U(0x348)
126 
127 #define CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT	(1U << 25U)
128 
129 /* IOU SCNTRS */
130 #define IOU_SCNTRS					U(0xEC920000)
131 #define IOU_SCNTRS_COUNTER_CONTROL_REG_OFFSET	U(0)
132 #define IOU_SCNTRS_BASE_FREQ_OFFSET			U(0x20)
133 
134 #define IOU_SCNTRS_CONTROL_EN	U(1)
135 
136 #define APU_CLUSTER0		U(0xECC00000)
137 #define APU_RVBAR_L_0		U(0x40)
138 #define APU_RVBAR_H_0		U(0x44)
139 #define APU_CLUSTER_STEP	U(0x100000)
140 
141 #define SLCR_OSPI_QSPI_IOU_AXI_MUX_SEL	U(0xF1060504)
142 #define PMXC_IOU_SLCR_SRAM_CSR	U(0xF106104C)
143 #define PMXC_IOU_SLCR_PHY_RESET	U(0xF1061050)
144 #define PMXC_IOU_SLCR_TX_RX_CONFIG_RDY	U(0xF1061054)
145 #define PMXC_CRP_RST_UFS	U(0xF1260340)
146 
147 /*******************************************************************************
148  * IRQ constants
149  ******************************************************************************/
150 #define IRQ_SEC_PHY_TIMER	U(29)
151 
152 /*******************************************************************************
153  * UART related constants
154  ******************************************************************************/
155 #define UART0_BASE		U(0xF1920000)
156 #define UART1_BASE		U(0xF1930000)
157 
158 #define UART_BAUDRATE	115200
159 
160 #if CONSOLE_IS(pl011) || CONSOLE_IS(dtb)
161 #define UART_BASE	    UART0_BASE
162 # define UART_TYPE	CONSOLE_PL011
163 #elif CONSOLE_IS(pl011_1)
164 #define UART_BASE           UART1_BASE
165 # define UART_TYPE	CONSOLE_PL011
166 #elif CONSOLE_IS(dcc)
167 # define UART_BASE	0x0
168 # define UART_TYPE	CONSOLE_DCC
169 #elif CONSOLE_IS(none)
170 # define UART_TYPE	CONSOLE_NONE
171 #else
172 # error "invalid VERSAL2_CONSOLE"
173 #endif
174 
175 /* Runtime console */
176 #if defined(CONSOLE_RUNTIME)
177 #if RT_CONSOLE_IS(pl011) || RT_CONSOLE_IS(dtb)
178 # define RT_UART_BASE UART0_BASE
179 # define RT_UART_TYPE	CONSOLE_PL011
180 #elif RT_CONSOLE_IS(pl011_1)
181 # define RT_UART_BASE UART1_BASE
182 # define RT_UART_TYPE	CONSOLE_PL011
183 #elif RT_CONSOLE_IS(dcc)
184 # define RT_UART_BASE	0x0
185 # define RT_UART_TYPE	CONSOLE_DCC
186 #else
187 # error "invalid CONSOLE_RUNTIME"
188 #endif
189 #endif
190 
191 #endif /* DEF_H */
192