14ecca339SDan Handley /* 293c78ed2SAntonio Nino Diaz * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. 34ecca339SDan Handley * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 54ecca339SDan Handley */ 64ecca339SDan Handley 7c3cf06f1SAntonio Nino Diaz #ifndef PL011_H 8c3cf06f1SAntonio Nino Diaz #define PL011_H 94ecca339SDan Handley 1009d40e0eSAntonio Nino Diaz #include <drivers/console.h> 114a0c4571SJulius Werner 124ecca339SDan Handley /* PL011 Registers */ 134ecca339SDan Handley #define UARTDR 0x000 144ecca339SDan Handley #define UARTRSR 0x004 154ecca339SDan Handley #define UARTECR 0x004 164ecca339SDan Handley #define UARTFR 0x018 1712f654b6SJuan Castillo #define UARTIMSC 0x038 1812f654b6SJuan Castillo #define UARTRIS 0x03C 1912f654b6SJuan Castillo #define UARTICR 0x044 2012f654b6SJuan Castillo 2112f654b6SJuan Castillo /* PL011 registers (out of the SBSA specification) */ 2212f654b6SJuan Castillo #if !PL011_GENERIC_UART 234ecca339SDan Handley #define UARTILPR 0x020 244ecca339SDan Handley #define UARTIBRD 0x024 254ecca339SDan Handley #define UARTFBRD 0x028 264ecca339SDan Handley #define UARTLCR_H 0x02C 274ecca339SDan Handley #define UARTCR 0x030 284ecca339SDan Handley #define UARTIFLS 0x034 294ecca339SDan Handley #define UARTMIS 0x040 304ecca339SDan Handley #define UARTDMACR 0x048 3112f654b6SJuan Castillo #endif /* !PL011_GENERIC_UART */ 324ecca339SDan Handley 334ecca339SDan Handley /* Data status bits */ 344ecca339SDan Handley #define UART_DATA_ERROR_MASK 0x0F00 354ecca339SDan Handley 364ecca339SDan Handley /* Status reg bits */ 374ecca339SDan Handley #define UART_STATUS_ERROR_MASK 0x0F 384ecca339SDan Handley 394ecca339SDan Handley /* Flag reg bits */ 404ecca339SDan Handley #define PL011_UARTFR_RI (1 << 8) /* Ring indicator */ 414ecca339SDan Handley #define PL011_UARTFR_TXFE (1 << 7) /* Transmit FIFO empty */ 424ecca339SDan Handley #define PL011_UARTFR_RXFF (1 << 6) /* Receive FIFO full */ 434ecca339SDan Handley #define PL011_UARTFR_TXFF (1 << 5) /* Transmit FIFO full */ 444ecca339SDan Handley #define PL011_UARTFR_RXFE (1 << 4) /* Receive FIFO empty */ 454ecca339SDan Handley #define PL011_UARTFR_BUSY (1 << 3) /* UART busy */ 464ecca339SDan Handley #define PL011_UARTFR_DCD (1 << 2) /* Data carrier detect */ 474ecca339SDan Handley #define PL011_UARTFR_DSR (1 << 1) /* Data set ready */ 484ecca339SDan Handley #define PL011_UARTFR_CTS (1 << 0) /* Clear to send */ 494ecca339SDan Handley 50fce5f750SSoby Mathew #define PL011_UARTFR_TXFF_BIT 5 /* Transmit FIFO full bit in UARTFR register */ 51fce5f750SSoby Mathew #define PL011_UARTFR_RXFE_BIT 4 /* Receive FIFO empty bit in UARTFR register */ 529400b40eSJuan Castillo #define PL011_UARTFR_BUSY_BIT 3 /* UART busy bit in UARTFR register */ 53fce5f750SSoby Mathew 544ecca339SDan Handley /* Control reg bits */ 5512f654b6SJuan Castillo #if !PL011_GENERIC_UART 564ecca339SDan Handley #define PL011_UARTCR_CTSEN (1 << 15) /* CTS hardware flow control enable */ 574ecca339SDan Handley #define PL011_UARTCR_RTSEN (1 << 14) /* RTS hardware flow control enable */ 584ecca339SDan Handley #define PL011_UARTCR_RTS (1 << 11) /* Request to send */ 594ecca339SDan Handley #define PL011_UARTCR_DTR (1 << 10) /* Data transmit ready. */ 604ecca339SDan Handley #define PL011_UARTCR_RXE (1 << 9) /* Receive enable */ 614ecca339SDan Handley #define PL011_UARTCR_TXE (1 << 8) /* Transmit enable */ 624ecca339SDan Handley #define PL011_UARTCR_LBE (1 << 7) /* Loopback enable */ 634ecca339SDan Handley #define PL011_UARTCR_UARTEN (1 << 0) /* UART Enable */ 644ecca339SDan Handley 654ecca339SDan Handley #if !defined(PL011_LINE_CONTROL) 664ecca339SDan Handley /* FIFO Enabled / No Parity / 8 Data bit / One Stop Bit */ 674ecca339SDan Handley #define PL011_LINE_CONTROL (PL011_UARTLCR_H_FEN | PL011_UARTLCR_H_WLEN_8) 684ecca339SDan Handley #endif 694ecca339SDan Handley 704ecca339SDan Handley /* Line Control Register Bits */ 714ecca339SDan Handley #define PL011_UARTLCR_H_SPS (1 << 7) /* Stick parity select */ 724ecca339SDan Handley #define PL011_UARTLCR_H_WLEN_8 (3 << 5) 734ecca339SDan Handley #define PL011_UARTLCR_H_WLEN_7 (2 << 5) 744ecca339SDan Handley #define PL011_UARTLCR_H_WLEN_6 (1 << 5) 754ecca339SDan Handley #define PL011_UARTLCR_H_WLEN_5 (0 << 5) 764ecca339SDan Handley #define PL011_UARTLCR_H_FEN (1 << 4) /* FIFOs Enable */ 774ecca339SDan Handley #define PL011_UARTLCR_H_STP2 (1 << 3) /* Two stop bits select */ 784ecca339SDan Handley #define PL011_UARTLCR_H_EPS (1 << 2) /* Even parity select */ 794ecca339SDan Handley #define PL011_UARTLCR_H_PEN (1 << 1) /* Parity Enable */ 804ecca339SDan Handley #define PL011_UARTLCR_H_BRK (1 << 0) /* Send break */ 814ecca339SDan Handley 8212f654b6SJuan Castillo #endif /* !PL011_GENERIC_UART */ 8312f654b6SJuan Castillo 84d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__ 854a0c4571SJulius Werner 8693c78ed2SAntonio Nino Diaz #include <stdint.h> 874a0c4571SJulius Werner 884a0c4571SJulius Werner /* 894a0c4571SJulius Werner * Initialize a new PL011 console instance and register it with the console 904a0c4571SJulius Werner * framework. The |console| pointer must point to storage that will be valid 914a0c4571SJulius Werner * for the lifetime of the console, such as a global or static local variable. 924a0c4571SJulius Werner * Its contents will be reinitialized from scratch. 934a0c4571SJulius Werner */ 944a0c4571SJulius Werner int console_pl011_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, 95*f695e1e0SAndre Przywara console_t *console); 964a0c4571SJulius Werner 97d5dfdeb6SJulius Werner #endif /*__ASSEMBLER__*/ 984a0c4571SJulius Werner 99c3cf06f1SAntonio Nino Diaz #endif /* PL011_H */ 100