blob: 33931afdaf64fae84dea4ba92546ce02737e3d20 [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>
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020017
18static console_a3700_t marvell_boot_console;
19static console_a3700_t marvell_runtime_console;
20#else
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000021#include <drivers/ti/uart/uart_16550.h>
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#endif
26
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 =
35#ifdef PLAT_a3700
36 console_a3700_register(
37#else
38 console_16550_register(
39#endif
40 PLAT_MARVELL_BOOT_UART_BASE,
41 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
42 MARVELL_CONSOLE_BAUDRATE,
43 &marvell_boot_console);
44 if (rc == 0) {
45 /*
46 * The crash console doesn't use the multi console API, it uses
47 * the core console functions directly. It is safe to call panic
48 * and let it print debug information.
49 */
50 panic();
51 }
52
Andre Przywara98b5a112020-01-25 00:58:35 +000053 console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020054}
55
56void marvell_console_boot_end(void)
57{
58 (void)console_flush();
59
Andre Przywara98b5a112020-01-25 00:58:35 +000060 (void)console_unregister(&marvell_boot_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020061}
62
63/* Initialize the runtime console */
64void marvell_console_runtime_init(void)
65{
66 int rc =
67#ifdef PLAT_a3700
68 console_a3700_register(
69#else
70 console_16550_register(
71#endif
72 PLAT_MARVELL_BOOT_UART_BASE,
73 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
74 MARVELL_CONSOLE_BAUDRATE,
75 &marvell_runtime_console);
76 if (rc == 0)
77 panic();
78
Andre Przywara98b5a112020-01-25 00:58:35 +000079 console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020080}
81
82void marvell_console_runtime_end(void)
83{
84 (void)console_flush();
85
Andre Przywara98b5a112020-01-25 00:58:35 +000086 (void)console_unregister(&marvell_runtime_console);
Konstantin Porotchkind8e39572018-11-14 17:15:08 +020087}