Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 1 | /* |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 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> |
Pali Rohár | 52c1de5 | 2021-05-14 15:52:11 +0200 | [diff] [blame] | 17 | #define PLAT_MARVELL_UART_CLK_IN_HZ (get_ref_clk() * 1000000) |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 18 | #define console_marvell_register console_a3700_register |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 19 | #else |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 20 | #include <drivers/ti/uart/uart_16550.h> |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 21 | #define console_marvell_register console_16550_register |
| 22 | #endif |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 23 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 24 | static console_t marvell_boot_console; |
| 25 | static console_t marvell_runtime_console; |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 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 = |
Pali Rohár | 168d81e | 2021-05-14 13:21:56 +0200 | [diff] [blame] | 35 | console_marvell_register(PLAT_MARVELL_UART_BASE, |
| 36 | PLAT_MARVELL_UART_CLK_IN_HZ, |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 37 | MARVELL_CONSOLE_BAUDRATE, |
| 38 | &marvell_boot_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 39 | if (rc == 0) { |
| 40 | /* |
| 41 | * The crash console doesn't use the multi console API, it uses |
| 42 | * the core console functions directly. It is safe to call panic |
| 43 | * and let it print debug information. |
| 44 | */ |
| 45 | panic(); |
| 46 | } |
| 47 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 48 | console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void marvell_console_boot_end(void) |
| 52 | { |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 53 | console_flush(); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 54 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 55 | (void)console_unregister(&marvell_boot_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | /* Initialize the runtime console */ |
| 59 | void marvell_console_runtime_init(void) |
| 60 | { |
| 61 | int rc = |
Pali Rohár | 168d81e | 2021-05-14 13:21:56 +0200 | [diff] [blame] | 62 | console_marvell_register(PLAT_MARVELL_UART_BASE, |
| 63 | PLAT_MARVELL_UART_CLK_IN_HZ, |
Andre Przywara | c5e8fec | 2020-01-25 23:55:08 +0000 | [diff] [blame] | 64 | MARVELL_CONSOLE_BAUDRATE, |
| 65 | &marvell_runtime_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 66 | if (rc == 0) |
| 67 | panic(); |
| 68 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 69 | console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | void marvell_console_runtime_end(void) |
| 73 | { |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 74 | console_flush(); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 75 | |
Andre Przywara | 98b5a11 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 76 | (void)console_unregister(&marvell_runtime_console); |
Konstantin Porotchkin | d8e3957 | 2018-11-14 17:15:08 +0200 | [diff] [blame] | 77 | } |