summaryrefslogtreecommitdiffstats
path: root/plat/brcm/board/common/bcm_console.c
blob: 5f2009403a4c8ea1c5ba014d9ac79af30430e1b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <assert.h>

#include <common/debug.h>
#include <drivers/console.h>
#include <drivers/ti/uart/uart_16550.h>

#include <platform_def.h>

/*******************************************************************************
 * Functions that set up the console
 ******************************************************************************/
static console_t bcm_boot_console;
static console_t bcm_runtime_console;

/* Initialize the console to provide early debug support */
void bcm_console_boot_init(void)
{
	int rc = console_16550_register(PLAT_BRCM_BOOT_UART_BASE,
					PLAT_BRCM_BOOT_UART_CLK_IN_HZ,
					BRCM_CONSOLE_BAUDRATE,
					&bcm_boot_console);
	if (rc == 0) {
		/*
		 * The crash console doesn't use the multi console API, it uses
		 * the core console functions directly. It is safe to call panic
		 * and let it print debug information.
		 */
		panic();
	}

	console_set_scope(&bcm_boot_console, CONSOLE_FLAG_BOOT);
}

void bcm_console_boot_end(void)
{
	console_flush();

	(void)console_unregister(&bcm_boot_console);
}

/* Initialize the runtime console */
void bcm_console_runtime_init(void)
{
	int rc = console_16550_register(PLAT_BRCM_BL31_RUN_UART_BASE,
					PLAT_BRCM_BL31_RUN_UART_CLK_IN_HZ,
					BRCM_CONSOLE_BAUDRATE,
					&bcm_runtime_console);
	if (rc == 0)
		panic();

	console_set_scope(&bcm_runtime_console, CONSOLE_FLAG_RUNTIME);
}

void bcm_console_runtime_end(void)
{
	console_flush();

	(void)console_unregister(&bcm_runtime_console);
}