rdv1mc_plat.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <drivers/arm/gic600_multichip.h>
  8. #include <plat/arm/common/plat_arm.h>
  9. #include <plat/common/platform.h>
  10. #include <sgi_soc_platform_def.h>
  11. #include <sgi_plat.h>
  12. #if defined(IMAGE_BL31)
  13. static const mmap_region_t rdv1mc_dynamic_mmap[] = {
  14. ARM_MAP_SHARED_RAM_REMOTE_CHIP(1),
  15. CSS_SGI_MAP_DEVICE_REMOTE_CHIP(1),
  16. SOC_CSS_MAP_DEVICE_REMOTE_CHIP(1),
  17. #if (CSS_SGI_CHIP_COUNT > 2)
  18. ARM_MAP_SHARED_RAM_REMOTE_CHIP(2),
  19. CSS_SGI_MAP_DEVICE_REMOTE_CHIP(2),
  20. SOC_CSS_MAP_DEVICE_REMOTE_CHIP(2),
  21. #endif
  22. #if (CSS_SGI_CHIP_COUNT > 3)
  23. ARM_MAP_SHARED_RAM_REMOTE_CHIP(3),
  24. CSS_SGI_MAP_DEVICE_REMOTE_CHIP(3),
  25. SOC_CSS_MAP_DEVICE_REMOTE_CHIP(3)
  26. #endif
  27. };
  28. static struct gic600_multichip_data rdv1mc_multichip_data __init = {
  29. .rt_owner_base = PLAT_ARM_GICD_BASE,
  30. .rt_owner = 0,
  31. .chip_count = CSS_SGI_CHIP_COUNT,
  32. .chip_addrs = {
  33. PLAT_ARM_GICD_BASE >> 16,
  34. (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1)) >> 16,
  35. #if (CSS_SGI_CHIP_COUNT > 2)
  36. (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2)) >> 16,
  37. #endif
  38. #if (CSS_SGI_CHIP_COUNT > 3)
  39. (PLAT_ARM_GICD_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3)) >> 16,
  40. #endif
  41. },
  42. .spi_ids = {
  43. {32, 255},
  44. {0, 0},
  45. #if (CSS_SGI_CHIP_COUNT > 2)
  46. {0, 0},
  47. #endif
  48. #if (CSS_SGI_CHIP_COUNT > 3)
  49. {0, 0},
  50. #endif
  51. }
  52. };
  53. static uintptr_t rdv1mc_multichip_gicr_frames[] = {
  54. /* Chip 0's GICR Base */
  55. PLAT_ARM_GICR_BASE,
  56. /* Chip 1's GICR BASE */
  57. PLAT_ARM_GICR_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(1),
  58. #if (CSS_SGI_CHIP_COUNT > 2)
  59. /* Chip 2's GICR BASE */
  60. PLAT_ARM_GICR_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(2),
  61. #endif
  62. #if (CSS_SGI_CHIP_COUNT > 3)
  63. /* Chip 3's GICR BASE */
  64. PLAT_ARM_GICR_BASE + CSS_SGI_REMOTE_CHIP_MEM_OFFSET(3),
  65. #endif
  66. UL(0) /* Zero Termination */
  67. };
  68. #endif /* IMAGE_BL31 */
  69. unsigned int plat_arm_sgi_get_platform_id(void)
  70. {
  71. return mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
  72. & SID_SYSTEM_ID_PART_NUM_MASK;
  73. }
  74. unsigned int plat_arm_sgi_get_config_id(void)
  75. {
  76. return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
  77. }
  78. unsigned int plat_arm_sgi_get_multi_chip_mode(void)
  79. {
  80. return (mmio_read_32(SID_REG_BASE + SID_NODE_ID_OFFSET) &
  81. SID_MULTI_CHIP_MODE_MASK) >> SID_MULTI_CHIP_MODE_SHIFT;
  82. }
  83. /*
  84. * bl31_platform_setup_function is guarded by IMAGE_BL31 macro because
  85. * PLAT_XLAT_TABLES_DYNAMIC macro is set to build only for BL31 and not
  86. * for other stages.
  87. */
  88. #if defined(IMAGE_BL31)
  89. void bl31_platform_setup(void)
  90. {
  91. int ret;
  92. unsigned int i;
  93. if ((plat_arm_sgi_get_multi_chip_mode() == 0) &&
  94. (CSS_SGI_CHIP_COUNT > 1)) {
  95. ERROR("Chip Count is set to %u but multi-chip mode is not "
  96. "enabled\n", CSS_SGI_CHIP_COUNT);
  97. panic();
  98. } else if ((plat_arm_sgi_get_multi_chip_mode() == 1) &&
  99. (CSS_SGI_CHIP_COUNT > 1)) {
  100. INFO("Enabling support for multi-chip in RD-V1-MC\n");
  101. for (i = 0; i < ARRAY_SIZE(rdv1mc_dynamic_mmap); i++) {
  102. ret = mmap_add_dynamic_region(
  103. rdv1mc_dynamic_mmap[i].base_pa,
  104. rdv1mc_dynamic_mmap[i].base_va,
  105. rdv1mc_dynamic_mmap[i].size,
  106. rdv1mc_dynamic_mmap[i].attr);
  107. if (ret != 0) {
  108. ERROR("Failed to add dynamic mmap entry "
  109. "(ret=%d)\n", ret);
  110. panic();
  111. }
  112. }
  113. plat_arm_override_gicr_frames(
  114. rdv1mc_multichip_gicr_frames);
  115. gic600_multichip_init(&rdv1mc_multichip_data);
  116. }
  117. sgi_bl31_common_platform_setup();
  118. }
  119. #endif /* IMAGE_BL31 */