Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 1 | /* |
Jeenu Viswambharan | eeb43be | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 7 | #include <platform_def.h> |
| 8 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame^] | 9 | #include <drivers/arm/gicv2.h> |
| 10 | #include <plat/common/platform.h> |
| 11 | |
| 12 | #include <plat_arm.h> |
| 13 | |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 14 | /****************************************************************************** |
| 15 | * The following functions are defined as weak to allow a platform to override |
| 16 | * the way the GICv2 driver is initialised and used. |
| 17 | *****************************************************************************/ |
| 18 | #pragma weak plat_arm_gic_driver_init |
| 19 | #pragma weak plat_arm_gic_init |
| 20 | #pragma weak plat_arm_gic_cpuif_enable |
| 21 | #pragma weak plat_arm_gic_cpuif_disable |
| 22 | #pragma weak plat_arm_gic_pcpu_init |
| 23 | |
| 24 | /****************************************************************************** |
| 25 | * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0 |
| 26 | * interrupts. |
| 27 | *****************************************************************************/ |
Jeenu Viswambharan | 723dce0 | 2017-09-22 08:59:59 +0100 | [diff] [blame] | 28 | static const interrupt_prop_t arm_interrupt_props[] = { |
| 29 | PLAT_ARM_G1S_IRQ_PROPS(GICV2_INTR_GROUP0), |
| 30 | PLAT_ARM_G0_IRQ_PROPS(GICV2_INTR_GROUP0) |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
Jeenu Viswambharan | eeb43be | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 33 | static unsigned int target_mask_array[PLATFORM_CORE_COUNT]; |
| 34 | |
Soby Mathew | cf022c5 | 2016-01-13 17:06:00 +0000 | [diff] [blame] | 35 | static const gicv2_driver_data_t arm_gic_data = { |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 36 | .gicd_base = PLAT_ARM_GICD_BASE, |
| 37 | .gicc_base = PLAT_ARM_GICC_BASE, |
Jeenu Viswambharan | 723dce0 | 2017-09-22 08:59:59 +0100 | [diff] [blame] | 38 | .interrupt_props = arm_interrupt_props, |
| 39 | .interrupt_props_num = ARRAY_SIZE(arm_interrupt_props), |
Jeenu Viswambharan | eeb43be | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 40 | .target_masks = target_mask_array, |
| 41 | .target_masks_num = ARRAY_SIZE(target_mask_array), |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | /****************************************************************************** |
| 45 | * ARM common helper to initialize the GICv2 only driver. |
| 46 | *****************************************************************************/ |
| 47 | void plat_arm_gic_driver_init(void) |
| 48 | { |
| 49 | gicv2_driver_init(&arm_gic_data); |
| 50 | } |
| 51 | |
| 52 | void plat_arm_gic_init(void) |
| 53 | { |
| 54 | gicv2_distif_init(); |
| 55 | gicv2_pcpu_distif_init(); |
Jeenu Viswambharan | fbf5bda | 2017-11-07 16:10:19 +0000 | [diff] [blame] | 56 | gicv2_set_pe_target_mask(plat_my_core_pos()); |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 57 | gicv2_cpuif_enable(); |
| 58 | } |
| 59 | |
| 60 | /****************************************************************************** |
| 61 | * ARM common helper to enable the GICv2 CPU interface |
| 62 | *****************************************************************************/ |
| 63 | void plat_arm_gic_cpuif_enable(void) |
| 64 | { |
| 65 | gicv2_cpuif_enable(); |
| 66 | } |
| 67 | |
| 68 | /****************************************************************************** |
| 69 | * ARM common helper to disable the GICv2 CPU interface |
| 70 | *****************************************************************************/ |
| 71 | void plat_arm_gic_cpuif_disable(void) |
| 72 | { |
| 73 | gicv2_cpuif_disable(); |
| 74 | } |
| 75 | |
| 76 | /****************************************************************************** |
| 77 | * ARM common helper to initialize the per cpu distributor interface in GICv2 |
| 78 | *****************************************************************************/ |
| 79 | void plat_arm_gic_pcpu_init(void) |
| 80 | { |
| 81 | gicv2_pcpu_distif_init(); |
Jeenu Viswambharan | eeb43be | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 82 | gicv2_set_pe_target_mask(plat_my_core_pos()); |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 83 | } |
Jeenu Viswambharan | 78132c9 | 2016-12-09 11:12:34 +0000 | [diff] [blame] | 84 | |
| 85 | /****************************************************************************** |
| 86 | * Stubs for Redistributor power management. Although GICv2 doesn't have |
| 87 | * Redistributor interface, these are provided for the sake of uniform GIC API |
| 88 | *****************************************************************************/ |
| 89 | void plat_arm_gic_redistif_on(void) |
| 90 | { |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | void plat_arm_gic_redistif_off(void) |
| 95 | { |
| 96 | return; |
| 97 | } |
Soby Mathew | 9ca2806 | 2017-10-11 16:08:58 +0100 | [diff] [blame] | 98 | |
| 99 | |
| 100 | /****************************************************************************** |
| 101 | * ARM common helper to save & restore the GICv3 on resume from system suspend. |
| 102 | * The normal world currently takes care of saving and restoring the GICv2 |
| 103 | * registers due to legacy reasons. Hence we just initialize the Distributor |
| 104 | * on resume from system suspend. |
| 105 | *****************************************************************************/ |
| 106 | void plat_arm_gic_save(void) |
| 107 | { |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | void plat_arm_gic_resume(void) |
| 112 | { |
| 113 | gicv2_distif_init(); |
| 114 | gicv2_pcpu_distif_init(); |
| 115 | } |