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