2 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
8 #include <common/bl_common.h>
9 #include <common/debug.h>
10 #include <common/ep_info.h>
11 #include <bl31/interrupt_mgmt.h>
12 #include <meson_console.h>
14 #include <platform_def.h>
16 #include <lib/xlat_tables/xlat_tables_v2.h>
18 /*******************************************************************************
19 * Platform memory map regions
20 ******************************************************************************/
21 #define MAP_NSDRAM0 MAP_REGION_FLAT(AML_NSDRAM0_BASE, \
23 MT_MEMORY | MT_RW | MT_NS)
25 #define MAP_NSDRAM1 MAP_REGION_FLAT(AML_NSDRAM1_BASE, \
27 MT_MEMORY | MT_RW | MT_NS)
29 #define MAP_SEC_DEVICE0 MAP_REGION_FLAT(AML_SEC_DEVICE0_BASE, \
30 AML_SEC_DEVICE0_SIZE, \
31 MT_DEVICE | MT_RW | MT_SECURE)
33 #define MAP_SEC_DEVICE1 MAP_REGION_FLAT(AML_SEC_DEVICE1_BASE, \
34 AML_SEC_DEVICE1_SIZE, \
35 MT_DEVICE | MT_RW | MT_SECURE)
37 #define MAP_TZRAM MAP_REGION_FLAT(AML_TZRAM_BASE, \
39 MT_DEVICE | MT_RW | MT_SECURE)
41 #define MAP_SEC_DEVICE2 MAP_REGION_FLAT(AML_SEC_DEVICE2_BASE, \
42 AML_SEC_DEVICE2_SIZE, \
43 MT_DEVICE | MT_RW | MT_SECURE)
45 #define MAP_SEC_DEVICE3 MAP_REGION_FLAT(AML_SEC_DEVICE3_BASE, \
46 AML_SEC_DEVICE3_SIZE, \
47 MT_DEVICE | MT_RW | MT_SECURE)
49 static const mmap_region_t gxl_mmap
[] = {
60 /*******************************************************************************
62 ******************************************************************************/
63 #define MAP_BL31 MAP_REGION_FLAT(BL31_BASE, \
64 BL31_END - BL31_BASE, \
65 MT_MEMORY | MT_RW | MT_SECURE)
67 #define MAP_BL_CODE MAP_REGION_FLAT(BL_CODE_BASE, \
68 BL_CODE_END - BL_CODE_BASE, \
71 #define MAP_BL_RO_DATA MAP_REGION_FLAT(BL_RO_DATA_BASE, \
72 BL_RO_DATA_END - BL_RO_DATA_BASE, \
73 MT_RO_DATA | MT_SECURE)
75 #define MAP_BL_COHERENT MAP_REGION_FLAT(BL_COHERENT_RAM_BASE, \
76 BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, \
77 MT_DEVICE | MT_RW | MT_SECURE)
79 /*******************************************************************************
80 * Function that sets up the translation tables.
81 ******************************************************************************/
82 void aml_setup_page_tables(void)
85 const mmap_region_t gxl_bl_mmap
[] = {
96 mmap_add(gxl_bl_mmap
);
103 /*******************************************************************************
104 * Function that sets up the console
105 ******************************************************************************/
106 static console_meson_t gxl_console
;
108 void aml_console_init(void)
110 int rc
= console_meson_register(AML_UART0_AO_BASE
,
111 AML_UART0_AO_CLK_IN_HZ
,
116 * The crash console doesn't use the multi console API, it uses
117 * the core console functions directly. It is safe to call panic
118 * and let it print debug information.
123 console_set_scope(&gxl_console
.console
,
124 CONSOLE_FLAG_BOOT
| CONSOLE_FLAG_RUNTIME
);
127 /*******************************************************************************
128 * Function that returns the system counter frequency
129 ******************************************************************************/
130 unsigned int plat_get_syscnt_freq2(void)
134 val
= mmio_read_32(AML_SYS_CPU_CFG7
);
136 mmio_write_32(AML_SYS_CPU_CFG7
, val
);
138 val
= mmio_read_32(AML_AO_TIMESTAMP_CNTL
);
140 mmio_write_32(AML_AO_TIMESTAMP_CNTL
, val
);
142 return AML_OSC24M_CLK_IN_HZ
;