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 #include <assert.h> 7*91f16700Schasinglulu 8*91f16700Schasinglulu #include <platform_def.h> 9*91f16700Schasinglulu 10*91f16700Schasinglulu #include <common/debug.h> 11*91f16700Schasinglulu #include <drivers/console.h> 12*91f16700Schasinglulu 13*91f16700Schasinglulu #include <plat_marvell.h> 14*91f16700Schasinglulu 15*91f16700Schasinglulu #ifdef PLAT_a3700 16*91f16700Schasinglulu #include <drivers/marvell/uart/a3700_console.h> 17*91f16700Schasinglulu #define PLAT_MARVELL_UART_CLK_IN_HZ (get_ref_clk() * 1000000) 18*91f16700Schasinglulu #define console_marvell_register console_a3700_register 19*91f16700Schasinglulu #else 20*91f16700Schasinglulu #include <drivers/ti/uart/uart_16550.h> 21*91f16700Schasinglulu #define console_marvell_register console_16550_register 22*91f16700Schasinglulu #endif 23*91f16700Schasinglulu 24*91f16700Schasinglulu static console_t marvell_boot_console; 25*91f16700Schasinglulu static console_t marvell_runtime_console; 26*91f16700Schasinglulu 27*91f16700Schasinglulu /******************************************************************************* 28*91f16700Schasinglulu * Functions that set up the console 29*91f16700Schasinglulu ******************************************************************************/ 30*91f16700Schasinglulu 31*91f16700Schasinglulu /* Initialize the console to provide early debug support */ 32*91f16700Schasinglulu void marvell_console_boot_init(void) 33*91f16700Schasinglulu { 34*91f16700Schasinglulu int rc = 35*91f16700Schasinglulu console_marvell_register(PLAT_MARVELL_UART_BASE, 36*91f16700Schasinglulu PLAT_MARVELL_UART_CLK_IN_HZ, 37*91f16700Schasinglulu MARVELL_CONSOLE_BAUDRATE, 38*91f16700Schasinglulu &marvell_boot_console); 39*91f16700Schasinglulu if (rc == 0) { 40*91f16700Schasinglulu /* 41*91f16700Schasinglulu * The crash console doesn't use the multi console API, it uses 42*91f16700Schasinglulu * the core console functions directly. It is safe to call panic 43*91f16700Schasinglulu * and let it print debug information. 44*91f16700Schasinglulu */ 45*91f16700Schasinglulu panic(); 46*91f16700Schasinglulu } 47*91f16700Schasinglulu 48*91f16700Schasinglulu console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT); 49*91f16700Schasinglulu } 50*91f16700Schasinglulu 51*91f16700Schasinglulu void marvell_console_boot_end(void) 52*91f16700Schasinglulu { 53*91f16700Schasinglulu console_flush(); 54*91f16700Schasinglulu 55*91f16700Schasinglulu (void)console_unregister(&marvell_boot_console); 56*91f16700Schasinglulu } 57*91f16700Schasinglulu 58*91f16700Schasinglulu /* Initialize the runtime console */ 59*91f16700Schasinglulu void marvell_console_runtime_init(void) 60*91f16700Schasinglulu { 61*91f16700Schasinglulu int rc = 62*91f16700Schasinglulu console_marvell_register(PLAT_MARVELL_UART_BASE, 63*91f16700Schasinglulu PLAT_MARVELL_UART_CLK_IN_HZ, 64*91f16700Schasinglulu MARVELL_CONSOLE_BAUDRATE, 65*91f16700Schasinglulu &marvell_runtime_console); 66*91f16700Schasinglulu if (rc == 0) 67*91f16700Schasinglulu panic(); 68*91f16700Schasinglulu 69*91f16700Schasinglulu console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME); 70*91f16700Schasinglulu } 71*91f16700Schasinglulu 72*91f16700Schasinglulu void marvell_console_runtime_end(void) 73*91f16700Schasinglulu { 74*91f16700Schasinglulu console_flush(); 75*91f16700Schasinglulu 76*91f16700Schasinglulu (void)console_unregister(&marvell_runtime_console); 77*91f16700Schasinglulu } 78