1df373737SAchin Gupta /* 2ebf1ca10SSoby Mathew * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. 3df373737SAchin Gupta * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 5df373737SAchin Gupta */ 6df373737SAchin Gupta 7df373737SAchin Gupta #ifndef __GICV3_H__ 8df373737SAchin Gupta #define __GICV3_H__ 9df373737SAchin Gupta 10ebf1ca10SSoby Mathew #include "utils_def.h" 11ebf1ca10SSoby Mathew 12df373737SAchin Gupta /******************************************************************************* 13df373737SAchin Gupta * GICv3 miscellaneous definitions 14df373737SAchin Gupta ******************************************************************************/ 15df373737SAchin Gupta /* Interrupt group definitions */ 1603ffb6bdSSoby Mathew #define INTR_GROUP1S 0 1703ffb6bdSSoby Mathew #define INTR_GROUP0 1 1803ffb6bdSSoby Mathew #define INTR_GROUP1NS 2 19df373737SAchin Gupta 20df373737SAchin Gupta /* Interrupt IDs reported by the HPPIR and IAR registers */ 21df373737SAchin Gupta #define PENDING_G1S_INTID 1020 22df373737SAchin Gupta #define PENDING_G1NS_INTID 1021 23df373737SAchin Gupta 24df373737SAchin Gupta /* Constant to categorize LPI interrupt */ 25df373737SAchin Gupta #define MIN_LPI_ID 8192 26df373737SAchin Gupta 27*8db978b5SJeenu Viswambharan /* GICv3 can only target up to 16 PEs with SGI */ 28*8db978b5SJeenu Viswambharan #define GICV3_MAX_SGI_TARGETS 16 29*8db978b5SJeenu Viswambharan 30df373737SAchin Gupta /******************************************************************************* 31df373737SAchin Gupta * GICv3 specific Distributor interface register offsets and constants. 32df373737SAchin Gupta ******************************************************************************/ 33df373737SAchin Gupta #define GICD_STATUSR 0x10 34df373737SAchin Gupta #define GICD_SETSPI_NSR 0x40 35df373737SAchin Gupta #define GICD_CLRSPI_NSR 0x48 36df373737SAchin Gupta #define GICD_SETSPI_SR 0x50 37df373737SAchin Gupta #define GICD_CLRSPI_SR 0x50 38df373737SAchin Gupta #define GICD_IGRPMODR 0xd00 3961e30277SSoby Mathew /* 4061e30277SSoby Mathew * GICD_IROUTER<n> register is at 0x6000 + 8n, where n is the interrupt id and 4161e30277SSoby Mathew * n >= 32, making the effective offset as 0x6100. 4261e30277SSoby Mathew */ 4361e30277SSoby Mathew #define GICD_IROUTER 0x6000 44df373737SAchin Gupta #define GICD_PIDR2_GICV3 0xffe8 45df373737SAchin Gupta 46df373737SAchin Gupta #define IGRPMODR_SHIFT 5 47df373737SAchin Gupta 48df373737SAchin Gupta /* GICD_CTLR bit definitions */ 49df373737SAchin Gupta #define CTLR_ENABLE_G1NS_SHIFT 1 50df373737SAchin Gupta #define CTLR_ENABLE_G1S_SHIFT 2 51df373737SAchin Gupta #define CTLR_ARE_S_SHIFT 4 52df373737SAchin Gupta #define CTLR_ARE_NS_SHIFT 5 53df373737SAchin Gupta #define CTLR_DS_SHIFT 6 54df373737SAchin Gupta #define CTLR_E1NWF_SHIFT 7 55df373737SAchin Gupta #define GICD_CTLR_RWP_SHIFT 31 56df373737SAchin Gupta 57df373737SAchin Gupta #define CTLR_ENABLE_G1NS_MASK 0x1 58df373737SAchin Gupta #define CTLR_ENABLE_G1S_MASK 0x1 59df373737SAchin Gupta #define CTLR_ARE_S_MASK 0x1 60df373737SAchin Gupta #define CTLR_ARE_NS_MASK 0x1 61df373737SAchin Gupta #define CTLR_DS_MASK 0x1 62df373737SAchin Gupta #define CTLR_E1NWF_MASK 0x1 63df373737SAchin Gupta #define GICD_CTLR_RWP_MASK 0x1 64df373737SAchin Gupta 65df373737SAchin Gupta #define CTLR_ENABLE_G1NS_BIT (1 << CTLR_ENABLE_G1NS_SHIFT) 66df373737SAchin Gupta #define CTLR_ENABLE_G1S_BIT (1 << CTLR_ENABLE_G1S_SHIFT) 67df373737SAchin Gupta #define CTLR_ARE_S_BIT (1 << CTLR_ARE_S_SHIFT) 68df373737SAchin Gupta #define CTLR_ARE_NS_BIT (1 << CTLR_ARE_NS_SHIFT) 69df373737SAchin Gupta #define CTLR_DS_BIT (1 << CTLR_DS_SHIFT) 70df373737SAchin Gupta #define CTLR_E1NWF_BIT (1 << CTLR_E1NWF_SHIFT) 71df373737SAchin Gupta #define GICD_CTLR_RWP_BIT (1 << GICD_CTLR_RWP_SHIFT) 72df373737SAchin Gupta 73df373737SAchin Gupta /* GICD_IROUTER shifts and masks */ 74ebf1ca10SSoby Mathew #define IROUTER_SHIFT 0 75df373737SAchin Gupta #define IROUTER_IRM_SHIFT 31 76df373737SAchin Gupta #define IROUTER_IRM_MASK 0x1 77df373737SAchin Gupta 78ebf1ca10SSoby Mathew #define NUM_OF_DIST_REGS 30 79ebf1ca10SSoby Mathew 80df373737SAchin Gupta /******************************************************************************* 81df373737SAchin Gupta * GICv3 Re-distributor interface registers & constants 82df373737SAchin Gupta ******************************************************************************/ 83df373737SAchin Gupta #define GICR_PCPUBASE_SHIFT 0x11 84df373737SAchin Gupta #define GICR_SGIBASE_OFFSET (1 << 0x10) /* 64 KB */ 85df373737SAchin Gupta #define GICR_CTLR 0x0 86df373737SAchin Gupta #define GICR_TYPER 0x08 87df373737SAchin Gupta #define GICR_WAKER 0x14 88ebf1ca10SSoby Mathew #define GICR_PROPBASER 0x70 89ebf1ca10SSoby Mathew #define GICR_PENDBASER 0x78 90df373737SAchin Gupta #define GICR_IGROUPR0 (GICR_SGIBASE_OFFSET + 0x80) 91df373737SAchin Gupta #define GICR_ISENABLER0 (GICR_SGIBASE_OFFSET + 0x100) 92df373737SAchin Gupta #define GICR_ICENABLER0 (GICR_SGIBASE_OFFSET + 0x180) 93ebf1ca10SSoby Mathew #define GICR_ISPENDR0 (GICR_SGIBASE_OFFSET + 0x200) 94ebf1ca10SSoby Mathew #define GICR_ICPENDR0 (GICR_SGIBASE_OFFSET + 0x280) 95ebf1ca10SSoby Mathew #define GICR_ISACTIVER0 (GICR_SGIBASE_OFFSET + 0x300) 96ebf1ca10SSoby Mathew #define GICR_ICACTIVER0 (GICR_SGIBASE_OFFSET + 0x380) 97df373737SAchin Gupta #define GICR_IPRIORITYR (GICR_SGIBASE_OFFSET + 0x400) 98df373737SAchin Gupta #define GICR_ICFGR0 (GICR_SGIBASE_OFFSET + 0xc00) 99df373737SAchin Gupta #define GICR_ICFGR1 (GICR_SGIBASE_OFFSET + 0xc04) 100df373737SAchin Gupta #define GICR_IGRPMODR0 (GICR_SGIBASE_OFFSET + 0xd00) 101ebf1ca10SSoby Mathew #define GICR_NSACR (GICR_SGIBASE_OFFSET + 0xe00) 102df373737SAchin Gupta 103df373737SAchin Gupta /* GICR_CTLR bit definitions */ 104ebf1ca10SSoby Mathew #define GICR_CTLR_UWP_SHIFT 31 105ebf1ca10SSoby Mathew #define GICR_CTLR_UWP_MASK 0x1 106ebf1ca10SSoby Mathew #define GICR_CTLR_UWP_BIT (1U << GICR_CTLR_UWP_SHIFT) 107df373737SAchin Gupta #define GICR_CTLR_RWP_SHIFT 3 108df373737SAchin Gupta #define GICR_CTLR_RWP_MASK 0x1 109ebf1ca10SSoby Mathew #define GICR_CTLR_RWP_BIT (1U << GICR_CTLR_RWP_SHIFT) 110ebf1ca10SSoby Mathew #define GICR_CTLR_EN_LPIS_BIT (1U << 0) 111df373737SAchin Gupta 112df373737SAchin Gupta /* GICR_WAKER bit definitions */ 113df373737SAchin Gupta #define WAKER_CA_SHIFT 2 114df373737SAchin Gupta #define WAKER_PS_SHIFT 1 115df373737SAchin Gupta 116df373737SAchin Gupta #define WAKER_CA_MASK 0x1 117df373737SAchin Gupta #define WAKER_PS_MASK 0x1 118df373737SAchin Gupta 119df373737SAchin Gupta #define WAKER_CA_BIT (1 << WAKER_CA_SHIFT) 120df373737SAchin Gupta #define WAKER_PS_BIT (1 << WAKER_PS_SHIFT) 121df373737SAchin Gupta 122df373737SAchin Gupta /* GICR_TYPER bit definitions */ 123df373737SAchin Gupta #define TYPER_AFF_VAL_SHIFT 32 124df373737SAchin Gupta #define TYPER_PROC_NUM_SHIFT 8 125df373737SAchin Gupta #define TYPER_LAST_SHIFT 4 126df373737SAchin Gupta 127df373737SAchin Gupta #define TYPER_AFF_VAL_MASK 0xffffffff 128df373737SAchin Gupta #define TYPER_PROC_NUM_MASK 0xffff 129df373737SAchin Gupta #define TYPER_LAST_MASK 0x1 130df373737SAchin Gupta 131df373737SAchin Gupta #define TYPER_LAST_BIT (1 << TYPER_LAST_SHIFT) 132df373737SAchin Gupta 133ebf1ca10SSoby Mathew #define NUM_OF_REDIST_REGS 30 134ebf1ca10SSoby Mathew 135df373737SAchin Gupta /******************************************************************************* 136df373737SAchin Gupta * GICv3 CPU interface registers & constants 137df373737SAchin Gupta ******************************************************************************/ 138df373737SAchin Gupta /* ICC_SRE bit definitions*/ 139df373737SAchin Gupta #define ICC_SRE_EN_BIT (1 << 3) 140df373737SAchin Gupta #define ICC_SRE_DIB_BIT (1 << 2) 141df373737SAchin Gupta #define ICC_SRE_DFB_BIT (1 << 1) 142df373737SAchin Gupta #define ICC_SRE_SRE_BIT (1 << 0) 143df373737SAchin Gupta 144df373737SAchin Gupta /* ICC_IGRPEN1_EL3 bit definitions */ 145df373737SAchin Gupta #define IGRPEN1_EL3_ENABLE_G1NS_SHIFT 0 146df373737SAchin Gupta #define IGRPEN1_EL3_ENABLE_G1S_SHIFT 1 147df373737SAchin Gupta 148df373737SAchin Gupta #define IGRPEN1_EL3_ENABLE_G1NS_BIT (1 << IGRPEN1_EL3_ENABLE_G1NS_SHIFT) 149df373737SAchin Gupta #define IGRPEN1_EL3_ENABLE_G1S_BIT (1 << IGRPEN1_EL3_ENABLE_G1S_SHIFT) 150df373737SAchin Gupta 151df373737SAchin Gupta /* ICC_IGRPEN0_EL1 bit definitions */ 152df373737SAchin Gupta #define IGRPEN1_EL1_ENABLE_G0_SHIFT 0 153df373737SAchin Gupta #define IGRPEN1_EL1_ENABLE_G0_BIT (1 << IGRPEN1_EL1_ENABLE_G0_SHIFT) 154df373737SAchin Gupta 155df373737SAchin Gupta /* ICC_HPPIR0_EL1 bit definitions */ 156df373737SAchin Gupta #define HPPIR0_EL1_INTID_SHIFT 0 157df373737SAchin Gupta #define HPPIR0_EL1_INTID_MASK 0xffffff 158df373737SAchin Gupta 159df373737SAchin Gupta /* ICC_HPPIR1_EL1 bit definitions */ 160df373737SAchin Gupta #define HPPIR1_EL1_INTID_SHIFT 0 161df373737SAchin Gupta #define HPPIR1_EL1_INTID_MASK 0xffffff 162df373737SAchin Gupta 163df373737SAchin Gupta /* ICC_IAR0_EL1 bit definitions */ 164df373737SAchin Gupta #define IAR0_EL1_INTID_SHIFT 0 165df373737SAchin Gupta #define IAR0_EL1_INTID_MASK 0xffffff 166df373737SAchin Gupta 167df373737SAchin Gupta /* ICC_IAR1_EL1 bit definitions */ 168df373737SAchin Gupta #define IAR1_EL1_INTID_SHIFT 0 169df373737SAchin Gupta #define IAR1_EL1_INTID_MASK 0xffffff 170df373737SAchin Gupta 171*8db978b5SJeenu Viswambharan /* ICC SGI macros */ 172*8db978b5SJeenu Viswambharan #define SGIR_TGT_MASK 0xffff 173*8db978b5SJeenu Viswambharan #define SGIR_AFF1_SHIFT 16 174*8db978b5SJeenu Viswambharan #define SGIR_INTID_SHIFT 24 175*8db978b5SJeenu Viswambharan #define SGIR_INTID_MASK 0xf 176*8db978b5SJeenu Viswambharan #define SGIR_AFF2_SHIFT 32 177*8db978b5SJeenu Viswambharan #define SGIR_IRM_SHIFT 40 178*8db978b5SJeenu Viswambharan #define SGIR_IRM_MASK 0x1 179*8db978b5SJeenu Viswambharan #define SGIR_AFF3_SHIFT 48 180*8db978b5SJeenu Viswambharan #define SGIR_AFF_MASK 0xf 181*8db978b5SJeenu Viswambharan 182*8db978b5SJeenu Viswambharan #define SGIR_IRM_TO_AFF 0 183*8db978b5SJeenu Viswambharan 184*8db978b5SJeenu Viswambharan #define GICV3_SGIR_VALUE(aff3, aff2, aff1, intid, irm, tgt) \ 185*8db978b5SJeenu Viswambharan ((((uint64_t) (aff3) & SGIR_AFF_MASK) << SGIR_AFF3_SHIFT) | \ 186*8db978b5SJeenu Viswambharan (((uint64_t) (irm) & SGIR_IRM_MASK) << SGIR_IRM_SHIFT) | \ 187*8db978b5SJeenu Viswambharan (((uint64_t) (aff2) & SGIR_AFF_MASK) << SGIR_AFF2_SHIFT) | \ 188*8db978b5SJeenu Viswambharan (((intid) & SGIR_INTID_MASK) << SGIR_INTID_SHIFT) | \ 189*8db978b5SJeenu Viswambharan (((aff1) & SGIR_AFF_MASK) << SGIR_AFF1_SHIFT) | \ 190*8db978b5SJeenu Viswambharan ((tgt) & SGIR_TGT_MASK)) 191*8db978b5SJeenu Viswambharan 192b258278eSSoby Mathew /***************************************************************************** 193b258278eSSoby Mathew * GICv3 ITS registers and constants 194b258278eSSoby Mathew *****************************************************************************/ 195b258278eSSoby Mathew 196b258278eSSoby Mathew #define GITS_CTLR 0x0 197b258278eSSoby Mathew #define GITS_IIDR 0x4 198b258278eSSoby Mathew #define GITS_TYPER 0x8 199b258278eSSoby Mathew #define GITS_CBASER 0x80 200b258278eSSoby Mathew #define GITS_CWRITER 0x88 201b258278eSSoby Mathew #define GITS_CREADR 0x90 202b258278eSSoby Mathew #define GITS_BASER 0x100 203b258278eSSoby Mathew 204b258278eSSoby Mathew /* GITS_CTLR bit definitions */ 205b258278eSSoby Mathew #define GITS_CTLR_ENABLED_BIT 1 206b258278eSSoby Mathew #define GITS_CTLR_QUIESCENT_SHIFT 31 207b258278eSSoby Mathew #define GITS_CTLR_QUIESCENT_BIT (1U << GITS_CTLR_QUIESCENT_SHIFT) 208b258278eSSoby Mathew 209df373737SAchin Gupta #ifndef __ASSEMBLY__ 210df373737SAchin Gupta 211ebf1ca10SSoby Mathew #include <gic_common.h> 212df373737SAchin Gupta #include <stdint.h> 2134c0d0390SSoby Mathew #include <types.h> 214ebf1ca10SSoby Mathew #include <utils_def.h> 215df373737SAchin Gupta 216df373737SAchin Gupta #define gicv3_is_intr_id_special_identifier(id) \ 217df373737SAchin Gupta (((id) >= PENDING_G1S_INTID) && ((id) <= GIC_SPURIOUS_INTERRUPT)) 218df373737SAchin Gupta 219df373737SAchin Gupta /******************************************************************************* 220df373737SAchin Gupta * Helper GICv3 macros for SEL1 221df373737SAchin Gupta ******************************************************************************/ 222df373737SAchin Gupta #define gicv3_acknowledge_interrupt_sel1() read_icc_iar1_el1() &\ 223df373737SAchin Gupta IAR1_EL1_INTID_MASK 224df373737SAchin Gupta #define gicv3_get_pending_interrupt_id_sel1() read_icc_hppir1_el1() &\ 225df373737SAchin Gupta HPPIR1_EL1_INTID_MASK 226df373737SAchin Gupta #define gicv3_end_of_interrupt_sel1(id) write_icc_eoir1_el1(id) 227df373737SAchin Gupta 228df373737SAchin Gupta 229df373737SAchin Gupta /******************************************************************************* 230df373737SAchin Gupta * Helper GICv3 macros for EL3 231df373737SAchin Gupta ******************************************************************************/ 232df373737SAchin Gupta #define gicv3_acknowledge_interrupt() read_icc_iar0_el1() &\ 233df373737SAchin Gupta IAR0_EL1_INTID_MASK 234df373737SAchin Gupta #define gicv3_end_of_interrupt(id) write_icc_eoir0_el1(id) 235df373737SAchin Gupta 236ebf1ca10SSoby Mathew /* 237ebf1ca10SSoby Mathew * This macro returns the total number of GICD registers corresponding to 238ebf1ca10SSoby Mathew * the name. 239ebf1ca10SSoby Mathew */ 240ebf1ca10SSoby Mathew #define GICD_NUM_REGS(reg_name) \ 241ebf1ca10SSoby Mathew DIV_ROUND_UP_2EVAL(TOTAL_SPI_INTR_NUM, (1 << reg_name ## _SHIFT)) 242ebf1ca10SSoby Mathew 243ebf1ca10SSoby Mathew #define GICR_NUM_REGS(reg_name) \ 244ebf1ca10SSoby Mathew DIV_ROUND_UP_2EVAL(TOTAL_PCPU_INTR_NUM, (1 << reg_name ## _SHIFT)) 245ebf1ca10SSoby Mathew 246df373737SAchin Gupta /******************************************************************************* 247df373737SAchin Gupta * This structure describes some of the implementation defined attributes of the 248df373737SAchin Gupta * GICv3 IP. It is used by the platform port to specify these attributes in order 249df373737SAchin Gupta * to initialise the GICV3 driver. The attributes are described below. 250df373737SAchin Gupta * 251df373737SAchin Gupta * 1. The 'gicd_base' field contains the base address of the Distributor 252df373737SAchin Gupta * interface programmer's view. 253df373737SAchin Gupta * 254df373737SAchin Gupta * 2. The 'gicr_base' field contains the base address of the Re-distributor 255df373737SAchin Gupta * interface programmer's view. 256df373737SAchin Gupta * 257df373737SAchin Gupta * 3. The 'g0_interrupt_array' field is a ponter to an array in which each 258df373737SAchin Gupta * entry corresponds to an ID of a Group 0 interrupt. 259df373737SAchin Gupta * 260df373737SAchin Gupta * 4. The 'g0_interrupt_num' field contains the number of entries in the 261df373737SAchin Gupta * 'g0_interrupt_array'. 262df373737SAchin Gupta * 263df373737SAchin Gupta * 5. The 'g1s_interrupt_array' field is a ponter to an array in which each 264df373737SAchin Gupta * entry corresponds to an ID of a Group 1 interrupt. 265df373737SAchin Gupta * 266df373737SAchin Gupta * 6. The 'g1s_interrupt_num' field contains the number of entries in the 267df373737SAchin Gupta * 'g1s_interrupt_array'. 268df373737SAchin Gupta * 269df373737SAchin Gupta * 7. The 'rdistif_num' field contains the number of Redistributor interfaces 270df373737SAchin Gupta * the GIC implements. This is equal to the number of CPUs or CPU interfaces 271df373737SAchin Gupta * instantiated in the GIC. 272df373737SAchin Gupta * 273df373737SAchin Gupta * 8. The 'rdistif_base_addrs' field is a pointer to an array that has an entry 274df373737SAchin Gupta * for storing the base address of the Redistributor interface frame of each 275df373737SAchin Gupta * CPU in the system. The size of the array = 'rdistif_num'. The base 276df373737SAchin Gupta * addresses are detected during driver initialisation. 277df373737SAchin Gupta * 278df373737SAchin Gupta * 9. The 'mpidr_to_core_pos' field is a pointer to a hash function which the 279df373737SAchin Gupta * driver will use to convert an MPIDR value to a linear core index. This 280df373737SAchin Gupta * index will be used for accessing the 'rdistif_base_addrs' array. This is 281df373737SAchin Gupta * an optional field. A GICv3 implementation maps each MPIDR to a linear core 282df373737SAchin Gupta * index as well. This mapping can be found by reading the "Affinity Value" 283df373737SAchin Gupta * and "Processor Number" fields in the GICR_TYPER. It is IMP. DEF. if the 284df373737SAchin Gupta * "Processor Numbers" are suitable to index into an array to access core 285df373737SAchin Gupta * specific information. If this not the case, the platform port must provide 286df373737SAchin Gupta * a hash function. Otherwise, the "Processor Number" field will be used to 287df373737SAchin Gupta * access the array elements. 288df373737SAchin Gupta ******************************************************************************/ 2894c0d0390SSoby Mathew typedef unsigned int (*mpidr_hash_fn)(u_register_t mpidr); 290df373737SAchin Gupta 291df373737SAchin Gupta typedef struct gicv3_driver_data { 292df373737SAchin Gupta uintptr_t gicd_base; 293df373737SAchin Gupta uintptr_t gicr_base; 294df373737SAchin Gupta unsigned int g0_interrupt_num; 295df373737SAchin Gupta unsigned int g1s_interrupt_num; 296df373737SAchin Gupta const unsigned int *g0_interrupt_array; 297df373737SAchin Gupta const unsigned int *g1s_interrupt_array; 298df373737SAchin Gupta unsigned int rdistif_num; 299df373737SAchin Gupta uintptr_t *rdistif_base_addrs; 300df373737SAchin Gupta mpidr_hash_fn mpidr_to_core_pos; 301df373737SAchin Gupta } gicv3_driver_data_t; 302df373737SAchin Gupta 303ebf1ca10SSoby Mathew typedef struct gicv3_redist_ctx { 304ebf1ca10SSoby Mathew /* 64 bits registers */ 305ebf1ca10SSoby Mathew uint64_t gicr_propbaser; 306ebf1ca10SSoby Mathew uint64_t gicr_pendbaser; 307ebf1ca10SSoby Mathew 308ebf1ca10SSoby Mathew /* 32 bits registers */ 309ebf1ca10SSoby Mathew uint32_t gicr_ctlr; 310ebf1ca10SSoby Mathew uint32_t gicr_igroupr0; 311ebf1ca10SSoby Mathew uint32_t gicr_isenabler0; 312ebf1ca10SSoby Mathew uint32_t gicr_ispendr0; 313ebf1ca10SSoby Mathew uint32_t gicr_isactiver0; 314ebf1ca10SSoby Mathew uint32_t gicr_ipriorityr[GICR_NUM_REGS(IPRIORITYR)]; 315ebf1ca10SSoby Mathew uint32_t gicr_icfgr0; 316ebf1ca10SSoby Mathew uint32_t gicr_icfgr1; 317ebf1ca10SSoby Mathew uint32_t gicr_igrpmodr0; 318ebf1ca10SSoby Mathew uint32_t gicr_nsacr; 319ebf1ca10SSoby Mathew } gicv3_redist_ctx_t; 320ebf1ca10SSoby Mathew 321ebf1ca10SSoby Mathew typedef struct gicv3_dist_ctx { 322ebf1ca10SSoby Mathew /* 64 bits registers */ 323ebf1ca10SSoby Mathew uint64_t gicd_irouter[TOTAL_SPI_INTR_NUM]; 324ebf1ca10SSoby Mathew 325ebf1ca10SSoby Mathew /* 32 bits registers */ 326ebf1ca10SSoby Mathew uint32_t gicd_ctlr; 327ebf1ca10SSoby Mathew uint32_t gicd_igroupr[GICD_NUM_REGS(IGROUPR)]; 328ebf1ca10SSoby Mathew uint32_t gicd_isenabler[GICD_NUM_REGS(ISENABLER)]; 329ebf1ca10SSoby Mathew uint32_t gicd_ispendr[GICD_NUM_REGS(ISPENDR)]; 330ebf1ca10SSoby Mathew uint32_t gicd_isactiver[GICD_NUM_REGS(ISACTIVER)]; 331ebf1ca10SSoby Mathew uint32_t gicd_ipriorityr[GICD_NUM_REGS(IPRIORITYR)]; 332ebf1ca10SSoby Mathew uint32_t gicd_icfgr[GICD_NUM_REGS(ICFGR)]; 333ebf1ca10SSoby Mathew uint32_t gicd_igrpmodr[GICD_NUM_REGS(IGRPMODR)]; 334ebf1ca10SSoby Mathew uint32_t gicd_nsacr[GICD_NUM_REGS(NSACR)]; 335ebf1ca10SSoby Mathew } gicv3_dist_ctx_t; 336ebf1ca10SSoby Mathew 337b258278eSSoby Mathew typedef struct gicv3_its_ctx { 338b258278eSSoby Mathew /* 64 bits registers */ 339b258278eSSoby Mathew uint64_t gits_cbaser; 340b258278eSSoby Mathew uint64_t gits_cwriter; 341b258278eSSoby Mathew uint64_t gits_baser[8]; 342b258278eSSoby Mathew 343b258278eSSoby Mathew /* 32 bits registers */ 344b258278eSSoby Mathew uint32_t gits_ctlr; 345b258278eSSoby Mathew } gicv3_its_ctx_t; 346b258278eSSoby Mathew 347df373737SAchin Gupta /******************************************************************************* 348df373737SAchin Gupta * GICv3 EL3 driver API 349df373737SAchin Gupta ******************************************************************************/ 350df373737SAchin Gupta void gicv3_driver_init(const gicv3_driver_data_t *plat_driver_data); 351df373737SAchin Gupta void gicv3_distif_init(void); 352df373737SAchin Gupta void gicv3_rdistif_init(unsigned int proc_num); 353d780699bSJeenu Viswambharan void gicv3_rdistif_on(unsigned int proc_num); 354d780699bSJeenu Viswambharan void gicv3_rdistif_off(unsigned int proc_num); 355df373737SAchin Gupta void gicv3_cpuif_enable(unsigned int proc_num); 356df373737SAchin Gupta void gicv3_cpuif_disable(unsigned int proc_num); 357df373737SAchin Gupta unsigned int gicv3_get_pending_interrupt_type(void); 358df373737SAchin Gupta unsigned int gicv3_get_pending_interrupt_id(void); 359df373737SAchin Gupta unsigned int gicv3_get_interrupt_type(unsigned int id, 360df373737SAchin Gupta unsigned int proc_num); 361ebf1ca10SSoby Mathew void gicv3_distif_init_restore(const gicv3_dist_ctx_t * const dist_ctx); 362ebf1ca10SSoby Mathew void gicv3_distif_save(gicv3_dist_ctx_t * const dist_ctx); 363ebf1ca10SSoby Mathew /* 364ebf1ca10SSoby Mathew * gicv3_distif_post_restore and gicv3_distif_pre_save must be implemented if 365ebf1ca10SSoby Mathew * gicv3_distif_save and gicv3_rdistif_init_restore are used. If no 366ebf1ca10SSoby Mathew * implementation-defined sequence is needed at these steps, an empty function 367ebf1ca10SSoby Mathew * can be provided. 368ebf1ca10SSoby Mathew */ 369ebf1ca10SSoby Mathew void gicv3_distif_post_restore(unsigned int proc_num); 370ebf1ca10SSoby Mathew void gicv3_distif_pre_save(unsigned int proc_num); 371ebf1ca10SSoby Mathew void gicv3_rdistif_init_restore(unsigned int proc_num, const gicv3_redist_ctx_t * const rdist_ctx); 372ebf1ca10SSoby Mathew void gicv3_rdistif_save(unsigned int proc_num, gicv3_redist_ctx_t * const rdist_ctx); 373b258278eSSoby Mathew void gicv3_its_save_disable(uintptr_t gits_base, gicv3_its_ctx_t * const its_ctx); 374b258278eSSoby Mathew void gicv3_its_restore(uintptr_t gits_base, const gicv3_its_ctx_t * const its_ctx); 375df373737SAchin Gupta 376eb68ea9bSJeenu Viswambharan unsigned int gicv3_get_running_priority(void); 377cbd3f370SJeenu Viswambharan unsigned int gicv3_get_interrupt_active(unsigned int id, unsigned int proc_num); 378979225f4SJeenu Viswambharan void gicv3_enable_interrupt(unsigned int id, unsigned int proc_num); 379979225f4SJeenu Viswambharan void gicv3_disable_interrupt(unsigned int id, unsigned int proc_num); 380f3a86600SJeenu Viswambharan void gicv3_set_interrupt_priority(unsigned int id, unsigned int proc_num, 381f3a86600SJeenu Viswambharan unsigned int priority); 38274dce7faSJeenu Viswambharan void gicv3_set_interrupt_type(unsigned int id, unsigned int proc_num, 38374dce7faSJeenu Viswambharan unsigned int group); 384*8db978b5SJeenu Viswambharan void gicv3_raise_secure_g0_sgi(int sgi_num, u_register_t target); 385eb68ea9bSJeenu Viswambharan 386df373737SAchin Gupta #endif /* __ASSEMBLY__ */ 387df373737SAchin Gupta #endif /* __GICV3_H__ */ 388