arm_gicv2.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <drivers/arm/gicv2.h>
  8. #include <plat/arm/common/plat_arm.h>
  9. #include <plat/common/platform.h>
  10. /******************************************************************************
  11. * The following functions are defined as weak to allow a platform to override
  12. * the way the GICv2 driver is initialised and used.
  13. *****************************************************************************/
  14. #pragma weak plat_arm_gic_driver_init
  15. #pragma weak plat_arm_gic_init
  16. #pragma weak plat_arm_gic_cpuif_enable
  17. #pragma weak plat_arm_gic_cpuif_disable
  18. #pragma weak plat_arm_gic_pcpu_init
  19. /******************************************************************************
  20. * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
  21. * interrupts.
  22. *****************************************************************************/
  23. static const interrupt_prop_t arm_interrupt_props[] = {
  24. PLAT_ARM_G1S_IRQ_PROPS(GICV2_INTR_GROUP0),
  25. PLAT_ARM_G0_IRQ_PROPS(GICV2_INTR_GROUP0)
  26. };
  27. static unsigned int target_mask_array[PLATFORM_CORE_COUNT];
  28. static const gicv2_driver_data_t arm_gic_data = {
  29. .gicd_base = PLAT_ARM_GICD_BASE,
  30. .gicc_base = PLAT_ARM_GICC_BASE,
  31. .interrupt_props = arm_interrupt_props,
  32. .interrupt_props_num = ARRAY_SIZE(arm_interrupt_props),
  33. .target_masks = target_mask_array,
  34. .target_masks_num = ARRAY_SIZE(target_mask_array),
  35. };
  36. /******************************************************************************
  37. * ARM common helper to initialize the GICv2 only driver.
  38. *****************************************************************************/
  39. void plat_arm_gic_driver_init(void)
  40. {
  41. gicv2_driver_init(&arm_gic_data);
  42. }
  43. void plat_arm_gic_init(void)
  44. {
  45. gicv2_distif_init();
  46. gicv2_pcpu_distif_init();
  47. gicv2_set_pe_target_mask(plat_my_core_pos());
  48. gicv2_cpuif_enable();
  49. }
  50. /******************************************************************************
  51. * ARM common helper to enable the GICv2 CPU interface
  52. *****************************************************************************/
  53. void plat_arm_gic_cpuif_enable(void)
  54. {
  55. gicv2_cpuif_enable();
  56. }
  57. /******************************************************************************
  58. * ARM common helper to disable the GICv2 CPU interface
  59. *****************************************************************************/
  60. void plat_arm_gic_cpuif_disable(void)
  61. {
  62. gicv2_cpuif_disable();
  63. }
  64. /******************************************************************************
  65. * ARM common helper to initialize the per cpu distributor interface in GICv2
  66. *****************************************************************************/
  67. void plat_arm_gic_pcpu_init(void)
  68. {
  69. gicv2_pcpu_distif_init();
  70. gicv2_set_pe_target_mask(plat_my_core_pos());
  71. }
  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. *****************************************************************************/
  76. void plat_arm_gic_redistif_on(void)
  77. {
  78. return;
  79. }
  80. void plat_arm_gic_redistif_off(void)
  81. {
  82. return;
  83. }
  84. /******************************************************************************
  85. * ARM common helper to save & restore the GICv3 on resume from system suspend.
  86. * The normal world currently takes care of saving and restoring the GICv2
  87. * registers due to legacy reasons. Hence we just initialize the Distributor
  88. * on resume from system suspend.
  89. *****************************************************************************/
  90. void plat_arm_gic_save(void)
  91. {
  92. return;
  93. }
  94. void plat_arm_gic_resume(void)
  95. {
  96. gicv2_distif_init();
  97. gicv2_pcpu_distif_init();
  98. }