platform_common.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (c) 2013-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <string.h>
  7. #include <platform_def.h>
  8. #include <arch_helpers.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <drivers/arm/cci.h>
  12. #include <lib/utils.h>
  13. #include <lib/xlat_tables/xlat_tables_compat.h>
  14. #include <plat_private.h>
  15. #ifdef PLAT_RK_CCI_BASE
  16. static const int cci_map[] = {
  17. PLAT_RK_CCI_CLUSTER0_SL_IFACE_IX,
  18. PLAT_RK_CCI_CLUSTER1_SL_IFACE_IX
  19. };
  20. #endif
  21. /******************************************************************************
  22. * Macro generating the code for the function setting up the pagetables as per
  23. * the platform memory map & initialize the mmu, for the given exception level
  24. ******************************************************************************/
  25. #define DEFINE_CONFIGURE_MMU_EL(_el) \
  26. void plat_configure_mmu_el ## _el(unsigned long total_base, \
  27. unsigned long total_size, \
  28. unsigned long ro_start, \
  29. unsigned long ro_limit, \
  30. unsigned long coh_start, \
  31. unsigned long coh_limit) \
  32. { \
  33. mmap_add_region(total_base, total_base, \
  34. total_size, \
  35. MT_MEMORY | MT_RW | MT_SECURE); \
  36. mmap_add_region(ro_start, ro_start, \
  37. ro_limit - ro_start, \
  38. MT_MEMORY | MT_RO | MT_SECURE); \
  39. if ((coh_limit - coh_start) != 0) \
  40. mmap_add_region(coh_start, coh_start, \
  41. coh_limit - coh_start, \
  42. MT_DEVICE | MT_RW | MT_SECURE); \
  43. mmap_add(plat_rk_mmap); \
  44. rockchip_plat_mmu_el##_el(); \
  45. init_xlat_tables(); \
  46. \
  47. enable_mmu_el ## _el(0); \
  48. }
  49. /* Define EL3 variants of the function initialising the MMU */
  50. DEFINE_CONFIGURE_MMU_EL(3)
  51. unsigned int plat_get_syscnt_freq2(void)
  52. {
  53. return SYS_COUNTER_FREQ_IN_TICKS;
  54. }
  55. void plat_cci_init(void)
  56. {
  57. #ifdef PLAT_RK_CCI_BASE
  58. /* Initialize CCI driver */
  59. cci_init(PLAT_RK_CCI_BASE, cci_map, ARRAY_SIZE(cci_map));
  60. #endif
  61. }
  62. void plat_cci_enable(void)
  63. {
  64. /*
  65. * Enable CCI coherency for this cluster.
  66. * No need for locks as no other cpu is active at the moment.
  67. */
  68. #ifdef PLAT_RK_CCI_BASE
  69. cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
  70. #endif
  71. }
  72. void plat_cci_disable(void)
  73. {
  74. #ifdef PLAT_RK_CCI_BASE
  75. cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
  76. #endif
  77. }