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 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame^] | 23 | static console_t marvell_boot_console; |
| 24 | static console_t marvell_runtime_console; |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 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 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame^] | 53 | console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void marvell_console_boot_end(void) |
| 57 | { |
| 58 | (void)console_flush(); |
| 59 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame^] | 60 | (void)console_unregister(&marvell_boot_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /* Initialize the runtime console */ |
| 64 | void 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 Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame^] | 79 | console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void marvell_console_runtime_end(void) |
| 83 | { |
| 84 | (void)console_flush(); |
| 85 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame^] | 86 | (void)console_unregister(&marvell_runtime_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 87 | } |