rockchip_gicv3.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <common/bl_common.h>
  8. #include <common/interrupt_props.h>
  9. #include <drivers/arm/gicv3.h>
  10. #include <lib/utils.h>
  11. #include <plat/common/platform.h>
  12. /******************************************************************************
  13. * The following functions are defined as weak to allow a platform to override
  14. * the way the GICv3 driver is initialised and used.
  15. *****************************************************************************/
  16. #pragma weak plat_rockchip_gic_driver_init
  17. #pragma weak plat_rockchip_gic_init
  18. #pragma weak plat_rockchip_gic_cpuif_enable
  19. #pragma weak plat_rockchip_gic_cpuif_disable
  20. #pragma weak plat_rockchip_gic_pcpu_init
  21. /* The GICv3 driver only needs to be initialized in EL3 */
  22. uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT];
  23. static const interrupt_prop_t g01s_interrupt_props[] = {
  24. PLAT_RK_GICV3_G0_IRQS,
  25. PLAT_RK_GICV3_G1S_IRQS
  26. };
  27. static unsigned int plat_rockchip_mpidr_to_core_pos(unsigned long mpidr)
  28. {
  29. return (unsigned int)plat_core_pos_by_mpidr(mpidr);
  30. }
  31. const gicv3_driver_data_t rockchip_gic_data = {
  32. .gicd_base = PLAT_RK_GICD_BASE,
  33. .gicr_base = PLAT_RK_GICR_BASE,
  34. .interrupt_props = g01s_interrupt_props,
  35. .interrupt_props_num = ARRAY_SIZE(g01s_interrupt_props),
  36. .rdistif_num = PLATFORM_CORE_COUNT,
  37. .rdistif_base_addrs = rdistif_base_addrs,
  38. .mpidr_to_core_pos = plat_rockchip_mpidr_to_core_pos,
  39. };
  40. void plat_rockchip_gic_driver_init(void)
  41. {
  42. /*
  43. * The GICv3 driver is initialized in EL3 and does not need
  44. * to be initialized again in SEL1. This is because the S-EL1
  45. * can use GIC system registers to manage interrupts and does
  46. * not need GIC interface base addresses to be configured.
  47. */
  48. #ifdef IMAGE_BL31
  49. gicv3_driver_init(&rockchip_gic_data);
  50. #endif
  51. }
  52. /******************************************************************************
  53. * RockChip common helper to initialize the GIC. Only invoked
  54. * by BL31
  55. *****************************************************************************/
  56. void plat_rockchip_gic_init(void)
  57. {
  58. gicv3_distif_init();
  59. gicv3_rdistif_init(plat_my_core_pos());
  60. gicv3_cpuif_enable(plat_my_core_pos());
  61. }
  62. /******************************************************************************
  63. * RockChip common helper to enable the GIC CPU interface
  64. *****************************************************************************/
  65. void plat_rockchip_gic_cpuif_enable(void)
  66. {
  67. gicv3_cpuif_enable(plat_my_core_pos());
  68. }
  69. /******************************************************************************
  70. * RockChip common helper to disable the GIC CPU interface
  71. *****************************************************************************/
  72. void plat_rockchip_gic_cpuif_disable(void)
  73. {
  74. gicv3_cpuif_disable(plat_my_core_pos());
  75. }
  76. /******************************************************************************
  77. * RockChip common helper to initialize the per-cpu redistributor interface
  78. * in GICv3
  79. *****************************************************************************/
  80. void plat_rockchip_gic_pcpu_init(void)
  81. {
  82. gicv3_rdistif_init(plat_my_core_pos());
  83. }