axg_common.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <bl31/interrupt_mgmt.h>
  8. #include <common/bl_common.h>
  9. #include <common/ep_info.h>
  10. #include <lib/mmio.h>
  11. #include <lib/xlat_tables/xlat_tables_v2.h>
  12. #include <platform_def.h>
  13. #include <stdint.h>
  14. /*******************************************************************************
  15. * Platform memory map regions
  16. ******************************************************************************/
  17. #define MAP_NSDRAM0 MAP_REGION_FLAT(AML_NSDRAM0_BASE, \
  18. AML_NSDRAM0_SIZE, \
  19. MT_MEMORY | MT_RW | MT_NS)
  20. #define MAP_NS_SHARE_MEM MAP_REGION_FLAT(AML_NS_SHARE_MEM_BASE, \
  21. AML_NS_SHARE_MEM_SIZE, \
  22. MT_MEMORY | MT_RW | MT_NS)
  23. #define MAP_SEC_SHARE_MEM MAP_REGION_FLAT(AML_SEC_SHARE_MEM_BASE, \
  24. AML_SEC_SHARE_MEM_SIZE, \
  25. MT_MEMORY | MT_RW | MT_SECURE)
  26. #define MAP_SEC_DEVICE0 MAP_REGION_FLAT(AML_SEC_DEVICE0_BASE, \
  27. AML_SEC_DEVICE0_SIZE, \
  28. MT_DEVICE | MT_RW)
  29. #define MAP_GIC_DEVICE MAP_REGION_FLAT(AML_GIC_DEVICE_BASE, \
  30. AML_GIC_DEVICE_SIZE, \
  31. MT_DEVICE | MT_RW | MT_SECURE)
  32. #define MAP_SEC_DEVICE1 MAP_REGION_FLAT(AML_SEC_DEVICE1_BASE, \
  33. AML_SEC_DEVICE1_SIZE, \
  34. MT_DEVICE | MT_RW | MT_SECURE)
  35. #define MAP_SEC_DEVICE2 MAP_REGION_FLAT(AML_SEC_DEVICE2_BASE, \
  36. AML_SEC_DEVICE2_SIZE, \
  37. MT_DEVICE | MT_RW | MT_SECURE)
  38. #define MAP_TZRAM MAP_REGION_FLAT(AML_TZRAM_BASE, \
  39. AML_TZRAM_SIZE, \
  40. MT_DEVICE | MT_RW | MT_SECURE)
  41. static const mmap_region_t axg_mmap[] = {
  42. MAP_NSDRAM0,
  43. MAP_NS_SHARE_MEM,
  44. MAP_SEC_SHARE_MEM,
  45. MAP_SEC_DEVICE0,
  46. MAP_GIC_DEVICE,
  47. MAP_SEC_DEVICE1,
  48. MAP_SEC_DEVICE2,
  49. MAP_TZRAM,
  50. {0}
  51. };
  52. /*******************************************************************************
  53. * Per-image regions
  54. ******************************************************************************/
  55. #define MAP_BL31 MAP_REGION_FLAT(BL31_BASE, \
  56. BL31_END - BL31_BASE, \
  57. MT_MEMORY | MT_RW | MT_SECURE)
  58. #define MAP_BL_CODE MAP_REGION_FLAT(BL_CODE_BASE, \
  59. BL_CODE_END - BL_CODE_BASE, \
  60. MT_CODE | MT_SECURE)
  61. #define MAP_BL_RO_DATA MAP_REGION_FLAT(BL_RO_DATA_BASE, \
  62. BL_RO_DATA_END - BL_RO_DATA_BASE, \
  63. MT_RO_DATA | MT_SECURE)
  64. #define MAP_BL_COHERENT MAP_REGION_FLAT(BL_COHERENT_RAM_BASE, \
  65. BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, \
  66. MT_DEVICE | MT_RW | MT_SECURE)
  67. /*******************************************************************************
  68. * Function that sets up the translation tables.
  69. ******************************************************************************/
  70. void aml_setup_page_tables(void)
  71. {
  72. #if IMAGE_BL31
  73. const mmap_region_t axg_bl_mmap[] = {
  74. MAP_BL31,
  75. MAP_BL_CODE,
  76. MAP_BL_RO_DATA,
  77. #if USE_COHERENT_MEM
  78. MAP_BL_COHERENT,
  79. #endif
  80. {0}
  81. };
  82. #endif
  83. mmap_add(axg_bl_mmap);
  84. mmap_add(axg_mmap);
  85. init_xlat_tables();
  86. }
  87. /*******************************************************************************
  88. * Function that returns the system counter frequency
  89. ******************************************************************************/
  90. unsigned int plat_get_syscnt_freq2(void)
  91. {
  92. mmio_clrbits_32(AML_SYS_CPU_CFG7, PLAT_SYS_CPU_CFG7);
  93. mmio_clrbits_32(AML_AO_TIMESTAMP_CNTL, PLAT_AO_TIMESTAMP_CNTL);
  94. return AML_OSC24M_CLK_IN_HZ;
  95. }