1*54fd6939SJiyong Park /*
2*54fd6939SJiyong Park * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3*54fd6939SJiyong Park *
4*54fd6939SJiyong Park * SPDX-License-Identifier: BSD-3-Clause
5*54fd6939SJiyong Park */
6*54fd6939SJiyong Park
7*54fd6939SJiyong Park #include <assert.h>
8*54fd6939SJiyong Park
9*54fd6939SJiyong Park #include <platform_def.h>
10*54fd6939SJiyong Park
11*54fd6939SJiyong Park #include <common/debug.h>
12*54fd6939SJiyong Park #include <drivers/arm/pl011.h>
13*54fd6939SJiyong Park #include <drivers/console.h>
14*54fd6939SJiyong Park #include <plat/arm/common/plat_arm.h>
15*54fd6939SJiyong Park
16*54fd6939SJiyong Park #pragma weak arm_console_runtime_init
17*54fd6939SJiyong Park #pragma weak arm_console_runtime_end
18*54fd6939SJiyong Park
19*54fd6939SJiyong Park /*******************************************************************************
20*54fd6939SJiyong Park * Functions that set up the console
21*54fd6939SJiyong Park ******************************************************************************/
22*54fd6939SJiyong Park static console_t arm_boot_console;
23*54fd6939SJiyong Park static console_t arm_runtime_console;
24*54fd6939SJiyong Park
25*54fd6939SJiyong Park /* Initialize the console to provide early debug support */
arm_console_boot_init(void)26*54fd6939SJiyong Park void __init arm_console_boot_init(void)
27*54fd6939SJiyong Park {
28*54fd6939SJiyong Park int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE,
29*54fd6939SJiyong Park PLAT_ARM_BOOT_UART_CLK_IN_HZ,
30*54fd6939SJiyong Park ARM_CONSOLE_BAUDRATE,
31*54fd6939SJiyong Park &arm_boot_console);
32*54fd6939SJiyong Park if (rc == 0) {
33*54fd6939SJiyong Park /*
34*54fd6939SJiyong Park * The crash console doesn't use the multi console API, it uses
35*54fd6939SJiyong Park * the core console functions directly. It is safe to call panic
36*54fd6939SJiyong Park * and let it print debug information.
37*54fd6939SJiyong Park */
38*54fd6939SJiyong Park panic();
39*54fd6939SJiyong Park }
40*54fd6939SJiyong Park
41*54fd6939SJiyong Park console_set_scope(&arm_boot_console, CONSOLE_FLAG_BOOT);
42*54fd6939SJiyong Park }
43*54fd6939SJiyong Park
arm_console_boot_end(void)44*54fd6939SJiyong Park void arm_console_boot_end(void)
45*54fd6939SJiyong Park {
46*54fd6939SJiyong Park console_flush();
47*54fd6939SJiyong Park (void)console_unregister(&arm_boot_console);
48*54fd6939SJiyong Park }
49*54fd6939SJiyong Park
50*54fd6939SJiyong Park /* Initialize the runtime console */
arm_console_runtime_init(void)51*54fd6939SJiyong Park void arm_console_runtime_init(void)
52*54fd6939SJiyong Park {
53*54fd6939SJiyong Park int rc = console_pl011_register(PLAT_ARM_RUN_UART_BASE,
54*54fd6939SJiyong Park PLAT_ARM_RUN_UART_CLK_IN_HZ,
55*54fd6939SJiyong Park ARM_CONSOLE_BAUDRATE,
56*54fd6939SJiyong Park &arm_runtime_console);
57*54fd6939SJiyong Park if (rc == 0)
58*54fd6939SJiyong Park panic();
59*54fd6939SJiyong Park
60*54fd6939SJiyong Park console_set_scope(&arm_runtime_console, CONSOLE_FLAG_RUNTIME);
61*54fd6939SJiyong Park }
62*54fd6939SJiyong Park
arm_console_runtime_end(void)63*54fd6939SJiyong Park void arm_console_runtime_end(void)
64*54fd6939SJiyong Park {
65*54fd6939SJiyong Park console_flush();
66*54fd6939SJiyong Park }
67