Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 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 | |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 16 | /******************************************************************************* |
| 17 | * Functions that set up the console |
| 18 | ******************************************************************************/ |
| 19 | #if MULTI_CONSOLE_API |
| 20 | static console_pl011_t arm_boot_console; |
| 21 | static console_pl011_t arm_runtime_console; |
| 22 | #endif |
| 23 | |
| 24 | /* Initialize the console to provide early debug support */ |
Daniel Boulby | f45a4bb | 2018-09-18 13:26:03 +0100 | [diff] [blame] | 25 | void __init arm_console_boot_init(void) |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 26 | { |
| 27 | #if MULTI_CONSOLE_API |
| 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 | |
| 41 | console_set_scope(&arm_boot_console.console, CONSOLE_FLAG_BOOT); |
| 42 | #else |
| 43 | (void)console_init(PLAT_ARM_BOOT_UART_BASE, |
| 44 | PLAT_ARM_BOOT_UART_CLK_IN_HZ, |
| 45 | ARM_CONSOLE_BAUDRATE); |
| 46 | #endif /* MULTI_CONSOLE_API */ |
| 47 | } |
| 48 | |
| 49 | void arm_console_boot_end(void) |
| 50 | { |
| 51 | (void)console_flush(); |
| 52 | |
| 53 | #if MULTI_CONSOLE_API |
| 54 | (void)console_unregister(&arm_boot_console.console); |
| 55 | #else |
| 56 | console_uninit(); |
| 57 | #endif /* MULTI_CONSOLE_API */ |
| 58 | } |
| 59 | |
| 60 | /* Initialize the runtime console */ |
| 61 | void arm_console_runtime_init(void) |
| 62 | { |
| 63 | #if MULTI_CONSOLE_API |
| 64 | int rc = console_pl011_register(PLAT_ARM_BL31_RUN_UART_BASE, |
| 65 | PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ, |
| 66 | ARM_CONSOLE_BAUDRATE, |
| 67 | &arm_runtime_console); |
| 68 | if (rc == 0) |
| 69 | panic(); |
| 70 | |
| 71 | console_set_scope(&arm_runtime_console.console, CONSOLE_FLAG_RUNTIME); |
| 72 | #else |
| 73 | (void)console_init(PLAT_ARM_BL31_RUN_UART_BASE, |
| 74 | PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ, |
| 75 | ARM_CONSOLE_BAUDRATE); |
| 76 | #endif /* MULTI_CONSOLE_API */ |
| 77 | } |
| 78 | |
| 79 | void arm_console_runtime_end(void) |
| 80 | { |
| 81 | (void)console_flush(); |
| 82 | |
| 83 | #if MULTI_CONSOLE_API |
| 84 | (void)console_unregister(&arm_runtime_console.console); |
| 85 | #else |
| 86 | console_uninit(); |
| 87 | #endif /* MULTI_CONSOLE_API */ |
| 88 | } |