blob: 6829658fa6f893d946a276199ef9e315f6beec10 [file] [log] [blame]
Konstantin Porotchkind8e39572018-11-14 17:15:08 +02001/*
Jimmy Brisson39f9eee2020-08-05 13:44:05 -05002 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
Konstantin Porotchkind8e39572018-11-14 17:15:08 +02003 *
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 =
Pali Rohár168d81e2021-05-14 13:21:56 +020034 console_marvell_register(PLAT_MARVELL_UART_BASE,
35 PLAT_MARVELL_UART_CLK_IN_HZ,
Andre Przywarac5e8fec2020-01-25 23:55:08 +000036 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{
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050052 console_flush();
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020053
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 =
Pali Rohár168d81e2021-05-14 13:21:56 +020061 console_marvell_register(PLAT_MARVELL_UART_BASE,
62 PLAT_MARVELL_UART_CLK_IN_HZ,
Andre Przywarac5e8fec2020-01-25 23:55:08 +000063 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{
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050073 console_flush();
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020074
Andre Przywara98b5a112020-01-25 00:58:35 +000075 (void)console_unregister(&marvell_runtime_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020076}