1 /*
2  * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <platform_def.h>
8 
9 #include <drivers/arm/gicv2.h>
10 #include <plat/common/platform.h>
11 
12 /******************************************************************************
13  * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
14  * interrupts.
15  *****************************************************************************/
16 static const interrupt_prop_t poplar_interrupt_props[] = {
17 	POPLAR_G1S_IRQ_PROPS(GICV2_INTR_GROUP0),
18 	POPLAR_G0_IRQ_PROPS(GICV2_INTR_GROUP0)
19 };
20 
21 static unsigned int target_mask_array[PLATFORM_CORE_COUNT];
22 
23 static const gicv2_driver_data_t poplar_gic_data = {
24 	.gicd_base = POPLAR_GICD_BASE,
25 	.gicc_base = POPLAR_GICC_BASE,
26 	.interrupt_props = poplar_interrupt_props,
27 	.interrupt_props_num = ARRAY_SIZE(poplar_interrupt_props),
28 	.target_masks = target_mask_array,
29 	.target_masks_num = ARRAY_SIZE(target_mask_array),
30 };
31 
32 /******************************************************************************
33  * Helper to initialize the GICv2 only driver.
34  *****************************************************************************/
poplar_gic_driver_init(void)35 void poplar_gic_driver_init(void)
36 {
37 	gicv2_driver_init(&poplar_gic_data);
38 }
39 
poplar_gic_init(void)40 void poplar_gic_init(void)
41 {
42 	gicv2_distif_init();
43 	gicv2_pcpu_distif_init();
44 	gicv2_set_pe_target_mask(plat_my_core_pos());
45 	gicv2_cpuif_enable();
46 }
47 
48 /******************************************************************************
49  * Helper to enable the GICv2 CPU interface
50  *****************************************************************************/
poplar_gic_cpuif_enable(void)51 void poplar_gic_cpuif_enable(void)
52 {
53 	gicv2_cpuif_enable();
54 }
55 
56 /******************************************************************************
57  * Helper to initialize the per cpu distributor interface in GICv2
58  *****************************************************************************/
poplar_gic_pcpu_init(void)59 void poplar_gic_pcpu_init(void)
60 {
61 	gicv2_pcpu_distif_init();
62 	gicv2_set_pe_target_mask(plat_my_core_pos());
63 }
64