gxl_common.c 3.2 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <assert.h>
Carlo Caione's avatar
Carlo Caione committed
8
#include <bl31/interrupt_mgmt.h>
9
10
11
#include <common/bl_common.h>
#include <common/ep_info.h>
#include <lib/mmio.h>
Carlo Caione's avatar
Carlo Caione committed
12
#include <lib/xlat_tables/xlat_tables_v2.h>
13
14
15
16
17
18
#include <platform_def.h>
#include <stdint.h>

/*******************************************************************************
 * Platform memory map regions
 ******************************************************************************/
19
20
#define MAP_NSDRAM0	MAP_REGION_FLAT(AML_NSDRAM0_BASE,		\
					AML_NSDRAM0_SIZE,		\
21
22
					MT_MEMORY | MT_RW | MT_NS)

23
24
#define MAP_NSDRAM1	MAP_REGION_FLAT(AML_NSDRAM1_BASE,		\
					AML_NSDRAM1_SIZE,		\
25
26
					MT_MEMORY | MT_RW | MT_NS)

27
28
#define MAP_SEC_DEVICE0	MAP_REGION_FLAT(AML_SEC_DEVICE0_BASE,		\
					AML_SEC_DEVICE0_SIZE,		\
29
30
					MT_DEVICE | MT_RW | MT_SECURE)

31
32
#define MAP_SEC_DEVICE1	MAP_REGION_FLAT(AML_SEC_DEVICE1_BASE,		\
					AML_SEC_DEVICE1_SIZE,		\
33
34
					MT_DEVICE | MT_RW | MT_SECURE)

Carlo Caione's avatar
Carlo Caione committed
35
36
#define MAP_TZRAM	MAP_REGION_FLAT(AML_TZRAM_BASE,			\
					AML_TZRAM_SIZE,			\
37
38
					MT_DEVICE | MT_RW | MT_SECURE)

39
40
#define MAP_SEC_DEVICE2	MAP_REGION_FLAT(AML_SEC_DEVICE2_BASE,		\
					AML_SEC_DEVICE2_SIZE,		\
41
42
					MT_DEVICE | MT_RW | MT_SECURE)

43
44
#define MAP_SEC_DEVICE3	MAP_REGION_FLAT(AML_SEC_DEVICE3_BASE,		\
					AML_SEC_DEVICE3_SIZE,		\
45
46
					MT_DEVICE | MT_RW | MT_SECURE)

47
static const mmap_region_t gxl_mmap[] = {
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	MAP_NSDRAM0,
	MAP_NSDRAM1,
	MAP_SEC_DEVICE0,
	MAP_SEC_DEVICE1,
	MAP_TZRAM,
	MAP_SEC_DEVICE2,
	MAP_SEC_DEVICE3,
	{0}
};

/*******************************************************************************
 * Per-image regions
 ******************************************************************************/
#define MAP_BL31	MAP_REGION_FLAT(BL31_BASE,			\
				BL31_END - BL31_BASE,			\
				MT_MEMORY | MT_RW | MT_SECURE)

#define MAP_BL_CODE	MAP_REGION_FLAT(BL_CODE_BASE,			\
				BL_CODE_END - BL_CODE_BASE,		\
				MT_CODE | MT_SECURE)

#define MAP_BL_RO_DATA	MAP_REGION_FLAT(BL_RO_DATA_BASE,		\
				BL_RO_DATA_END - BL_RO_DATA_BASE,	\
				MT_RO_DATA | MT_SECURE)

#define MAP_BL_COHERENT	MAP_REGION_FLAT(BL_COHERENT_RAM_BASE,		\
				BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, \
				MT_DEVICE | MT_RW | MT_SECURE)

/*******************************************************************************
 * Function that sets up the translation tables.
 ******************************************************************************/
80
void aml_setup_page_tables(void)
81
82
{
#if IMAGE_BL31
83
	const mmap_region_t gxl_bl_mmap[] = {
84
85
86
87
88
89
90
91
92
93
		MAP_BL31,
		MAP_BL_CODE,
		MAP_BL_RO_DATA,
#if USE_COHERENT_MEM
		MAP_BL_COHERENT,
#endif
		{0}
	};
#endif

94
	mmap_add(gxl_bl_mmap);
95

96
	mmap_add(gxl_mmap);
97
98
99
100
101
102
103
104
105
106
107

	init_xlat_tables();
}

/*******************************************************************************
 * Function that returns the system counter frequency
 ******************************************************************************/
unsigned int plat_get_syscnt_freq2(void)
{
	uint32_t val;

108
	val = mmio_read_32(AML_SYS_CPU_CFG7);
109
	val &= 0xFDFFFFFF;
110
	mmio_write_32(AML_SYS_CPU_CFG7, val);
111

112
	val = mmio_read_32(AML_AO_TIMESTAMP_CNTL);
113
	val &= 0xFFFFFE00;
114
	mmio_write_32(AML_AO_TIMESTAMP_CNTL, val);
115

116
	return AML_OSC24M_CLK_IN_HZ;
117
}