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> |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 17 | #define console_marvell_register console_a3700_register |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 18 | #else |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 19 | #include <drivers/ti/uart/uart_16550.h> |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 20 | #define console_marvell_register console_16550_register |
| 21 | #endif |
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 | |
| 26 | /******************************************************************************* |
| 27 | * Functions that set up the console |
| 28 | ******************************************************************************/ |
| 29 | |
| 30 | /* Initialize the console to provide early debug support */ |
| 31 | void marvell_console_boot_init(void) |
| 32 | { |
| 33 | int rc = |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 34 | console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE, |
| 35 | PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, |
| 36 | MARVELL_CONSOLE_BAUDRATE, |
| 37 | &marvell_boot_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 38 | if (rc == 0) { |
| 39 | /* |
| 40 | * The crash console doesn't use the multi console API, it uses |
| 41 | * the core console functions directly. It is safe to call panic |
| 42 | * and let it print debug information. |
| 43 | */ |
| 44 | panic(); |
| 45 | } |
| 46 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 47 | console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | void marvell_console_boot_end(void) |
| 51 | { |
| 52 | (void)console_flush(); |
| 53 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 54 | (void)console_unregister(&marvell_boot_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | /* Initialize the runtime console */ |
| 58 | void marvell_console_runtime_init(void) |
| 59 | { |
| 60 | int rc = |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 61 | console_marvell_register(PLAT_MARVELL_BOOT_UART_BASE, |
| 62 | PLAT_MARVELL_BOOT_UART_CLK_IN_HZ, |
| 63 | MARVELL_CONSOLE_BAUDRATE, |
| 64 | &marvell_runtime_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 65 | if (rc == 0) |
| 66 | panic(); |
| 67 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 68 | console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | void marvell_console_runtime_end(void) |
| 72 | { |
| 73 | (void)console_flush(); |
| 74 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 75 | (void)console_unregister(&marvell_runtime_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 76 | } |