xref: /arm-trusted-firmware/include/drivers/marvell/uart/a3700_console.h (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (C) 2016 Marvell International Ltd.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier:	BSD-3-Clause
5*91f16700Schasinglulu  * https://spdx.org/licenses
6*91f16700Schasinglulu  */
7*91f16700Schasinglulu 
8*91f16700Schasinglulu #ifndef A3700_CONSOLE_H
9*91f16700Schasinglulu #define A3700_CONSOLE_H
10*91f16700Schasinglulu 
11*91f16700Schasinglulu #include <drivers/console.h>
12*91f16700Schasinglulu #include <platform_def.h>
13*91f16700Schasinglulu 
14*91f16700Schasinglulu /* MVEBU UART Registers */
15*91f16700Schasinglulu #define UART_RX_REG		0x00
16*91f16700Schasinglulu #define UART_TX_REG		0x04
17*91f16700Schasinglulu #define UART_CTRL_REG		0x08
18*91f16700Schasinglulu #define UART_STATUS_REG		0x0c
19*91f16700Schasinglulu #define UART_BAUD_REG		0x10
20*91f16700Schasinglulu #define UART_POSSR_REG		0x14
21*91f16700Schasinglulu 
22*91f16700Schasinglulu /* FIFO Control Register bits */
23*91f16700Schasinglulu #define UARTFCR_FIFOMD_16450	(0 << 6)
24*91f16700Schasinglulu #define UARTFCR_FIFOMD_16550	(1 << 6)
25*91f16700Schasinglulu #define UARTFCR_RXTRIG_1	(0 << 6)
26*91f16700Schasinglulu #define UARTFCR_RXTRIG_4	(1 << 6)
27*91f16700Schasinglulu #define UARTFCR_RXTRIG_8	(2 << 6)
28*91f16700Schasinglulu #define UARTFCR_RXTRIG_16	(3 << 6)
29*91f16700Schasinglulu #define UARTFCR_TXTRIG_1	(0 << 4)
30*91f16700Schasinglulu #define UARTFCR_TXTRIG_4	(1 << 4)
31*91f16700Schasinglulu #define UARTFCR_TXTRIG_8	(2 << 4)
32*91f16700Schasinglulu #define UARTFCR_TXTRIG_16	(3 << 4)
33*91f16700Schasinglulu #define UARTFCR_DMAEN		(1 << 3)	/* Enable DMA mode */
34*91f16700Schasinglulu #define UARTFCR_TXCLR		(1 << 2)	/* Clear contents of Tx FIFO */
35*91f16700Schasinglulu #define UARTFCR_RXCLR		(1 << 1)	/* Clear contents of Rx FIFO */
36*91f16700Schasinglulu #define UARTFCR_FIFOEN		(1 << 0)	/* Enable the Tx/Rx FIFO */
37*91f16700Schasinglulu 
38*91f16700Schasinglulu /* Line Control Register bits */
39*91f16700Schasinglulu #define UARTLCR_DLAB		(1 << 7)	/* Divisor Latch Access */
40*91f16700Schasinglulu #define UARTLCR_SETB		(1 << 6)	/* Set BREAK Condition */
41*91f16700Schasinglulu #define UARTLCR_SETP		(1 << 5)	/* Set Parity to LCR[4] */
42*91f16700Schasinglulu #define UARTLCR_EVEN		(1 << 4)	/* Even Parity Format */
43*91f16700Schasinglulu #define UARTLCR_PAR		(1 << 3)	/* Parity */
44*91f16700Schasinglulu #define UARTLCR_STOP		(1 << 2)	/* Stop Bit */
45*91f16700Schasinglulu #define UARTLCR_WORDSZ_5	0		/* Word Length of 5 */
46*91f16700Schasinglulu #define UARTLCR_WORDSZ_6	1		/* Word Length of 6 */
47*91f16700Schasinglulu #define UARTLCR_WORDSZ_7	2		/* Word Length of 7 */
48*91f16700Schasinglulu #define UARTLCR_WORDSZ_8	3		/* Word Length of 8 */
49*91f16700Schasinglulu 
50*91f16700Schasinglulu /* Line Status Register bits */
51*91f16700Schasinglulu #define UARTLSR_TXFIFOFULL	(1 << 11)	/* Tx Fifo Full */
52*91f16700Schasinglulu #define UARTLSR_TXEMPTY		(1 << 6)	/* Tx Empty */
53*91f16700Schasinglulu #define UARTLSR_RXRDY		(1 << 4)	/* Rx Ready */
54*91f16700Schasinglulu 
55*91f16700Schasinglulu /* UART Control Register bits */
56*91f16700Schasinglulu #define UART_CTRL_RXFIFO_RESET	(1 << 14)
57*91f16700Schasinglulu #define UART_CTRL_TXFIFO_RESET	(1 << 15)
58*91f16700Schasinglulu 
59*91f16700Schasinglulu #ifndef __ASSEMBLER__
60*91f16700Schasinglulu 
61*91f16700Schasinglulu #include <stdint.h>
62*91f16700Schasinglulu 
63*91f16700Schasinglulu /*
64*91f16700Schasinglulu  * Initialize a new a3700 console instance and register it with the console
65*91f16700Schasinglulu  * framework. The |console| pointer must point to storage that will be valid
66*91f16700Schasinglulu  * for the lifetime of the console, such as a global or static local variable.
67*91f16700Schasinglulu  * Its contents will be reinitialized from scratch.
68*91f16700Schasinglulu  */
69*91f16700Schasinglulu int console_a3700_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud,
70*91f16700Schasinglulu 			   console_t *console);
71*91f16700Schasinglulu 
72*91f16700Schasinglulu #endif /*__ASSEMBLER__*/
73*91f16700Schasinglulu 
74*91f16700Schasinglulu #endif	/* A3700_CONSOLE_H */
75