uniphier_gicv3.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <platform_def.h>
  8. #include <drivers/arm/gicv3.h>
  9. #include <common/interrupt_props.h>
  10. #include <plat/common/platform.h>
  11. #include "uniphier.h"
  12. static uintptr_t uniphier_rdistif_base_addrs[PLATFORM_CORE_COUNT];
  13. static const interrupt_prop_t uniphier_interrupt_props[] = {
  14. /* G0 interrupts */
  15. /* SGI0 */
  16. INTR_PROP_DESC(8, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP0,
  17. GIC_INTR_CFG_EDGE),
  18. /* SGI6 */
  19. INTR_PROP_DESC(14, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP0,
  20. GIC_INTR_CFG_EDGE),
  21. /* G1S interrupts */
  22. /* Timer */
  23. INTR_PROP_DESC(29, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  24. GIC_INTR_CFG_LEVEL),
  25. /* SGI1 */
  26. INTR_PROP_DESC(9, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  27. GIC_INTR_CFG_EDGE),
  28. /* SGI2 */
  29. INTR_PROP_DESC(10, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  30. GIC_INTR_CFG_EDGE),
  31. /* SGI3 */
  32. INTR_PROP_DESC(11, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  33. GIC_INTR_CFG_EDGE),
  34. /* SGI4 */
  35. INTR_PROP_DESC(12, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  36. GIC_INTR_CFG_EDGE),
  37. /* SGI5 */
  38. INTR_PROP_DESC(13, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  39. GIC_INTR_CFG_EDGE),
  40. /* SGI7 */
  41. INTR_PROP_DESC(15, GIC_HIGHEST_SEC_PRIORITY, INTR_GROUP1S,
  42. GIC_INTR_CFG_EDGE)
  43. };
  44. static unsigned int uniphier_mpidr_to_core_pos(u_register_t mpidr)
  45. {
  46. return plat_core_pos_by_mpidr(mpidr);
  47. }
  48. static const struct gicv3_driver_data uniphier_gic_driver_data[] = {
  49. [UNIPHIER_SOC_LD11] = {
  50. .gicd_base = 0x5fe00000,
  51. .gicr_base = 0x5fe40000,
  52. .interrupt_props = uniphier_interrupt_props,
  53. .interrupt_props_num = ARRAY_SIZE(uniphier_interrupt_props),
  54. .rdistif_num = PLATFORM_CORE_COUNT,
  55. .rdistif_base_addrs = uniphier_rdistif_base_addrs,
  56. .mpidr_to_core_pos = uniphier_mpidr_to_core_pos,
  57. },
  58. [UNIPHIER_SOC_LD20] = {
  59. .gicd_base = 0x5fe00000,
  60. .gicr_base = 0x5fe80000,
  61. .interrupt_props = uniphier_interrupt_props,
  62. .interrupt_props_num = ARRAY_SIZE(uniphier_interrupt_props),
  63. .rdistif_num = PLATFORM_CORE_COUNT,
  64. .rdistif_base_addrs = uniphier_rdistif_base_addrs,
  65. .mpidr_to_core_pos = uniphier_mpidr_to_core_pos,
  66. },
  67. [UNIPHIER_SOC_PXS3] = {
  68. .gicd_base = 0x5fe00000,
  69. .gicr_base = 0x5fe80000,
  70. .interrupt_props = uniphier_interrupt_props,
  71. .interrupt_props_num = ARRAY_SIZE(uniphier_interrupt_props),
  72. .rdistif_num = PLATFORM_CORE_COUNT,
  73. .rdistif_base_addrs = uniphier_rdistif_base_addrs,
  74. .mpidr_to_core_pos = uniphier_mpidr_to_core_pos,
  75. },
  76. };
  77. void uniphier_gic_driver_init(unsigned int soc)
  78. {
  79. assert(soc < ARRAY_SIZE(uniphier_gic_driver_data));
  80. gicv3_driver_init(&uniphier_gic_driver_data[soc]);
  81. }
  82. void uniphier_gic_init(void)
  83. {
  84. gicv3_distif_init();
  85. gicv3_rdistif_init(plat_my_core_pos());
  86. gicv3_cpuif_enable(plat_my_core_pos());
  87. }
  88. void uniphier_gic_cpuif_enable(void)
  89. {
  90. gicv3_cpuif_enable(plat_my_core_pos());
  91. }
  92. void uniphier_gic_cpuif_disable(void)
  93. {
  94. gicv3_cpuif_disable(plat_my_core_pos());
  95. }
  96. void uniphier_gic_pcpu_init(void)
  97. {
  98. gicv3_rdistif_init(plat_my_core_pos());
  99. }