blob: 51830c9c1e7fab0d62760b4418e7125c5718aee6 [file] [log] [blame]
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01001/*
Juan Pablo Condeb36eca12022-02-01 15:19:58 -05002 * Copyright (c) 2018-2022, 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
Madhukar Pappireddyd0cf0a92020-04-16 17:54:25 -050016#pragma weak arm_console_runtime_init
17#pragma weak arm_console_runtime_end
18
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010019/*******************************************************************************
20 * Functions that set up the console
21 ******************************************************************************/
Andre Przywara2b1b1a52020-01-25 00:58:35 +000022static console_t arm_boot_console;
23static console_t arm_runtime_console;
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010024
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{
Juan Pablo Condeb36eca12022-02-01 15:19:58 -050028 /* If the console was initialized already, don't initialize again */
29 if (arm_boot_console.base == PLAT_ARM_BOOT_UART_BASE) {
30 return;
31 }
32
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010033 int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE,
34 PLAT_ARM_BOOT_UART_CLK_IN_HZ,
35 ARM_CONSOLE_BAUDRATE,
36 &arm_boot_console);
37 if (rc == 0) {
38 /*
39 * The crash console doesn't use the multi console API, it uses
40 * the core console functions directly. It is safe to call panic
41 * and let it print debug information.
42 */
43 panic();
44 }
45
Andre Przywara2b1b1a52020-01-25 00:58:35 +000046 console_set_scope(&arm_boot_console, CONSOLE_FLAG_BOOT);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010047}
48
49void arm_console_boot_end(void)
50{
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050051 console_flush();
Andre Przywara2b1b1a52020-01-25 00:58:35 +000052 (void)console_unregister(&arm_boot_console);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010053}
54
55/* Initialize the runtime console */
56void arm_console_runtime_init(void)
57{
Usama Arif81eb5ce2019-02-11 16:35:42 +000058 int rc = console_pl011_register(PLAT_ARM_RUN_UART_BASE,
59 PLAT_ARM_RUN_UART_CLK_IN_HZ,
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010060 ARM_CONSOLE_BAUDRATE,
61 &arm_runtime_console);
62 if (rc == 0)
63 panic();
64
Andre Przywara2b1b1a52020-01-25 00:58:35 +000065 console_set_scope(&arm_runtime_console, CONSOLE_FLAG_RUNTIME);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010066}
67
68void arm_console_runtime_end(void)
69{
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050070 console_flush();
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010071}