1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu #include <assert.h> 8*91f16700Schasinglulu 9*91f16700Schasinglulu #include <common/debug.h> 10*91f16700Schasinglulu #include <drivers/console.h> 11*91f16700Schasinglulu #include <drivers/ti/uart/uart_16550.h> 12*91f16700Schasinglulu 13*91f16700Schasinglulu #include <platform_def.h> 14*91f16700Schasinglulu 15*91f16700Schasinglulu /******************************************************************************* 16*91f16700Schasinglulu * Functions that set up the console 17*91f16700Schasinglulu ******************************************************************************/ 18*91f16700Schasinglulu static console_t bcm_boot_console; 19*91f16700Schasinglulu static console_t bcm_runtime_console; 20*91f16700Schasinglulu 21*91f16700Schasinglulu /* Initialize the console to provide early debug support */ 22*91f16700Schasinglulu void bcm_console_boot_init(void) 23*91f16700Schasinglulu { 24*91f16700Schasinglulu int rc = console_16550_register(PLAT_BRCM_BOOT_UART_BASE, 25*91f16700Schasinglulu PLAT_BRCM_BOOT_UART_CLK_IN_HZ, 26*91f16700Schasinglulu BRCM_CONSOLE_BAUDRATE, 27*91f16700Schasinglulu &bcm_boot_console); 28*91f16700Schasinglulu if (rc == 0) { 29*91f16700Schasinglulu /* 30*91f16700Schasinglulu * The crash console doesn't use the multi console API, it uses 31*91f16700Schasinglulu * the core console functions directly. It is safe to call panic 32*91f16700Schasinglulu * and let it print debug information. 33*91f16700Schasinglulu */ 34*91f16700Schasinglulu panic(); 35*91f16700Schasinglulu } 36*91f16700Schasinglulu 37*91f16700Schasinglulu console_set_scope(&bcm_boot_console, CONSOLE_FLAG_BOOT); 38*91f16700Schasinglulu } 39*91f16700Schasinglulu 40*91f16700Schasinglulu void bcm_console_boot_end(void) 41*91f16700Schasinglulu { 42*91f16700Schasinglulu console_flush(); 43*91f16700Schasinglulu 44*91f16700Schasinglulu (void)console_unregister(&bcm_boot_console); 45*91f16700Schasinglulu } 46*91f16700Schasinglulu 47*91f16700Schasinglulu /* Initialize the runtime console */ 48*91f16700Schasinglulu void bcm_console_runtime_init(void) 49*91f16700Schasinglulu { 50*91f16700Schasinglulu int rc = console_16550_register(PLAT_BRCM_BL31_RUN_UART_BASE, 51*91f16700Schasinglulu PLAT_BRCM_BL31_RUN_UART_CLK_IN_HZ, 52*91f16700Schasinglulu BRCM_CONSOLE_BAUDRATE, 53*91f16700Schasinglulu &bcm_runtime_console); 54*91f16700Schasinglulu if (rc == 0) 55*91f16700Schasinglulu panic(); 56*91f16700Schasinglulu 57*91f16700Schasinglulu console_set_scope(&bcm_runtime_console, CONSOLE_FLAG_RUNTIME); 58*91f16700Schasinglulu } 59*91f16700Schasinglulu 60*91f16700Schasinglulu void bcm_console_runtime_end(void) 61*91f16700Schasinglulu { 62*91f16700Schasinglulu console_flush(); 63*91f16700Schasinglulu 64*91f16700Schasinglulu (void)console_unregister(&bcm_runtime_console); 65*91f16700Schasinglulu } 66