xref: /rk3399_ARM-atf/plat/xilinx/versal_net/include/versal_net_def.h (revision 9ef62bd88d84cf97968af740907dd229aa1eb975)
11d333e69SMichal Simek /*
2619bc13eSMichal Simek  * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
31d333e69SMichal Simek  * Copyright (c) 2021-2022, Xilinx, Inc. All rights reserved.
427749653SMichal Simek  * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
51d333e69SMichal Simek  *
61d333e69SMichal Simek  * SPDX-License-Identifier: BSD-3-Clause
71d333e69SMichal Simek  */
81d333e69SMichal Simek 
91d333e69SMichal Simek #ifndef VERSAL_NET_DEF_H
101d333e69SMichal Simek #define VERSAL_NET_DEF_H
111d333e69SMichal Simek 
121d333e69SMichal Simek #include <plat/arm/common/smccc_def.h>
131d333e69SMichal Simek #include <plat/common/common_def.h>
141d333e69SMichal Simek 
15*3cbe0ae5SMaheedhar Bollapalli #define MAX_INTR_EL3			2U
161d333e69SMichal Simek 
171d333e69SMichal Simek /* List all consoles */
186d413983SMichal Simek #define VERSAL_NET_CONSOLE_ID_none	U(0)
191d333e69SMichal Simek #define VERSAL_NET_CONSOLE_ID_pl011	U(1)
201d333e69SMichal Simek #define VERSAL_NET_CONSOLE_ID_pl011_0	U(1)
211d333e69SMichal Simek #define VERSAL_NET_CONSOLE_ID_pl011_1	U(2)
2230e8bc36SAkshay Belsare #define VERSAL_NET_CONSOLE_ID_dcc	U(3)
23d61ba95eSPrasad Kummari #define VERSAL_NET_CONSOLE_ID_dtb	U(4)
241d333e69SMichal Simek 
2504a48335SMichal Simek #define CONSOLE_IS(con)	(VERSAL_NET_CONSOLE_ID_ ## con == VERSAL_NET_CONSOLE)
261d333e69SMichal Simek 
2728ad0e02SPrasad Kummari /* Runtime console */
2828ad0e02SPrasad Kummari #define RT_CONSOLE_ID_pl011    1
2928ad0e02SPrasad Kummari #define RT_CONSOLE_ID_pl011_0  1
3028ad0e02SPrasad Kummari #define RT_CONSOLE_ID_pl011_1  2
3128ad0e02SPrasad Kummari #define RT_CONSOLE_ID_dcc      3
3228ad0e02SPrasad Kummari #define RT_CONSOLE_ID_dtb      4
3328ad0e02SPrasad Kummari 
3428ad0e02SPrasad Kummari #define RT_CONSOLE_IS(con)     (RT_CONSOLE_ID_ ## con == CONSOLE_RUNTIME)
3528ad0e02SPrasad Kummari 
361d333e69SMichal Simek /* List all platforms */
371d333e69SMichal Simek #define VERSAL_NET_SILICON		U(0)
381d333e69SMichal Simek #define VERSAL_NET_SPP			U(1)
391d333e69SMichal Simek #define VERSAL_NET_EMU			U(2)
401d333e69SMichal Simek #define VERSAL_NET_QEMU			U(3)
416a079efdSSai Pavan Boddu #define VERSAL_NET_QEMU_COSIM		U(7)
421d333e69SMichal Simek 
431d333e69SMichal Simek /* For platform detection */
441d333e69SMichal Simek #define PMC_TAP				U(0xF11A0000)
451d333e69SMichal Simek #define PMC_TAP_VERSION			(PMC_TAP + 0x4U)
461d333e69SMichal Simek # define PLATFORM_MASK			GENMASK(27U, 24U)
471d333e69SMichal Simek # define PLATFORM_VERSION_MASK		GENMASK(31U, 28U)
481d333e69SMichal Simek 
491d333e69SMichal Simek /* Global timer reset */
501d333e69SMichal Simek #define PSX_CRF			U(0xEC200000)
518529c769SMichal Simek #define ACPU0_CLK_CTRL		U(0x10C)
528529c769SMichal Simek #define ACPU_CLK_CTRL_CLKACT	BIT(25)
538529c769SMichal Simek 
548529c769SMichal Simek #define RST_APU0_OFFSET		U(0x300)
558529c769SMichal Simek #define RST_APU_COLD_RESET	BIT(0)
568529c769SMichal Simek #define RST_APU_WARN_RESET	BIT(4)
578529c769SMichal Simek #define RST_APU_CLUSTER_COLD_RESET	BIT(8)
588529c769SMichal Simek #define RST_APU_CLUSTER_WARM_RESET	BIT(9)
598529c769SMichal Simek 
601d333e69SMichal Simek #define PSX_CRF_RST_TIMESTAMP_OFFSET	U(0x33C)
611d333e69SMichal Simek 
628c23775eSJay Buddhabhatti #define APU_PCLI			(0xECB10000ULL)
638c23775eSJay Buddhabhatti #define APU_PCLI_CPU_STEP		(0x30ULL)
648c23775eSJay Buddhabhatti #define APU_PCLI_CLUSTER_CPU_STEP	(4ULL * APU_PCLI_CPU_STEP)
658529c769SMichal Simek #define APU_PCLI_CLUSTER_OFFSET		U(0x8000)
668529c769SMichal Simek #define APU_PCLI_CLUSTER_STEP		U(0x1000)
678529c769SMichal Simek #define PCLI_PREQ_OFFSET		U(0x4)
688529c769SMichal Simek #define PREQ_CHANGE_REQUEST		BIT(0)
698529c769SMichal Simek #define PCLI_PSTATE_OFFSET		U(0x8)
708529c769SMichal Simek #define PCLI_PSTATE_VAL_SET		U(0x48)
718529c769SMichal Simek #define PCLI_PSTATE_VAL_CLEAR		U(0x38)
728529c769SMichal Simek 
731d333e69SMichal Simek /* Firmware Image Package */
741d333e69SMichal Simek #define VERSAL_NET_PRIMARY_CPU		U(0)
751d333e69SMichal Simek 
76e663f09bSJay Buddhabhatti #define CORE_0_ISR_WAKE_OFFSET			(0x00000020ULL)
77e663f09bSJay Buddhabhatti #define APU_PCIL_CORE_X_ISR_WAKE_REG(cpu_id)	(APU_PCLI + (CORE_0_ISR_WAKE_OFFSET + \
78e663f09bSJay Buddhabhatti 						 (APU_PCLI_CPU_STEP * (cpu_id))))
79e663f09bSJay Buddhabhatti #define APU_PCIL_CORE_X_ISR_WAKE_MASK		(0x00000001U)
80e663f09bSJay Buddhabhatti #define CORE_0_IEN_WAKE_OFFSET			(0x00000028ULL)
81e663f09bSJay Buddhabhatti #define APU_PCIL_CORE_X_IEN_WAKE_REG(cpu_id)	(APU_PCLI + (CORE_0_IEN_WAKE_OFFSET + \
82e663f09bSJay Buddhabhatti 						 (APU_PCLI_CPU_STEP * (cpu_id))))
83e663f09bSJay Buddhabhatti #define APU_PCIL_CORE_X_IEN_WAKE_MASK		(0x00000001U)
84e663f09bSJay Buddhabhatti #define CORE_0_IDS_WAKE_OFFSET			(0x0000002CULL)
85e663f09bSJay Buddhabhatti #define APU_PCIL_CORE_X_IDS_WAKE_REG(cpu_id)	(APU_PCLI + (CORE_0_IDS_WAKE_OFFSET + \
86e663f09bSJay Buddhabhatti 						 (APU_PCLI_CPU_STEP * (cpu_id))))
87e663f09bSJay Buddhabhatti #define APU_PCIL_CORE_X_IDS_WAKE_MASK		(0x00000001U)
882d056db4SJay Buddhabhatti #define CORE_0_ISR_POWER_OFFSET			(0x00000010ULL)
892d056db4SJay Buddhabhatti #define APU_PCIL_CORE_X_ISR_POWER_REG(cpu_id)	(APU_PCLI + (CORE_0_ISR_POWER_OFFSET + \
902d056db4SJay Buddhabhatti 						 (APU_PCLI_CPU_STEP * (cpu_id))))
912d056db4SJay Buddhabhatti #define APU_PCIL_CORE_X_ISR_POWER_MASK		U(0x00000001)
928c23775eSJay Buddhabhatti #define CORE_0_IEN_POWER_OFFSET			(0x00000018ULL)
930654ab7fSJay Buddhabhatti #define APU_PCIL_CORE_X_IEN_POWER_REG(cpu_id)	(APU_PCLI + (CORE_0_IEN_POWER_OFFSET + \
9421d1966aSJay Buddhabhatti 						 (APU_PCLI_CPU_STEP * (cpu_id))))
950654ab7fSJay Buddhabhatti #define APU_PCIL_CORE_X_IEN_POWER_MASK		(0x00000001U)
968c23775eSJay Buddhabhatti #define CORE_0_IDS_POWER_OFFSET			(0x0000001CULL)
970654ab7fSJay Buddhabhatti #define APU_PCIL_CORE_X_IDS_POWER_REG(cpu_id)	(APU_PCLI + (CORE_0_IDS_POWER_OFFSET + \
9821d1966aSJay Buddhabhatti 						 (APU_PCLI_CPU_STEP * (cpu_id))))
990654ab7fSJay Buddhabhatti #define APU_PCIL_CORE_X_IDS_POWER_MASK		(0x00000001U)
1000654ab7fSJay Buddhabhatti #define CORE_PWRDN_EN_BIT_MASK			(0x1U)
1010654ab7fSJay Buddhabhatti 
1021d333e69SMichal Simek /*******************************************************************************
1031d333e69SMichal Simek  * memory map related constants
1041d333e69SMichal Simek  ******************************************************************************/
1051d333e69SMichal Simek /* IPP 1.2/SPP 0.9 mapping */
1061d333e69SMichal Simek #define DEVICE0_BASE		U(0xE8000000) /* psx, crl, iou */
1071d333e69SMichal Simek #define DEVICE0_SIZE		U(0x08000000)
1081d333e69SMichal Simek #define DEVICE1_BASE		U(0xE2000000) /* gic */
1091d333e69SMichal Simek #define DEVICE1_SIZE		U(0x00800000)
1101d333e69SMichal Simek #define DEVICE2_BASE		U(0xF1000000) /* uart, pmc_tap */
1111d333e69SMichal Simek #define DEVICE2_SIZE		U(0x01000000)
1121d333e69SMichal Simek #define CRF_BASE		U(0xFD1A0000)
1131d333e69SMichal Simek #define CRF_SIZE		U(0x00600000)
1140bf622deSMichal Simek #define IPI_BASE		U(0xEB300000)
1150bf622deSMichal Simek #define IPI_SIZE		U(0x00100000)
1161d333e69SMichal Simek 
1171d333e69SMichal Simek /* CRL */
1181d333e69SMichal Simek #define VERSAL_NET_CRL					U(0xEB5E0000)
1191d333e69SMichal Simek #define VERSAL_NET_CRL_TIMESTAMP_REF_CTRL_OFFSET	U(0x14C)
1201d333e69SMichal Simek #define VERSAL_NET_CRL_RST_TIMESTAMP_OFFSET		U(0x348)
1211d333e69SMichal Simek 
1221d333e69SMichal Simek #define VERSAL_NET_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT	(1U << 25U)
1231d333e69SMichal Simek 
1241d333e69SMichal Simek /* IOU SCNTRS */
1251f02024bSPrasad Kummari #define IOU_SCNTRS_BASE	U(0xEC920000)
1261f02024bSPrasad Kummari #define IOU_SCNTRS_COUNTER_CONTROL_REG_OFFSET	U(0)
1271f02024bSPrasad Kummari #define IOU_SCNTRS_BASE_FREQ_OFFSET	U(0x20)
1281d333e69SMichal Simek 
1291f02024bSPrasad Kummari #define IOU_SCNTRS_CONTROL_EN	U(1)
1301d333e69SMichal Simek 
1318529c769SMichal Simek #define APU_CLUSTER0		U(0xECC00000)
1328529c769SMichal Simek #define APU_RVBAR_L_0		U(0x40)
1338529c769SMichal Simek #define APU_RVBAR_H_0		U(0x44)
1348529c769SMichal Simek #define APU_CLUSTER_STEP	U(0x100000)
1358529c769SMichal Simek 
1368529c769SMichal Simek #define SLCR_OSPI_QSPI_IOU_AXI_MUX_SEL	U(0xF1060504)
1378529c769SMichal Simek 
1381d333e69SMichal Simek /*******************************************************************************
1391d333e69SMichal Simek  * IRQ constants
1401d333e69SMichal Simek  ******************************************************************************/
1411d333e69SMichal Simek #define VERSAL_NET_IRQ_SEC_PHY_TIMER	U(29)
142639b3676SPrasad Kummari #define ARM_IRQ_SEC_PHY_TIMER	29
1431d333e69SMichal Simek 
1441d333e69SMichal Simek /*******************************************************************************
1451d333e69SMichal Simek  * UART related constants
1461d333e69SMichal Simek  ******************************************************************************/
1471d333e69SMichal Simek #define VERSAL_NET_UART0_BASE		U(0xF1920000)
1482f1b4c55SAkshay Belsare #define VERSAL_NET_UART1_BASE		U(0xF1930000)
1492f1b4c55SAkshay Belsare 
150e2ef1dfcSPrasad Kummari #define UART_BAUDRATE	115200
1511d333e69SMichal Simek 
152d61ba95eSPrasad Kummari #if CONSOLE_IS(pl011) || CONSOLE_IS(dtb)
15304a48335SMichal Simek #define UART_BASE		VERSAL_NET_UART0_BASE
154d61ba95eSPrasad Kummari # define UART_TYPE	CONSOLE_PL011
155d61ba95eSPrasad Kummari #elif CONSOLE_IS(pl011_1)
156d61ba95eSPrasad Kummari #define UART_BASE            VERSAL_NET_UART1_BASE
157d61ba95eSPrasad Kummari # define UART_TYPE	CONSOLE_PL011
158d61ba95eSPrasad Kummari #elif CONSOLE_IS(dcc)
159d61ba95eSPrasad Kummari # define UART_BASE	0x0
160d61ba95eSPrasad Kummari # define UART_TYPE	CONSOLE_DCC
1616d413983SMichal Simek #elif CONSOLE_IS(none)
1626d413983SMichal Simek # define UART_TYPE	CONSOLE_NONE
163d61ba95eSPrasad Kummari #else
164d61ba95eSPrasad Kummari # error "invalid VERSAL_NET_CONSOLE"
1652f1b4c55SAkshay Belsare #endif
1661d333e69SMichal Simek 
16728ad0e02SPrasad Kummari /* Runtime console */
16828ad0e02SPrasad Kummari #if defined(CONSOLE_RUNTIME)
169d61ba95eSPrasad Kummari #if RT_CONSOLE_IS(pl011) || RT_CONSOLE_IS(dtb)
17028ad0e02SPrasad Kummari # define RT_UART_BASE VERSAL_NET_UART0_BASE
171d61ba95eSPrasad Kummari # define RT_UART_TYPE	CONSOLE_PL011
17228ad0e02SPrasad Kummari #elif RT_CONSOLE_IS(pl011_1)
17328ad0e02SPrasad Kummari # define RT_UART_BASE VERSAL_NET_UART1_BASE
174d61ba95eSPrasad Kummari # define RT_UART_TYPE	CONSOLE_PL011
175d61ba95eSPrasad Kummari #elif RT_CONSOLE_IS(dcc)
176d61ba95eSPrasad Kummari # define RT_UART_BASE	0x0
177d61ba95eSPrasad Kummari # define RT_UART_TYPE	CONSOLE_DCC
17828ad0e02SPrasad Kummari #else
17928ad0e02SPrasad Kummari # error "invalid CONSOLE_RUNTIME"
18028ad0e02SPrasad Kummari #endif
18128ad0e02SPrasad Kummari #endif
18228ad0e02SPrasad Kummari 
1830654ab7fSJay Buddhabhatti /* Processor core device IDs */
1840654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER0_ACPU_0	(0x1810C0AFU)
1850654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER0_ACPU_1	(0x1810C0B0U)
1860654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER0_ACPU_2	(0x1810C0B1U)
1870654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER0_ACPU_3	(0x1810C0B2U)
1880654ab7fSJay Buddhabhatti 
1890654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER1_ACPU_0	(0x1810C0B3U)
1900654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER1_ACPU_1	(0x1810C0B4U)
1910654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER1_ACPU_2	(0x1810C0B5U)
1920654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER1_ACPU_3	(0x1810C0B6U)
1930654ab7fSJay Buddhabhatti 
1940654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER2_ACPU_0	(0x1810C0B7U)
1950654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER2_ACPU_1	(0x1810C0B8U)
1960654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER2_ACPU_2	(0x1810C0B9U)
1970654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER2_ACPU_3	(0x1810C0BAU)
1980654ab7fSJay Buddhabhatti 
1990654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER3_ACPU_0	(0x1810C0BBU)
2000654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER3_ACPU_1	(0x1810C0BCU)
2010654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER3_ACPU_2	(0x1810C0BDU)
2020654ab7fSJay Buddhabhatti #define PM_DEV_CLUSTER3_ACPU_3	(0x1810C0BEU)
2030654ab7fSJay Buddhabhatti 
2041d333e69SMichal Simek #endif /* VERSAL_NET_DEF_H */
205