versal_common.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #include <common/debug.h>
  8. #include <lib/mmio.h>
  9. #include <lib/xlat_tables/xlat_tables_v2.h>
  10. #include <plat/common/platform.h>
  11. #include <plat_common.h>
  12. #include <plat_ipi.h>
  13. #include <plat_private.h>
  14. #include <pm_api_sys.h>
  15. #include <versal_def.h>
  16. uint32_t platform_id, platform_version;
  17. uint32_t cpu_clock;
  18. /*
  19. * Table of regions to map using the MMU.
  20. * This doesn't include TZRAM as the 'mem_layout' argument passed to
  21. * configure_mmu_elx() will give the available subset of that,
  22. */
  23. const mmap_region_t plat_versal_mmap[] = {
  24. MAP_REGION_FLAT(DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
  25. MAP_REGION_FLAT(DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
  26. MAP_REGION_FLAT(CRF_BASE, CRF_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
  27. MAP_REGION_FLAT(PLAT_ARM_CCI_BASE, PLAT_ARM_CCI_SIZE, MT_DEVICE | MT_RW |
  28. MT_SECURE),
  29. { 0 }
  30. };
  31. const mmap_region_t *plat_get_mmap(void)
  32. {
  33. return plat_versal_mmap;
  34. }
  35. void versal_config_setup(void)
  36. {
  37. /* Configure IPI data for versal */
  38. versal_ipi_config_table_init();
  39. }
  40. void board_detection(void)
  41. {
  42. uint32_t plat_info[2];
  43. if (pm_get_chipid(plat_info) != PM_RET_SUCCESS) {
  44. /* If the call is failed we cannot proceed with further
  45. * setup. TF-A to panic in this situation.
  46. */
  47. NOTICE("Failed to read the chip information");
  48. panic();
  49. }
  50. platform_id = FIELD_GET(PLATFORM_MASK, plat_info[1]);
  51. platform_version = FIELD_GET(PLATFORM_VERSION_MASK, plat_info[1]);
  52. if (platform_id == VERSAL_COSIM) {
  53. platform_id = VERSAL_QEMU;
  54. }
  55. }
  56. const char *board_name_decode(void)
  57. {
  58. const char *platform;
  59. switch (platform_id) {
  60. case VERSAL_SPP:
  61. platform = "IPP";
  62. break;
  63. case VERSAL_EMU:
  64. platform = "EMU";
  65. break;
  66. case VERSAL_QEMU:
  67. platform = "QEMU";
  68. break;
  69. case VERSAL_SILICON:
  70. platform = "SILICON";
  71. break;
  72. default:
  73. platform = "unknown";
  74. }
  75. return platform;
  76. }
  77. uint32_t get_uart_clk(void)
  78. {
  79. uint32_t uart_clock;
  80. switch (platform_id) {
  81. case VERSAL_SPP:
  82. uart_clock = 25000000;
  83. break;
  84. case VERSAL_EMU:
  85. uart_clock = 212000;
  86. break;
  87. case VERSAL_QEMU:
  88. case VERSAL_SILICON:
  89. uart_clock = 100000000;
  90. break;
  91. default:
  92. panic();
  93. }
  94. return uart_clock;
  95. }