Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 1 | /* |
Ambroise Vincent | 500163d | 2019-04-24 10:34:17 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 6 | |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 9 | #include <platform_def.h> |
| 10 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <common/debug.h> |
| 12 | #include <drivers/arm/pl011.h> |
| 13 | #include <drivers/console.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 14 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | |
Madhukar Pappireddy | d0cf0a9 | 2020-04-16 17:54:25 -0500 | [diff] [blame] | 16 | #pragma weak arm_console_runtime_init |
| 17 | #pragma weak arm_console_runtime_end |
| 18 | |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 19 | /******************************************************************************* |
| 20 | * Functions that set up the console |
| 21 | ******************************************************************************/ |
Andre Przywara | 2b1b1a5 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 22 | static console_t arm_boot_console; |
| 23 | static console_t arm_runtime_console; |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 24 | |
| 25 | /* Initialize the console to provide early debug support */ |
Daniel Boulby | f45a4bb | 2018-09-18 13:26:03 +0100 | [diff] [blame] | 26 | void __init arm_console_boot_init(void) |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 27 | { |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 28 | int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE, |
| 29 | PLAT_ARM_BOOT_UART_CLK_IN_HZ, |
| 30 | ARM_CONSOLE_BAUDRATE, |
| 31 | &arm_boot_console); |
| 32 | if (rc == 0) { |
| 33 | /* |
| 34 | * The crash console doesn't use the multi console API, it uses |
| 35 | * the core console functions directly. It is safe to call panic |
| 36 | * and let it print debug information. |
| 37 | */ |
| 38 | panic(); |
| 39 | } |
| 40 | |
Andre Przywara | 2b1b1a5 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 41 | console_set_scope(&arm_boot_console, CONSOLE_FLAG_BOOT); |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void arm_console_boot_end(void) |
| 45 | { |
| 46 | (void)console_flush(); |
Andre Przywara | 2b1b1a5 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 47 | (void)console_unregister(&arm_boot_console); |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /* Initialize the runtime console */ |
| 51 | void arm_console_runtime_init(void) |
| 52 | { |
Usama Arif | 81eb5ce | 2019-02-11 16:35:42 +0000 | [diff] [blame] | 53 | int rc = console_pl011_register(PLAT_ARM_RUN_UART_BASE, |
| 54 | PLAT_ARM_RUN_UART_CLK_IN_HZ, |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 55 | ARM_CONSOLE_BAUDRATE, |
| 56 | &arm_runtime_console); |
| 57 | if (rc == 0) |
| 58 | panic(); |
| 59 | |
Andre Przywara | 2b1b1a5 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 60 | console_set_scope(&arm_runtime_console, CONSOLE_FLAG_RUNTIME); |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void arm_console_runtime_end(void) |
| 64 | { |
| 65 | (void)console_flush(); |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 66 | } |