1/* 2 * Copyright 2016, General Dynamics C4 Systems 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7#include <config.h> 8#include <stdint.h> 9#include <util.h> 10#include <machine/io.h> 11#include <plat/machine/devices_gen.h> 12 13#define UARTDR 0x000 14#define UARTFR 0x018 15 16#define PL011_UARTFR_TXFF BIT(5) 17#define PL011_UARTFR_RXFE BIT(4) 18 19#define UART_REG(x) ((volatile uint32_t *)(UART_PPTR + (x))) 20 21#if defined(CONFIG_DEBUG_BUILD) || defined(CONFIG_PRINTING) 22void putDebugChar(unsigned char c) 23{ 24 while ((*UART_REG(UARTFR) & PL011_UARTFR_TXFF) != 0); 25 26 *UART_REG(UARTDR) = c; 27} 28#endif 29 30#ifdef CONFIG_DEBUG_BUILD 31unsigned char getDebugChar(void) 32{ 33 while ((*UART_REG(UARTFR) & PL011_UARTFR_RXFE) != 0); 34 35 return *UART_REG(UARTDR); 36} 37#endif //CONFIG_DEBUG_BUILD 38