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 UTHR 0x0 14 #define ULSR 0x14 15 16 #define ULSR_THRE BIT(5) 17 #define ULSR_RDR BIT(0) 18 19 #define UART_REG(x) ((volatile uint32_t *)(UART_PPTR + (x))) 20 21 #ifdef CONFIG_PRINTING uart_drv_putchar(unsigned char c)22void uart_drv_putchar(unsigned char c) 23 { 24 while ((*UART_REG(ULSR) & ULSR_THRE) == 0); 25 26 *UART_REG(UTHR) = c; 27 } 28 #endif /* CONFIG_PRINTING */ 29 30 #ifdef CONFIG_DEBUG_BUILD uart_drv_getchar(void)31unsigned char uart_drv_getchar(void) 32 { 33 while ((*UART_REG(ULSR) & ULSR_RDR) == 0); 34 35 return *UART_REG(UTHR); 36 } 37 #endif /* CONFIG_DEBUG_BUILD */ 38