blob: ef54bff4023b509ea6d55159a5d17be8e13287cb [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>
Pali Rohár52c1de52021-05-14 15:52:11 +020017#define PLAT_MARVELL_UART_CLK_IN_HZ (get_ref_clk() * 1000000)
Andre Przywarac5e8fec2020-01-25 23:55:08 +000018#define console_marvell_register console_a3700_register
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020019#else
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000020#include <drivers/ti/uart/uart_16550.h>
Andre Przywarac5e8fec2020-01-25 23:55:08 +000021#define console_marvell_register console_16550_register
22#endif
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020023
Andre Przywara98b5a112020-01-25 00:58:35 +000024static console_t marvell_boot_console;
25static console_t marvell_runtime_console;
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020026
27/*******************************************************************************
28 * Functions that set up the console
29 ******************************************************************************/
30
31/* Initialize the console to provide early debug support */
32void marvell_console_boot_init(void)
33{
34 int rc =
Pali Rohár168d81e2021-05-14 13:21:56 +020035 console_marvell_register(PLAT_MARVELL_UART_BASE,
36 PLAT_MARVELL_UART_CLK_IN_HZ,
Andre Przywarac5e8fec2020-01-25 23:55:08 +000037 MARVELL_CONSOLE_BAUDRATE,
38 &marvell_boot_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020039 if (rc == 0) {
40 /*
41 * The crash console doesn't use the multi console API, it uses
42 * the core console functions directly. It is safe to call panic
43 * and let it print debug information.
44 */
45 panic();
46 }
47
Andre Przywara98b5a112020-01-25 00:58:35 +000048 console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020049}
50
51void marvell_console_boot_end(void)
52{
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050053 console_flush();
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020054
Andre Przywara98b5a112020-01-25 00:58:35 +000055 (void)console_unregister(&marvell_boot_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020056}
57
58/* Initialize the runtime console */
59void marvell_console_runtime_init(void)
60{
61 int rc =
Pali Rohár168d81e2021-05-14 13:21:56 +020062 console_marvell_register(PLAT_MARVELL_UART_BASE,
63 PLAT_MARVELL_UART_CLK_IN_HZ,
Andre Przywarac5e8fec2020-01-25 23:55:08 +000064 MARVELL_CONSOLE_BAUDRATE,
65 &marvell_runtime_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020066 if (rc == 0)
67 panic();
68
Andre Przywara98b5a112020-01-25 00:58:35 +000069 console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020070}
71
72void marvell_console_runtime_end(void)
73{
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050074 console_flush();
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020075
Andre Przywara98b5a112020-01-25 00:58:35 +000076 (void)console_unregister(&marvell_runtime_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020077}