Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 1 | /* |
| 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 Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 8 | #include <platform_def.h> |
| 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <common/debug.h> |
| 11 | #include <drivers/console.h> |
| 12 | |
| 13 | #include <plat_marvell.h> |
| 14 | |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 15 | #ifdef PLAT_a3700 |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 16 | #include <drivers/marvell/uart/a3700_console.h> |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 17 | |
| 18 | static console_a3700_t marvell_boot_console; |
| 19 | static console_a3700_t marvell_runtime_console; |
| 20 | #else |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 21 | #include <drivers/ti/uart/uart_16550.h> |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 22 | |
| 23 | static console_16550_t marvell_boot_console; |
| 24 | static 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 */ |
| 32 | void 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 | |
| 57 | void 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 */ |
| 65 | void 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 | |
| 84 | void marvell_console_runtime_end(void) |
| 85 | { |
| 86 | (void)console_flush(); |
| 87 | |
| 88 | (void)console_unregister(&marvell_runtime_console.console); |
| 89 | } |