| 1 |
/* |
| 2 |
* Copyright (c) 2013-2023, ARM Limited and Contributors. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
#include <platform_def.h> |
| 10 |
|
| 11 |
#include <arch_helpers.h> |
| 12 |
#include <common/bl_common.h> |
| 13 |
#include <common/debug.h> |
| 14 |
#include <drivers/arm/cci.h> |
| 15 |
#include <lib/utils.h> |
| 16 |
#include <lib/xlat_tables/xlat_tables_compat.h> |
| 17 |
|
| 18 |
#include <plat_private.h> |
| 19 |
|
| 20 |
#ifdef PLAT_RK_CCI_BASE |
| 21 |
static 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); \ |
| 45 |
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); \ |
| 49 |
mmap_add(plat_rk_mmap); \ |
| 50 |
rockchip_plat_mmu_el##_el(); \ |
| 51 |
init_xlat_tables(); \ |
| 52 |
\ |
| 53 |
enable_mmu_el ## _el(0); \ |
| 54 |
} |
| 55 |
|
| 56 |
/* Define EL3 variants of the function initialising the MMU */ |
| 57 |
DEFINE_CONFIGURE_MMU_EL(3) |
| 58 |
|
| 59 |
unsigned int plat_get_syscnt_freq2(void) |
| 60 |
{ |
| 61 |
return SYS_COUNTER_FREQ_IN_TICKS; |
| 62 |
} |
| 63 |
|
| 64 |
void 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 |
|
| 72 |
void 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 |
|
| 83 |
void 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 |
} |