xref: /optee_os/core/include/drivers/gic.h (revision 1bb929836182ecb96d2d9d268daa807c67596396)
1*1bb92983SJerome 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  * All rights reserved.
6b0104773SPascal Brand  *
7b0104773SPascal Brand  * Redistribution and use in source and binary forms, with or without
8b0104773SPascal Brand  * modification, are permitted provided that the following conditions are met:
9b0104773SPascal Brand  *
10b0104773SPascal Brand  * 1. Redistributions of source code must retain the above copyright notice,
11b0104773SPascal Brand  * this list of conditions and the following disclaimer.
12b0104773SPascal Brand  *
13b0104773SPascal Brand  * 2. Redistributions in binary form must reproduce the above copyright notice,
14b0104773SPascal Brand  * this list of conditions and the following disclaimer in the documentation
15b0104773SPascal Brand  * and/or other materials provided with the distribution.
16b0104773SPascal Brand  *
17b0104773SPascal Brand  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18b0104773SPascal Brand  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19b0104773SPascal Brand  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20b0104773SPascal Brand  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21b0104773SPascal Brand  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22b0104773SPascal Brand  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23b0104773SPascal Brand  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24b0104773SPascal Brand  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25b0104773SPascal Brand  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26b0104773SPascal Brand  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27b0104773SPascal Brand  * POSSIBILITY OF SUCH DAMAGE.
28b0104773SPascal Brand  */
29b0104773SPascal Brand 
307315b7b4SJens Wiklander #ifndef __DRIVERS_GIC_H
317315b7b4SJens Wiklander #define __DRIVERS_GIC_H
32ec219598SPascal Brand #include <types_ext.h>
337315b7b4SJens Wiklander #include <kernel/interrupt.h>
34b0104773SPascal Brand 
352729a4d6SJens Wiklander #define GIC_DIST_REG_SIZE	0x10000
362729a4d6SJens Wiklander #define GIC_CPU_REG_SIZE	0x10000
372729a4d6SJens Wiklander 
387315b7b4SJens Wiklander struct gic_data {
397315b7b4SJens Wiklander 	vaddr_t gicc_base;
407315b7b4SJens Wiklander 	vaddr_t gicd_base;
417315b7b4SJens Wiklander 	size_t max_it;
427315b7b4SJens Wiklander 	struct itr_chip chip;
437315b7b4SJens Wiklander };
447315b7b4SJens Wiklander 
457315b7b4SJens Wiklander /*
467315b7b4SJens Wiklander  * The two gic_init_* functions initializes the struct gic_data which is
477315b7b4SJens Wiklander  * then used by the other functions.
487315b7b4SJens Wiklander  */
497315b7b4SJens Wiklander 
50e0c081a3SJens Wiklander void gic_init(struct gic_data *gd, vaddr_t gicc_base, vaddr_t gicd_base);
5153bd332aSSY Chiu /* initial base address only */
527315b7b4SJens Wiklander void gic_init_base_addr(struct gic_data *gd, vaddr_t gicc_base,
537315b7b4SJens Wiklander 			vaddr_t gicd_base);
54bedc2b9fSsunny /* initial cpu if only, mainly use for secondary cpu setup cpu interface */
557315b7b4SJens Wiklander void gic_cpu_init(struct gic_data *gd);
56b0104773SPascal Brand 
577315b7b4SJens Wiklander void gic_it_handle(struct gic_data *gd);
58b0104773SPascal Brand 
597315b7b4SJens Wiklander void gic_dump_state(struct gic_data *gd);
607315b7b4SJens Wiklander #endif /*__DRIVERS_GIC_H*/
61