xref: /rk3399_ARM-atf/plat/rockchip/common/rockchip_gicv2.c (revision 82cb2c1ad9897473743f08437d0a3995bed561b9)
16fba6e04STony Xie /*
26fba6e04STony Xie  * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
36fba6e04STony Xie  *
4*82cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
56fba6e04STony Xie  */
66fba6e04STony Xie 
76fba6e04STony Xie #include <bl_common.h>
86fba6e04STony Xie #include <gicv2.h>
96fba6e04STony Xie #include <platform_def.h>
10ed81f3ebSSandrine Bailleux #include <utils.h>
116fba6e04STony Xie 
126fba6e04STony Xie /******************************************************************************
136fba6e04STony Xie  * The following functions are defined as weak to allow a platform to override
146fba6e04STony Xie  * the way the GICv2 driver is initialised and used.
156fba6e04STony Xie  *****************************************************************************/
166fba6e04STony Xie #pragma weak plat_rockchip_gic_driver_init
176fba6e04STony Xie #pragma weak plat_rockchip_gic_init
186fba6e04STony Xie #pragma weak plat_rockchip_gic_cpuif_enable
196fba6e04STony Xie #pragma weak plat_rockchip_gic_cpuif_disable
206fba6e04STony Xie #pragma weak plat_rockchip_gic_pcpu_init
216fba6e04STony Xie 
226fba6e04STony Xie /******************************************************************************
236fba6e04STony Xie  * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
246fba6e04STony Xie  * interrupts.
256fba6e04STony Xie  *****************************************************************************/
266fba6e04STony Xie const unsigned int g0_interrupt_array[] = {
276fba6e04STony Xie 	PLAT_RK_G1S_IRQS,
286fba6e04STony Xie };
296fba6e04STony Xie 
306fba6e04STony Xie /*
316fba6e04STony Xie  * Ideally `rockchip_gic_data` structure definition should be a `const` but it
326fba6e04STony Xie  * is kept as modifiable for overwriting with different GICD and GICC base when
336fba6e04STony Xie  * running on FVP with VE memory map.
346fba6e04STony Xie  */
356fba6e04STony Xie gicv2_driver_data_t rockchip_gic_data = {
366fba6e04STony Xie 	.gicd_base = PLAT_RK_GICD_BASE,
376fba6e04STony Xie 	.gicc_base = PLAT_RK_GICC_BASE,
386fba6e04STony Xie 	.g0_interrupt_num = ARRAY_SIZE(g0_interrupt_array),
396fba6e04STony Xie 	.g0_interrupt_array = g0_interrupt_array,
406fba6e04STony Xie };
416fba6e04STony Xie 
426fba6e04STony Xie /******************************************************************************
436fba6e04STony Xie  * RockChip common helper to initialize the GICv2 only driver.
446fba6e04STony Xie  *****************************************************************************/
456fba6e04STony Xie void plat_rockchip_gic_driver_init(void)
466fba6e04STony Xie {
476fba6e04STony Xie 	gicv2_driver_init(&rockchip_gic_data);
486fba6e04STony Xie }
496fba6e04STony Xie 
506fba6e04STony Xie void plat_rockchip_gic_init(void)
516fba6e04STony Xie {
526fba6e04STony Xie 	gicv2_distif_init();
536fba6e04STony Xie 	gicv2_pcpu_distif_init();
546fba6e04STony Xie 	gicv2_cpuif_enable();
556fba6e04STony Xie }
566fba6e04STony Xie 
576fba6e04STony Xie /******************************************************************************
586fba6e04STony Xie  * RockChip common helper to enable the GICv2 CPU interface
596fba6e04STony Xie  *****************************************************************************/
606fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void)
616fba6e04STony Xie {
626fba6e04STony Xie 	gicv2_cpuif_enable();
636fba6e04STony Xie }
646fba6e04STony Xie 
656fba6e04STony Xie /******************************************************************************
666fba6e04STony Xie  * RockChip common helper to disable the GICv2 CPU interface
676fba6e04STony Xie  *****************************************************************************/
686fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void)
696fba6e04STony Xie {
706fba6e04STony Xie 	gicv2_cpuif_disable();
716fba6e04STony Xie }
726fba6e04STony Xie 
736fba6e04STony Xie /******************************************************************************
746fba6e04STony Xie  * RockChip common helper to initialize the per cpu distributor interface
756fba6e04STony Xie  * in GICv2
766fba6e04STony Xie  *****************************************************************************/
776fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void)
786fba6e04STony Xie {
796fba6e04STony Xie 	gicv2_pcpu_distif_init();
806fba6e04STony Xie }
81