xref: /openbmc/linux/drivers/tty/serial/8250/8250_dwlib.c (revision f287f971e2569827fe9fb3a8d55a37703a13cf29)
1136e0ab9SAndy Shevchenko // SPDX-License-Identifier: GPL-2.0+
2136e0ab9SAndy Shevchenko /* Synopsys DesignWare 8250 library. */
3136e0ab9SAndy Shevchenko 
4136e0ab9SAndy Shevchenko #include <linux/bitops.h>
5642aa760SIlpo Järvinen #include <linux/bitfield.h>
6*f287f971SIlpo Järvinen #include <linux/delay.h>
7136e0ab9SAndy Shevchenko #include <linux/device.h>
8136e0ab9SAndy Shevchenko #include <linux/kernel.h>
9*f287f971SIlpo Järvinen #include <linux/math.h>
10642aa760SIlpo Järvinen #include <linux/property.h>
11136e0ab9SAndy Shevchenko #include <linux/serial_8250.h>
12136e0ab9SAndy Shevchenko #include <linux/serial_core.h>
13136e0ab9SAndy Shevchenko 
14136e0ab9SAndy Shevchenko #include "8250_dwlib.h"
15136e0ab9SAndy Shevchenko 
16136e0ab9SAndy Shevchenko /* Offsets for the DesignWare specific registers */
17642aa760SIlpo Järvinen #define DW_UART_TCR	0xac /* Transceiver Control Register (RS485) */
18642aa760SIlpo Järvinen #define DW_UART_DE_EN	0xb0 /* Driver Output Enable Register */
19642aa760SIlpo Järvinen #define DW_UART_RE_EN	0xb4 /* Receiver Output Enable Register */
20136e0ab9SAndy Shevchenko #define DW_UART_DLF	0xc0 /* Divisor Latch Fraction Register */
21*f287f971SIlpo Järvinen #define DW_UART_RAR	0xc4 /* Receive Address Register */
22*f287f971SIlpo Järvinen #define DW_UART_TAR	0xc8 /* Transmit Address Register */
23*f287f971SIlpo Järvinen #define DW_UART_LCR_EXT	0xcc /* Line Extended Control Register */
24136e0ab9SAndy Shevchenko #define DW_UART_CPR	0xf4 /* Component Parameter Register */
25136e0ab9SAndy Shevchenko #define DW_UART_UCV	0xf8 /* UART Component Version */
26136e0ab9SAndy Shevchenko 
27*f287f971SIlpo Järvinen /* Receive / Transmit Address Register bits */
28*f287f971SIlpo Järvinen #define DW_UART_ADDR_MASK		GENMASK(7, 0)
29*f287f971SIlpo Järvinen 
30*f287f971SIlpo Järvinen /* Line Status Register bits */
31*f287f971SIlpo Järvinen #define DW_UART_LSR_ADDR_RCVD		BIT(8)
32*f287f971SIlpo Järvinen 
33642aa760SIlpo Järvinen /* Transceiver Control Register bits */
34642aa760SIlpo Järvinen #define DW_UART_TCR_RS485_EN		BIT(0)
35642aa760SIlpo Järvinen #define DW_UART_TCR_RE_POL		BIT(1)
36642aa760SIlpo Järvinen #define DW_UART_TCR_DE_POL		BIT(2)
37642aa760SIlpo Järvinen #define DW_UART_TCR_XFER_MODE		GENMASK(4, 3)
38642aa760SIlpo Järvinen #define DW_UART_TCR_XFER_MODE_DE_DURING_RE	FIELD_PREP(DW_UART_TCR_XFER_MODE, 0)
39642aa760SIlpo Järvinen #define DW_UART_TCR_XFER_MODE_SW_DE_OR_RE	FIELD_PREP(DW_UART_TCR_XFER_MODE, 1)
40642aa760SIlpo Järvinen #define DW_UART_TCR_XFER_MODE_DE_OR_RE		FIELD_PREP(DW_UART_TCR_XFER_MODE, 2)
41642aa760SIlpo Järvinen 
42*f287f971SIlpo Järvinen /* Line Extended Control Register bits */
43*f287f971SIlpo Järvinen #define DW_UART_LCR_EXT_DLS_E		BIT(0)
44*f287f971SIlpo Järvinen #define DW_UART_LCR_EXT_ADDR_MATCH	BIT(1)
45*f287f971SIlpo Järvinen #define DW_UART_LCR_EXT_SEND_ADDR	BIT(2)
46*f287f971SIlpo Järvinen #define DW_UART_LCR_EXT_TRANSMIT_MODE	BIT(3)
47*f287f971SIlpo Järvinen 
48136e0ab9SAndy Shevchenko /* Component Parameter Register bits */
49136e0ab9SAndy Shevchenko #define DW_UART_CPR_ABP_DATA_WIDTH	(3 << 0)
50136e0ab9SAndy Shevchenko #define DW_UART_CPR_AFCE_MODE		(1 << 4)
51136e0ab9SAndy Shevchenko #define DW_UART_CPR_THRE_MODE		(1 << 5)
52136e0ab9SAndy Shevchenko #define DW_UART_CPR_SIR_MODE		(1 << 6)
53136e0ab9SAndy Shevchenko #define DW_UART_CPR_SIR_LP_MODE		(1 << 7)
54136e0ab9SAndy Shevchenko #define DW_UART_CPR_ADDITIONAL_FEATURES	(1 << 8)
55136e0ab9SAndy Shevchenko #define DW_UART_CPR_FIFO_ACCESS		(1 << 9)
56136e0ab9SAndy Shevchenko #define DW_UART_CPR_FIFO_STAT		(1 << 10)
57136e0ab9SAndy Shevchenko #define DW_UART_CPR_SHADOW		(1 << 11)
58136e0ab9SAndy Shevchenko #define DW_UART_CPR_ENCODED_PARMS	(1 << 12)
59136e0ab9SAndy Shevchenko #define DW_UART_CPR_DMA_EXTRA		(1 << 13)
60136e0ab9SAndy Shevchenko #define DW_UART_CPR_FIFO_MODE		(0xff << 16)
61136e0ab9SAndy Shevchenko 
62136e0ab9SAndy Shevchenko /* Helper for FIFO size calculation */
63136e0ab9SAndy Shevchenko #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
64136e0ab9SAndy Shevchenko 
65136e0ab9SAndy Shevchenko /*
66136e0ab9SAndy Shevchenko  * divisor = div(I) + div(F)
67136e0ab9SAndy Shevchenko  * "I" means integer, "F" means fractional
68136e0ab9SAndy Shevchenko  * quot = div(I) = clk / (16 * baud)
69136e0ab9SAndy Shevchenko  * frac = div(F) * 2^dlf_size
70136e0ab9SAndy Shevchenko  *
71136e0ab9SAndy Shevchenko  * let rem = clk % (16 * baud)
72136e0ab9SAndy Shevchenko  * we have: div(F) * (16 * baud) = rem
73136e0ab9SAndy Shevchenko  * so frac = 2^dlf_size * rem / (16 * baud) = (rem << dlf_size) / (16 * baud)
74136e0ab9SAndy Shevchenko  */
75136e0ab9SAndy Shevchenko static unsigned int dw8250_get_divisor(struct uart_port *p, unsigned int baud,
76136e0ab9SAndy Shevchenko 				       unsigned int *frac)
77136e0ab9SAndy Shevchenko {
78136e0ab9SAndy Shevchenko 	unsigned int quot, rem, base_baud = baud * 16;
79136e0ab9SAndy Shevchenko 	struct dw8250_port_data *d = p->private_data;
80136e0ab9SAndy Shevchenko 
81136e0ab9SAndy Shevchenko 	quot = p->uartclk / base_baud;
82136e0ab9SAndy Shevchenko 	rem = p->uartclk % base_baud;
83136e0ab9SAndy Shevchenko 	*frac = DIV_ROUND_CLOSEST(rem << d->dlf_size, base_baud);
84136e0ab9SAndy Shevchenko 
85136e0ab9SAndy Shevchenko 	return quot;
86136e0ab9SAndy Shevchenko }
87136e0ab9SAndy Shevchenko 
88136e0ab9SAndy Shevchenko static void dw8250_set_divisor(struct uart_port *p, unsigned int baud,
89136e0ab9SAndy Shevchenko 			       unsigned int quot, unsigned int quot_frac)
90136e0ab9SAndy Shevchenko {
91136e0ab9SAndy Shevchenko 	dw8250_writel_ext(p, DW_UART_DLF, quot_frac);
92136e0ab9SAndy Shevchenko 	serial8250_do_set_divisor(p, baud, quot, quot_frac);
93136e0ab9SAndy Shevchenko }
94136e0ab9SAndy Shevchenko 
957c4fc082SAndy Shevchenko void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old)
967c4fc082SAndy Shevchenko {
977c4fc082SAndy Shevchenko 	p->status &= ~UPSTAT_AUTOCTS;
987c4fc082SAndy Shevchenko 	if (termios->c_cflag & CRTSCTS)
997c4fc082SAndy Shevchenko 		p->status |= UPSTAT_AUTOCTS;
1007c4fc082SAndy Shevchenko 
1017c4fc082SAndy Shevchenko 	serial8250_do_set_termios(p, termios, old);
102*f287f971SIlpo Järvinen 
103*f287f971SIlpo Järvinen 	/* Filter addresses which have 9th bit set */
104*f287f971SIlpo Järvinen 	p->ignore_status_mask |= DW_UART_LSR_ADDR_RCVD;
105*f287f971SIlpo Järvinen 	p->read_status_mask |= DW_UART_LSR_ADDR_RCVD;
1067c4fc082SAndy Shevchenko }
1077c4fc082SAndy Shevchenko EXPORT_SYMBOL_GPL(dw8250_do_set_termios);
1087c4fc082SAndy Shevchenko 
109*f287f971SIlpo Järvinen /*
110*f287f971SIlpo Järvinen  * Wait until re is de-asserted for sure. An ongoing receive will keep
111*f287f971SIlpo Järvinen  * re asserted until end of frame. Without BUSY indication available,
112*f287f971SIlpo Järvinen  * only available course of action is to wait for the time it takes to
113*f287f971SIlpo Järvinen  * receive one frame (there might nothing to receive but w/o BUSY the
114*f287f971SIlpo Järvinen  * driver cannot know).
115*f287f971SIlpo Järvinen  */
116*f287f971SIlpo Järvinen static void dw8250_wait_re_deassert(struct uart_port *p)
117*f287f971SIlpo Järvinen {
118*f287f971SIlpo Järvinen 	ndelay(p->frame_time);
119*f287f971SIlpo Järvinen }
120*f287f971SIlpo Järvinen 
121*f287f971SIlpo Järvinen static void dw8250_update_rar(struct uart_port *p, u32 addr)
122*f287f971SIlpo Järvinen {
123*f287f971SIlpo Järvinen 	u32 re_en = dw8250_readl_ext(p, DW_UART_RE_EN);
124*f287f971SIlpo Järvinen 
125*f287f971SIlpo Järvinen 	/*
126*f287f971SIlpo Järvinen 	 * RAR shouldn't be changed while receiving. Thus, de-assert RE_EN
127*f287f971SIlpo Järvinen 	 * if asserted and wait.
128*f287f971SIlpo Järvinen 	 */
129*f287f971SIlpo Järvinen 	if (re_en)
130*f287f971SIlpo Järvinen 		dw8250_writel_ext(p, DW_UART_RE_EN, 0);
131*f287f971SIlpo Järvinen 	dw8250_wait_re_deassert(p);
132*f287f971SIlpo Järvinen 	dw8250_writel_ext(p, DW_UART_RAR, addr);
133*f287f971SIlpo Järvinen 	if (re_en)
134*f287f971SIlpo Järvinen 		dw8250_writel_ext(p, DW_UART_RE_EN, re_en);
135*f287f971SIlpo Järvinen }
136*f287f971SIlpo Järvinen 
137*f287f971SIlpo Järvinen static void dw8250_rs485_set_addr(struct uart_port *p, struct serial_rs485 *rs485,
138*f287f971SIlpo Järvinen 				  struct ktermios *termios)
139*f287f971SIlpo Järvinen {
140*f287f971SIlpo Järvinen 	u32 lcr = dw8250_readl_ext(p, DW_UART_LCR_EXT);
141*f287f971SIlpo Järvinen 
142*f287f971SIlpo Järvinen 	if (rs485->flags & SER_RS485_ADDRB) {
143*f287f971SIlpo Järvinen 		lcr |= DW_UART_LCR_EXT_DLS_E;
144*f287f971SIlpo Järvinen 		if (termios)
145*f287f971SIlpo Järvinen 			termios->c_cflag |= ADDRB;
146*f287f971SIlpo Järvinen 
147*f287f971SIlpo Järvinen 		if (rs485->flags & SER_RS485_ADDR_RECV) {
148*f287f971SIlpo Järvinen 			u32 delta = p->rs485.flags ^ rs485->flags;
149*f287f971SIlpo Järvinen 
150*f287f971SIlpo Järvinen 			/*
151*f287f971SIlpo Järvinen 			 * rs485 (param) is equal to uart_port's rs485 only during init
152*f287f971SIlpo Järvinen 			 * (during init, delta is not yet applicable).
153*f287f971SIlpo Järvinen 			 */
154*f287f971SIlpo Järvinen 			if (unlikely(&p->rs485 == rs485))
155*f287f971SIlpo Järvinen 				delta = rs485->flags;
156*f287f971SIlpo Järvinen 
157*f287f971SIlpo Järvinen 			if ((delta & SER_RS485_ADDR_RECV) ||
158*f287f971SIlpo Järvinen 			    (p->rs485.addr_recv != rs485->addr_recv))
159*f287f971SIlpo Järvinen 				dw8250_update_rar(p, rs485->addr_recv);
160*f287f971SIlpo Järvinen 			lcr |= DW_UART_LCR_EXT_ADDR_MATCH;
161*f287f971SIlpo Järvinen 		} else {
162*f287f971SIlpo Järvinen 			lcr &= ~DW_UART_LCR_EXT_ADDR_MATCH;
163*f287f971SIlpo Järvinen 		}
164*f287f971SIlpo Järvinen 		if (rs485->flags & SER_RS485_ADDR_DEST) {
165*f287f971SIlpo Järvinen 			/*
166*f287f971SIlpo Järvinen 			 * Don't skip writes here as another endpoint could
167*f287f971SIlpo Järvinen 			 * have changed communication line's destination
168*f287f971SIlpo Järvinen 			 * address in between.
169*f287f971SIlpo Järvinen 			 */
170*f287f971SIlpo Järvinen 			dw8250_writel_ext(p, DW_UART_TAR, rs485->addr_dest);
171*f287f971SIlpo Järvinen 			lcr |= DW_UART_LCR_EXT_SEND_ADDR;
172*f287f971SIlpo Järvinen 		}
173*f287f971SIlpo Järvinen 	} else {
174*f287f971SIlpo Järvinen 		lcr = 0;
175*f287f971SIlpo Järvinen 	}
176*f287f971SIlpo Järvinen 	dw8250_writel_ext(p, DW_UART_LCR_EXT, lcr);
177*f287f971SIlpo Järvinen }
178*f287f971SIlpo Järvinen 
179ae50bb27SIlpo Järvinen static int dw8250_rs485_config(struct uart_port *p, struct ktermios *termios,
180ae50bb27SIlpo Järvinen 			       struct serial_rs485 *rs485)
181642aa760SIlpo Järvinen {
182642aa760SIlpo Järvinen 	u32 tcr;
183642aa760SIlpo Järvinen 
184642aa760SIlpo Järvinen 	tcr = dw8250_readl_ext(p, DW_UART_TCR);
185642aa760SIlpo Järvinen 	tcr &= ~DW_UART_TCR_XFER_MODE;
186642aa760SIlpo Järvinen 
187642aa760SIlpo Järvinen 	if (rs485->flags & SER_RS485_ENABLED) {
188642aa760SIlpo Järvinen 		tcr |= DW_UART_TCR_RS485_EN;
189642aa760SIlpo Järvinen 
190642aa760SIlpo Järvinen 		if (rs485->flags & SER_RS485_RX_DURING_TX) {
191642aa760SIlpo Järvinen 			tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE;
192642aa760SIlpo Järvinen 		} else {
193642aa760SIlpo Järvinen 			/* HW does not support same DE level for tx and rx */
194642aa760SIlpo Järvinen 			if (!(rs485->flags & SER_RS485_RTS_ON_SEND) ==
195642aa760SIlpo Järvinen 			    !(rs485->flags & SER_RS485_RTS_AFTER_SEND))
196642aa760SIlpo Järvinen 				return -EINVAL;
197642aa760SIlpo Järvinen 
198642aa760SIlpo Järvinen 			tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE;
199642aa760SIlpo Järvinen 		}
200642aa760SIlpo Järvinen 		dw8250_writel_ext(p, DW_UART_DE_EN, 1);
201642aa760SIlpo Järvinen 		dw8250_writel_ext(p, DW_UART_RE_EN, 1);
202642aa760SIlpo Järvinen 	} else {
203*f287f971SIlpo Järvinen 		if (termios)
204*f287f971SIlpo Järvinen 			termios->c_cflag &= ~ADDRB;
205*f287f971SIlpo Järvinen 
206642aa760SIlpo Järvinen 		tcr &= ~DW_UART_TCR_RS485_EN;
207642aa760SIlpo Järvinen 	}
208642aa760SIlpo Järvinen 
209642aa760SIlpo Järvinen 	/* Reset to default polarity */
210642aa760SIlpo Järvinen 	tcr |= DW_UART_TCR_DE_POL;
211642aa760SIlpo Järvinen 	tcr &= ~DW_UART_TCR_RE_POL;
212642aa760SIlpo Järvinen 
213642aa760SIlpo Järvinen 	if (!(rs485->flags & SER_RS485_RTS_ON_SEND))
214642aa760SIlpo Järvinen 		tcr &= ~DW_UART_TCR_DE_POL;
215642aa760SIlpo Järvinen 	if (device_property_read_bool(p->dev, "rs485-rx-active-high"))
216642aa760SIlpo Järvinen 		tcr |= DW_UART_TCR_RE_POL;
217642aa760SIlpo Järvinen 
218642aa760SIlpo Järvinen 	dw8250_writel_ext(p, DW_UART_TCR, tcr);
219642aa760SIlpo Järvinen 
220*f287f971SIlpo Järvinen 	/* Addressing mode can only be set up after TCR */
221*f287f971SIlpo Järvinen 	if (rs485->flags & SER_RS485_ENABLED)
222*f287f971SIlpo Järvinen 		dw8250_rs485_set_addr(p, rs485, termios);
223*f287f971SIlpo Järvinen 
224642aa760SIlpo Järvinen 	return 0;
225642aa760SIlpo Järvinen }
226642aa760SIlpo Järvinen 
227642aa760SIlpo Järvinen /*
228642aa760SIlpo Järvinen  * Tests if RE_EN register can have non-zero value to see if RS-485 HW support
229642aa760SIlpo Järvinen  * is present.
230642aa760SIlpo Järvinen  */
231642aa760SIlpo Järvinen static bool dw8250_detect_rs485_hw(struct uart_port *p)
232642aa760SIlpo Järvinen {
233642aa760SIlpo Järvinen 	u32 reg;
234642aa760SIlpo Järvinen 
235642aa760SIlpo Järvinen 	dw8250_writel_ext(p, DW_UART_RE_EN, 1);
236642aa760SIlpo Järvinen 	reg = dw8250_readl_ext(p, DW_UART_RE_EN);
237642aa760SIlpo Järvinen 	dw8250_writel_ext(p, DW_UART_RE_EN, 0);
238642aa760SIlpo Järvinen 	return reg;
239642aa760SIlpo Järvinen }
240642aa760SIlpo Järvinen 
24162a4b3d2SIlpo Järvinen static const struct serial_rs485 dw8250_rs485_supported = {
24262a4b3d2SIlpo Järvinen 	.flags = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | SER_RS485_RTS_ON_SEND |
243*f287f971SIlpo Järvinen 		 SER_RS485_RTS_AFTER_SEND | SER_RS485_ADDRB | SER_RS485_ADDR_RECV |
244*f287f971SIlpo Järvinen 		 SER_RS485_ADDR_DEST,
24562a4b3d2SIlpo Järvinen };
24662a4b3d2SIlpo Järvinen 
247136e0ab9SAndy Shevchenko void dw8250_setup_port(struct uart_port *p)
248136e0ab9SAndy Shevchenko {
249593dea00SMiquel Raynal 	struct dw8250_port_data *pd = p->private_data;
250593dea00SMiquel Raynal 	struct dw8250_data *data = to_dw8250_data(pd);
251136e0ab9SAndy Shevchenko 	struct uart_8250_port *up = up_to_u8250p(p);
252136e0ab9SAndy Shevchenko 	u32 reg;
253136e0ab9SAndy Shevchenko 
254642aa760SIlpo Järvinen 	pd->hw_rs485_support = dw8250_detect_rs485_hw(p);
2555ff33917SIlpo Järvinen 	if (pd->hw_rs485_support) {
256642aa760SIlpo Järvinen 		p->rs485_config = dw8250_rs485_config;
257*f287f971SIlpo Järvinen 		up->lsr_save_mask = LSR_SAVE_FLAGS | DW_UART_LSR_ADDR_RCVD;
25862a4b3d2SIlpo Järvinen 		p->rs485_supported = &dw8250_rs485_supported;
2595ff33917SIlpo Järvinen 	} else {
2605ff33917SIlpo Järvinen 		p->rs485_config = serial8250_em485_config;
26162a4b3d2SIlpo Järvinen 		p->rs485_supported = &serial8250_em485_supported;
2625ff33917SIlpo Järvinen 		up->rs485_start_tx = serial8250_em485_start_tx;
2635ff33917SIlpo Järvinen 		up->rs485_stop_tx = serial8250_em485_stop_tx;
2645ff33917SIlpo Järvinen 	}
2655ff33917SIlpo Järvinen 	up->capabilities |= UART_CAP_NOTEMT;
266642aa760SIlpo Järvinen 
267136e0ab9SAndy Shevchenko 	/*
268136e0ab9SAndy Shevchenko 	 * If the Component Version Register returns zero, we know that
269136e0ab9SAndy Shevchenko 	 * ADDITIONAL_FEATURES are not enabled. No need to go any further.
270136e0ab9SAndy Shevchenko 	 */
271136e0ab9SAndy Shevchenko 	reg = dw8250_readl_ext(p, DW_UART_UCV);
272136e0ab9SAndy Shevchenko 	if (!reg)
273136e0ab9SAndy Shevchenko 		return;
274136e0ab9SAndy Shevchenko 
275136e0ab9SAndy Shevchenko 	dev_dbg(p->dev, "Designware UART version %c.%c%c\n",
276136e0ab9SAndy Shevchenko 		(reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff);
277136e0ab9SAndy Shevchenko 
278136e0ab9SAndy Shevchenko 	dw8250_writel_ext(p, DW_UART_DLF, ~0U);
279136e0ab9SAndy Shevchenko 	reg = dw8250_readl_ext(p, DW_UART_DLF);
280136e0ab9SAndy Shevchenko 	dw8250_writel_ext(p, DW_UART_DLF, 0);
281136e0ab9SAndy Shevchenko 
282136e0ab9SAndy Shevchenko 	if (reg) {
283593dea00SMiquel Raynal 		pd->dlf_size = fls(reg);
284136e0ab9SAndy Shevchenko 		p->get_divisor = dw8250_get_divisor;
285136e0ab9SAndy Shevchenko 		p->set_divisor = dw8250_set_divisor;
286136e0ab9SAndy Shevchenko 	}
287136e0ab9SAndy Shevchenko 
288136e0ab9SAndy Shevchenko 	reg = dw8250_readl_ext(p, DW_UART_CPR);
289593dea00SMiquel Raynal 	if (!reg) {
290593dea00SMiquel Raynal 		reg = data->pdata->cpr_val;
291593dea00SMiquel Raynal 		dev_dbg(p->dev, "CPR is not available, using 0x%08x instead\n", reg);
292593dea00SMiquel Raynal 	}
293136e0ab9SAndy Shevchenko 	if (!reg)
294136e0ab9SAndy Shevchenko 		return;
295136e0ab9SAndy Shevchenko 
296136e0ab9SAndy Shevchenko 	/* Select the type based on FIFO */
297136e0ab9SAndy Shevchenko 	if (reg & DW_UART_CPR_FIFO_MODE) {
298136e0ab9SAndy Shevchenko 		p->type = PORT_16550A;
299136e0ab9SAndy Shevchenko 		p->flags |= UPF_FIXED_TYPE;
300136e0ab9SAndy Shevchenko 		p->fifosize = DW_UART_CPR_FIFO_SIZE(reg);
3015ff33917SIlpo Järvinen 		up->capabilities = UART_CAP_FIFO | UART_CAP_NOTEMT;
302136e0ab9SAndy Shevchenko 	}
303136e0ab9SAndy Shevchenko 
304136e0ab9SAndy Shevchenko 	if (reg & DW_UART_CPR_AFCE_MODE)
305136e0ab9SAndy Shevchenko 		up->capabilities |= UART_CAP_AFE;
306136e0ab9SAndy Shevchenko 
307136e0ab9SAndy Shevchenko 	if (reg & DW_UART_CPR_SIR_MODE)
308136e0ab9SAndy Shevchenko 		up->capabilities |= UART_CAP_IRDA;
309136e0ab9SAndy Shevchenko }
310136e0ab9SAndy Shevchenko EXPORT_SYMBOL_GPL(dw8250_setup_port);
311