xref: /rk3399_ARM-atf/plat/arm/board/fvp/fvp_console.c (revision 5be66449a98c341493b3cb70bde171399912abd9)
1 /*
2  * Copyright (c) 2020-2025, 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 */
20 void arm_console_runtime_init(void)
21 {
22 	uintptr_t uart_base;
23 	uint32_t uart_clk;
24 
25 	/* If the console was initialized already, don't initialize again */
26 	if (fvp_runtime_console.base != 0UL) {
27 		return;
28 	}
29 
30 	/*
31 	 * fconf APIs are not supported for RESET_TO_SP_MIN, RESET_TO_BL31 and
32 	 * RESET_TO_BL2 systems.
33 	 */
34 #if RESET_TO_SP_MIN || RESET_TO_BL31 || RESET_TO_BL2
35 	uart_base = PLAT_ARM_RUN_UART_BASE;
36 	uart_clk = PLAT_ARM_RUN_UART_CLK_IN_HZ;
37 #else
38 	uart_base = FCONF_GET_PROPERTY(hw_config, uart_serial_config,
39 					uart_base);
40 	uart_clk = FCONF_GET_PROPERTY(hw_config, uart_serial_config,
41 					uart_clk);
42 #endif
43 
44 	int rc = console_pl011_register(uart_base, uart_clk,
45 					ARM_CONSOLE_BAUDRATE,
46 					&fvp_runtime_console);
47 
48 	if (rc == 0) {
49 		panic();
50 	}
51 
52 	console_set_scope(&fvp_runtime_console, CONSOLE_FLAG_RUNTIME);
53 }
54