3cf88251f1fb2e4292fcb343de4e6437b6ac84a2
[project/bcm63xx/atf.git] / plat / arm / common / tsp / arm_tsp_setup.c
1 /*
2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <arm_def.h>
8 #include <assert.h>
9 #include <bl_common.h>
10 #include <console.h>
11 #include <debug.h>
12 #include <pl011.h>
13 #include <plat_arm.h>
14 #include <platform_def.h>
15 #include <platform_tsp.h>
16
17 #define BL32_END (unsigned long)(&__BL32_END__)
18
19 /* Weak definitions may be overridden in specific ARM standard platform */
20 #pragma weak tsp_early_platform_setup
21 #pragma weak tsp_platform_setup
22 #pragma weak tsp_plat_arch_setup
23
24 #define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \
25 BL32_BASE, \
26 BL32_END - BL32_BASE, \
27 MT_MEMORY | MT_RW | MT_SECURE)
28
29 /*******************************************************************************
30 * Initialize the UART
31 ******************************************************************************/
32 #if MULTI_CONSOLE_API
33 static console_pl011_t arm_tsp_runtime_console;
34 #endif
35
36 void arm_tsp_early_platform_setup(void)
37 {
38 #if MULTI_CONSOLE_API
39 /*
40 * Initialize a different console than already in use to display
41 * messages from TSP
42 */
43 int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
44 PLAT_ARM_TSP_UART_CLK_IN_HZ,
45 ARM_CONSOLE_BAUDRATE,
46 &arm_tsp_runtime_console);
47 if (rc == 0)
48 panic();
49
50 console_set_scope(&arm_tsp_runtime_console.console,
51 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
52 #else
53 console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ,
54 ARM_CONSOLE_BAUDRATE);
55 #endif /* MULTI_CONSOLE_API */
56 }
57
58 void tsp_early_platform_setup(void)
59 {
60 arm_tsp_early_platform_setup();
61 }
62
63 /*******************************************************************************
64 * Perform platform specific setup placeholder
65 ******************************************************************************/
66 void tsp_platform_setup(void)
67 {
68 plat_arm_gic_driver_init();
69 }
70
71 /*******************************************************************************
72 * Perform the very early platform specific architectural setup here. At the
73 * moment this is only intializes the MMU
74 ******************************************************************************/
75 void tsp_plat_arch_setup(void)
76 {
77 #if USE_COHERENT_MEM
78 /* Ensure ARM platforms dont use coherent memory in TSP */
79 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
80 #endif
81
82 const mmap_region_t bl_regions[] = {
83 MAP_BL_TSP_TOTAL,
84 ARM_MAP_BL_RO,
85 {0}
86 };
87
88 setup_page_tables(bl_regions, plat_arm_get_mmap());
89 enable_mmu_el1(0);
90 }