blob: 17166618af6c4bd61afa575059d9cae7e614d671 [file] [log] [blame]
Konstantin Porotchkind8e39572018-11-14 17:15:08 +02001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007
Konstantin Porotchkind8e39572018-11-14 17:15:08 +02008#include <platform_def.h>
9
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <common/debug.h>
11#include <drivers/console.h>
12
13#include <plat_marvell.h>
14
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020015#ifdef PLAT_a3700
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000016#include <drivers/marvell/uart/a3700_console.h>
Andre Przywarac5e8fec2020-01-25 23:55:08 +000017#define console_marvell_register console_a3700_register
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020018#else
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000019#include <drivers/ti/uart/uart_16550.h>
Andre Przywarac5e8fec2020-01-25 23:55:08 +000020#define console_marvell_register console_16550_register
21#endif
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020022
Andre Przywara98b5a112020-01-25 00:58:35 +000023static console_t marvell_boot_console;
24static console_t marvell_runtime_console;
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020025
26/*******************************************************************************
27 * Functions that set up the console
28 ******************************************************************************/
29
30/* Initialize the console to provide early debug support */
31void marvell_console_boot_init(void)
32{
33 int rc =
Andre Przywarac5e8fec2020-01-25 23:55:08 +000034 console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE,
35 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
36 MARVELL_CONSOLE_BAUDRATE,
37 &marvell_boot_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020038 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
Andre Przywara98b5a112020-01-25 00:58:35 +000047 console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020048}
49
50void marvell_console_boot_end(void)
51{
52 (void)console_flush();
53
Andre Przywara98b5a112020-01-25 00:58:35 +000054 (void)console_unregister(&marvell_boot_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020055}
56
57/* Initialize the runtime console */
58void marvell_console_runtime_init(void)
59{
60 int rc =
Andre Przywarac5e8fec2020-01-25 23:55:08 +000061 console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE,
62 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
63 MARVELL_CONSOLE_BAUDRATE,
64 &marvell_runtime_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020065 if (rc == 0)
66 panic();
67
Andre Przywara98b5a112020-01-25 00:58:35 +000068 console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020069}
70
71void marvell_console_runtime_end(void)
72{
73 (void)console_flush();
74
Andre Przywara98b5a112020-01-25 00:58:35 +000075 (void)console_unregister(&marvell_runtime_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020076}