hikey960_common.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (c) 2017-2022, 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 <arch_helpers.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <lib/mmio.h>
  12. #include <lib/xlat_tables/xlat_tables_v2.h>
  13. #include <plat/common/platform.h>
  14. #include "../hikey960_def.h"
  15. #include "../hikey960_private.h"
  16. #define MAP_DDR MAP_REGION_FLAT(DDR_BASE, \
  17. DDR_SIZE - DDR_SEC_SIZE, \
  18. MT_MEMORY | MT_RW | MT_NS)
  19. #define MAP_DEVICE MAP_REGION_FLAT(DEVICE_BASE, \
  20. DEVICE_SIZE, \
  21. MT_DEVICE | MT_RW | MT_SECURE)
  22. #define MAP_BL1_RW MAP_REGION_FLAT(BL1_RW_BASE, \
  23. BL1_RW_LIMIT - BL1_RW_BASE, \
  24. MT_MEMORY | MT_RW | MT_NS)
  25. #define MAP_UFS_DATA MAP_REGION_FLAT(HIKEY960_UFS_DATA_BASE, \
  26. HIKEY960_UFS_DATA_SIZE, \
  27. MT_MEMORY | MT_RW | MT_NS)
  28. #define MAP_UFS_DESC MAP_REGION_FLAT(HIKEY960_UFS_DESC_BASE, \
  29. HIKEY960_UFS_DESC_SIZE, \
  30. MT_MEMORY | MT_RW | MT_NS)
  31. #define MAP_TSP_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \
  32. TSP_SEC_MEM_SIZE, \
  33. MT_MEMORY | MT_RW | MT_SECURE)
  34. /*
  35. * Table of regions for different BL stages to map using the MMU.
  36. * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
  37. * hikey960_init_mmu_elx() will give the available subset of that,
  38. */
  39. #ifdef IMAGE_BL1
  40. static const mmap_region_t hikey960_mmap[] = {
  41. MAP_UFS_DATA,
  42. MAP_BL1_RW,
  43. MAP_UFS_DESC,
  44. MAP_DEVICE,
  45. {0}
  46. };
  47. #endif
  48. #ifdef IMAGE_BL2
  49. static const mmap_region_t hikey960_mmap[] = {
  50. MAP_DDR,
  51. MAP_DEVICE,
  52. MAP_TSP_MEM,
  53. {0}
  54. };
  55. #endif
  56. #ifdef IMAGE_BL31
  57. static const mmap_region_t hikey960_mmap[] = {
  58. MAP_DEVICE,
  59. {0}
  60. };
  61. #endif
  62. #ifdef IMAGE_BL32
  63. static const mmap_region_t hikey960_mmap[] = {
  64. MAP_DEVICE,
  65. MAP_DDR,
  66. {0}
  67. };
  68. #endif
  69. /*
  70. * Macro generating the code for the function setting up the pagetables as per
  71. * the platform memory map & initialize the mmu, for the given exception level
  72. */
  73. #define HIKEY960_CONFIGURE_MMU_EL(_el) \
  74. void hikey960_init_mmu_el##_el(unsigned long total_base, \
  75. unsigned long total_size, \
  76. unsigned long ro_start, \
  77. unsigned long ro_limit, \
  78. unsigned long coh_start, \
  79. unsigned long coh_limit) \
  80. { \
  81. mmap_add_region(total_base, total_base, \
  82. total_size, \
  83. MT_MEMORY | MT_RW | MT_SECURE); \
  84. mmap_add_region(ro_start, ro_start, \
  85. ro_limit - ro_start, \
  86. MT_MEMORY | MT_RO | MT_SECURE); \
  87. mmap_add_region(coh_start, coh_start, \
  88. coh_limit - coh_start, \
  89. MT_DEVICE | MT_RW | MT_SECURE); \
  90. mmap_add(hikey960_mmap); \
  91. init_xlat_tables(); \
  92. \
  93. enable_mmu_el##_el(0); \
  94. }
  95. /* Define EL1 and EL3 variants of the function initialising the MMU */
  96. HIKEY960_CONFIGURE_MMU_EL(1)
  97. HIKEY960_CONFIGURE_MMU_EL(3)
  98. unsigned long plat_get_ns_image_entrypoint(void)
  99. {
  100. return NS_BL1U_BASE;
  101. }
  102. unsigned int plat_get_syscnt_freq2(void)
  103. {
  104. return 1920000;
  105. }