blob: 549806505cb759ab38148a4cf9a4e19bd95d0004 [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>
8#include <arm_gic.h>
9#include <assert.h>
10#include <bl_common.h>
11#include <debug.h>
12#include <delay_timer.h>
13#include <errno.h>
14#include <mmio.h>
15#include <platform.h>
16#include <xlat_tables.h>
17#include "hi3798cv200.h"
18#include "platform_def.h"
19
20#define MAP_DDR MAP_REGION_FLAT(DDR_BASE, \
21 DDR_SIZE, \
22 MT_MEMORY | MT_RW | MT_NS)
23
24#define MAP_DEVICE MAP_REGION_FLAT(DEVICE_BASE, \
25 DEVICE_SIZE, \
26 MT_DEVICE | MT_RW | MT_SECURE)
27
Victor Chong662556a2017-10-28 01:59:41 +090028#define MAP_TSP_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \
29 TSP_SEC_MEM_SIZE, \
30 MT_MEMORY | MT_RW | MT_SECURE)
31
Victor Chongaa033472018-02-01 00:35:39 +090032#if LOAD_IMAGE_V2
33#ifdef SPD_opteed
34#define MAP_OPTEE_PAGEABLE MAP_REGION_FLAT( \
35 POPLAR_OPTEE_PAGEABLE_LOAD_BASE, \
36 POPLAR_OPTEE_PAGEABLE_LOAD_SIZE, \
37 MT_MEMORY | MT_RW | MT_SECURE)
38#endif
39#endif
40
Jorge Ramirez-Ortiza29d9a62017-06-28 10:11:31 +020041static const mmap_region_t poplar_mmap[] = {
42 MAP_DDR,
43 MAP_DEVICE,
Victor Chong662556a2017-10-28 01:59:41 +090044 MAP_TSP_MEM,
Victor Chongaa033472018-02-01 00:35:39 +090045#if LOAD_IMAGE_V2
46#ifdef SPD_opteed
47 MAP_OPTEE_PAGEABLE,
48#endif
49#endif
Jorge Ramirez-Ortiza29d9a62017-06-28 10:11:31 +020050 {0}
51};
52
53#define DEFINE_CONFIGURE_MMU_EL(_el) \
54 void plat_configure_mmu_el##_el(unsigned long total_base, \
55 unsigned long total_size, \
56 unsigned long ro_start, \
57 unsigned long ro_limit, \
58 unsigned long coh_start, \
59 unsigned long coh_limit) \
60 { \
61 mmap_add_region(total_base, total_base, \
62 total_size, \
63 MT_MEMORY | MT_RW | MT_SECURE); \
64 mmap_add_region(ro_start, ro_start, \
65 ro_limit - ro_start, \
66 MT_MEMORY | MT_RO | MT_SECURE); \
67 mmap_add_region(coh_start, coh_start, \
68 coh_limit - coh_start, \
69 MT_DEVICE | MT_RW | MT_SECURE); \
70 mmap_add(poplar_mmap); \
71 init_xlat_tables(); \
72 \
73 enable_mmu_el##_el(0); \
74 }
75
76DEFINE_CONFIGURE_MMU_EL(3)
77DEFINE_CONFIGURE_MMU_EL(1)
78
79unsigned int plat_get_syscnt_freq2(void)
80{
81 return SYS_COUNTER_FREQ_IN_TICKS;
82}