blob: 0cac5d99974abc71a156fe17da2fe0884e3eeb0e [file] [log] [blame]
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01001/*
Ambroise Vincent500163d2019-04-24 10:34:17 +01002 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01003 *
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>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000014#include <plat/arm/common/plat_arm.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000015
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010016/*******************************************************************************
17 * Functions that set up the console
18 ******************************************************************************/
Andre Przywara2b1b1a52020-01-25 00:58:35 +000019static console_t arm_boot_console;
20static console_t arm_runtime_console;
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010021
22/* Initialize the console to provide early debug support */
Daniel Boulbyf45a4bb2018-09-18 13:26:03 +010023void __init arm_console_boot_init(void)
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010024{
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010025 int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE,
26 PLAT_ARM_BOOT_UART_CLK_IN_HZ,
27 ARM_CONSOLE_BAUDRATE,
28 &arm_boot_console);
29 if (rc == 0) {
30 /*
31 * The crash console doesn't use the multi console API, it uses
32 * the core console functions directly. It is safe to call panic
33 * and let it print debug information.
34 */
35 panic();
36 }
37
Andre Przywara2b1b1a52020-01-25 00:58:35 +000038 console_set_scope(&arm_boot_console, CONSOLE_FLAG_BOOT);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010039}
40
41void arm_console_boot_end(void)
42{
43 (void)console_flush();
Andre Przywara2b1b1a52020-01-25 00:58:35 +000044 (void)console_unregister(&arm_boot_console);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010045}
46
47/* Initialize the runtime console */
48void arm_console_runtime_init(void)
49{
Usama Arif81eb5ce2019-02-11 16:35:42 +000050 int rc = console_pl011_register(PLAT_ARM_RUN_UART_BASE,
51 PLAT_ARM_RUN_UART_CLK_IN_HZ,
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010052 ARM_CONSOLE_BAUDRATE,
53 &arm_runtime_console);
54 if (rc == 0)
55 panic();
56
Andre Przywara2b1b1a52020-01-25 00:58:35 +000057 console_set_scope(&arm_runtime_console, CONSOLE_FLAG_RUNTIME);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010058}
59
60void arm_console_runtime_end(void)
61{
62 (void)console_flush();
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010063}