blob: 22c5eb3afd98a967253f632a40b8f6c00f6693f8 [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
23static console_16550_t marvell_boot_console;
24static console_16550_t marvell_runtime_console;
25#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
53 console_set_scope(&marvell_boot_console.console,
54 CONSOLE_FLAG_BOOT);
55}
56
57void marvell_console_boot_end(void)
58{
59 (void)console_flush();
60
61 (void)console_unregister(&marvell_boot_console.console);
62}
63
64/* Initialize the runtime console */
65void marvell_console_runtime_init(void)
66{
67 int rc =
68#ifdef PLAT_a3700
69 console_a3700_register(
70#else
71 console_16550_register(
72#endif
73 PLAT_MARVELL_BOOT_UART_BASE,
74 PLAT_MARVELL_BOOT_UART_CLK_IN_HZ,
75 MARVELL_CONSOLE_BAUDRATE,
76 &marvell_runtime_console);
77 if (rc == 0)
78 panic();
79
80 console_set_scope(&marvell_runtime_console.console,
81 CONSOLE_FLAG_RUNTIME);
82}
83
84void marvell_console_runtime_end(void)
85{
86 (void)console_flush();
87
88 (void)console_unregister(&marvell_runtime_console.console);
89}