1 /*
2  * Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 
9 #include <platform_def.h>
10 
11 #include <common/debug.h>
12 #include <drivers/arm/pl011.h>
13 #include <drivers/console.h>
14 #include <fconf_hw_config_getter.h>
15 #include <plat/arm/common/plat_arm.h>
16 
17 static console_t fvp_runtime_console;
18 
19 /* Initialize the runtime console */
arm_console_runtime_init(void)20 void arm_console_runtime_init(void)
21 {
22 	uintptr_t uart_base;
23 	uint32_t uart_clk;
24 
25 	/*
26 	 * fconf APIs are not supported for RESET_TO_SP_MIN, RESET_TO_BL31 and
27 	 * BL2_AT_EL3 systems.
28 	 */
29 #if RESET_TO_SP_MIN || RESET_TO_BL31 || BL2_AT_EL3
30 	uart_base = PLAT_ARM_RUN_UART_BASE;
31 	uart_clk = PLAT_ARM_RUN_UART_CLK_IN_HZ;
32 #else
33 	uart_base = FCONF_GET_PROPERTY(hw_config, uart_serial_config,
34 					uart_base);
35 	uart_clk = FCONF_GET_PROPERTY(hw_config, uart_serial_config,
36 					uart_clk);
37 #endif
38 
39 	int rc = console_pl011_register(uart_base, uart_clk,
40 					ARM_CONSOLE_BAUDRATE,
41 					&fvp_runtime_console);
42 
43 	if (rc == 0) {
44 		panic();
45 	}
46 
47 	console_set_scope(&fvp_runtime_console, CONSOLE_FLAG_RUNTIME);
48 }
49 
arm_console_runtime_end(void)50 void arm_console_runtime_end(void)
51 {
52 	console_flush();
53 	(void)console_unregister(&fvp_runtime_console);
54 }
55