blob: 29cb378275803b901e9907d8da58f5d45d579d07 [file] [log] [blame]
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01009#include <platform_def.h>
10
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <common/debug.h>
12#include <drivers/arm/pl011.h>
13#include <drivers/console.h>
14
15#include <plat_arm.h>
16
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010017/*******************************************************************************
18 * Functions that set up the console
19 ******************************************************************************/
20#if MULTI_CONSOLE_API
21static console_pl011_t arm_boot_console;
22static console_pl011_t arm_runtime_console;
23#endif
24
25/* Initialize the console to provide early debug support */
Daniel Boulbyf45a4bb2018-09-18 13:26:03 +010026void __init arm_console_boot_init(void)
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010027{
28#if MULTI_CONSOLE_API
29 int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE,
30 PLAT_ARM_BOOT_UART_CLK_IN_HZ,
31 ARM_CONSOLE_BAUDRATE,
32 &arm_boot_console);
33 if (rc == 0) {
34 /*
35 * The crash console doesn't use the multi console API, it uses
36 * the core console functions directly. It is safe to call panic
37 * and let it print debug information.
38 */
39 panic();
40 }
41
42 console_set_scope(&arm_boot_console.console, CONSOLE_FLAG_BOOT);
43#else
44 (void)console_init(PLAT_ARM_BOOT_UART_BASE,
45 PLAT_ARM_BOOT_UART_CLK_IN_HZ,
46 ARM_CONSOLE_BAUDRATE);
47#endif /* MULTI_CONSOLE_API */
48}
49
50void arm_console_boot_end(void)
51{
52 (void)console_flush();
53
54#if MULTI_CONSOLE_API
55 (void)console_unregister(&arm_boot_console.console);
56#else
57 console_uninit();
58#endif /* MULTI_CONSOLE_API */
59}
60
61/* Initialize the runtime console */
62void arm_console_runtime_init(void)
63{
64#if MULTI_CONSOLE_API
65 int rc = console_pl011_register(PLAT_ARM_BL31_RUN_UART_BASE,
66 PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ,
67 ARM_CONSOLE_BAUDRATE,
68 &arm_runtime_console);
69 if (rc == 0)
70 panic();
71
72 console_set_scope(&arm_runtime_console.console, CONSOLE_FLAG_RUNTIME);
73#else
74 (void)console_init(PLAT_ARM_BL31_RUN_UART_BASE,
75 PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ,
76 ARM_CONSOLE_BAUDRATE);
77#endif /* MULTI_CONSOLE_API */
78}
79
80void arm_console_runtime_end(void)
81{
82 (void)console_flush();
83
84#if MULTI_CONSOLE_API
85 (void)console_unregister(&arm_runtime_console.console);
86#else
87 console_uninit();
88#endif /* MULTI_CONSOLE_API */
89}