blob: df51d895fcdbbd805bc3b225d0f0f180fcd6cf71 [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>
XiaoDong Huang4fad4db2023-06-25 15:55:42 +080016#include <lib/xlat_tables/xlat_tables_compat.h>
17
Tony Xief6118cc2016-01-15 17:17:32 +080018#include <plat_private.h>
19
20#ifdef PLAT_RK_CCI_BASE
21static const int cci_map[] = {
22 PLAT_RK_CCI_CLUSTER0_SL_IFACE_IX,
23 PLAT_RK_CCI_CLUSTER1_SL_IFACE_IX
24};
25#endif
26
27/******************************************************************************
28 * Macro generating the code for the function setting up the pagetables as per
29 * the platform memory map & initialize the mmu, for the given exception level
30 ******************************************************************************/
31#define DEFINE_CONFIGURE_MMU_EL(_el) \
32 void plat_configure_mmu_el ## _el(unsigned long total_base, \
33 unsigned long total_size, \
34 unsigned long ro_start, \
35 unsigned long ro_limit, \
36 unsigned long coh_start, \
37 unsigned long coh_limit) \
38 { \
39 mmap_add_region(total_base, total_base, \
40 total_size, \
41 MT_MEMORY | MT_RW | MT_SECURE); \
42 mmap_add_region(ro_start, ro_start, \
43 ro_limit - ro_start, \
44 MT_MEMORY | MT_RO | MT_SECURE); \
shengfei Xu9b9e5222022-09-30 08:56:21 +000045 if ((coh_limit - coh_start) != 0) \
46 mmap_add_region(coh_start, coh_start, \
47 coh_limit - coh_start, \
48 MT_DEVICE | MT_RW | MT_SECURE); \
Tony Xief6118cc2016-01-15 17:17:32 +080049 mmap_add(plat_rk_mmap); \
Lin Huang30e43392017-05-04 16:02:45 +080050 rockchip_plat_mmu_el##_el(); \
Tony Xief6118cc2016-01-15 17:17:32 +080051 init_xlat_tables(); \
52 \
53 enable_mmu_el ## _el(0); \
54 }
55
56/* Define EL3 variants of the function initialising the MMU */
57DEFINE_CONFIGURE_MMU_EL(3)
58
Antonio Nino Diaze82e29c2016-05-19 10:00:28 +010059unsigned int plat_get_syscnt_freq2(void)
Tony Xief6118cc2016-01-15 17:17:32 +080060{
61 return SYS_COUNTER_FREQ_IN_TICKS;
62}
63
64void plat_cci_init(void)
65{
66#ifdef PLAT_RK_CCI_BASE
67 /* Initialize CCI driver */
68 cci_init(PLAT_RK_CCI_BASE, cci_map, ARRAY_SIZE(cci_map));
69#endif
70}
71
72void plat_cci_enable(void)
73{
74 /*
75 * Enable CCI coherency for this cluster.
76 * No need for locks as no other cpu is active at the moment.
77 */
78#ifdef PLAT_RK_CCI_BASE
79 cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
80#endif
81}
82
83void plat_cci_disable(void)
84{
85#ifdef PLAT_RK_CCI_BASE
86 cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
87#endif
88}