xref: /optee_os/core/include/drivers/gic.h (revision 5da157f55e4ae09227454c134be945bc73929dbc)
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*5da157f5SJens Wiklander  * The two gic_init() and gic_init_v3() functions initializes the struct
29*5da157f5SJens Wiklander  * gic_data which is then used by the other functions. These two functions
30*5da157f5SJens Wiklander  * also initializes the GIC and are only supposed to be called from the
31*5da157f5SJens Wiklander  * primary boot CPU.
327315b7b4SJens Wiklander  */
3305089e5fSJens Wiklander void gic_init_v3(paddr_t gicc_base_pa, paddr_t gicd_base_pa,
3405089e5fSJens Wiklander 		 paddr_t gicr_base_pa);
3505089e5fSJens Wiklander static inline void gic_init(paddr_t gicc_base_pa, paddr_t gicd_base_pa)
3605089e5fSJens Wiklander {
3705089e5fSJens Wiklander 	gic_init_v3(gicc_base_pa, gicd_base_pa, 0);
3805089e5fSJens Wiklander }
39b0104773SPascal Brand 
40*5da157f5SJens Wiklander /*
41*5da157f5SJens Wiklander  * Does per-CPU specific GIC initialization, should be called by all
42*5da157f5SJens Wiklander  * secondary CPUs when booting.
43*5da157f5SJens Wiklander  */
44*5da157f5SJens Wiklander void gic_init_per_cpu(void);
45*5da157f5SJens Wiklander 
46*5da157f5SJens Wiklander /*
47*5da157f5SJens Wiklander  * Only initialize CPU GIC interface, mainly use for secondary CPUs in
48*5da157f5SJens Wiklander  * non-TF-A configurations.
49*5da157f5SJens Wiklander  *
50*5da157f5SJens Wiklander  * This function is deprecated, please use gic_init_per_cpu() instead.
51*5da157f5SJens Wiklander  */
5267e55c51SEtienne Carriere void gic_cpu_init(void);
5367e55c51SEtienne Carriere 
5467e55c51SEtienne Carriere /* Print GIC state to console */
5567e55c51SEtienne Carriere void gic_dump_state(void);
567315b7b4SJens Wiklander #endif /*__DRIVERS_GIC_H*/
57