xref: /linux/drivers/tty/serial/8250/8250_exar.c (revision d813d90085aefacc3500db94d82c60e0702965fa)
1e3b3d0f5SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2d0aeaa83SSudip Mukherjee /*
3d0aeaa83SSudip Mukherjee  *  Probe module for 8250/16550-type Exar chips PCI serial ports.
4d0aeaa83SSudip Mukherjee  *
5d0aeaa83SSudip Mukherjee  *  Based on drivers/tty/serial/8250/8250_pci.c,
6d0aeaa83SSudip Mukherjee  *
7d0aeaa83SSudip Mukherjee  *  Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved.
8d0aeaa83SSudip Mukherjee  */
9413058dfSJan Kiszka #include <linux/dmi.h>
10d0aeaa83SSudip Mukherjee #include <linux/io.h>
11d0aeaa83SSudip Mukherjee #include <linux/kernel.h>
12d0aeaa83SSudip Mukherjee #include <linux/module.h>
13d0aeaa83SSudip Mukherjee #include <linux/pci.h>
1473f76db8SAndy Shevchenko #include <linux/platform_device.h>
1582f9cefaSAndy Shevchenko #include <linux/pm.h>
16380b1e2fSJan Kiszka #include <linux/property.h>
17d0aeaa83SSudip Mukherjee #include <linux/serial_core.h>
18d0aeaa83SSudip Mukherjee #include <linux/serial_reg.h>
19d0aeaa83SSudip Mukherjee #include <linux/slab.h>
20d0aeaa83SSudip Mukherjee #include <linux/string.h>
21d0aeaa83SSudip Mukherjee #include <linux/tty.h>
2247b1747fSRobert Middleton #include <linux/delay.h>
23d0aeaa83SSudip Mukherjee 
24d0aeaa83SSudip Mukherjee #include <asm/byteorder.h>
25d0aeaa83SSudip Mukherjee 
26d0aeaa83SSudip Mukherjee #include "8250.h"
27*d813d900SAndy Shevchenko #include "8250_pcilib.h"
28d0aeaa83SSudip Mukherjee 
2924637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM_2S		0x1052
3024637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM_4S		0x105d
3124637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM_8S		0x106c
3224637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM232_8		0x10a8
3324637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM_2SM		0x10d2
3424637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM_4SM		0x10db
3524637007SAndy Shevchenko #define PCI_DEVICE_ID_ACCESSIO_COM_8SM		0x10ea
3610c5ccc3SJay Dolan 
37fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_4224PCI335	0x0002
38fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_4222PCI335	0x0004
39fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_2324PCI335	0x000a
40fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_2328PCI335	0x000b
41d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4224PCIE		0x0020
42d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4228PCIE		0x0021
43d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4222PCIE		0x0022
4495d69886SAndrew Davis 
45d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_EXAR_XR17V4358		0x4358
46d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_EXAR_XR17V8358		0x8358
47d0aeaa83SSudip Mukherjee 
4895d69886SAndrew Davis #define PCI_SUBDEVICE_ID_USR_2980		0x0128
4995d69886SAndrew Davis #define PCI_SUBDEVICE_ID_USR_2981		0x0129
5095d69886SAndrew Davis 
51c7e1b405SAaron Sierra #define UART_EXAR_INT0		0x80
527e12357eSJan Kiszka #define UART_EXAR_8XMODE	0x88	/* 8X sampling rate select */
53ef4e281eSAndy Shevchenko #define UART_EXAR_SLEEP		0x8b	/* Sleep mode */
546be254c2SAndy Shevchenko #define UART_EXAR_DVID		0x8d	/* Device identification */
557e12357eSJan Kiszka 
567e12357eSJan Kiszka #define UART_EXAR_FCTR		0x08	/* Feature Control Register */
577e12357eSJan Kiszka #define UART_FCTR_EXAR_IRDA	0x10	/* IrDa data encode select */
587e12357eSJan Kiszka #define UART_FCTR_EXAR_485	0x20	/* Auto 485 half duplex dir ctl */
597e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGA	0x00	/* FIFO trigger table A */
607e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGB	0x60	/* FIFO trigger table B */
617e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGC	0x80	/* FIFO trigger table C */
627e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGD	0xc0	/* FIFO trigger table D programmable */
637e12357eSJan Kiszka 
647e12357eSJan Kiszka #define UART_EXAR_TXTRG		0x0a	/* Tx FIFO trigger level write-only */
657e12357eSJan Kiszka #define UART_EXAR_RXTRG		0x0b	/* Rx FIFO trigger level write-only */
667e12357eSJan Kiszka 
67d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINT_7_0	0x8f	/* MPIOINT[7:0] */
68d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOLVL_7_0	0x90	/* MPIOLVL[7:0] */
69d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIO3T_7_0	0x91	/* MPIO3T[7:0] */
70d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINV_7_0	0x92	/* MPIOINV[7:0] */
71d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOSEL_7_0	0x93	/* MPIOSEL[7:0] */
72d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOOD_7_0	0x94	/* MPIOOD[7:0] */
73d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINT_15_8	0x95	/* MPIOINT[15:8] */
74d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOLVL_15_8	0x96	/* MPIOLVL[15:8] */
75d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIO3T_15_8	0x97	/* MPIO3T[15:8] */
76d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINV_15_8	0x98	/* MPIOINV[15:8] */
77d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOSEL_15_8	0x99	/* MPIOSEL[15:8] */
78d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOOD_15_8	0x9a	/* MPIOOD[15:8] */
79d0aeaa83SSudip Mukherjee 
80413058dfSJan Kiszka #define UART_EXAR_RS485_DLY(x)	((x) << 4)
81413058dfSJan Kiszka 
82687911b3SMatthew Howell #define UART_EXAR_DLD			0x02 /* Divisor Fractional */
83687911b3SMatthew Howell #define UART_EXAR_DLD_485_POLARITY	0x80 /* RS-485 Enable Signal Polarity */
84687911b3SMatthew Howell 
85413058dfSJan Kiszka /*
86413058dfSJan Kiszka  * IOT2040 MPIO wiring semantics:
87413058dfSJan Kiszka  *
88413058dfSJan Kiszka  * MPIO		Port	Function
89413058dfSJan Kiszka  * ----		----	--------
90413058dfSJan Kiszka  * 0		2 	Mode bit 0
91413058dfSJan Kiszka  * 1		2	Mode bit 1
92413058dfSJan Kiszka  * 2		2	Terminate bus
93413058dfSJan Kiszka  * 3		-	<reserved>
94413058dfSJan Kiszka  * 4		3	Mode bit 0
95413058dfSJan Kiszka  * 5		3	Mode bit 1
96413058dfSJan Kiszka  * 6		3	Terminate bus
97413058dfSJan Kiszka  * 7		-	<reserved>
98413058dfSJan Kiszka  * 8		2	Enable
99413058dfSJan Kiszka  * 9		3	Enable
100413058dfSJan Kiszka  * 10		-	Red LED
101413058dfSJan Kiszka  * 11..15	-	<unused>
102413058dfSJan Kiszka  */
103413058dfSJan Kiszka 
104413058dfSJan Kiszka /* IOT2040 MPIOs 0..7 */
105413058dfSJan Kiszka #define IOT2040_UART_MODE_RS232		0x01
106413058dfSJan Kiszka #define IOT2040_UART_MODE_RS485		0x02
107413058dfSJan Kiszka #define IOT2040_UART_MODE_RS422		0x03
108413058dfSJan Kiszka #define IOT2040_UART_TERMINATE_BUS	0x04
109413058dfSJan Kiszka 
110413058dfSJan Kiszka #define IOT2040_UART1_MASK		0x0f
111413058dfSJan Kiszka #define IOT2040_UART2_SHIFT		4
112413058dfSJan Kiszka 
113413058dfSJan Kiszka #define IOT2040_UARTS_DEFAULT_MODE	0x11	/* both RS232 */
114413058dfSJan Kiszka #define IOT2040_UARTS_GPIO_LO_MODE	0x88	/* reserved pins as input */
115413058dfSJan Kiszka 
116413058dfSJan Kiszka /* IOT2040 MPIOs 8..15 */
117413058dfSJan Kiszka #define IOT2040_UARTS_ENABLE		0x03
118413058dfSJan Kiszka #define IOT2040_UARTS_GPIO_HI_MODE	0xF8	/* enable & LED as outputs */
119413058dfSJan Kiszka 
120d0aeaa83SSudip Mukherjee struct exar8250;
121d0aeaa83SSudip Mukherjee 
1220d963ebfSJan Kiszka struct exar8250_platform {
123ae50bb27SIlpo Järvinen 	int (*rs485_config)(struct uart_port *port, struct ktermios *termios,
124ae50bb27SIlpo Järvinen 			    struct serial_rs485 *rs485);
12559c221f8SIlpo Järvinen 	const struct serial_rs485 *rs485_supported;
1260d963ebfSJan Kiszka 	int (*register_gpio)(struct pci_dev *, struct uart_8250_port *);
12733969db7SAndy Shevchenko 	void (*unregister_gpio)(struct uart_8250_port *);
1280d963ebfSJan Kiszka };
1290d963ebfSJan Kiszka 
130d0aeaa83SSudip Mukherjee /**
131d0aeaa83SSudip Mukherjee  * struct exar8250_board - board information
132d0aeaa83SSudip Mukherjee  * @num_ports: number of serial ports
133d0aeaa83SSudip Mukherjee  * @reg_shift: describes UART register mapping in PCI memory
13426f22d57SAndy Shevchenko  * @setup: quirk run at ->probe() stage
13526f22d57SAndy Shevchenko  * @exit: quirk run at ->remove() stage
136d0aeaa83SSudip Mukherjee  */
137d0aeaa83SSudip Mukherjee struct exar8250_board {
138d0aeaa83SSudip Mukherjee 	unsigned int num_ports;
139d0aeaa83SSudip Mukherjee 	unsigned int reg_shift;
140d0aeaa83SSudip Mukherjee 	int	(*setup)(struct exar8250 *, struct pci_dev *,
141d0aeaa83SSudip Mukherjee 			 struct uart_8250_port *, int);
142d0aeaa83SSudip Mukherjee 	void	(*exit)(struct pci_dev *pcidev);
143d0aeaa83SSudip Mukherjee };
144d0aeaa83SSudip Mukherjee 
145d0aeaa83SSudip Mukherjee struct exar8250 {
146d0aeaa83SSudip Mukherjee 	unsigned int		nr;
147d0aeaa83SSudip Mukherjee 	struct exar8250_board	*board;
148c7e1b405SAaron Sierra 	void __iomem		*virt;
14900d963abSGustavo A. R. Silva 	int			line[];
150d0aeaa83SSudip Mukherjee };
151d0aeaa83SSudip Mukherjee 
152ef4e281eSAndy Shevchenko static void exar_pm(struct uart_port *port, unsigned int state, unsigned int old)
153ef4e281eSAndy Shevchenko {
154ef4e281eSAndy Shevchenko 	/*
155ef4e281eSAndy Shevchenko 	 * Exar UARTs have a SLEEP register that enables or disables each UART
156ef4e281eSAndy Shevchenko 	 * to enter sleep mode separately. On the XR17V35x the register
157ef4e281eSAndy Shevchenko 	 * is accessible to each UART at the UART_EXAR_SLEEP offset, but
158ef4e281eSAndy Shevchenko 	 * the UART channel may only write to the corresponding bit.
159ef4e281eSAndy Shevchenko 	 */
160ef4e281eSAndy Shevchenko 	serial_port_out(port, UART_EXAR_SLEEP, state ? 0xff : 0);
161ef4e281eSAndy Shevchenko }
162ef4e281eSAndy Shevchenko 
163b2b4b8edSAndy Shevchenko /*
164b2b4b8edSAndy Shevchenko  * XR17V35x UARTs have an extra fractional divisor register (DLD)
165b2b4b8edSAndy Shevchenko  * Calculate divisor with extra 4-bit fractional portion
166b2b4b8edSAndy Shevchenko  */
167b2b4b8edSAndy Shevchenko static unsigned int xr17v35x_get_divisor(struct uart_port *p, unsigned int baud,
168b2b4b8edSAndy Shevchenko 					 unsigned int *frac)
169b2b4b8edSAndy Shevchenko {
170b2b4b8edSAndy Shevchenko 	unsigned int quot_16;
171b2b4b8edSAndy Shevchenko 
172b2b4b8edSAndy Shevchenko 	quot_16 = DIV_ROUND_CLOSEST(p->uartclk, baud);
173b2b4b8edSAndy Shevchenko 	*frac = quot_16 & 0x0f;
174b2b4b8edSAndy Shevchenko 
175b2b4b8edSAndy Shevchenko 	return quot_16 >> 4;
176b2b4b8edSAndy Shevchenko }
177b2b4b8edSAndy Shevchenko 
178b2b4b8edSAndy Shevchenko static void xr17v35x_set_divisor(struct uart_port *p, unsigned int baud,
179b2b4b8edSAndy Shevchenko 				 unsigned int quot, unsigned int quot_frac)
180b2b4b8edSAndy Shevchenko {
181b2b4b8edSAndy Shevchenko 	serial8250_do_set_divisor(p, baud, quot, quot_frac);
182b2b4b8edSAndy Shevchenko 
183b2b4b8edSAndy Shevchenko 	/* Preserve bits not related to baudrate; DLD[7:4]. */
184b2b4b8edSAndy Shevchenko 	quot_frac |= serial_port_in(p, 0x2) & 0xf0;
185b2b4b8edSAndy Shevchenko 	serial_port_out(p, 0x2, quot_frac);
186b2b4b8edSAndy Shevchenko }
187b2b4b8edSAndy Shevchenko 
1886e731137SAndy Shevchenko static int xr17v35x_startup(struct uart_port *port)
1896e731137SAndy Shevchenko {
1906e731137SAndy Shevchenko 	/*
1916e731137SAndy Shevchenko 	 * First enable access to IER [7:5], ISR [5:4], FCR [5:4],
1926e731137SAndy Shevchenko 	 * MCR [7:5] and MSR [7:0]
1936e731137SAndy Shevchenko 	 */
1946e731137SAndy Shevchenko 	serial_port_out(port, UART_XR_EFR, UART_EFR_ECB);
1956e731137SAndy Shevchenko 
1966e731137SAndy Shevchenko 	/*
1976e731137SAndy Shevchenko 	 * Make sure all interrups are masked until initialization is
1986e731137SAndy Shevchenko 	 * complete and the FIFOs are cleared
199b1207d86SJohn Ogness 	 *
200b1207d86SJohn Ogness 	 * Synchronize UART_IER access against the console.
2016e731137SAndy Shevchenko 	 */
2022b71b31fSThomas Gleixner 	uart_port_lock_irq(port);
2036e731137SAndy Shevchenko 	serial_port_out(port, UART_IER, 0);
2042b71b31fSThomas Gleixner 	uart_port_unlock_irq(port);
2056e731137SAndy Shevchenko 
2066e731137SAndy Shevchenko 	return serial8250_do_startup(port);
2076e731137SAndy Shevchenko }
2086e731137SAndy Shevchenko 
209653d00c8SAndy Shevchenko static void exar_shutdown(struct uart_port *port)
210653d00c8SAndy Shevchenko {
21167e977f3SZheng Bin 	bool tx_complete = false;
212653d00c8SAndy Shevchenko 	struct uart_8250_port *up = up_to_u8250p(port);
213653d00c8SAndy Shevchenko 	struct circ_buf *xmit = &port->state->xmit;
214653d00c8SAndy Shevchenko 	int i = 0;
215f8ba5680SIlpo Järvinen 	u16 lsr;
216653d00c8SAndy Shevchenko 
217653d00c8SAndy Shevchenko 	do {
218653d00c8SAndy Shevchenko 		lsr = serial_in(up, UART_LSR);
219653d00c8SAndy Shevchenko 		if (lsr & (UART_LSR_TEMT | UART_LSR_THRE))
22067e977f3SZheng Bin 			tx_complete = true;
221653d00c8SAndy Shevchenko 		else
22267e977f3SZheng Bin 			tx_complete = false;
2233f72879eSAndy Shevchenko 		usleep_range(1000, 1100);
224653d00c8SAndy Shevchenko 	} while (!uart_circ_empty(xmit) && !tx_complete && i++ < 1000);
225653d00c8SAndy Shevchenko 
226653d00c8SAndy Shevchenko 	serial8250_do_shutdown(port);
227653d00c8SAndy Shevchenko }
228653d00c8SAndy Shevchenko 
229d0aeaa83SSudip Mukherjee static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
230d0aeaa83SSudip Mukherjee 			 int idx, unsigned int offset,
231d0aeaa83SSudip Mukherjee 			 struct uart_8250_port *port)
232d0aeaa83SSudip Mukherjee {
233d0aeaa83SSudip Mukherjee 	const struct exar8250_board *board = priv->board;
2346be254c2SAndy Shevchenko 	unsigned char status;
235*d813d900SAndy Shevchenko 	int err;
236d0aeaa83SSudip Mukherjee 
237*d813d900SAndy Shevchenko 	err = serial8250_pci_setup_port(pcidev, port, 0, offset, board->reg_shift);
238*d813d900SAndy Shevchenko 	if (err)
239*d813d900SAndy Shevchenko 		return err;
240d0aeaa83SSudip Mukherjee 
2416be254c2SAndy Shevchenko 	/*
2426be254c2SAndy Shevchenko 	 * XR17V35x UARTs have an extra divisor register, DLD that gets enabled
2436be254c2SAndy Shevchenko 	 * with when DLAB is set which will cause the device to incorrectly match
2446be254c2SAndy Shevchenko 	 * and assign port type to PORT_16650. The EFR for this UART is found
2456be254c2SAndy Shevchenko 	 * at offset 0x09. Instead check the Deice ID (DVID) register
2466be254c2SAndy Shevchenko 	 * for a 2, 4 or 8 port UART.
2476be254c2SAndy Shevchenko 	 */
2486be254c2SAndy Shevchenko 	status = readb(port->port.membase + UART_EXAR_DVID);
2496be254c2SAndy Shevchenko 	if (status == 0x82 || status == 0x84 || status == 0x88) {
2506be254c2SAndy Shevchenko 		port->port.type = PORT_XR17V35X;
251b2b4b8edSAndy Shevchenko 
252b2b4b8edSAndy Shevchenko 		port->port.get_divisor = xr17v35x_get_divisor;
253b2b4b8edSAndy Shevchenko 		port->port.set_divisor = xr17v35x_set_divisor;
2546e731137SAndy Shevchenko 
2556e731137SAndy Shevchenko 		port->port.startup = xr17v35x_startup;
2566be254c2SAndy Shevchenko 	} else {
2576be254c2SAndy Shevchenko 		port->port.type = PORT_XR17D15X;
2586be254c2SAndy Shevchenko 	}
2596be254c2SAndy Shevchenko 
260ef4e281eSAndy Shevchenko 	port->port.pm = exar_pm;
261653d00c8SAndy Shevchenko 	port->port.shutdown = exar_shutdown;
262ef4e281eSAndy Shevchenko 
263d0aeaa83SSudip Mukherjee 	return 0;
264d0aeaa83SSudip Mukherjee }
265d0aeaa83SSudip Mukherjee 
266d0aeaa83SSudip Mukherjee static int
267fc6cc961SJan Kiszka pci_fastcom335_setup(struct exar8250 *priv, struct pci_dev *pcidev,
268fc6cc961SJan Kiszka 		     struct uart_8250_port *port, int idx)
269fc6cc961SJan Kiszka {
270fc6cc961SJan Kiszka 	unsigned int offset = idx * 0x200;
271fc6cc961SJan Kiszka 	unsigned int baud = 1843200;
272fc6cc961SJan Kiszka 	u8 __iomem *p;
273fc6cc961SJan Kiszka 	int err;
274fc6cc961SJan Kiszka 
275fc6cc961SJan Kiszka 	port->port.uartclk = baud * 16;
276fc6cc961SJan Kiszka 
277fc6cc961SJan Kiszka 	err = default_setup(priv, pcidev, idx, offset, port);
278fc6cc961SJan Kiszka 	if (err)
279fc6cc961SJan Kiszka 		return err;
280fc6cc961SJan Kiszka 
281fc6cc961SJan Kiszka 	p = port->port.membase;
282fc6cc961SJan Kiszka 
283fc6cc961SJan Kiszka 	writeb(0x00, p + UART_EXAR_8XMODE);
284fc6cc961SJan Kiszka 	writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
285fc6cc961SJan Kiszka 	writeb(32, p + UART_EXAR_TXTRG);
286fc6cc961SJan Kiszka 	writeb(32, p + UART_EXAR_RXTRG);
287fc6cc961SJan Kiszka 
288fc6cc961SJan Kiszka 	/*
289fc6cc961SJan Kiszka 	 * Setup Multipurpose Input/Output pins.
290fc6cc961SJan Kiszka 	 */
291fc6cc961SJan Kiszka 	if (idx == 0) {
292fc6cc961SJan Kiszka 		switch (pcidev->device) {
293fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_4222PCI335:
294fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_4224PCI335:
295fc6cc961SJan Kiszka 			writeb(0x78, p + UART_EXAR_MPIOLVL_7_0);
296fc6cc961SJan Kiszka 			writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
297fc6cc961SJan Kiszka 			writeb(0x00, p + UART_EXAR_MPIOSEL_7_0);
298fc6cc961SJan Kiszka 			break;
299fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_2324PCI335:
300fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_2328PCI335:
301fc6cc961SJan Kiszka 			writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
302fc6cc961SJan Kiszka 			writeb(0xc0, p + UART_EXAR_MPIOINV_7_0);
303fc6cc961SJan Kiszka 			writeb(0xc0, p + UART_EXAR_MPIOSEL_7_0);
304fc6cc961SJan Kiszka 			break;
305fc6cc961SJan Kiszka 		}
306fc6cc961SJan Kiszka 		writeb(0x00, p + UART_EXAR_MPIOINT_7_0);
307fc6cc961SJan Kiszka 		writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
308fc6cc961SJan Kiszka 		writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
309fc6cc961SJan Kiszka 	}
310fc6cc961SJan Kiszka 
311fc6cc961SJan Kiszka 	return 0;
312fc6cc961SJan Kiszka }
313fc6cc961SJan Kiszka 
314fc6cc961SJan Kiszka static int
315d0aeaa83SSudip Mukherjee pci_connect_tech_setup(struct exar8250 *priv, struct pci_dev *pcidev,
316d0aeaa83SSudip Mukherjee 		       struct uart_8250_port *port, int idx)
317d0aeaa83SSudip Mukherjee {
318d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x200;
319d0aeaa83SSudip Mukherjee 	unsigned int baud = 1843200;
320d0aeaa83SSudip Mukherjee 
321d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
322d0aeaa83SSudip Mukherjee 	return default_setup(priv, pcidev, idx, offset, port);
323d0aeaa83SSudip Mukherjee }
324d0aeaa83SSudip Mukherjee 
325d0aeaa83SSudip Mukherjee static int
326d0aeaa83SSudip Mukherjee pci_xr17c154_setup(struct exar8250 *priv, struct pci_dev *pcidev,
327d0aeaa83SSudip Mukherjee 		   struct uart_8250_port *port, int idx)
328d0aeaa83SSudip Mukherjee {
329d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x200;
330d0aeaa83SSudip Mukherjee 	unsigned int baud = 921600;
331d0aeaa83SSudip Mukherjee 
332d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
333d0aeaa83SSudip Mukherjee 	return default_setup(priv, pcidev, idx, offset, port);
334d0aeaa83SSudip Mukherjee }
335d0aeaa83SSudip Mukherjee 
336bea8be65SJan Kiszka static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
337d0aeaa83SSudip Mukherjee {
338bea8be65SJan Kiszka 	/*
339bea8be65SJan Kiszka 	 * The Commtech adapters required the MPIOs to be driven low. The Exar
340bea8be65SJan Kiszka 	 * devices will export them as GPIOs, so we pre-configure them safely
341bea8be65SJan Kiszka 	 * as inputs.
342bea8be65SJan Kiszka 	 */
3435fdbe136SMatthew Howell 
3445fdbe136SMatthew Howell 	u8 dir = 0x00;
3455fdbe136SMatthew Howell 
3465fdbe136SMatthew Howell 	if  ((pcidev->vendor == PCI_VENDOR_ID_EXAR) &&
3475fdbe136SMatthew Howell 		(pcidev->subsystem_vendor != PCI_VENDOR_ID_SEALEVEL)) {
3485fdbe136SMatthew Howell 		// Configure GPIO as inputs for Commtech adapters
3495fdbe136SMatthew Howell 		dir = 0xff;
3505fdbe136SMatthew Howell 	} else {
3515fdbe136SMatthew Howell 		// Configure GPIO as outputs for SeaLevel adapters
3525fdbe136SMatthew Howell 		dir = 0x00;
3535fdbe136SMatthew Howell 	}
354bea8be65SJan Kiszka 
355d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINT_7_0);
356d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
357d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
358d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
359bea8be65SJan Kiszka 	writeb(dir,  p + UART_EXAR_MPIOSEL_7_0);
360d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
361d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINT_15_8);
362d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOLVL_15_8);
363d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIO3T_15_8);
364d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINV_15_8);
365bea8be65SJan Kiszka 	writeb(dir,  p + UART_EXAR_MPIOSEL_15_8);
366d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOOD_15_8);
367d0aeaa83SSudip Mukherjee }
368d0aeaa83SSudip Mukherjee 
36933969db7SAndy Shevchenko static struct platform_device *__xr17v35x_register_gpio(struct pci_dev *pcidev,
37081171e7dSHeikki Krogerus 							const struct software_node *node)
371d0aeaa83SSudip Mukherjee {
372d0aeaa83SSudip Mukherjee 	struct platform_device *pdev;
373d0aeaa83SSudip Mukherjee 
374d0aeaa83SSudip Mukherjee 	pdev = platform_device_alloc("gpio_exar", PLATFORM_DEVID_AUTO);
375d0aeaa83SSudip Mukherjee 	if (!pdev)
376d0aeaa83SSudip Mukherjee 		return NULL;
377d0aeaa83SSudip Mukherjee 
378d3936d74SJan Kiszka 	pdev->dev.parent = &pcidev->dev;
37973f76db8SAndy Shevchenko 	device_set_node(&pdev->dev, dev_fwnode(&pcidev->dev));
380d3936d74SJan Kiszka 
38181171e7dSHeikki Krogerus 	if (device_add_software_node(&pdev->dev, node) < 0 ||
382380b1e2fSJan Kiszka 	    platform_device_add(pdev) < 0) {
383d0aeaa83SSudip Mukherjee 		platform_device_put(pdev);
384d0aeaa83SSudip Mukherjee 		return NULL;
385d0aeaa83SSudip Mukherjee 	}
386d0aeaa83SSudip Mukherjee 
387d0aeaa83SSudip Mukherjee 	return pdev;
388d0aeaa83SSudip Mukherjee }
389d0aeaa83SSudip Mukherjee 
39033969db7SAndy Shevchenko static void __xr17v35x_unregister_gpio(struct platform_device *pdev)
39133969db7SAndy Shevchenko {
39233969db7SAndy Shevchenko 	device_remove_software_node(&pdev->dev);
39333969db7SAndy Shevchenko 	platform_device_unregister(pdev);
39433969db7SAndy Shevchenko }
39533969db7SAndy Shevchenko 
396380b1e2fSJan Kiszka static const struct property_entry exar_gpio_properties[] = {
397a589e211SJan Kiszka 	PROPERTY_ENTRY_U32("exar,first-pin", 0),
398380b1e2fSJan Kiszka 	PROPERTY_ENTRY_U32("ngpios", 16),
399380b1e2fSJan Kiszka 	{ }
400380b1e2fSJan Kiszka };
401380b1e2fSJan Kiszka 
40281171e7dSHeikki Krogerus static const struct software_node exar_gpio_node = {
40381171e7dSHeikki Krogerus 	.properties = exar_gpio_properties,
40481171e7dSHeikki Krogerus };
40581171e7dSHeikki Krogerus 
40633969db7SAndy Shevchenko static int xr17v35x_register_gpio(struct pci_dev *pcidev, struct uart_8250_port *port)
4070d963ebfSJan Kiszka {
4080d963ebfSJan Kiszka 	if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
4090d963ebfSJan Kiszka 		port->port.private_data =
41081171e7dSHeikki Krogerus 			__xr17v35x_register_gpio(pcidev, &exar_gpio_node);
4110d963ebfSJan Kiszka 
4120d963ebfSJan Kiszka 	return 0;
4130d963ebfSJan Kiszka }
4140d963ebfSJan Kiszka 
41533969db7SAndy Shevchenko static void xr17v35x_unregister_gpio(struct uart_8250_port *port)
41633969db7SAndy Shevchenko {
41733969db7SAndy Shevchenko 	if (!port->port.private_data)
41833969db7SAndy Shevchenko 		return;
41933969db7SAndy Shevchenko 
42033969db7SAndy Shevchenko 	__xr17v35x_unregister_gpio(port->port.private_data);
42133969db7SAndy Shevchenko 	port->port.private_data = NULL;
42233969db7SAndy Shevchenko }
42333969db7SAndy Shevchenko 
424ae50bb27SIlpo Järvinen static int generic_rs485_config(struct uart_port *port, struct ktermios *termios,
4259d939894SDaniel Golle 				struct serial_rs485 *rs485)
4269d939894SDaniel Golle {
4279d939894SDaniel Golle 	bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
4289d939894SDaniel Golle 	u8 __iomem *p = port->membase;
4299d939894SDaniel Golle 	u8 value;
4309d939894SDaniel Golle 
4319d939894SDaniel Golle 	value = readb(p + UART_EXAR_FCTR);
4329d939894SDaniel Golle 	if (is_rs485)
4339d939894SDaniel Golle 		value |= UART_FCTR_EXAR_485;
4349d939894SDaniel Golle 	else
4359d939894SDaniel Golle 		value &= ~UART_FCTR_EXAR_485;
4369d939894SDaniel Golle 
4379d939894SDaniel Golle 	writeb(value, p + UART_EXAR_FCTR);
4389d939894SDaniel Golle 
4399d939894SDaniel Golle 	if (is_rs485)
4409d939894SDaniel Golle 		writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
4419d939894SDaniel Golle 
4429d939894SDaniel Golle 	return 0;
4439d939894SDaniel Golle }
4449d939894SDaniel Golle 
445687911b3SMatthew Howell static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termios,
446687911b3SMatthew Howell 				  struct serial_rs485 *rs485)
447687911b3SMatthew Howell {
448687911b3SMatthew Howell 	u8 __iomem *p = port->membase;
449687911b3SMatthew Howell 	u8 old_lcr;
450687911b3SMatthew Howell 	u8 efr;
451687911b3SMatthew Howell 	u8 dld;
452687911b3SMatthew Howell 	int ret;
453687911b3SMatthew Howell 
454687911b3SMatthew Howell 	ret = generic_rs485_config(port, termios, rs485);
455687911b3SMatthew Howell 	if (ret)
456687911b3SMatthew Howell 		return ret;
457687911b3SMatthew Howell 
458687911b3SMatthew Howell 	if (rs485->flags & SER_RS485_ENABLED) {
459687911b3SMatthew Howell 		old_lcr = readb(p + UART_LCR);
460687911b3SMatthew Howell 
461687911b3SMatthew Howell 		/* Set EFR[4]=1 to enable enhanced feature registers */
462687911b3SMatthew Howell 		efr = readb(p + UART_XR_EFR);
463687911b3SMatthew Howell 		efr |= UART_EFR_ECB;
464687911b3SMatthew Howell 		writeb(efr, p + UART_XR_EFR);
465687911b3SMatthew Howell 
466687911b3SMatthew Howell 		/* Set MCR to use DTR as Auto-RS485 Enable signal */
467687911b3SMatthew Howell 		writeb(UART_MCR_OUT1, p + UART_MCR);
468687911b3SMatthew Howell 
469687911b3SMatthew Howell 		/* Set LCR[7]=1 to enable access to DLD register */
470687911b3SMatthew Howell 		writeb(old_lcr | UART_LCR_DLAB, p + UART_LCR);
471687911b3SMatthew Howell 
472687911b3SMatthew Howell 		/* Set DLD[7]=1 for inverted RS485 Enable logic */
473687911b3SMatthew Howell 		dld = readb(p + UART_EXAR_DLD);
474687911b3SMatthew Howell 		dld |= UART_EXAR_DLD_485_POLARITY;
475687911b3SMatthew Howell 		writeb(dld, p + UART_EXAR_DLD);
476687911b3SMatthew Howell 
477687911b3SMatthew Howell 		writeb(old_lcr, p + UART_LCR);
478687911b3SMatthew Howell 	}
479687911b3SMatthew Howell 
480687911b3SMatthew Howell 	return 0;
481687911b3SMatthew Howell }
482687911b3SMatthew Howell 
48359c221f8SIlpo Järvinen static const struct serial_rs485 generic_rs485_supported = {
4840c2a5f47SLino Sanfilippo 	.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND,
48559c221f8SIlpo Järvinen };
48659c221f8SIlpo Järvinen 
4870d963ebfSJan Kiszka static const struct exar8250_platform exar8250_default_platform = {
4880d963ebfSJan Kiszka 	.register_gpio = xr17v35x_register_gpio,
48933969db7SAndy Shevchenko 	.unregister_gpio = xr17v35x_unregister_gpio,
4909d939894SDaniel Golle 	.rs485_config = generic_rs485_config,
49159c221f8SIlpo Järvinen 	.rs485_supported = &generic_rs485_supported,
4920d963ebfSJan Kiszka };
4930d963ebfSJan Kiszka 
494ae50bb27SIlpo Järvinen static int iot2040_rs485_config(struct uart_port *port, struct ktermios *termios,
495413058dfSJan Kiszka 				struct serial_rs485 *rs485)
496413058dfSJan Kiszka {
497413058dfSJan Kiszka 	bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
498413058dfSJan Kiszka 	u8 __iomem *p = port->membase;
499413058dfSJan Kiszka 	u8 mask = IOT2040_UART1_MASK;
500413058dfSJan Kiszka 	u8 mode, value;
501413058dfSJan Kiszka 
502413058dfSJan Kiszka 	if (is_rs485) {
503413058dfSJan Kiszka 		if (rs485->flags & SER_RS485_RX_DURING_TX)
504413058dfSJan Kiszka 			mode = IOT2040_UART_MODE_RS422;
505413058dfSJan Kiszka 		else
506413058dfSJan Kiszka 			mode = IOT2040_UART_MODE_RS485;
507413058dfSJan Kiszka 
508413058dfSJan Kiszka 		if (rs485->flags & SER_RS485_TERMINATE_BUS)
509413058dfSJan Kiszka 			mode |= IOT2040_UART_TERMINATE_BUS;
510413058dfSJan Kiszka 	} else {
511413058dfSJan Kiszka 		mode = IOT2040_UART_MODE_RS232;
512413058dfSJan Kiszka 	}
513413058dfSJan Kiszka 
514413058dfSJan Kiszka 	if (port->line == 3) {
515413058dfSJan Kiszka 		mask <<= IOT2040_UART2_SHIFT;
516413058dfSJan Kiszka 		mode <<= IOT2040_UART2_SHIFT;
517413058dfSJan Kiszka 	}
518413058dfSJan Kiszka 
519413058dfSJan Kiszka 	value = readb(p + UART_EXAR_MPIOLVL_7_0);
520413058dfSJan Kiszka 	value &= ~mask;
521413058dfSJan Kiszka 	value |= mode;
522413058dfSJan Kiszka 	writeb(value, p + UART_EXAR_MPIOLVL_7_0);
523413058dfSJan Kiszka 
524ae50bb27SIlpo Järvinen 	return generic_rs485_config(port, termios, rs485);
525413058dfSJan Kiszka }
526413058dfSJan Kiszka 
52759c221f8SIlpo Järvinen static const struct serial_rs485 iot2040_rs485_supported = {
5280c2a5f47SLino Sanfilippo 	.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND |
5290c2a5f47SLino Sanfilippo 		 SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS,
53059c221f8SIlpo Järvinen };
53159c221f8SIlpo Järvinen 
532413058dfSJan Kiszka static const struct property_entry iot2040_gpio_properties[] = {
533a589e211SJan Kiszka 	PROPERTY_ENTRY_U32("exar,first-pin", 10),
534413058dfSJan Kiszka 	PROPERTY_ENTRY_U32("ngpios", 1),
535413058dfSJan Kiszka 	{ }
536413058dfSJan Kiszka };
537413058dfSJan Kiszka 
53881171e7dSHeikki Krogerus static const struct software_node iot2040_gpio_node = {
53981171e7dSHeikki Krogerus 	.properties = iot2040_gpio_properties,
54081171e7dSHeikki Krogerus };
54181171e7dSHeikki Krogerus 
542413058dfSJan Kiszka static int iot2040_register_gpio(struct pci_dev *pcidev,
543413058dfSJan Kiszka 			      struct uart_8250_port *port)
544413058dfSJan Kiszka {
545413058dfSJan Kiszka 	u8 __iomem *p = port->port.membase;
546413058dfSJan Kiszka 
547413058dfSJan Kiszka 	writeb(IOT2040_UARTS_DEFAULT_MODE, p + UART_EXAR_MPIOLVL_7_0);
548413058dfSJan Kiszka 	writeb(IOT2040_UARTS_GPIO_LO_MODE, p + UART_EXAR_MPIOSEL_7_0);
549413058dfSJan Kiszka 	writeb(IOT2040_UARTS_ENABLE, p + UART_EXAR_MPIOLVL_15_8);
550413058dfSJan Kiszka 	writeb(IOT2040_UARTS_GPIO_HI_MODE, p + UART_EXAR_MPIOSEL_15_8);
551413058dfSJan Kiszka 
552413058dfSJan Kiszka 	port->port.private_data =
55381171e7dSHeikki Krogerus 		__xr17v35x_register_gpio(pcidev, &iot2040_gpio_node);
554413058dfSJan Kiszka 
555413058dfSJan Kiszka 	return 0;
556413058dfSJan Kiszka }
557413058dfSJan Kiszka 
558413058dfSJan Kiszka static const struct exar8250_platform iot2040_platform = {
559413058dfSJan Kiszka 	.rs485_config = iot2040_rs485_config,
56059c221f8SIlpo Järvinen 	.rs485_supported = &iot2040_rs485_supported,
561413058dfSJan Kiszka 	.register_gpio = iot2040_register_gpio,
56233969db7SAndy Shevchenko 	.unregister_gpio = xr17v35x_unregister_gpio,
563413058dfSJan Kiszka };
564413058dfSJan Kiszka 
5653e51ceeaSSu Bao Cheng /*
5663e51ceeaSSu Bao Cheng  * For SIMATIC IOT2000, only IOT2040 and its variants have the Exar device,
5673e51ceeaSSu Bao Cheng  * IOT2020 doesn't have. Therefore it is sufficient to match on the common
5683e51ceeaSSu Bao Cheng  * board name after the device was found.
5693e51ceeaSSu Bao Cheng  */
570413058dfSJan Kiszka static const struct dmi_system_id exar_platforms[] = {
571413058dfSJan Kiszka 	{
572413058dfSJan Kiszka 		.matches = {
573413058dfSJan Kiszka 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
574413058dfSJan Kiszka 		},
575413058dfSJan Kiszka 		.driver_data = (void *)&iot2040_platform,
576413058dfSJan Kiszka 	},
577413058dfSJan Kiszka 	{}
578413058dfSJan Kiszka };
579413058dfSJan Kiszka 
5807d356a43SAndy Shevchenko static const struct exar8250_platform *exar_get_platform(void)
5817d356a43SAndy Shevchenko {
5827d356a43SAndy Shevchenko 	const struct dmi_system_id *dmi_match;
5837d356a43SAndy Shevchenko 
5847d356a43SAndy Shevchenko 	dmi_match = dmi_first_match(exar_platforms);
5857d356a43SAndy Shevchenko 	if (dmi_match)
5867d356a43SAndy Shevchenko 		return dmi_match->driver_data;
5877d356a43SAndy Shevchenko 
5887d356a43SAndy Shevchenko 	return &exar8250_default_platform;
5897d356a43SAndy Shevchenko }
5907d356a43SAndy Shevchenko 
591d0aeaa83SSudip Mukherjee static int
592d0aeaa83SSudip Mukherjee pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
593d0aeaa83SSudip Mukherjee 		   struct uart_8250_port *port, int idx)
594d0aeaa83SSudip Mukherjee {
5957d356a43SAndy Shevchenko 	const struct exar8250_platform *platform = exar_get_platform();
596d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x400;
597d0aeaa83SSudip Mukherjee 	unsigned int baud = 7812500;
598d0aeaa83SSudip Mukherjee 	u8 __iomem *p;
599d0aeaa83SSudip Mukherjee 	int ret;
600d0aeaa83SSudip Mukherjee 
601d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
6020d963ebfSJan Kiszka 	port->port.rs485_config = platform->rs485_config;
6030139da50SIlpo Järvinen 	port->port.rs485_supported = *(platform->rs485_supported);
6040d963ebfSJan Kiszka 
605687911b3SMatthew Howell 	if (pcidev->subsystem_vendor == PCI_VENDOR_ID_SEALEVEL)
606687911b3SMatthew Howell 		port->port.rs485_config = sealevel_rs485_config;
607687911b3SMatthew Howell 
608d0aeaa83SSudip Mukherjee 	/*
609328c11f2SAndy Shevchenko 	 * Setup the UART clock for the devices on expansion slot to
610d0aeaa83SSudip Mukherjee 	 * half the clock speed of the main chip (which is 125MHz)
611d0aeaa83SSudip Mukherjee 	 */
612328c11f2SAndy Shevchenko 	if (idx >= 8)
613d0aeaa83SSudip Mukherjee 		port->port.uartclk /= 2;
614d0aeaa83SSudip Mukherjee 
6155b5f252dSJan Kiszka 	ret = default_setup(priv, pcidev, idx, offset, port);
6165b5f252dSJan Kiszka 	if (ret)
6175b5f252dSJan Kiszka 		return ret;
618d0aeaa83SSudip Mukherjee 
6195b5f252dSJan Kiszka 	p = port->port.membase;
620d0aeaa83SSudip Mukherjee 
621d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_8XMODE);
622d0aeaa83SSudip Mukherjee 	writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
623d0aeaa83SSudip Mukherjee 	writeb(128, p + UART_EXAR_TXTRG);
624d0aeaa83SSudip Mukherjee 	writeb(128, p + UART_EXAR_RXTRG);
625d0aeaa83SSudip Mukherjee 
6265b5f252dSJan Kiszka 	if (idx == 0) {
6275b5f252dSJan Kiszka 		/* Setup Multipurpose Input/Output pins. */
628bea8be65SJan Kiszka 		setup_gpio(pcidev, p);
629d0aeaa83SSudip Mukherjee 
6300d963ebfSJan Kiszka 		ret = platform->register_gpio(pcidev, port);
6315b5f252dSJan Kiszka 	}
632d0aeaa83SSudip Mukherjee 
6330d963ebfSJan Kiszka 	return ret;
634d0aeaa83SSudip Mukherjee }
635d0aeaa83SSudip Mukherjee 
636d0aeaa83SSudip Mukherjee static void pci_xr17v35x_exit(struct pci_dev *pcidev)
637d0aeaa83SSudip Mukherjee {
63833969db7SAndy Shevchenko 	const struct exar8250_platform *platform = exar_get_platform();
639d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
640d0aeaa83SSudip Mukherjee 	struct uart_8250_port *port = serial8250_get_port(priv->line[0]);
6417c3e8d9dSAndy Shevchenko 
64233969db7SAndy Shevchenko 	platform->unregister_gpio(port);
643d0aeaa83SSudip Mukherjee }
644d0aeaa83SSudip Mukherjee 
64572169e42SAaron Sierra static inline void exar_misc_clear(struct exar8250 *priv)
64672169e42SAaron Sierra {
64772169e42SAaron Sierra 	/* Clear all PCI interrupts by reading INT0. No effect on IIR */
64872169e42SAaron Sierra 	readb(priv->virt + UART_EXAR_INT0);
64972169e42SAaron Sierra 
65072169e42SAaron Sierra 	/* Clear INT0 for Expansion Interface slave ports, too */
65172169e42SAaron Sierra 	if (priv->board->num_ports > 8)
65272169e42SAaron Sierra 		readb(priv->virt + 0x2000 + UART_EXAR_INT0);
65372169e42SAaron Sierra }
65472169e42SAaron Sierra 
655c7e1b405SAaron Sierra /*
656c7e1b405SAaron Sierra  * These Exar UARTs have an extra interrupt indicator that could fire for a
657c7e1b405SAaron Sierra  * few interrupts that are not presented/cleared through IIR.  One of which is
658c7e1b405SAaron Sierra  * a wakeup interrupt when coming out of sleep.  These interrupts are only
659c7e1b405SAaron Sierra  * cleared by reading global INT0 or INT1 registers as interrupts are
660c7e1b405SAaron Sierra  * associated with channel 0. The INT[3:0] registers _are_ accessible from each
661c7e1b405SAaron Sierra  * channel's address space, but for the sake of bus efficiency we register a
662c7e1b405SAaron Sierra  * dedicated handler at the PCI device level to handle them.
663c7e1b405SAaron Sierra  */
664c7e1b405SAaron Sierra static irqreturn_t exar_misc_handler(int irq, void *data)
665c7e1b405SAaron Sierra {
66672169e42SAaron Sierra 	exar_misc_clear(data);
667c7e1b405SAaron Sierra 
668c7e1b405SAaron Sierra 	return IRQ_HANDLED;
669c7e1b405SAaron Sierra }
670c7e1b405SAaron Sierra 
671d0aeaa83SSudip Mukherjee static int
672d0aeaa83SSudip Mukherjee exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
673d0aeaa83SSudip Mukherjee {
674d0aeaa83SSudip Mukherjee 	unsigned int nr_ports, i, bar = 0, maxnr;
675d0aeaa83SSudip Mukherjee 	struct exar8250_board *board;
676d0aeaa83SSudip Mukherjee 	struct uart_8250_port uart;
677d0aeaa83SSudip Mukherjee 	struct exar8250 *priv;
678d0aeaa83SSudip Mukherjee 	int rc;
679d0aeaa83SSudip Mukherjee 
680d0aeaa83SSudip Mukherjee 	board = (struct exar8250_board *)ent->driver_data;
681d0aeaa83SSudip Mukherjee 	if (!board)
682d0aeaa83SSudip Mukherjee 		return -EINVAL;
683d0aeaa83SSudip Mukherjee 
684d0aeaa83SSudip Mukherjee 	rc = pcim_enable_device(pcidev);
685d0aeaa83SSudip Mukherjee 	if (rc)
686d0aeaa83SSudip Mukherjee 		return rc;
687d0aeaa83SSudip Mukherjee 
688d0aeaa83SSudip Mukherjee 	maxnr = pci_resource_len(pcidev, bar) >> (board->reg_shift + 3);
689d0aeaa83SSudip Mukherjee 
6908e4413aaSAndy Shevchenko 	if (pcidev->vendor == PCI_VENDOR_ID_ACCESSIO)
6918e4413aaSAndy Shevchenko 		nr_ports = BIT(((pcidev->device & 0x38) >> 3) - 1);
6928e4413aaSAndy Shevchenko 	else if (board->num_ports)
6938e4413aaSAndy Shevchenko 		nr_ports = board->num_ports;
6948e4413aaSAndy Shevchenko 	else
6958e4413aaSAndy Shevchenko 		nr_ports = pcidev->device & 0x0f;
696d0aeaa83SSudip Mukherjee 
697df60a8afSAndy Shevchenko 	priv = devm_kzalloc(&pcidev->dev, struct_size(priv, line, nr_ports), GFP_KERNEL);
698d0aeaa83SSudip Mukherjee 	if (!priv)
699d0aeaa83SSudip Mukherjee 		return -ENOMEM;
700d0aeaa83SSudip Mukherjee 
701d0aeaa83SSudip Mukherjee 	priv->board = board;
702c7e1b405SAaron Sierra 	priv->virt = pcim_iomap(pcidev, bar, 0);
703c7e1b405SAaron Sierra 	if (!priv->virt)
704c7e1b405SAaron Sierra 		return -ENOMEM;
705d0aeaa83SSudip Mukherjee 
706172c33cbSJan Kiszka 	pci_set_master(pcidev);
707172c33cbSJan Kiszka 
708172c33cbSJan Kiszka 	rc = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
709172c33cbSJan Kiszka 	if (rc < 0)
710172c33cbSJan Kiszka 		return rc;
711172c33cbSJan Kiszka 
712d0aeaa83SSudip Mukherjee 	memset(&uart, 0, sizeof(uart));
7136be254c2SAndy Shevchenko 	uart.port.flags = UPF_SHARE_IRQ | UPF_EXAR_EFR | UPF_FIXED_TYPE | UPF_FIXED_PORT;
714172c33cbSJan Kiszka 	uart.port.irq = pci_irq_vector(pcidev, 0);
715d0aeaa83SSudip Mukherjee 	uart.port.dev = &pcidev->dev;
716d0aeaa83SSudip Mukherjee 
7175bc430afSAndy Shevchenko 	/* Clear interrupts */
7185bc430afSAndy Shevchenko 	exar_misc_clear(priv);
7195bc430afSAndy Shevchenko 
720c7e1b405SAaron Sierra 	rc = devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler,
721c7e1b405SAaron Sierra 			 IRQF_SHARED, "exar_uart", priv);
722c7e1b405SAaron Sierra 	if (rc)
723c7e1b405SAaron Sierra 		return rc;
724c7e1b405SAaron Sierra 
725d0aeaa83SSudip Mukherjee 	for (i = 0; i < nr_ports && i < maxnr; i++) {
726d0aeaa83SSudip Mukherjee 		rc = board->setup(priv, pcidev, &uart, i);
727d0aeaa83SSudip Mukherjee 		if (rc) {
728d0aeaa83SSudip Mukherjee 			dev_err(&pcidev->dev, "Failed to setup port %u\n", i);
729d0aeaa83SSudip Mukherjee 			break;
730d0aeaa83SSudip Mukherjee 		}
731d0aeaa83SSudip Mukherjee 
732d0aeaa83SSudip Mukherjee 		dev_dbg(&pcidev->dev, "Setup PCI port: port %lx, irq %d, type %d\n",
733d0aeaa83SSudip Mukherjee 			uart.port.iobase, uart.port.irq, uart.port.iotype);
734d0aeaa83SSudip Mukherjee 
735d0aeaa83SSudip Mukherjee 		priv->line[i] = serial8250_register_8250_port(&uart);
736d0aeaa83SSudip Mukherjee 		if (priv->line[i] < 0) {
737d0aeaa83SSudip Mukherjee 			dev_err(&pcidev->dev,
738d0aeaa83SSudip Mukherjee 				"Couldn't register serial port %lx, irq %d, type %d, error %d\n",
739d0aeaa83SSudip Mukherjee 				uart.port.iobase, uart.port.irq,
740d0aeaa83SSudip Mukherjee 				uart.port.iotype, priv->line[i]);
741d0aeaa83SSudip Mukherjee 			break;
742d0aeaa83SSudip Mukherjee 		}
743d0aeaa83SSudip Mukherjee 	}
744d0aeaa83SSudip Mukherjee 	priv->nr = i;
745d0aeaa83SSudip Mukherjee 	pci_set_drvdata(pcidev, priv);
746d0aeaa83SSudip Mukherjee 	return 0;
747d0aeaa83SSudip Mukherjee }
748d0aeaa83SSudip Mukherjee 
749d0aeaa83SSudip Mukherjee static void exar_pci_remove(struct pci_dev *pcidev)
750d0aeaa83SSudip Mukherjee {
751d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
752d0aeaa83SSudip Mukherjee 	unsigned int i;
753d0aeaa83SSudip Mukherjee 
754d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
755d0aeaa83SSudip Mukherjee 		serial8250_unregister_port(priv->line[i]);
756d0aeaa83SSudip Mukherjee 
75773b5a5c0SAndy Shevchenko 	/* Ensure that every init quirk is properly torn down */
758d0aeaa83SSudip Mukherjee 	if (priv->board->exit)
759d0aeaa83SSudip Mukherjee 		priv->board->exit(pcidev);
760d0aeaa83SSudip Mukherjee }
761d0aeaa83SSudip Mukherjee 
76282f9cefaSAndy Shevchenko static int exar_suspend(struct device *dev)
763d0aeaa83SSudip Mukherjee {
7647a345dc1SAndy Shevchenko 	struct exar8250 *priv = dev_get_drvdata(dev);
765d0aeaa83SSudip Mukherjee 	unsigned int i;
766d0aeaa83SSudip Mukherjee 
767d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
768d0aeaa83SSudip Mukherjee 		if (priv->line[i] >= 0)
769d0aeaa83SSudip Mukherjee 			serial8250_suspend_port(priv->line[i]);
770d0aeaa83SSudip Mukherjee 
771d0aeaa83SSudip Mukherjee 	return 0;
772d0aeaa83SSudip Mukherjee }
773d0aeaa83SSudip Mukherjee 
77482f9cefaSAndy Shevchenko static int exar_resume(struct device *dev)
775d0aeaa83SSudip Mukherjee {
77676b4106cSChuhong Yuan 	struct exar8250 *priv = dev_get_drvdata(dev);
777d0aeaa83SSudip Mukherjee 	unsigned int i;
778d0aeaa83SSudip Mukherjee 
77972169e42SAaron Sierra 	exar_misc_clear(priv);
78072169e42SAaron Sierra 
781d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
782d0aeaa83SSudip Mukherjee 		if (priv->line[i] >= 0)
783d0aeaa83SSudip Mukherjee 			serial8250_resume_port(priv->line[i]);
784d0aeaa83SSudip Mukherjee 
785d0aeaa83SSudip Mukherjee 	return 0;
786d0aeaa83SSudip Mukherjee }
787d0aeaa83SSudip Mukherjee 
78882f9cefaSAndy Shevchenko static DEFINE_SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);
789d0aeaa83SSudip Mukherjee 
790fc6cc961SJan Kiszka static const struct exar8250_board pbn_fastcom335_2 = {
791fc6cc961SJan Kiszka 	.num_ports	= 2,
792fc6cc961SJan Kiszka 	.setup		= pci_fastcom335_setup,
793fc6cc961SJan Kiszka };
794fc6cc961SJan Kiszka 
795fc6cc961SJan Kiszka static const struct exar8250_board pbn_fastcom335_4 = {
796fc6cc961SJan Kiszka 	.num_ports	= 4,
797fc6cc961SJan Kiszka 	.setup		= pci_fastcom335_setup,
798fc6cc961SJan Kiszka };
799fc6cc961SJan Kiszka 
800fc6cc961SJan Kiszka static const struct exar8250_board pbn_fastcom335_8 = {
801fc6cc961SJan Kiszka 	.num_ports	= 8,
802fc6cc961SJan Kiszka 	.setup		= pci_fastcom335_setup,
803fc6cc961SJan Kiszka };
804fc6cc961SJan Kiszka 
805d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_connect = {
806d0aeaa83SSudip Mukherjee 	.setup		= pci_connect_tech_setup,
807d0aeaa83SSudip Mukherjee };
808d0aeaa83SSudip Mukherjee 
809d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_ibm_saturn = {
810d0aeaa83SSudip Mukherjee 	.num_ports	= 1,
811d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17c154_setup,
812d0aeaa83SSudip Mukherjee };
813d0aeaa83SSudip Mukherjee 
814d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17C15x = {
815d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17c154_setup,
816d0aeaa83SSudip Mukherjee };
817d0aeaa83SSudip Mukherjee 
818d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V35x = {
819d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
820d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
821d0aeaa83SSudip Mukherjee };
822d0aeaa83SSudip Mukherjee 
823c6b9e95dSValmer Huhn static const struct exar8250_board pbn_fastcom35x_2 = {
824c6b9e95dSValmer Huhn 	.num_ports	= 2,
825c6b9e95dSValmer Huhn 	.setup		= pci_xr17v35x_setup,
826c6b9e95dSValmer Huhn 	.exit		= pci_xr17v35x_exit,
827c6b9e95dSValmer Huhn };
828c6b9e95dSValmer Huhn 
829c6b9e95dSValmer Huhn static const struct exar8250_board pbn_fastcom35x_4 = {
830c6b9e95dSValmer Huhn 	.num_ports	= 4,
831c6b9e95dSValmer Huhn 	.setup		= pci_xr17v35x_setup,
832c6b9e95dSValmer Huhn 	.exit		= pci_xr17v35x_exit,
833c6b9e95dSValmer Huhn };
834c6b9e95dSValmer Huhn 
835c6b9e95dSValmer Huhn static const struct exar8250_board pbn_fastcom35x_8 = {
836c6b9e95dSValmer Huhn 	.num_ports	= 8,
837c6b9e95dSValmer Huhn 	.setup		= pci_xr17v35x_setup,
838c6b9e95dSValmer Huhn 	.exit		= pci_xr17v35x_exit,
839c6b9e95dSValmer Huhn };
840c6b9e95dSValmer Huhn 
841d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V4358 = {
842d0aeaa83SSudip Mukherjee 	.num_ports	= 12,
843d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
844d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
845d0aeaa83SSudip Mukherjee };
846d0aeaa83SSudip Mukherjee 
847d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V8358 = {
848d0aeaa83SSudip Mukherjee 	.num_ports	= 16,
849d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
850d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
851d0aeaa83SSudip Mukherjee };
852d0aeaa83SSudip Mukherjee 
853d0aeaa83SSudip Mukherjee #define CONNECT_DEVICE(devid, sdevid, bd) {				\
854d0aeaa83SSudip Mukherjee 	PCI_DEVICE_SUB(							\
855d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_EXAR,					\
856d0aeaa83SSudip Mukherjee 		PCI_DEVICE_ID_EXAR_##devid,				\
857d0aeaa83SSudip Mukherjee 		PCI_SUBVENDOR_ID_CONNECT_TECH,				\
858d0aeaa83SSudip Mukherjee 		PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_##sdevid), 0, 0,	\
859d0aeaa83SSudip Mukherjee 		(kernel_ulong_t)&bd					\
860d0aeaa83SSudip Mukherjee 	}
861d0aeaa83SSudip Mukherjee 
86224637007SAndy Shevchenko #define EXAR_DEVICE(vend, devid, bd) { PCI_DEVICE_DATA(vend, devid, &bd) }
863d0aeaa83SSudip Mukherjee 
864d0aeaa83SSudip Mukherjee #define IBM_DEVICE(devid, sdevid, bd) {			\
865d0aeaa83SSudip Mukherjee 	PCI_DEVICE_SUB(					\
866d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_EXAR,			\
867d0aeaa83SSudip Mukherjee 		PCI_DEVICE_ID_EXAR_##devid,		\
868d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_IBM,			\
869d0aeaa83SSudip Mukherjee 		PCI_SUBDEVICE_ID_IBM_##sdevid), 0, 0,	\
870d0aeaa83SSudip Mukherjee 		(kernel_ulong_t)&bd			\
871d0aeaa83SSudip Mukherjee 	}
872d0aeaa83SSudip Mukherjee 
87395d69886SAndrew Davis #define USR_DEVICE(devid, sdevid, bd) {			\
87495d69886SAndrew Davis 	PCI_DEVICE_SUB(					\
87595d69886SAndrew Davis 		PCI_VENDOR_ID_USR,			\
87695d69886SAndrew Davis 		PCI_DEVICE_ID_EXAR_##devid,		\
87795d69886SAndrew Davis 		PCI_VENDOR_ID_EXAR,			\
87895d69886SAndrew Davis 		PCI_SUBDEVICE_ID_USR_##sdevid), 0, 0,	\
87995d69886SAndrew Davis 		(kernel_ulong_t)&bd			\
88095d69886SAndrew Davis 	}
88195d69886SAndrew Davis 
8823637c460SArvind Yadav static const struct pci_device_id exar_pci_tbl[] = {
8838e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM_2S, pbn_exar_XR17C15x),
8848e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM_4S, pbn_exar_XR17C15x),
8858e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM_8S, pbn_exar_XR17C15x),
8868e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM232_8, pbn_exar_XR17C15x),
8878e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM_2SM, pbn_exar_XR17C15x),
8888e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM_4SM, pbn_exar_XR17C15x),
8898e4413aaSAndy Shevchenko 	EXAR_DEVICE(ACCESSIO, COM_8SM, pbn_exar_XR17C15x),
89010c5ccc3SJay Dolan 
891d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2_232, pbn_connect),
892d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4_232, pbn_connect),
893d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8_232, pbn_connect),
894d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_1_1, pbn_connect),
895d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_2_2, pbn_connect),
896d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_4_4, pbn_connect),
897d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2, pbn_connect),
898d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4, pbn_connect),
899d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8, pbn_connect),
900d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2_485, pbn_connect),
901d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4_485, pbn_connect),
902d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8_485, pbn_connect),
903d0aeaa83SSudip Mukherjee 
904d0aeaa83SSudip Mukherjee 	IBM_DEVICE(XR17C152, SATURN_SERIAL_ONE_PORT, pbn_exar_ibm_saturn),
905d0aeaa83SSudip Mukherjee 
90695d69886SAndrew Davis 	/* USRobotics USR298x-OEM PCI Modems */
90795d69886SAndrew Davis 	USR_DEVICE(XR17C152, 2980, pbn_exar_XR17C15x),
90895d69886SAndrew Davis 	USR_DEVICE(XR17C152, 2981, pbn_exar_XR17C15x),
90995d69886SAndrew Davis 
910d0aeaa83SSudip Mukherjee 	/* Exar Corp. XR17C15[248] Dual/Quad/Octal UART */
91124637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17C152, pbn_exar_XR17C15x),
91224637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17C154, pbn_exar_XR17C15x),
91324637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17C158, pbn_exar_XR17C15x),
914d0aeaa83SSudip Mukherjee 
915d0aeaa83SSudip Mukherjee 	/* Exar Corp. XR17V[48]35[248] Dual/Quad/Octal/Hexa PCIe UARTs */
91624637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17V352, pbn_exar_XR17V35x),
91724637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17V354, pbn_exar_XR17V35x),
91824637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17V358, pbn_exar_XR17V35x),
91924637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17V4358, pbn_exar_XR17V4358),
92024637007SAndy Shevchenko 	EXAR_DEVICE(EXAR, XR17V8358, pbn_exar_XR17V8358),
921c6b9e95dSValmer Huhn 	EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_fastcom35x_2),
922c6b9e95dSValmer Huhn 	EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_fastcom35x_4),
923c6b9e95dSValmer Huhn 	EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_fastcom35x_8),
924fc6cc961SJan Kiszka 
92524637007SAndy Shevchenko 	EXAR_DEVICE(COMMTECH, 4222PCI335, pbn_fastcom335_2),
92624637007SAndy Shevchenko 	EXAR_DEVICE(COMMTECH, 4224PCI335, pbn_fastcom335_4),
92724637007SAndy Shevchenko 	EXAR_DEVICE(COMMTECH, 2324PCI335, pbn_fastcom335_4),
92824637007SAndy Shevchenko 	EXAR_DEVICE(COMMTECH, 2328PCI335, pbn_fastcom335_8),
929d0aeaa83SSudip Mukherjee 	{ 0, }
930d0aeaa83SSudip Mukherjee };
931d0aeaa83SSudip Mukherjee MODULE_DEVICE_TABLE(pci, exar_pci_tbl);
932d0aeaa83SSudip Mukherjee 
933d0aeaa83SSudip Mukherjee static struct pci_driver exar_pci_driver = {
934d0aeaa83SSudip Mukherjee 	.name		= "exar_serial",
935d0aeaa83SSudip Mukherjee 	.probe		= exar_pci_probe,
936d0aeaa83SSudip Mukherjee 	.remove		= exar_pci_remove,
937d0aeaa83SSudip Mukherjee 	.driver         = {
93882f9cefaSAndy Shevchenko 		.pm     = pm_sleep_ptr(&exar_pci_pm),
939d0aeaa83SSudip Mukherjee 	},
940d0aeaa83SSudip Mukherjee 	.id_table	= exar_pci_tbl,
941d0aeaa83SSudip Mukherjee };
942d0aeaa83SSudip Mukherjee module_pci_driver(exar_pci_driver);
943d0aeaa83SSudip Mukherjee 
944*d813d900SAndy Shevchenko MODULE_IMPORT_NS(SERIAL_8250_PCI);
945d0aeaa83SSudip Mukherjee MODULE_LICENSE("GPL");
9462b57b7ffSAndy Shevchenko MODULE_DESCRIPTION("Exar Serial Driver");
947d0aeaa83SSudip Mukherjee MODULE_AUTHOR("Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>");
948