1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. 4 */ 5 6 #ifndef PL011_H 7 #define PL011_H 8 9 #include <stdint.h> 10 11 /* PL011 Registers */ 12 #define UARTDR 0x000 13 #define UARTECR 0x004 14 #define UARTFR 0x018 15 16 /* PL011 registers (out of the SBSA specification) */ 17 #define UARTIBRD 0x024 18 #define UARTFBRD 0x028 19 #define UARTLCR_H 0x02C 20 #define UARTCR 0x030 21 22 /* Flag reg bits */ 23 #define PL011_UARTFR_TXFF (1U << 5) /* Transmit FIFO full */ 24 25 /* Control reg bits */ 26 #define PL011_UARTCR_RXE (1U << 9) /* Receive enable */ 27 #define PL011_UARTCR_TXE (1U << 8) /* Transmit enable */ 28 #define PL011_UARTCR_UARTEN (1U << 0) /* UART Enable */ 29 30 /* FIFO Enabled / No Parity / 8 Data bit / One Stop Bit */ 31 #define PL011_LINE_CONTROL (PL011_UARTLCR_H_FEN | PL011_UARTLCR_H_WLEN_8) 32 33 /* Line Control Register Bits */ 34 #define PL011_UARTLCR_H_WLEN_8 (3U << 5) 35 #define PL011_UARTLCR_H_FEN (1U << 4) /* FIFOs Enable */ 36 37 /* 38 * Function that initiates UART for console output 39 * Arguments: 40 * baseaddr - UART base address 41 * clock - UART input clock which sets master trasmit/receive rate 42 * baud - UART Baudrate 43 * Returns: 44 * 0 on success or -1 when invalid baseaddr/clock/baud is used 45 */ 46 int uart_init(uintptr_t baseaddr, unsigned int clock, unsigned int baud); 47 48 /* 49 * Function that outputs a character to console 50 * Arguments: 51 * ch - Character that must be sent to console output 52 * Returns: 53 * void 54 */ 55 void uart_putc(char ch); 56 57 #endif /* PL011_H */ 58