blob: 80a845fa12b2c6f7d95a03c6c13b37b9da65001a [file] [log] [blame]
Achin Gupta1fa7eb62015-11-03 14:18:34 +00001/*
Jeenu Viswambharaneeb43be2017-09-22 08:32:09 +01002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Achin Gupta1fa7eb62015-11-03 14:18:34 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta1fa7eb62015-11-03 14:18:34 +00005 */
6
Achin Gupta1fa7eb62015-11-03 14:18:34 +00007#include <platform_def.h>
8
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <drivers/arm/gicv2.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000010#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <plat/common/platform.h>
12
Achin Gupta1fa7eb62015-11-03 14:18:34 +000013/******************************************************************************
14 * The following functions are defined as weak to allow a platform to override
15 * the way the GICv2 driver is initialised and used.
16 *****************************************************************************/
17#pragma weak plat_arm_gic_driver_init
18#pragma weak plat_arm_gic_init
19#pragma weak plat_arm_gic_cpuif_enable
20#pragma weak plat_arm_gic_cpuif_disable
21#pragma weak plat_arm_gic_pcpu_init
22
23/******************************************************************************
24 * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
25 * interrupts.
26 *****************************************************************************/
Jeenu Viswambharan723dce02017-09-22 08:59:59 +010027static const interrupt_prop_t arm_interrupt_props[] = {
28 PLAT_ARM_G1S_IRQ_PROPS(GICV2_INTR_GROUP0),
29 PLAT_ARM_G0_IRQ_PROPS(GICV2_INTR_GROUP0)
Achin Gupta1fa7eb62015-11-03 14:18:34 +000030};
31
Jeenu Viswambharaneeb43be2017-09-22 08:32:09 +010032static unsigned int target_mask_array[PLATFORM_CORE_COUNT];
33
Soby Mathewcf022c52016-01-13 17:06:00 +000034static const gicv2_driver_data_t arm_gic_data = {
Achin Gupta1fa7eb62015-11-03 14:18:34 +000035 .gicd_base = PLAT_ARM_GICD_BASE,
36 .gicc_base = PLAT_ARM_GICC_BASE,
Jeenu Viswambharan723dce02017-09-22 08:59:59 +010037 .interrupt_props = arm_interrupt_props,
38 .interrupt_props_num = ARRAY_SIZE(arm_interrupt_props),
Jeenu Viswambharaneeb43be2017-09-22 08:32:09 +010039 .target_masks = target_mask_array,
40 .target_masks_num = ARRAY_SIZE(target_mask_array),
Achin Gupta1fa7eb62015-11-03 14:18:34 +000041};
42
43/******************************************************************************
44 * ARM common helper to initialize the GICv2 only driver.
45 *****************************************************************************/
46void plat_arm_gic_driver_init(void)
47{
48 gicv2_driver_init(&arm_gic_data);
49}
50
51void plat_arm_gic_init(void)
52{
53 gicv2_distif_init();
54 gicv2_pcpu_distif_init();
Jeenu Viswambharanfbf5bda2017-11-07 16:10:19 +000055 gicv2_set_pe_target_mask(plat_my_core_pos());
Achin Gupta1fa7eb62015-11-03 14:18:34 +000056 gicv2_cpuif_enable();
57}
58
59/******************************************************************************
60 * ARM common helper to enable the GICv2 CPU interface
61 *****************************************************************************/
62void plat_arm_gic_cpuif_enable(void)
63{
64 gicv2_cpuif_enable();
65}
66
67/******************************************************************************
68 * ARM common helper to disable the GICv2 CPU interface
69 *****************************************************************************/
70void plat_arm_gic_cpuif_disable(void)
71{
72 gicv2_cpuif_disable();
73}
74
75/******************************************************************************
76 * ARM common helper to initialize the per cpu distributor interface in GICv2
77 *****************************************************************************/
78void plat_arm_gic_pcpu_init(void)
79{
80 gicv2_pcpu_distif_init();
Jeenu Viswambharaneeb43be2017-09-22 08:32:09 +010081 gicv2_set_pe_target_mask(plat_my_core_pos());
Achin Gupta1fa7eb62015-11-03 14:18:34 +000082}
Jeenu Viswambharan78132c92016-12-09 11:12:34 +000083
84/******************************************************************************
85 * Stubs for Redistributor power management. Although GICv2 doesn't have
86 * Redistributor interface, these are provided for the sake of uniform GIC API
87 *****************************************************************************/
88void plat_arm_gic_redistif_on(void)
89{
90 return;
91}
92
93void plat_arm_gic_redistif_off(void)
94{
95 return;
96}
Soby Mathew9ca28062017-10-11 16:08:58 +010097
98
99/******************************************************************************
100 * ARM common helper to save & restore the GICv3 on resume from system suspend.
101 * The normal world currently takes care of saving and restoring the GICv2
102 * registers due to legacy reasons. Hence we just initialize the Distributor
103 * on resume from system suspend.
104 *****************************************************************************/
105void plat_arm_gic_save(void)
106{
107 return;
108}
109
110void plat_arm_gic_resume(void)
111{
112 gicv2_distif_init();
113 gicv2_pcpu_distif_init();
114}