blob: d563dfd8f9dc050e8cd6647397dbb1293bfe8ee7 [file] [log] [blame]
Tony Xief6118cc2016-01-15 17:17:32 +08001/*
shengfei Xu9b9e5222022-09-30 08:56:21 +00002 * Copyright (c) 2013-2023, ARM Limited and Contributors. All rights reserved.
Tony Xief6118cc2016-01-15 17:17:32 +08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Tony Xief6118cc2016-01-15 17:17:32 +08005 */
6
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#include <string.h>
8
9#include <platform_def.h>
10
Tony Xief6118cc2016-01-15 17:17:32 +080011#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <common/bl_common.h>
13#include <common/debug.h>
14#include <drivers/arm/cci.h>
15#include <lib/utils.h>
Tony Xief6118cc2016-01-15 17:17:32 +080016#include <plat_private.h>
17
18#ifdef PLAT_RK_CCI_BASE
19static const int cci_map[] = {
20 PLAT_RK_CCI_CLUSTER0_SL_IFACE_IX,
21 PLAT_RK_CCI_CLUSTER1_SL_IFACE_IX
22};
23#endif
24
25/******************************************************************************
26 * Macro generating the code for the function setting up the pagetables as per
27 * the platform memory map & initialize the mmu, for the given exception level
28 ******************************************************************************/
29#define DEFINE_CONFIGURE_MMU_EL(_el) \
30 void plat_configure_mmu_el ## _el(unsigned long total_base, \
31 unsigned long total_size, \
32 unsigned long ro_start, \
33 unsigned long ro_limit, \
34 unsigned long coh_start, \
35 unsigned long coh_limit) \
36 { \
37 mmap_add_region(total_base, total_base, \
38 total_size, \
39 MT_MEMORY | MT_RW | MT_SECURE); \
40 mmap_add_region(ro_start, ro_start, \
41 ro_limit - ro_start, \
42 MT_MEMORY | MT_RO | MT_SECURE); \
shengfei Xu9b9e5222022-09-30 08:56:21 +000043 if ((coh_limit - coh_start) != 0) \
44 mmap_add_region(coh_start, coh_start, \
45 coh_limit - coh_start, \
46 MT_DEVICE | MT_RW | MT_SECURE); \
Tony Xief6118cc2016-01-15 17:17:32 +080047 mmap_add(plat_rk_mmap); \
Lin Huang30e43392017-05-04 16:02:45 +080048 rockchip_plat_mmu_el##_el(); \
Tony Xief6118cc2016-01-15 17:17:32 +080049 init_xlat_tables(); \
50 \
51 enable_mmu_el ## _el(0); \
52 }
53
54/* Define EL3 variants of the function initialising the MMU */
55DEFINE_CONFIGURE_MMU_EL(3)
56
Antonio Nino Diaze82e29c2016-05-19 10:00:28 +010057unsigned int plat_get_syscnt_freq2(void)
Tony Xief6118cc2016-01-15 17:17:32 +080058{
59 return SYS_COUNTER_FREQ_IN_TICKS;
60}
61
62void plat_cci_init(void)
63{
64#ifdef PLAT_RK_CCI_BASE
65 /* Initialize CCI driver */
66 cci_init(PLAT_RK_CCI_BASE, cci_map, ARRAY_SIZE(cci_map));
67#endif
68}
69
70void plat_cci_enable(void)
71{
72 /*
73 * Enable CCI coherency for this cluster.
74 * No need for locks as no other cpu is active at the moment.
75 */
76#ifdef PLAT_RK_CCI_BASE
77 cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
78#endif
79}
80
81void plat_cci_disable(void)
82{
83#ifdef PLAT_RK_CCI_BASE
84 cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
85#endif
86}