xref: /linux/include/linux/amba/serial.h (revision 7ec758718920e5e5876d0d02ece6855128c8eb1e)
1a62c80e5SRussell King /*
2a62c80e5SRussell King  *  linux/include/asm-arm/hardware/serial_amba.h
3a62c80e5SRussell King  *
4a62c80e5SRussell King  *  Internal header file for AMBA serial ports
5a62c80e5SRussell King  *
6a62c80e5SRussell King  *  Copyright (C) ARM Limited
7a62c80e5SRussell King  *  Copyright (C) 2000 Deep Blue Solutions Ltd.
8a62c80e5SRussell King  *
9a62c80e5SRussell King  * This program is free software; you can redistribute it and/or modify
10a62c80e5SRussell King  * it under the terms of the GNU General Public License as published by
11a62c80e5SRussell King  * the Free Software Foundation; either version 2 of the License, or
12a62c80e5SRussell King  * (at your option) any later version.
13a62c80e5SRussell King  *
14a62c80e5SRussell King  * This program is distributed in the hope that it will be useful,
15a62c80e5SRussell King  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16a62c80e5SRussell King  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17a62c80e5SRussell King  * GNU General Public License for more details.
18a62c80e5SRussell King  *
19a62c80e5SRussell King  * You should have received a copy of the GNU General Public License
20a62c80e5SRussell King  * along with this program; if not, write to the Free Software
21a62c80e5SRussell King  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22a62c80e5SRussell King  */
23a62c80e5SRussell King #ifndef ASM_ARM_HARDWARE_SERIAL_AMBA_H
24a62c80e5SRussell King #define ASM_ARM_HARDWARE_SERIAL_AMBA_H
25a62c80e5SRussell King 
267e55d052Sviresh kumar #include <linux/types.h>
277e55d052Sviresh kumar 
28a62c80e5SRussell King /* -------------------------------------------------------------------------------
29a62c80e5SRussell King  *  From AMBA UART (PL010) Block Specification
30a62c80e5SRussell King  * -------------------------------------------------------------------------------
31a62c80e5SRussell King  *  UART Register Offsets.
32a62c80e5SRussell King  */
33a62c80e5SRussell King #define UART01x_DR		0x00	/* Data read or written from the interface. */
34a62c80e5SRussell King #define UART01x_RSR		0x04	/* Receive status register (Read). */
35a62c80e5SRussell King #define UART01x_ECR		0x04	/* Error clear register (Write). */
36a62c80e5SRussell King #define UART010_LCRH		0x08	/* Line control register, high byte. */
3729e29f27SLinus Walleij #define ST_UART011_DMAWM	0x08    /* DMA watermark configure register. */
38a62c80e5SRussell King #define UART010_LCRM		0x0C	/* Line control register, middle byte. */
3929e29f27SLinus Walleij #define ST_UART011_TIMEOUT	0x0C    /* Timeout period register. */
40a62c80e5SRussell King #define UART010_LCRL		0x10	/* Line control register, low byte. */
41a62c80e5SRussell King #define UART010_CR		0x14	/* Control register. */
42a62c80e5SRussell King #define UART01x_FR		0x18	/* Flag register (Read only). */
433f79410cSMaxime Jayat #define UART010_IIR		0x1C	/* Interrupt identification register (Read). */
44a62c80e5SRussell King #define UART010_ICR		0x1C	/* Interrupt clear register (Write). */
45ec489aa8SLinus Walleij #define ST_UART011_LCRH_RX	0x1C    /* Rx line control register. */
46a62c80e5SRussell King #define UART01x_ILPR		0x20	/* IrDA low power counter register. */
47a62c80e5SRussell King #define UART011_IBRD		0x24	/* Integer baud rate divisor register. */
48a62c80e5SRussell King #define UART011_FBRD		0x28	/* Fractional baud rate divisor register. */
49a62c80e5SRussell King #define UART011_LCRH		0x2c	/* Line control register. */
50ec489aa8SLinus Walleij #define ST_UART011_LCRH_TX	0x2c    /* Tx Line control register. */
51a62c80e5SRussell King #define UART011_CR		0x30	/* Control register. */
52a62c80e5SRussell King #define UART011_IFLS		0x34	/* Interrupt fifo level select. */
53a62c80e5SRussell King #define UART011_IMSC		0x38	/* Interrupt mask. */
54a62c80e5SRussell King #define UART011_RIS		0x3c	/* Raw interrupt status. */
55a62c80e5SRussell King #define UART011_MIS		0x40	/* Masked interrupt status. */
56a62c80e5SRussell King #define UART011_ICR		0x44	/* Interrupt clear register. */
57a62c80e5SRussell King #define UART011_DMACR		0x48	/* DMA control register. */
5829e29f27SLinus Walleij #define ST_UART011_XFCR		0x50	/* XON/XOFF control register. */
5929e29f27SLinus Walleij #define ST_UART011_XON1		0x54	/* XON1 register. */
6029e29f27SLinus Walleij #define ST_UART011_XON2		0x58	/* XON2 register. */
6129e29f27SLinus Walleij #define ST_UART011_XOFF1	0x5C	/* XON1 register. */
6229e29f27SLinus Walleij #define ST_UART011_XOFF2	0x60	/* XON2 register. */
6329e29f27SLinus Walleij #define ST_UART011_ITCR		0x80	/* Integration test control register. */
6429e29f27SLinus Walleij #define ST_UART011_ITIP		0x84	/* Integration test input register. */
6529e29f27SLinus Walleij #define ST_UART011_ABCR		0x100	/* Autobaud control register. */
6629e29f27SLinus Walleij #define ST_UART011_ABIMSC	0x15C	/* Autobaud interrupt mask/clear register. */
67a62c80e5SRussell King 
68*7ec75871SRussell King /*
69*7ec75871SRussell King  * ZTE UART register offsets.  This UART has a radically different address
70*7ec75871SRussell King  * allocation from the ARM and ST variants, so we list all registers here.
71*7ec75871SRussell King  * We assume unlisted registers do not exist.
72*7ec75871SRussell King  */
73*7ec75871SRussell King #define ZX_UART011_DR		0x04
74*7ec75871SRussell King #define ZX_UART011_FR		0x14
75*7ec75871SRussell King #define ZX_UART011_IBRD		0x24
76*7ec75871SRussell King #define ZX_UART011_FBRD		0x28
77*7ec75871SRussell King #define ZX_UART011_LCRH		0x30
78*7ec75871SRussell King #define ZX_UART011_CR		0x34
79*7ec75871SRussell King #define ZX_UART011_IFLS		0x38
80*7ec75871SRussell King #define ZX_UART011_IMSC		0x40
81*7ec75871SRussell King #define ZX_UART011_RIS		0x44
82*7ec75871SRussell King #define ZX_UART011_MIS		0x48
83*7ec75871SRussell King #define ZX_UART011_ICR		0x4c
84*7ec75871SRussell King #define ZX_UART011_DMACR	0x50
85*7ec75871SRussell King 
86a62c80e5SRussell King #define UART011_DR_OE		(1 << 11)
87a62c80e5SRussell King #define UART011_DR_BE		(1 << 10)
88a62c80e5SRussell King #define UART011_DR_PE		(1 << 9)
89a62c80e5SRussell King #define UART011_DR_FE		(1 << 8)
90a62c80e5SRussell King 
91a62c80e5SRussell King #define UART01x_RSR_OE 		0x08
92a62c80e5SRussell King #define UART01x_RSR_BE 		0x04
93a62c80e5SRussell King #define UART01x_RSR_PE 		0x02
94a62c80e5SRussell King #define UART01x_RSR_FE 		0x01
95a62c80e5SRussell King 
96a62c80e5SRussell King #define UART011_FR_RI		0x100
97a62c80e5SRussell King #define UART011_FR_TXFE		0x080
98a62c80e5SRussell King #define UART011_FR_RXFF		0x040
99a62c80e5SRussell King #define UART01x_FR_TXFF		0x020
100a62c80e5SRussell King #define UART01x_FR_RXFE		0x010
101a62c80e5SRussell King #define UART01x_FR_BUSY		0x008
102a62c80e5SRussell King #define UART01x_FR_DCD 		0x004
103a62c80e5SRussell King #define UART01x_FR_DSR 		0x002
104a62c80e5SRussell King #define UART01x_FR_CTS 		0x001
105a62c80e5SRussell King #define UART01x_FR_TMSK		(UART01x_FR_TXFF + UART01x_FR_BUSY)
106a62c80e5SRussell King 
107a62c80e5SRussell King #define UART011_CR_CTSEN	0x8000	/* CTS hardware flow control */
108a62c80e5SRussell King #define UART011_CR_RTSEN	0x4000	/* RTS hardware flow control */
109a62c80e5SRussell King #define UART011_CR_OUT2		0x2000	/* OUT2 */
110a62c80e5SRussell King #define UART011_CR_OUT1		0x1000	/* OUT1 */
111a62c80e5SRussell King #define UART011_CR_RTS		0x0800	/* RTS */
112a62c80e5SRussell King #define UART011_CR_DTR		0x0400	/* DTR */
113a62c80e5SRussell King #define UART011_CR_RXE		0x0200	/* receive enable */
114a62c80e5SRussell King #define UART011_CR_TXE		0x0100	/* transmit enable */
115a62c80e5SRussell King #define UART011_CR_LBE		0x0080	/* loopback enable */
116a62c80e5SRussell King #define UART010_CR_RTIE		0x0040
117a62c80e5SRussell King #define UART010_CR_TIE 		0x0020
118a62c80e5SRussell King #define UART010_CR_RIE 		0x0010
119a62c80e5SRussell King #define UART010_CR_MSIE		0x0008
120ac3e3fb4SLinus Walleij #define ST_UART011_CR_OVSFACT	0x0008	/* Oversampling factor */
121a62c80e5SRussell King #define UART01x_CR_IIRLP	0x0004	/* SIR low power mode */
122a62c80e5SRussell King #define UART01x_CR_SIREN	0x0002	/* SIR enable */
123a62c80e5SRussell King #define UART01x_CR_UARTEN	0x0001	/* UART enable */
124a62c80e5SRussell King 
125a62c80e5SRussell King #define UART011_LCRH_SPS	0x80
126a62c80e5SRussell King #define UART01x_LCRH_WLEN_8	0x60
127a62c80e5SRussell King #define UART01x_LCRH_WLEN_7	0x40
128a62c80e5SRussell King #define UART01x_LCRH_WLEN_6	0x20
129a62c80e5SRussell King #define UART01x_LCRH_WLEN_5	0x00
130a62c80e5SRussell King #define UART01x_LCRH_FEN	0x10
131a62c80e5SRussell King #define UART01x_LCRH_STP2	0x08
132a62c80e5SRussell King #define UART01x_LCRH_EPS	0x04
133a62c80e5SRussell King #define UART01x_LCRH_PEN	0x02
134a62c80e5SRussell King #define UART01x_LCRH_BRK	0x01
135a62c80e5SRussell King 
13638d62436SRussell King #define ST_UART011_DMAWM_RX_1	(0 << 3)
13738d62436SRussell King #define ST_UART011_DMAWM_RX_2	(1 << 3)
13838d62436SRussell King #define ST_UART011_DMAWM_RX_4	(2 << 3)
13938d62436SRussell King #define ST_UART011_DMAWM_RX_8	(3 << 3)
14038d62436SRussell King #define ST_UART011_DMAWM_RX_16	(4 << 3)
14138d62436SRussell King #define ST_UART011_DMAWM_RX_32	(5 << 3)
14238d62436SRussell King #define ST_UART011_DMAWM_RX_48	(6 << 3)
14338d62436SRussell King #define ST_UART011_DMAWM_TX_1	0
14438d62436SRussell King #define ST_UART011_DMAWM_TX_2	1
14538d62436SRussell King #define ST_UART011_DMAWM_TX_4	2
14638d62436SRussell King #define ST_UART011_DMAWM_TX_8	3
14738d62436SRussell King #define ST_UART011_DMAWM_TX_16	4
14838d62436SRussell King #define ST_UART011_DMAWM_TX_32	5
14938d62436SRussell King #define ST_UART011_DMAWM_TX_48	6
15038d62436SRussell King 
151a62c80e5SRussell King #define UART010_IIR_RTIS	0x08
152a62c80e5SRussell King #define UART010_IIR_TIS		0x04
153a62c80e5SRussell King #define UART010_IIR_RIS		0x02
154a62c80e5SRussell King #define UART010_IIR_MIS		0x01
155a62c80e5SRussell King 
156a62c80e5SRussell King #define UART011_IFLS_RX1_8	(0 << 3)
157a62c80e5SRussell King #define UART011_IFLS_RX2_8	(1 << 3)
158a62c80e5SRussell King #define UART011_IFLS_RX4_8	(2 << 3)
159a62c80e5SRussell King #define UART011_IFLS_RX6_8	(3 << 3)
160a62c80e5SRussell King #define UART011_IFLS_RX7_8	(4 << 3)
161a62c80e5SRussell King #define UART011_IFLS_TX1_8	(0 << 0)
162a62c80e5SRussell King #define UART011_IFLS_TX2_8	(1 << 0)
163a62c80e5SRussell King #define UART011_IFLS_TX4_8	(2 << 0)
164a62c80e5SRussell King #define UART011_IFLS_TX6_8	(3 << 0)
165a62c80e5SRussell King #define UART011_IFLS_TX7_8	(4 << 0)
1665926a295SAlessandro Rubini /* special values for ST vendor with deeper fifo */
1675926a295SAlessandro Rubini #define UART011_IFLS_RX_HALF	(5 << 3)
1685926a295SAlessandro Rubini #define UART011_IFLS_TX_HALF	(5 << 0)
169a62c80e5SRussell King 
170a62c80e5SRussell King #define UART011_OEIM		(1 << 10)	/* overrun error interrupt mask */
171a62c80e5SRussell King #define UART011_BEIM		(1 << 9)	/* break error interrupt mask */
172a62c80e5SRussell King #define UART011_PEIM		(1 << 8)	/* parity error interrupt mask */
173a62c80e5SRussell King #define UART011_FEIM		(1 << 7)	/* framing error interrupt mask */
174a62c80e5SRussell King #define UART011_RTIM		(1 << 6)	/* receive timeout interrupt mask */
175a62c80e5SRussell King #define UART011_TXIM		(1 << 5)	/* transmit interrupt mask */
176a62c80e5SRussell King #define UART011_RXIM		(1 << 4)	/* receive interrupt mask */
177a62c80e5SRussell King #define UART011_DSRMIM		(1 << 3)	/* DSR interrupt mask */
178a62c80e5SRussell King #define UART011_DCDMIM		(1 << 2)	/* DCD interrupt mask */
179a62c80e5SRussell King #define UART011_CTSMIM		(1 << 1)	/* CTS interrupt mask */
180a62c80e5SRussell King #define UART011_RIMIM		(1 << 0)	/* RI interrupt mask */
181a62c80e5SRussell King 
182a62c80e5SRussell King #define UART011_OEIS		(1 << 10)	/* overrun error interrupt status */
183a62c80e5SRussell King #define UART011_BEIS		(1 << 9)	/* break error interrupt status */
184a62c80e5SRussell King #define UART011_PEIS		(1 << 8)	/* parity error interrupt status */
185a62c80e5SRussell King #define UART011_FEIS		(1 << 7)	/* framing error interrupt status */
186a62c80e5SRussell King #define UART011_RTIS		(1 << 6)	/* receive timeout interrupt status */
187a62c80e5SRussell King #define UART011_TXIS		(1 << 5)	/* transmit interrupt status */
188a62c80e5SRussell King #define UART011_RXIS		(1 << 4)	/* receive interrupt status */
189a62c80e5SRussell King #define UART011_DSRMIS		(1 << 3)	/* DSR interrupt status */
190a62c80e5SRussell King #define UART011_DCDMIS		(1 << 2)	/* DCD interrupt status */
191a62c80e5SRussell King #define UART011_CTSMIS		(1 << 1)	/* CTS interrupt status */
192a62c80e5SRussell King #define UART011_RIMIS		(1 << 0)	/* RI interrupt status */
193a62c80e5SRussell King 
194a62c80e5SRussell King #define UART011_OEIC		(1 << 10)	/* overrun error interrupt clear */
195a62c80e5SRussell King #define UART011_BEIC		(1 << 9)	/* break error interrupt clear */
196a62c80e5SRussell King #define UART011_PEIC		(1 << 8)	/* parity error interrupt clear */
197a62c80e5SRussell King #define UART011_FEIC		(1 << 7)	/* framing error interrupt clear */
198a62c80e5SRussell King #define UART011_RTIC		(1 << 6)	/* receive timeout interrupt clear */
199a62c80e5SRussell King #define UART011_TXIC		(1 << 5)	/* transmit interrupt clear */
200a62c80e5SRussell King #define UART011_RXIC		(1 << 4)	/* receive interrupt clear */
201a62c80e5SRussell King #define UART011_DSRMIC		(1 << 3)	/* DSR interrupt clear */
202a62c80e5SRussell King #define UART011_DCDMIC		(1 << 2)	/* DCD interrupt clear */
203a62c80e5SRussell King #define UART011_CTSMIC		(1 << 1)	/* CTS interrupt clear */
204a62c80e5SRussell King #define UART011_RIMIC		(1 << 0)	/* RI interrupt clear */
205a62c80e5SRussell King 
206a62c80e5SRussell King #define UART011_DMAONERR	(1 << 2)	/* disable dma on error */
207a62c80e5SRussell King #define UART011_TXDMAE		(1 << 1)	/* enable transmit dma */
208a62c80e5SRussell King #define UART011_RXDMAE		(1 << 0)	/* enable receive dma */
209a62c80e5SRussell King 
210a62c80e5SRussell King #define UART01x_RSR_ANY		(UART01x_RSR_OE|UART01x_RSR_BE|UART01x_RSR_PE|UART01x_RSR_FE)
211a62c80e5SRussell King #define UART01x_FR_MODEM_ANY	(UART01x_FR_DCD|UART01x_FR_DSR|UART01x_FR_CTS)
212a62c80e5SRussell King 
213fbb18a27SRussell King #ifndef __ASSEMBLY__
214aa853f85SAlessandro Rubini struct amba_device; /* in uncompress this is included but amba/bus.h is not */
215fbb18a27SRussell King struct amba_pl010_data {
216fbb18a27SRussell King 	void (*set_mctrl)(struct amba_device *dev, void __iomem *base, unsigned int mctrl);
217fbb18a27SRussell King };
21868b65f73SRussell King 
21968b65f73SRussell King struct dma_chan;
22068b65f73SRussell King struct amba_pl011_data {
22168b65f73SRussell King 	bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
22268b65f73SRussell King 	void *dma_rx_param;
22368b65f73SRussell King 	void *dma_tx_param;
224cb06ff10SChanho Min 	bool dma_rx_poll_enable;
225cb06ff10SChanho Min 	unsigned int dma_rx_poll_rate;
226cb06ff10SChanho Min 	unsigned int dma_rx_poll_timeout;
227c16d51a3SShreshtha Kumar Sahu         void (*init) (void);
228c16d51a3SShreshtha Kumar Sahu 	void (*exit) (void);
22968b65f73SRussell King };
230fbb18a27SRussell King #endif
231fbb18a27SRussell King 
232a62c80e5SRussell King #endif
233