1 /* 2 * Copyright 2014, 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 UART_CONTROL 0x00 14 #define UART_MODE 0x04 15 #define UART_INTRPT_EN 0x08 16 #define UART_INTRPT_DIS 0x0C 17 #define UART_INTRPT_MASK 0x10 18 #define UART_CHNL_INT_STS 0x14 19 #define UART_BAUD_RATE_GEN 0x18 20 #define UART_RCVR_TIMEOUT 0x1C 21 #define UART_RCVR_FIFO_TRIGGER_LEVEL 0x20 22 #define UART_MODEM_CTRL 0x24 23 #define UART_MODEM_STS 0x28 24 #define UART_CHANNEL_STS 0x2C 25 #define UART_TX_RX_FIFO 0x30 26 #define UART_BAUD_RATE_DIVIDER 0x34 27 #define UART_FLOW_DELAY 0x38 28 #define UART_TX_FIFO_TRIGGER_LEVEL 0x44 29 30 #define UART_INTRPT_MASK_TXEMPTY BIT(3) 31 #define UART_CHANNEL_STS_TXEMPTY BIT(3) 32 33 #define UART_REG(x) ((volatile uint32_t *)(UART_PPTR + (x))) 34 35 #ifdef CONFIG_PRINTING uart_drv_putchar(unsigned char c)36void uart_drv_putchar(unsigned char c) 37 { 38 while (!(*UART_REG(UART_CHANNEL_STS) & UART_CHANNEL_STS_TXEMPTY)); 39 *UART_REG(UART_TX_RX_FIFO) = c; 40 } 41 #endif /* CONFIG_PRINTING */ 42 43 #ifdef CONFIG_DEBUG_BUILD uart_drv_getchar(void)44unsigned char uart_drv_getchar(void) 45 { 46 while (!(*UART_REG(UART_CHANNEL_STS) & BIT(UART_CHANNEL_STS_TXEMPTY))); 47 return *UART_REG(UART_TX_RX_FIFO); 48 } 49 #endif /* CONFIG_DEBUG_BUILD */ 50