blob: d408209d895a13f592c687c7f55ca893245d374d [file] [log] [blame]
Jorge Ramirez-Ortiza29d9a62017-06-28 10:11:31 +02001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
Jorge Ramirez-Ortiza29d9a62017-06-28 10:11:31 +02008#include <assert.h>
9#include <bl_common.h>
10#include <debug.h>
11#include <delay_timer.h>
12#include <errno.h>
13#include <mmio.h>
14#include <platform.h>
15#include <xlat_tables.h>
16#include "hi3798cv200.h"
17#include "platform_def.h"
18
19#define MAP_DDR MAP_REGION_FLAT(DDR_BASE, \
20 DDR_SIZE, \
21 MT_MEMORY | MT_RW | MT_NS)
22
23#define MAP_DEVICE MAP_REGION_FLAT(DEVICE_BASE, \
24 DEVICE_SIZE, \
25 MT_DEVICE | MT_RW | MT_SECURE)
26
Victor Chong662556a2017-10-28 01:59:41 +090027#define MAP_TSP_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \
28 TSP_SEC_MEM_SIZE, \
29 MT_MEMORY | MT_RW | MT_SECURE)
30
Victor Chongaa033472018-02-01 00:35:39 +090031#ifdef SPD_opteed
32#define MAP_OPTEE_PAGEABLE MAP_REGION_FLAT( \
33 POPLAR_OPTEE_PAGEABLE_LOAD_BASE, \
34 POPLAR_OPTEE_PAGEABLE_LOAD_SIZE, \
35 MT_MEMORY | MT_RW | MT_SECURE)
36#endif
Victor Chongaa033472018-02-01 00:35:39 +090037
Jorge Ramirez-Ortiza29d9a62017-06-28 10:11:31 +020038static const mmap_region_t poplar_mmap[] = {
39 MAP_DDR,
40 MAP_DEVICE,
Victor Chong662556a2017-10-28 01:59:41 +090041 MAP_TSP_MEM,
Victor Chongaa033472018-02-01 00:35:39 +090042#ifdef SPD_opteed
43 MAP_OPTEE_PAGEABLE,
44#endif
Jorge Ramirez-Ortiza29d9a62017-06-28 10:11:31 +020045 {0}
46};
47
48#define DEFINE_CONFIGURE_MMU_EL(_el) \
49 void plat_configure_mmu_el##_el(unsigned long total_base, \
50 unsigned long total_size, \
51 unsigned long ro_start, \
52 unsigned long ro_limit, \
53 unsigned long coh_start, \
54 unsigned long coh_limit) \
55 { \
56 mmap_add_region(total_base, total_base, \
57 total_size, \
58 MT_MEMORY | MT_RW | MT_SECURE); \
59 mmap_add_region(ro_start, ro_start, \
60 ro_limit - ro_start, \
61 MT_MEMORY | MT_RO | MT_SECURE); \
62 mmap_add_region(coh_start, coh_start, \
63 coh_limit - coh_start, \
64 MT_DEVICE | MT_RW | MT_SECURE); \
65 mmap_add(poplar_mmap); \
66 init_xlat_tables(); \
67 \
68 enable_mmu_el##_el(0); \
69 }
70
71DEFINE_CONFIGURE_MMU_EL(3)
72DEFINE_CONFIGURE_MMU_EL(1)
73
74unsigned int plat_get_syscnt_freq2(void)
75{
76 return SYS_COUNTER_FREQ_IN_TICKS;
77}