blob: c51c1955f5809bc556e72600f909b6273bfb7c44 [file] [log] [blame]
Achin Gupta27573c52015-11-03 14:18:34 +00001/*
Boyan Karatotev5d893412025-01-07 11:00:03 +00002 * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved.
Achin Gupta27573c52015-11-03 14:18:34 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta27573c52015-11-03 14:18:34 +00005 */
6
Achin Gupta27573c52015-11-03 14:18:34 +00007#include <platform_def.h>
8
Boyan Karatotev5d893412025-01-07 11:00:03 +00009#include <drivers/arm/gic.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000010#include <drivers/arm/gicv2.h>
Antonio Nino Diazbd9344f2019-01-25 14:30:04 +000011#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000012#include <plat/common/platform.h>
13
Boyan Karatotev5d893412025-01-07 11:00:03 +000014#if USE_GIC_DRIVER != 2
Boyan Karatotevdf21ca02025-04-22 10:17:37 +010015#error "This file should only be used with USE_GIC_DRIVER=2"
Boyan Karatotev5d893412025-01-07 11:00:03 +000016#endif
Achin Gupta27573c52015-11-03 14:18:34 +000017
18/******************************************************************************
19 * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
20 * interrupts.
21 *****************************************************************************/
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +010022static const interrupt_prop_t arm_interrupt_props[] = {
23 PLAT_ARM_G1S_IRQ_PROPS(GICV2_INTR_GROUP0),
24 PLAT_ARM_G0_IRQ_PROPS(GICV2_INTR_GROUP0)
Achin Gupta27573c52015-11-03 14:18:34 +000025};
26
Jeenu Viswambharandea417c2017-09-22 08:32:09 +010027static unsigned int target_mask_array[PLATFORM_CORE_COUNT];
28
Soby Mathew21a39732016-01-13 17:06:00 +000029static const gicv2_driver_data_t arm_gic_data = {
Achin Gupta27573c52015-11-03 14:18:34 +000030 .gicd_base = PLAT_ARM_GICD_BASE,
31 .gicc_base = PLAT_ARM_GICC_BASE,
Jeenu Viswambharanb2c363b2017-09-22 08:59:59 +010032 .interrupt_props = arm_interrupt_props,
33 .interrupt_props_num = ARRAY_SIZE(arm_interrupt_props),
Jeenu Viswambharandea417c2017-09-22 08:32:09 +010034 .target_masks = target_mask_array,
35 .target_masks_num = ARRAY_SIZE(target_mask_array),
Achin Gupta27573c52015-11-03 14:18:34 +000036};
37
38/******************************************************************************
39 * ARM common helper to initialize the GICv2 only driver.
40 *****************************************************************************/
Boyan Karatotev5d893412025-01-07 11:00:03 +000041void __init gic_init(unsigned int cpu_idx)
Achin Gupta27573c52015-11-03 14:18:34 +000042{
43 gicv2_driver_init(&arm_gic_data);
Achin Gupta27573c52015-11-03 14:18:34 +000044 gicv2_distif_init();
Achin Gupta27573c52015-11-03 14:18:34 +000045}
46
47/******************************************************************************
48 * ARM common helper to enable the GICv2 CPU interface
49 *****************************************************************************/
Boyan Karatotev5d893412025-01-07 11:00:03 +000050void gic_cpuif_enable(unsigned int cpu_idx)
Achin Gupta27573c52015-11-03 14:18:34 +000051{
52 gicv2_cpuif_enable();
53}
54
55/******************************************************************************
56 * ARM common helper to disable the GICv2 CPU interface
57 *****************************************************************************/
Boyan Karatotev5d893412025-01-07 11:00:03 +000058void gic_cpuif_disable(unsigned int cpu_idx)
Achin Gupta27573c52015-11-03 14:18:34 +000059{
60 gicv2_cpuif_disable();
61}
62
63/******************************************************************************
64 * ARM common helper to initialize the per cpu distributor interface in GICv2
65 *****************************************************************************/
Boyan Karatotev5d893412025-01-07 11:00:03 +000066void gic_pcpu_init(unsigned int cpu_idx)
Achin Gupta27573c52015-11-03 14:18:34 +000067{
68 gicv2_pcpu_distif_init();
Jeenu Viswambharandea417c2017-09-22 08:32:09 +010069 gicv2_set_pe_target_mask(plat_my_core_pos());
Achin Gupta27573c52015-11-03 14:18:34 +000070}
Jeenu Viswambharand17b9532016-12-09 11:12:34 +000071
72/******************************************************************************
73 * Stubs for Redistributor power management. Although GICv2 doesn't have
74 * Redistributor interface, these are provided for the sake of uniform GIC API
75 *****************************************************************************/
Boyan Karatotev5d893412025-01-07 11:00:03 +000076void gic_pcpu_off(unsigned int cpu_idx)
Jeenu Viswambharand17b9532016-12-09 11:12:34 +000077{
78 return;
79}
80
Soby Mathewe35a3fb2017-10-11 16:08:58 +010081/******************************************************************************
82 * ARM common helper to save & restore the GICv3 on resume from system suspend.
83 * The normal world currently takes care of saving and restoring the GICv2
84 * registers due to legacy reasons. Hence we just initialize the Distributor
85 * on resume from system suspend.
86 *****************************************************************************/
Boyan Karatotev5d893412025-01-07 11:00:03 +000087void gic_save(void)
Soby Mathewe35a3fb2017-10-11 16:08:58 +010088{
89 return;
90}
91
Boyan Karatotev5d893412025-01-07 11:00:03 +000092void gic_resume(void)
Soby Mathewe35a3fb2017-10-11 16:08:58 +010093{
94 gicv2_distif_init();
95 gicv2_pcpu_distif_init();
96}