arm_console.c 1.62 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3
4
5
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
6

7
#include <assert.h>
8

9
10
#include <platform_def.h>

11
12
13
#include <common/debug.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
14
#include <plat/arm/common/plat_arm.h>
15

16
17
18
#pragma weak arm_console_runtime_init
#pragma weak arm_console_runtime_end

19
20
21
/*******************************************************************************
 * Functions that set up the console
 ******************************************************************************/
22
23
static console_t arm_boot_console;
static console_t arm_runtime_console;
24
25

/* Initialize the console to provide early debug support */
26
void __init arm_console_boot_init(void)
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
	int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE,
					PLAT_ARM_BOOT_UART_CLK_IN_HZ,
					ARM_CONSOLE_BAUDRATE,
					&arm_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();
	}

41
	console_set_scope(&arm_boot_console, CONSOLE_FLAG_BOOT);
42
43
44
45
46
}

void arm_console_boot_end(void)
{
	(void)console_flush();
47
	(void)console_unregister(&arm_boot_console);
48
49
50
51
52
}

/* Initialize the runtime console */
void arm_console_runtime_init(void)
{
53
54
	int rc = console_pl011_register(PLAT_ARM_RUN_UART_BASE,
					PLAT_ARM_RUN_UART_CLK_IN_HZ,
55
56
57
58
59
					ARM_CONSOLE_BAUDRATE,
					&arm_runtime_console);
	if (rc == 0)
		panic();

60
	console_set_scope(&arm_runtime_console, CONSOLE_FLAG_RUNTIME);
61
62
63
64
65
66
}

void arm_console_runtime_end(void)
{
	(void)console_flush();
}