blob: 3e19ee8959979f53aca9abb9319635dc49fec774 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __PL011_H__
8#define __PL011_H__
9
10/* PL011 Registers */
11#define UARTDR 0x000
12#define UARTRSR 0x004
13#define UARTECR 0x004
14#define UARTFR 0x018
15#define UARTILPR 0x020
16#define UARTIBRD 0x024
17#define UARTFBRD 0x028
18#define UARTLCR_H 0x02C
19#define UARTCR 0x030
20#define UARTIFLS 0x034
21#define UARTIMSC 0x038
22#define UARTRIS 0x03C
23#define UARTMIS 0x040
24#define UARTICR 0x044
25#define UARTDMACR 0x048
26
27/* Data status bits */
28#define UART_DATA_ERROR_MASK 0x0F00
29
30/* Status reg bits */
31#define UART_STATUS_ERROR_MASK 0x0F
32
33/* Flag reg bits */
34#define PL011_UARTFR_RI (1 << 8) /* Ring indicator */
35#define PL011_UARTFR_TXFE (1 << 7) /* Transmit FIFO empty */
36#define PL011_UARTFR_RXFF (1 << 6) /* Receive FIFO full */
37#define PL011_UARTFR_TXFF (1 << 5) /* Transmit FIFO full */
38#define PL011_UARTFR_RXFE (1 << 4) /* Receive FIFO empty */
39#define PL011_UARTFR_BUSY (1 << 3) /* UART busy */
40#define PL011_UARTFR_DCD (1 << 2) /* Data carrier detect */
41#define PL011_UARTFR_DSR (1 << 1) /* Data set ready */
42#define PL011_UARTFR_CTS (1 << 0) /* Clear to send */
43
44#define PL011_UARTFR_TXFF_BIT 5 /* Transmit FIFO full bit in UARTFR register */
45#define PL011_UARTFR_RXFE_BIT 4 /* Receive FIFO empty bit in UARTFR register */
46#define PL011_UARTFR_BUSY_BIT 3 /* UART busy bit in UARTFR register */
47
48/* Control reg bits */
49#define PL011_UARTCR_CTSEN (1 << 15) /* CTS hardware flow control enable */
50#define PL011_UARTCR_RTSEN (1 << 14) /* RTS hardware flow control enable */
51#define PL011_UARTCR_RTS (1 << 11) /* Request to send */
52#define PL011_UARTCR_DTR (1 << 10) /* Data transmit ready. */
53#define PL011_UARTCR_RXE (1 << 9) /* Receive enable */
54#define PL011_UARTCR_TXE (1 << 8) /* Transmit enable */
55#define PL011_UARTCR_LBE (1 << 7) /* Loopback enable */
56#define PL011_UARTCR_UARTEN (1 << 0) /* UART Enable */
57
58#if !defined(PL011_LINE_CONTROL)
59/* FIFO Enabled / No Parity / 8 Data bit / One Stop Bit */
60#define PL011_LINE_CONTROL (PL011_UARTLCR_H_FEN | PL011_UARTLCR_H_WLEN_8)
61#endif
62
63/* Line Control Register Bits */
64#define PL011_UARTLCR_H_SPS (1 << 7) /* Stick parity select */
65#define PL011_UARTLCR_H_WLEN_8 (3 << 5)
66#define PL011_UARTLCR_H_WLEN_7 (2 << 5)
67#define PL011_UARTLCR_H_WLEN_6 (1 << 5)
68#define PL011_UARTLCR_H_WLEN_5 (0 << 5)
69#define PL011_UARTLCR_H_FEN (1 << 4) /* FIFOs Enable */
70#define PL011_UARTLCR_H_STP2 (1 << 3) /* Two stop bits select */
71#define PL011_UARTLCR_H_EPS (1 << 2) /* Even parity select */
72#define PL011_UARTLCR_H_PEN (1 << 1) /* Parity Enable */
73#define PL011_UARTLCR_H_BRK (1 << 0) /* Send break */
74
75/* Constants */
76#define PL011_BAUDRATE 115200
77
Manish Pandeyf218ffe2020-04-09 15:16:40 +010078#ifndef __ASSEMBLER__
79#include <stdint.h>
80
81/* Functions */
82
83int console_pl011_putc(int);
84
85#endif /* __ASSEMBLER__ */
86
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020087#endif /* __PL011_H__ */