xref: /rk3399_ARM-atf/plat/arm/common/tsp/arm_tsp_setup.c (revision b56dc2a98cab0ea618cce83b3702814b7fcafd7d)
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 <bl_common.h>
9 #include <console.h>
10 #include <debug.h>
11 #include <pl011.h>
12 #include <plat_arm.h>
13 #include <platform_def.h>
14 #include <platform_tsp.h>
15 
16 #define BL32_END (unsigned long)(&__BL32_END__)
17 
18 /* Weak definitions may be overridden in specific ARM standard platform */
19 #pragma weak tsp_early_platform_setup
20 #pragma weak tsp_platform_setup
21 #pragma weak tsp_plat_arch_setup
22 
23 
24 /*******************************************************************************
25  * Initialize the UART
26  ******************************************************************************/
27 #if MULTI_CONSOLE_API
28 static console_pl011_t arm_tsp_runtime_console;
29 #endif
30 
31 void arm_tsp_early_platform_setup(void)
32 {
33 #if MULTI_CONSOLE_API
34 	/*
35 	 * Initialize a different console than already in use to display
36 	 * messages from TSP
37 	 */
38 	int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
39 					PLAT_ARM_TSP_UART_CLK_IN_HZ,
40 					ARM_CONSOLE_BAUDRATE,
41 					&arm_tsp_runtime_console);
42 	if (rc == 0)
43 		panic();
44 
45 	console_set_scope(&arm_tsp_runtime_console.console,
46 			  CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
47 #else
48 	console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ,
49 			ARM_CONSOLE_BAUDRATE);
50 #endif /* MULTI_CONSOLE_API */
51 }
52 
53 void tsp_early_platform_setup(void)
54 {
55 	arm_tsp_early_platform_setup();
56 }
57 
58 /*******************************************************************************
59  * Perform platform specific setup placeholder
60  ******************************************************************************/
61 void tsp_platform_setup(void)
62 {
63 	plat_arm_gic_driver_init();
64 }
65 
66 /*******************************************************************************
67  * Perform the very early platform specific architectural setup here. At the
68  * moment this is only intializes the MMU
69  ******************************************************************************/
70 void tsp_plat_arch_setup(void)
71 {
72 	arm_setup_page_tables(BL32_BASE,
73 			      (BL32_END - BL32_BASE),
74 			      BL_CODE_BASE,
75 			      BL_CODE_END,
76 			      BL_RO_DATA_BASE,
77 			      BL_RO_DATA_END
78 #if USE_COHERENT_MEM
79 			      , BL_COHERENT_RAM_BASE,
80 			      BL_COHERENT_RAM_END
81 #endif
82 			      );
83 	enable_mmu_el1(0);
84 }
85