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> |
| 14 | |
| 15 | #include <plat_arm.h> |
| 16 | |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 17 | /******************************************************************************* |
| 18 | * Functions that set up the console |
| 19 | ******************************************************************************/ |
| 20 | #if MULTI_CONSOLE_API |
| 21 | static console_pl011_t arm_boot_console; |
| 22 | static console_pl011_t arm_runtime_console; |
| 23 | #endif |
| 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 | { |
| 28 | #if MULTI_CONSOLE_API |
| 29 | int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE, |
| 30 | PLAT_ARM_BOOT_UART_CLK_IN_HZ, |
| 31 | ARM_CONSOLE_BAUDRATE, |
| 32 | &arm_boot_console); |
| 33 | if (rc == 0) { |
| 34 | /* |
| 35 | * The crash console doesn't use the multi console API, it uses |
| 36 | * the core console functions directly. It is safe to call panic |
| 37 | * and let it print debug information. |
| 38 | */ |
| 39 | panic(); |
| 40 | } |
| 41 | |
| 42 | console_set_scope(&arm_boot_console.console, CONSOLE_FLAG_BOOT); |
| 43 | #else |
| 44 | (void)console_init(PLAT_ARM_BOOT_UART_BASE, |
| 45 | PLAT_ARM_BOOT_UART_CLK_IN_HZ, |
| 46 | ARM_CONSOLE_BAUDRATE); |
| 47 | #endif /* MULTI_CONSOLE_API */ |
| 48 | } |
| 49 | |
| 50 | void arm_console_boot_end(void) |
| 51 | { |
| 52 | (void)console_flush(); |
| 53 | |
| 54 | #if MULTI_CONSOLE_API |
| 55 | (void)console_unregister(&arm_boot_console.console); |
| 56 | #else |
| 57 | console_uninit(); |
| 58 | #endif /* MULTI_CONSOLE_API */ |
| 59 | } |
| 60 | |
| 61 | /* Initialize the runtime console */ |
| 62 | void arm_console_runtime_init(void) |
| 63 | { |
| 64 | #if MULTI_CONSOLE_API |
| 65 | int rc = console_pl011_register(PLAT_ARM_BL31_RUN_UART_BASE, |
| 66 | PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ, |
| 67 | ARM_CONSOLE_BAUDRATE, |
| 68 | &arm_runtime_console); |
| 69 | if (rc == 0) |
| 70 | panic(); |
| 71 | |
| 72 | console_set_scope(&arm_runtime_console.console, CONSOLE_FLAG_RUNTIME); |
| 73 | #else |
| 74 | (void)console_init(PLAT_ARM_BL31_RUN_UART_BASE, |
| 75 | PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ, |
| 76 | ARM_CONSOLE_BAUDRATE); |
| 77 | #endif /* MULTI_CONSOLE_API */ |
| 78 | } |
| 79 | |
| 80 | void arm_console_runtime_end(void) |
| 81 | { |
| 82 | (void)console_flush(); |
| 83 | |
| 84 | #if MULTI_CONSOLE_API |
| 85 | (void)console_unregister(&arm_runtime_console.console); |
| 86 | #else |
| 87 | console_uninit(); |
| 88 | #endif /* MULTI_CONSOLE_API */ |
| 89 | } |