11bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */ 2b0104773SPascal Brand /* 37315b7b4SJens Wiklander * Copyright (c) 2016, Linaro Limited 4b0104773SPascal Brand * Copyright (c) 2014, STMicroelectronics International N.V. 5b0104773SPascal Brand */ 6b0104773SPascal Brand 77315b7b4SJens Wiklander #ifndef __DRIVERS_GIC_H 87315b7b4SJens Wiklander #define __DRIVERS_GIC_H 9ec219598SPascal Brand #include <types_ext.h> 107315b7b4SJens Wiklander #include <kernel/interrupt.h> 11b0104773SPascal Brand 124e6eecf6SJens Wiklander #if defined(CFG_ARM_GICV3) 132729a4d6SJens Wiklander #define GIC_DIST_REG_SIZE 0x10000 142729a4d6SJens Wiklander #define GIC_CPU_REG_SIZE 0x10000 154e6eecf6SJens Wiklander #else 164e6eecf6SJens Wiklander #define GIC_DIST_REG_SIZE 0x1000 174e6eecf6SJens Wiklander #define GIC_CPU_REG_SIZE 0x1000 184e6eecf6SJens Wiklander #endif 19f13b1003SJens Wiklander 20f13b1003SJens Wiklander #define GIC_PPI_BASE U(16) 21f13b1003SJens Wiklander #define GIC_SPI_BASE U(32) 22f13b1003SJens Wiklander 231428fce8SEtienne Carriere #define GIC_SGI_TO_ITNUM(x) (x) 241428fce8SEtienne Carriere #define GIC_PPI_TO_ITNUM(x) ((x) + GIC_PPI_BASE) 251428fce8SEtienne Carriere #define GIC_SPI_TO_ITNUM(x) ((x) + GIC_SPI_BASE) 262729a4d6SJens Wiklander 277315b7b4SJens Wiklander /* 28*84603456SJens Wiklander * Default lowest ID for secure SGIs, note that this does not account for 29*84603456SJens Wiklander * interrupts donated to non-secure world with gic_init_donate_sgi_to_ns(). 30*84603456SJens Wiklander */ 31*84603456SJens Wiklander #define GIC_SGI_SEC_BASE 8 32*84603456SJens Wiklander /* Max ID for secure SGIs */ 33*84603456SJens Wiklander #define GIC_SGI_SEC_MAX 15 34*84603456SJens Wiklander 35*84603456SJens Wiklander /* 365da157f5SJens Wiklander * The two gic_init() and gic_init_v3() functions initializes the struct 375da157f5SJens Wiklander * gic_data which is then used by the other functions. These two functions 385da157f5SJens Wiklander * also initializes the GIC and are only supposed to be called from the 395da157f5SJens Wiklander * primary boot CPU. 407315b7b4SJens Wiklander */ 4105089e5fSJens Wiklander void gic_init_v3(paddr_t gicc_base_pa, paddr_t gicd_base_pa, 4205089e5fSJens Wiklander paddr_t gicr_base_pa); 4305089e5fSJens Wiklander static inline void gic_init(paddr_t gicc_base_pa, paddr_t gicd_base_pa) 4405089e5fSJens Wiklander { 4505089e5fSJens Wiklander gic_init_v3(gicc_base_pa, gicd_base_pa, 0); 4605089e5fSJens Wiklander } 47b0104773SPascal Brand 48*84603456SJens Wiklander /* Donates one of the secure SGIs to normal world */ 49*84603456SJens Wiklander void gic_init_donate_sgi_to_ns(size_t it); 50*84603456SJens Wiklander 515da157f5SJens Wiklander /* 525da157f5SJens Wiklander * Does per-CPU specific GIC initialization, should be called by all 535da157f5SJens Wiklander * secondary CPUs when booting. 545da157f5SJens Wiklander */ 555da157f5SJens Wiklander void gic_init_per_cpu(void); 565da157f5SJens Wiklander 575da157f5SJens Wiklander /* 585da157f5SJens Wiklander * Only initialize CPU GIC interface, mainly use for secondary CPUs in 595da157f5SJens Wiklander * non-TF-A configurations. 605da157f5SJens Wiklander * 615da157f5SJens Wiklander * This function is deprecated, please use gic_init_per_cpu() instead. 625da157f5SJens Wiklander */ 6367e55c51SEtienne Carriere void gic_cpu_init(void); 6467e55c51SEtienne Carriere 6567e55c51SEtienne Carriere /* Print GIC state to console */ 6667e55c51SEtienne Carriere void gic_dump_state(void); 677315b7b4SJens Wiklander #endif /*__DRIVERS_GIC_H*/ 68