g12a_common.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (c) 2019, 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_HDCP_RX MAP_REGION_FLAT(AML_HDCP_RX_BASE, \
  30. AML_HDCP_RX_SIZE, \
  31. MT_DEVICE | MT_RW | MT_SECURE)
  32. #define MAP_HDCP_TX MAP_REGION_FLAT(AML_HDCP_TX_BASE, \
  33. AML_HDCP_TX_SIZE, \
  34. MT_DEVICE | MT_RW | MT_SECURE)
  35. #define MAP_GIC_DEVICE MAP_REGION_FLAT(AML_GIC_DEVICE_BASE, \
  36. AML_GIC_DEVICE_SIZE, \
  37. MT_DEVICE | MT_RW | MT_SECURE)
  38. #define MAP_SEC_DEVICE1 MAP_REGION_FLAT(AML_SEC_DEVICE1_BASE, \
  39. AML_SEC_DEVICE1_SIZE, \
  40. MT_DEVICE | MT_RW | MT_SECURE)
  41. #define MAP_SEC_DEVICE2 MAP_REGION_FLAT(AML_SEC_DEVICE2_BASE, \
  42. AML_SEC_DEVICE2_SIZE, \
  43. MT_DEVICE | MT_RW | MT_SECURE)
  44. #define MAP_TZRAM MAP_REGION_FLAT(AML_TZRAM_BASE, \
  45. AML_TZRAM_SIZE, \
  46. MT_DEVICE | MT_RW | MT_SECURE)
  47. static const mmap_region_t g12a_mmap[] = {
  48. MAP_NSDRAM0,
  49. MAP_NS_SHARE_MEM,
  50. MAP_SEC_SHARE_MEM,
  51. MAP_SEC_DEVICE0,
  52. MAP_HDCP_RX,
  53. MAP_HDCP_TX,
  54. MAP_GIC_DEVICE,
  55. MAP_SEC_DEVICE1,
  56. MAP_SEC_DEVICE2,
  57. MAP_TZRAM,
  58. {0}
  59. };
  60. /*******************************************************************************
  61. * Per-image regions
  62. ******************************************************************************/
  63. #define MAP_BL31 MAP_REGION_FLAT(BL31_BASE, \
  64. BL31_END - BL31_BASE, \
  65. MT_MEMORY | MT_RW | MT_SECURE)
  66. #define MAP_BL_CODE MAP_REGION_FLAT(BL_CODE_BASE, \
  67. BL_CODE_END - BL_CODE_BASE, \
  68. MT_CODE | MT_SECURE)
  69. #define MAP_BL_RO_DATA MAP_REGION_FLAT(BL_RO_DATA_BASE, \
  70. BL_RO_DATA_END - BL_RO_DATA_BASE, \
  71. MT_RO_DATA | MT_SECURE)
  72. #define MAP_BL_COHERENT MAP_REGION_FLAT(BL_COHERENT_RAM_BASE, \
  73. BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, \
  74. MT_DEVICE | MT_RW | MT_SECURE)
  75. /*******************************************************************************
  76. * Function that sets up the translation tables.
  77. ******************************************************************************/
  78. void aml_setup_page_tables(void)
  79. {
  80. #if IMAGE_BL31
  81. const mmap_region_t g12a_bl_mmap[] = {
  82. MAP_BL31,
  83. MAP_BL_CODE,
  84. MAP_BL_RO_DATA,
  85. #if USE_COHERENT_MEM
  86. MAP_BL_COHERENT,
  87. #endif
  88. {0}
  89. };
  90. #endif
  91. mmap_add(g12a_bl_mmap);
  92. mmap_add(g12a_mmap);
  93. init_xlat_tables();
  94. }
  95. /*******************************************************************************
  96. * Function that returns the system counter frequency
  97. ******************************************************************************/
  98. unsigned int plat_get_syscnt_freq2(void)
  99. {
  100. mmio_clrbits_32(AML_SYS_CPU_CFG7, ~0xFDFFFFFF);
  101. mmio_clrbits_32(AML_AO_TIMESTAMP_CNTL, ~0xFFFFFE00);
  102. return AML_OSC24M_CLK_IN_HZ;
  103. }