Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 3 | * Copyright (c) 2021-2022, Xilinx, Inc. All rights reserved. |
Michal Simek | 0129707 | 2023-04-25 14:14:06 +0200 | [diff] [blame] | 4 | * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved. |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 5 | * |
| 6 | * SPDX-License-Identifier: BSD-3-Clause |
| 7 | */ |
| 8 | |
| 9 | #ifndef VERSAL_NET_DEF_H |
| 10 | #define VERSAL_NET_DEF_H |
| 11 | |
| 12 | #include <plat/arm/common/smccc_def.h> |
| 13 | #include <plat/common/common_def.h> |
| 14 | |
Jay Buddhabhatti | c6daff0 | 2022-09-05 02:56:32 -0700 | [diff] [blame] | 15 | #define MAX_INTR_EL3 2 |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 16 | /* This part is taken from U-Boot project under GPL that's why dual license above */ |
| 17 | #define __bf_shf(x) (__builtin_ffsll(x) - 1U) |
| 18 | #define FIELD_GET(_mask, _reg) \ |
| 19 | ({ \ |
| 20 | (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \ |
| 21 | }) |
| 22 | |
| 23 | /* List all consoles */ |
| 24 | #define VERSAL_NET_CONSOLE_ID_pl011 U(1) |
| 25 | #define VERSAL_NET_CONSOLE_ID_pl011_0 U(1) |
| 26 | #define VERSAL_NET_CONSOLE_ID_pl011_1 U(2) |
Akshay Belsare | 50a2968 | 2023-01-18 15:54:12 +0530 | [diff] [blame] | 27 | #define VERSAL_NET_CONSOLE_ID_dcc U(3) |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 28 | |
| 29 | #define VERSAL_NET_CONSOLE_IS(con) (VERSAL_NET_CONSOLE_ID_ ## con == VERSAL_NET_CONSOLE) |
| 30 | |
| 31 | /* List all platforms */ |
| 32 | #define VERSAL_NET_SILICON U(0) |
| 33 | #define VERSAL_NET_SPP U(1) |
| 34 | #define VERSAL_NET_EMU U(2) |
| 35 | #define VERSAL_NET_QEMU U(3) |
Sai Pavan Boddu | 7524b22 | 2022-09-08 16:09:04 +0530 | [diff] [blame] | 36 | #define VERSAL_NET_QEMU_COSIM U(7) |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 37 | |
| 38 | /* For platform detection */ |
| 39 | #define PMC_TAP U(0xF11A0000) |
| 40 | #define PMC_TAP_VERSION (PMC_TAP + 0x4U) |
| 41 | # define PLATFORM_MASK GENMASK(27U, 24U) |
| 42 | # define PLATFORM_VERSION_MASK GENMASK(31U, 28U) |
| 43 | |
| 44 | /* Global timer reset */ |
| 45 | #define PSX_CRF U(0xEC200000) |
Michal Simek | dc708ac | 2022-09-19 13:52:54 +0200 | [diff] [blame] | 46 | #define ACPU0_CLK_CTRL U(0x10C) |
| 47 | #define ACPU_CLK_CTRL_CLKACT BIT(25) |
| 48 | |
| 49 | #define RST_APU0_OFFSET U(0x300) |
| 50 | #define RST_APU_COLD_RESET BIT(0) |
| 51 | #define RST_APU_WARN_RESET BIT(4) |
| 52 | #define RST_APU_CLUSTER_COLD_RESET BIT(8) |
| 53 | #define RST_APU_CLUSTER_WARM_RESET BIT(9) |
| 54 | |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 55 | #define PSX_CRF_RST_TIMESTAMP_OFFSET U(0x33C) |
| 56 | |
Jay Buddhabhatti | 3d832ea | 2023-01-09 04:33:25 -0800 | [diff] [blame] | 57 | #define APU_PCLI (0xECB10000ULL) |
| 58 | #define APU_PCLI_CPU_STEP (0x30ULL) |
| 59 | #define APU_PCLI_CLUSTER_CPU_STEP (4ULL * APU_PCLI_CPU_STEP) |
Michal Simek | dc708ac | 2022-09-19 13:52:54 +0200 | [diff] [blame] | 60 | #define APU_PCLI_CLUSTER_OFFSET U(0x8000) |
| 61 | #define APU_PCLI_CLUSTER_STEP U(0x1000) |
| 62 | #define PCLI_PREQ_OFFSET U(0x4) |
| 63 | #define PREQ_CHANGE_REQUEST BIT(0) |
| 64 | #define PCLI_PSTATE_OFFSET U(0x8) |
| 65 | #define PCLI_PSTATE_VAL_SET U(0x48) |
| 66 | #define PCLI_PSTATE_VAL_CLEAR U(0x38) |
| 67 | |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 68 | /* Firmware Image Package */ |
| 69 | #define VERSAL_NET_PRIMARY_CPU U(0) |
| 70 | |
Jay Buddhabhatti | edfadb7 | 2022-12-29 22:21:00 -0800 | [diff] [blame] | 71 | #define CORE_0_ISR_WAKE_OFFSET (0x00000020ULL) |
| 72 | #define APU_PCIL_CORE_X_ISR_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_ISR_WAKE_OFFSET + \ |
| 73 | (APU_PCLI_CPU_STEP * (cpu_id)))) |
| 74 | #define APU_PCIL_CORE_X_ISR_WAKE_MASK (0x00000001U) |
| 75 | #define CORE_0_IEN_WAKE_OFFSET (0x00000028ULL) |
| 76 | #define APU_PCIL_CORE_X_IEN_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_IEN_WAKE_OFFSET + \ |
| 77 | (APU_PCLI_CPU_STEP * (cpu_id)))) |
| 78 | #define APU_PCIL_CORE_X_IEN_WAKE_MASK (0x00000001U) |
| 79 | #define CORE_0_IDS_WAKE_OFFSET (0x0000002CULL) |
| 80 | #define APU_PCIL_CORE_X_IDS_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_IDS_WAKE_OFFSET + \ |
| 81 | (APU_PCLI_CPU_STEP * (cpu_id)))) |
| 82 | #define APU_PCIL_CORE_X_IDS_WAKE_MASK (0x00000001U) |
Jay Buddhabhatti | c235865 | 2022-12-29 21:47:54 -0800 | [diff] [blame] | 83 | #define CORE_0_ISR_POWER_OFFSET (0x00000010ULL) |
| 84 | #define APU_PCIL_CORE_X_ISR_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_ISR_POWER_OFFSET + \ |
| 85 | (APU_PCLI_CPU_STEP * (cpu_id)))) |
| 86 | #define APU_PCIL_CORE_X_ISR_POWER_MASK U(0x00000001) |
Jay Buddhabhatti | 3d832ea | 2023-01-09 04:33:25 -0800 | [diff] [blame] | 87 | #define CORE_0_IEN_POWER_OFFSET (0x00000018ULL) |
Jay Buddhabhatti | c6daff0 | 2022-09-05 02:56:32 -0700 | [diff] [blame] | 88 | #define APU_PCIL_CORE_X_IEN_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_IEN_POWER_OFFSET + \ |
Jay Buddhabhatti | 43cbf7e | 2023-01-09 04:46:54 -0800 | [diff] [blame] | 89 | (APU_PCLI_CPU_STEP * (cpu_id)))) |
Jay Buddhabhatti | c6daff0 | 2022-09-05 02:56:32 -0700 | [diff] [blame] | 90 | #define APU_PCIL_CORE_X_IEN_POWER_MASK (0x00000001U) |
Jay Buddhabhatti | 3d832ea | 2023-01-09 04:33:25 -0800 | [diff] [blame] | 91 | #define CORE_0_IDS_POWER_OFFSET (0x0000001CULL) |
Jay Buddhabhatti | c6daff0 | 2022-09-05 02:56:32 -0700 | [diff] [blame] | 92 | #define APU_PCIL_CORE_X_IDS_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_IDS_POWER_OFFSET + \ |
Jay Buddhabhatti | 43cbf7e | 2023-01-09 04:46:54 -0800 | [diff] [blame] | 93 | (APU_PCLI_CPU_STEP * (cpu_id)))) |
Jay Buddhabhatti | c6daff0 | 2022-09-05 02:56:32 -0700 | [diff] [blame] | 94 | #define APU_PCIL_CORE_X_IDS_POWER_MASK (0x00000001U) |
| 95 | #define CORE_PWRDN_EN_BIT_MASK (0x1U) |
| 96 | |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 97 | /******************************************************************************* |
| 98 | * memory map related constants |
| 99 | ******************************************************************************/ |
| 100 | /* IPP 1.2/SPP 0.9 mapping */ |
| 101 | #define DEVICE0_BASE U(0xE8000000) /* psx, crl, iou */ |
| 102 | #define DEVICE0_SIZE U(0x08000000) |
| 103 | #define DEVICE1_BASE U(0xE2000000) /* gic */ |
| 104 | #define DEVICE1_SIZE U(0x00800000) |
| 105 | #define DEVICE2_BASE U(0xF1000000) /* uart, pmc_tap */ |
| 106 | #define DEVICE2_SIZE U(0x01000000) |
| 107 | #define CRF_BASE U(0xFD1A0000) |
| 108 | #define CRF_SIZE U(0x00600000) |
Michal Simek | aa5443e | 2022-09-19 14:04:55 +0200 | [diff] [blame] | 109 | #define IPI_BASE U(0xEB300000) |
| 110 | #define IPI_SIZE U(0x00100000) |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 111 | |
| 112 | /* CRL */ |
| 113 | #define VERSAL_NET_CRL U(0xEB5E0000) |
| 114 | #define VERSAL_NET_CRL_TIMESTAMP_REF_CTRL_OFFSET U(0x14C) |
| 115 | #define VERSAL_NET_CRL_RST_TIMESTAMP_OFFSET U(0x348) |
| 116 | |
| 117 | #define VERSAL_NET_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT (1U << 25U) |
| 118 | |
| 119 | /* IOU SCNTRS */ |
| 120 | #define VERSAL_NET_IOU_SCNTRS U(0xEC920000) |
| 121 | #define VERSAL_NET_IOU_SCNTRS_COUNTER_CONTROL_REG_OFFSET U(0) |
| 122 | #define VERSAL_NET_IOU_SCNTRS_BASE_FREQ_OFFSET U(0x20) |
| 123 | |
| 124 | #define VERSAL_NET_IOU_SCNTRS_CONTROL_EN U(1) |
| 125 | |
Michal Simek | dc708ac | 2022-09-19 13:52:54 +0200 | [diff] [blame] | 126 | #define APU_CLUSTER0 U(0xECC00000) |
| 127 | #define APU_RVBAR_L_0 U(0x40) |
| 128 | #define APU_RVBAR_H_0 U(0x44) |
| 129 | #define APU_CLUSTER_STEP U(0x100000) |
| 130 | |
| 131 | #define SLCR_OSPI_QSPI_IOU_AXI_MUX_SEL U(0xF1060504) |
| 132 | |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 133 | /******************************************************************************* |
| 134 | * IRQ constants |
| 135 | ******************************************************************************/ |
| 136 | #define VERSAL_NET_IRQ_SEC_PHY_TIMER U(29) |
| 137 | |
| 138 | /******************************************************************************* |
| 139 | * UART related constants |
| 140 | ******************************************************************************/ |
| 141 | #define VERSAL_NET_UART0_BASE U(0xF1920000) |
Akshay Belsare | 0babc5f | 2023-01-13 14:40:37 +0530 | [diff] [blame] | 142 | #define VERSAL_NET_UART1_BASE U(0xF1930000) |
| 143 | |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 144 | #define VERSAL_NET_UART_BAUDRATE 115200 |
| 145 | |
Akshay Belsare | 50a2968 | 2023-01-18 15:54:12 +0530 | [diff] [blame] | 146 | #if VERSAL_NET_CONSOLE_IS(pl011_1) |
Akshay Belsare | 0babc5f | 2023-01-13 14:40:37 +0530 | [diff] [blame] | 147 | #define VERSAL_NET_UART_BASE VERSAL_NET_UART1_BASE |
| 148 | #else |
Akshay Belsare | 50a2968 | 2023-01-18 15:54:12 +0530 | [diff] [blame] | 149 | /* Default console is UART0 */ |
| 150 | #define VERSAL_NET_UART_BASE VERSAL_NET_UART0_BASE |
Akshay Belsare | 0babc5f | 2023-01-13 14:40:37 +0530 | [diff] [blame] | 151 | #endif |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 152 | |
| 153 | #define PLAT_VERSAL_NET_CRASH_UART_BASE VERSAL_NET_UART_BASE |
| 154 | #define PLAT_VERSAL_NET_CRASH_UART_CLK_IN_HZ VERSAL_NET_UART_CLOCK |
| 155 | #define VERSAL_NET_CONSOLE_BAUDRATE VERSAL_NET_UART_BAUDRATE |
| 156 | |
Jay Buddhabhatti | c6daff0 | 2022-09-05 02:56:32 -0700 | [diff] [blame] | 157 | /* Processor core device IDs */ |
| 158 | #define PM_DEV_CLUSTER0_ACPU_0 (0x1810C0AFU) |
| 159 | #define PM_DEV_CLUSTER0_ACPU_1 (0x1810C0B0U) |
| 160 | #define PM_DEV_CLUSTER0_ACPU_2 (0x1810C0B1U) |
| 161 | #define PM_DEV_CLUSTER0_ACPU_3 (0x1810C0B2U) |
| 162 | |
| 163 | #define PM_DEV_CLUSTER1_ACPU_0 (0x1810C0B3U) |
| 164 | #define PM_DEV_CLUSTER1_ACPU_1 (0x1810C0B4U) |
| 165 | #define PM_DEV_CLUSTER1_ACPU_2 (0x1810C0B5U) |
| 166 | #define PM_DEV_CLUSTER1_ACPU_3 (0x1810C0B6U) |
| 167 | |
| 168 | #define PM_DEV_CLUSTER2_ACPU_0 (0x1810C0B7U) |
| 169 | #define PM_DEV_CLUSTER2_ACPU_1 (0x1810C0B8U) |
| 170 | #define PM_DEV_CLUSTER2_ACPU_2 (0x1810C0B9U) |
| 171 | #define PM_DEV_CLUSTER2_ACPU_3 (0x1810C0BAU) |
| 172 | |
| 173 | #define PM_DEV_CLUSTER3_ACPU_0 (0x1810C0BBU) |
| 174 | #define PM_DEV_CLUSTER3_ACPU_1 (0x1810C0BCU) |
| 175 | #define PM_DEV_CLUSTER3_ACPU_2 (0x1810C0BDU) |
| 176 | #define PM_DEV_CLUSTER3_ACPU_3 (0x1810C0BEU) |
| 177 | |
Michal Simek | 9179436 | 2022-08-31 16:45:14 +0200 | [diff] [blame] | 178 | #endif /* VERSAL_NET_DEF_H */ |