brcm_gicv3.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2019-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <drivers/arm/gicv3.h>
  7. #include <plat/common/platform.h>
  8. #include <platform_def.h>
  9. /* The GICv3 driver only needs to be initialized in EL3 */
  10. static uintptr_t brcm_rdistif_base_addrs[PLATFORM_CORE_COUNT];
  11. static const interrupt_prop_t brcm_interrupt_props[] = {
  12. /* G1S interrupts */
  13. PLAT_BRCM_G1S_IRQ_PROPS(INTR_GROUP1S),
  14. /* G0 interrupts */
  15. PLAT_BRCM_G0_IRQ_PROPS(INTR_GROUP0)
  16. };
  17. /*
  18. * MPIDR hashing function for translating MPIDRs read from GICR_TYPER register
  19. * to core position.
  20. *
  21. * Calculating core position is dependent on MPIDR_EL1.MT bit. However, affinity
  22. * values read from GICR_TYPER don't have an MT field. To reuse the same
  23. * translation used for CPUs, we insert MT bit read from the PE's MPIDR into
  24. * that read from GICR_TYPER.
  25. *
  26. * Assumptions:
  27. *
  28. * - All CPUs implemented in the system have MPIDR_EL1.MT bit set;
  29. * - No CPUs implemented in the system use affinity level 3.
  30. */
  31. static unsigned int brcm_gicv3_mpidr_hash(u_register_t mpidr)
  32. {
  33. mpidr |= (read_mpidr_el1() & MPIDR_MT_MASK);
  34. return plat_core_pos_by_mpidr(mpidr);
  35. }
  36. static const gicv3_driver_data_t brcm_gic_data = {
  37. .gicd_base = PLAT_BRCM_GICD_BASE,
  38. .gicr_base = PLAT_BRCM_GICR_BASE,
  39. .interrupt_props = brcm_interrupt_props,
  40. .interrupt_props_num = ARRAY_SIZE(brcm_interrupt_props),
  41. .rdistif_num = PLATFORM_CORE_COUNT,
  42. .rdistif_base_addrs = brcm_rdistif_base_addrs,
  43. .mpidr_to_core_pos = brcm_gicv3_mpidr_hash
  44. };
  45. void plat_brcm_gic_driver_init(void)
  46. {
  47. /* TODO Check if this is required to be initialized here
  48. * after getting initialized in EL3, should we re-init this here
  49. * in S-EL1
  50. */
  51. gicv3_driver_init(&brcm_gic_data);
  52. }
  53. void plat_brcm_gic_init(void)
  54. {
  55. gicv3_distif_init();
  56. gicv3_rdistif_init(plat_my_core_pos());
  57. gicv3_cpuif_enable(plat_my_core_pos());
  58. }
  59. void plat_brcm_gic_cpuif_enable(void)
  60. {
  61. gicv3_cpuif_enable(plat_my_core_pos());
  62. }
  63. void plat_brcm_gic_cpuif_disable(void)
  64. {
  65. gicv3_cpuif_disable(plat_my_core_pos());
  66. }
  67. void plat_brcm_gic_pcpu_init(void)
  68. {
  69. gicv3_rdistif_init(plat_my_core_pos());
  70. }
  71. void plat_brcm_gic_redistif_on(void)
  72. {
  73. gicv3_rdistif_on(plat_my_core_pos());
  74. }
  75. void plat_brcm_gic_redistif_off(void)
  76. {
  77. gicv3_rdistif_off(plat_my_core_pos());
  78. }