marvell_console.c 1.84 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3
4
5
6
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
#include <assert.h>
7

8
9
#include <platform_def.h>

10
11
12
13
14
#include <common/debug.h>
#include <drivers/console.h>

#include <plat_marvell.h>

15
#ifdef PLAT_a3700
16
#include <drivers/marvell/uart/a3700_console.h>
17
#define console_marvell_register console_a3700_register
18
#else
19
#include <drivers/ti/uart/uart_16550.h>
20
21
#define console_marvell_register console_16550_register
#endif
22

23
24
static console_t marvell_boot_console;
static console_t marvell_runtime_console;
25
26
27
28
29
30
31
32
33

/*******************************************************************************
 * Functions that set up the console
 ******************************************************************************/

/* Initialize the console to provide early debug support */
void marvell_console_boot_init(void)
{
	int rc =
34
35
36
37
	console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE,
				 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
				 MARVELL_CONSOLE_BAUDRATE,
				 &marvell_boot_console);
38
39
40
41
42
43
44
45
46
	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();
	}

47
	console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT);
48
49
50
51
}

void marvell_console_boot_end(void)
{
52
	console_flush();
53

54
	(void)console_unregister(&marvell_boot_console);
55
56
57
58
59
60
}

/* Initialize the runtime console */
void marvell_console_runtime_init(void)
{
	int rc =
61
62
63
64
	console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE,
				 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
				 MARVELL_CONSOLE_BAUDRATE,
				 &marvell_runtime_console);
65
66
67
	if (rc == 0)
		panic();

68
	console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME);
69
70
71
72
}

void marvell_console_runtime_end(void)
{
73
	console_flush();
74

75
	(void)console_unregister(&marvell_runtime_console);
76
}