platform_common.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <errno.h>
  8. #include <arch_helpers.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <drivers/delay_timer.h>
  12. #include <lib/mmio.h>
  13. #include <lib/xlat_tables/xlat_tables.h>
  14. #include <plat/common/platform.h>
  15. #include "hi3798cv200.h"
  16. #include "platform_def.h"
  17. #define MAP_DDR MAP_REGION_FLAT(DDR_BASE, \
  18. DDR_SIZE, \
  19. MT_MEMORY | MT_RW | MT_NS)
  20. #define MAP_DEVICE MAP_REGION_FLAT(DEVICE_BASE, \
  21. DEVICE_SIZE, \
  22. MT_DEVICE | MT_RW | MT_SECURE)
  23. #define MAP_TSP_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \
  24. TSP_SEC_MEM_SIZE, \
  25. MT_MEMORY | MT_RW | MT_SECURE)
  26. #ifdef SPD_opteed
  27. #define MAP_OPTEE_PAGEABLE MAP_REGION_FLAT( \
  28. POPLAR_OPTEE_PAGEABLE_LOAD_BASE, \
  29. POPLAR_OPTEE_PAGEABLE_LOAD_SIZE, \
  30. MT_MEMORY | MT_RW | MT_SECURE)
  31. #endif
  32. static const mmap_region_t poplar_mmap[] = {
  33. MAP_DDR,
  34. MAP_DEVICE,
  35. MAP_TSP_MEM,
  36. #ifdef SPD_opteed
  37. MAP_OPTEE_PAGEABLE,
  38. #endif
  39. {0}
  40. };
  41. #define DEFINE_CONFIGURE_MMU_EL(_el) \
  42. void plat_configure_mmu_el##_el(unsigned long total_base, \
  43. unsigned long total_size, \
  44. unsigned long ro_start, \
  45. unsigned long ro_limit, \
  46. unsigned long coh_start, \
  47. unsigned long coh_limit) \
  48. { \
  49. mmap_add_region(total_base, total_base, \
  50. total_size, \
  51. MT_MEMORY | MT_RW | MT_SECURE); \
  52. mmap_add_region(ro_start, ro_start, \
  53. ro_limit - ro_start, \
  54. MT_MEMORY | MT_RO | MT_SECURE); \
  55. mmap_add_region(coh_start, coh_start, \
  56. coh_limit - coh_start, \
  57. MT_DEVICE | MT_RW | MT_SECURE); \
  58. mmap_add(poplar_mmap); \
  59. init_xlat_tables(); \
  60. \
  61. enable_mmu_el##_el(0); \
  62. }
  63. DEFINE_CONFIGURE_MMU_EL(3)
  64. DEFINE_CONFIGURE_MMU_EL(1)
  65. unsigned int plat_get_syscnt_freq2(void)
  66. {
  67. return SYS_COUNTER_FREQ_IN_TICKS;
  68. }