platform_common.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch_helpers.h>
  7. #include <common/bl_common.h>
  8. #include <common/debug.h>
  9. #include <mcsi/mcsi.h>
  10. #include <platform_def.h>
  11. #include <lib/utils.h>
  12. #include <lib/xlat_tables/xlat_tables.h>
  13. static const int cci_map[] = {
  14. PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX,
  15. PLAT_MT_CCI_CLUSTER1_SL_IFACE_IX
  16. };
  17. /* Table of regions to map using the MMU. */
  18. const mmap_region_t plat_mmap[] = {
  19. /* for TF text, RO, RW */
  20. MAP_REGION_FLAT(TZRAM_BASE, TZRAM_SIZE,
  21. MT_MEMORY | MT_RW | MT_SECURE),
  22. MAP_REGION_FLAT(MTK_DEV_RNG0_BASE, MTK_DEV_RNG0_SIZE,
  23. MT_DEVICE | MT_RW | MT_SECURE),
  24. MAP_REGION_FLAT(MTK_DEV_RNG1_BASE, MTK_DEV_RNG1_SIZE,
  25. MT_DEVICE | MT_RW | MT_SECURE),
  26. MAP_REGION_FLAT(MTK_DEV_RNG2_BASE, MTK_DEV_RNG2_SIZE,
  27. MT_DEVICE | MT_RW | MT_SECURE),
  28. { 0 }
  29. };
  30. /*******************************************************************************
  31. * Macro generating the code for the function setting up the pagetables as per
  32. * the platform memory map & initialize the mmu, for the given exception level
  33. ******************************************************************************/
  34. void plat_configure_mmu_el3(uintptr_t total_base,
  35. uintptr_t total_size,
  36. uintptr_t ro_start,
  37. uintptr_t ro_limit,
  38. uintptr_t coh_start,
  39. uintptr_t coh_limit)
  40. {
  41. mmap_add_region(total_base, total_base, total_size,
  42. MT_MEMORY | MT_RW | MT_SECURE);
  43. mmap_add_region(ro_start, ro_start, ro_limit - ro_start,
  44. MT_MEMORY | MT_RO | MT_SECURE);
  45. mmap_add_region(coh_start, coh_start, coh_limit - coh_start,
  46. MT_DEVICE | MT_RW | MT_SECURE);
  47. mmap_add(plat_mmap);
  48. init_xlat_tables();
  49. enable_mmu_el3(0);
  50. }
  51. unsigned int plat_get_syscnt_freq2(void)
  52. {
  53. return SYS_COUNTER_FREQ_IN_TICKS;
  54. }
  55. void plat_mtk_cci_init(void)
  56. {
  57. /* Initialize CCI driver */
  58. mcsi_init(PLAT_MT_CCI_BASE, ARRAY_SIZE(cci_map));
  59. }
  60. void plat_mtk_cci_enable(void)
  61. {
  62. /* Enable CCI coherency for this cluster.
  63. * No need for locks as no other cpu is active at the moment.
  64. */
  65. cci_enable_cluster_coherency(read_mpidr());
  66. }
  67. void plat_mtk_cci_disable(void)
  68. {
  69. cci_disable_cluster_coherency(read_mpidr());
  70. }
  71. void plat_mtk_cci_init_sf(void)
  72. {
  73. /* Init mcsi snoop filter. */
  74. cci_init_sf();
  75. }