1 /*
2 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6 #include <assert.h>
7
8 #include <platform_def.h>
9
10 #include <common/debug.h>
11 #include <drivers/console.h>
12
13 #include <plat_marvell.h>
14
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 #define console_marvell_register console_16550_register
21 #endif
22
23 static console_t marvell_boot_console;
24 static console_t marvell_runtime_console;
25
26 /*******************************************************************************
27 * Functions that set up the console
28 ******************************************************************************/
29
30 /* Initialize the console to provide early debug support */
marvell_console_boot_init(void)31 void marvell_console_boot_init(void)
32 {
33 int rc =
34 console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE,
35 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
36 MARVELL_CONSOLE_BAUDRATE,
37 &marvell_boot_console);
38 if (rc == 0) {
39 /*
40 * The crash console doesn't use the multi console API, it uses
41 * the core console functions directly. It is safe to call panic
42 * and let it print debug information.
43 */
44 panic();
45 }
46
47 console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT);
48 }
49
marvell_console_boot_end(void)50 void marvell_console_boot_end(void)
51 {
52 console_flush();
53
54 (void)console_unregister(&marvell_boot_console);
55 }
56
57 /* Initialize the runtime console */
marvell_console_runtime_init(void)58 void marvell_console_runtime_init(void)
59 {
60 int rc =
61 console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE,
62 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
63 MARVELL_CONSOLE_BAUDRATE,
64 &marvell_runtime_console);
65 if (rc == 0)
66 panic();
67
68 console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME);
69 }
70
marvell_console_runtime_end(void)71 void marvell_console_runtime_end(void)
72 {
73 console_flush();
74
75 (void)console_unregister(&marvell_runtime_console);
76 }
77