xref: /linux/drivers/tty/serial/8250/8250_exar.c (revision 9d9398944488cd3a3e1e0912b26fbc4d5921e547)
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  */
94076cf08SJan Kiszka #include <linux/acpi.h>
10413058dfSJan Kiszka #include <linux/dmi.h>
11d0aeaa83SSudip Mukherjee #include <linux/io.h>
12d0aeaa83SSudip Mukherjee #include <linux/kernel.h>
13d0aeaa83SSudip Mukherjee #include <linux/module.h>
14d0aeaa83SSudip Mukherjee #include <linux/pci.h>
15380b1e2fSJan Kiszka #include <linux/property.h>
16d0aeaa83SSudip Mukherjee #include <linux/serial_core.h>
17d0aeaa83SSudip Mukherjee #include <linux/serial_reg.h>
18d0aeaa83SSudip Mukherjee #include <linux/slab.h>
19d0aeaa83SSudip Mukherjee #include <linux/string.h>
20d0aeaa83SSudip Mukherjee #include <linux/tty.h>
21d0aeaa83SSudip Mukherjee #include <linux/8250_pci.h>
22d0aeaa83SSudip Mukherjee 
23d0aeaa83SSudip Mukherjee #include <asm/byteorder.h>
24d0aeaa83SSudip Mukherjee 
25d0aeaa83SSudip Mukherjee #include "8250.h"
26d0aeaa83SSudip Mukherjee 
27fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_4224PCI335	0x0002
28fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_4222PCI335	0x0004
29fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_2324PCI335	0x000a
30fc6cc961SJan Kiszka #define PCI_DEVICE_ID_COMMTECH_2328PCI335	0x000b
31d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4224PCIE		0x0020
32d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4228PCIE		0x0021
33d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4222PCIE		0x0022
34d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_EXAR_XR17V4358		0x4358
35d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_EXAR_XR17V8358		0x8358
36d0aeaa83SSudip Mukherjee 
37c7e1b405SAaron Sierra #define UART_EXAR_INT0		0x80
387e12357eSJan Kiszka #define UART_EXAR_8XMODE	0x88	/* 8X sampling rate select */
397e12357eSJan Kiszka 
407e12357eSJan Kiszka #define UART_EXAR_FCTR		0x08	/* Feature Control Register */
417e12357eSJan Kiszka #define UART_FCTR_EXAR_IRDA	0x10	/* IrDa data encode select */
427e12357eSJan Kiszka #define UART_FCTR_EXAR_485	0x20	/* Auto 485 half duplex dir ctl */
437e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGA	0x00	/* FIFO trigger table A */
447e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGB	0x60	/* FIFO trigger table B */
457e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGC	0x80	/* FIFO trigger table C */
467e12357eSJan Kiszka #define UART_FCTR_EXAR_TRGD	0xc0	/* FIFO trigger table D programmable */
477e12357eSJan Kiszka 
487e12357eSJan Kiszka #define UART_EXAR_TXTRG		0x0a	/* Tx FIFO trigger level write-only */
497e12357eSJan Kiszka #define UART_EXAR_RXTRG		0x0b	/* Rx FIFO trigger level write-only */
507e12357eSJan Kiszka 
51d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINT_7_0	0x8f	/* MPIOINT[7:0] */
52d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOLVL_7_0	0x90	/* MPIOLVL[7:0] */
53d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIO3T_7_0	0x91	/* MPIO3T[7:0] */
54d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINV_7_0	0x92	/* MPIOINV[7:0] */
55d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOSEL_7_0	0x93	/* MPIOSEL[7:0] */
56d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOOD_7_0	0x94	/* MPIOOD[7:0] */
57d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINT_15_8	0x95	/* MPIOINT[15:8] */
58d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOLVL_15_8	0x96	/* MPIOLVL[15:8] */
59d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIO3T_15_8	0x97	/* MPIO3T[15:8] */
60d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINV_15_8	0x98	/* MPIOINV[15:8] */
61d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOSEL_15_8	0x99	/* MPIOSEL[15:8] */
62d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOOD_15_8	0x9a	/* MPIOOD[15:8] */
63d0aeaa83SSudip Mukherjee 
64413058dfSJan Kiszka #define UART_EXAR_RS485_DLY(x)	((x) << 4)
65413058dfSJan Kiszka 
66413058dfSJan Kiszka /*
67413058dfSJan Kiszka  * IOT2040 MPIO wiring semantics:
68413058dfSJan Kiszka  *
69413058dfSJan Kiszka  * MPIO		Port	Function
70413058dfSJan Kiszka  * ----		----	--------
71413058dfSJan Kiszka  * 0		2 	Mode bit 0
72413058dfSJan Kiszka  * 1		2	Mode bit 1
73413058dfSJan Kiszka  * 2		2	Terminate bus
74413058dfSJan Kiszka  * 3		-	<reserved>
75413058dfSJan Kiszka  * 4		3	Mode bit 0
76413058dfSJan Kiszka  * 5		3	Mode bit 1
77413058dfSJan Kiszka  * 6		3	Terminate bus
78413058dfSJan Kiszka  * 7		-	<reserved>
79413058dfSJan Kiszka  * 8		2	Enable
80413058dfSJan Kiszka  * 9		3	Enable
81413058dfSJan Kiszka  * 10		-	Red LED
82413058dfSJan Kiszka  * 11..15	-	<unused>
83413058dfSJan Kiszka  */
84413058dfSJan Kiszka 
85413058dfSJan Kiszka /* IOT2040 MPIOs 0..7 */
86413058dfSJan Kiszka #define IOT2040_UART_MODE_RS232		0x01
87413058dfSJan Kiszka #define IOT2040_UART_MODE_RS485		0x02
88413058dfSJan Kiszka #define IOT2040_UART_MODE_RS422		0x03
89413058dfSJan Kiszka #define IOT2040_UART_TERMINATE_BUS	0x04
90413058dfSJan Kiszka 
91413058dfSJan Kiszka #define IOT2040_UART1_MASK		0x0f
92413058dfSJan Kiszka #define IOT2040_UART2_SHIFT		4
93413058dfSJan Kiszka 
94413058dfSJan Kiszka #define IOT2040_UARTS_DEFAULT_MODE	0x11	/* both RS232 */
95413058dfSJan Kiszka #define IOT2040_UARTS_GPIO_LO_MODE	0x88	/* reserved pins as input */
96413058dfSJan Kiszka 
97413058dfSJan Kiszka /* IOT2040 MPIOs 8..15 */
98413058dfSJan Kiszka #define IOT2040_UARTS_ENABLE		0x03
99413058dfSJan Kiszka #define IOT2040_UARTS_GPIO_HI_MODE	0xF8	/* enable & LED as outputs */
100413058dfSJan Kiszka 
101d0aeaa83SSudip Mukherjee struct exar8250;
102d0aeaa83SSudip Mukherjee 
1030d963ebfSJan Kiszka struct exar8250_platform {
1040d963ebfSJan Kiszka 	int (*rs485_config)(struct uart_port *, struct serial_rs485 *);
1050d963ebfSJan Kiszka 	int (*register_gpio)(struct pci_dev *, struct uart_8250_port *);
1060d963ebfSJan Kiszka };
1070d963ebfSJan Kiszka 
108d0aeaa83SSudip Mukherjee /**
109d0aeaa83SSudip Mukherjee  * struct exar8250_board - board information
110d0aeaa83SSudip Mukherjee  * @num_ports: number of serial ports
111d0aeaa83SSudip Mukherjee  * @reg_shift: describes UART register mapping in PCI memory
112d0aeaa83SSudip Mukherjee  */
113d0aeaa83SSudip Mukherjee struct exar8250_board {
114d0aeaa83SSudip Mukherjee 	unsigned int num_ports;
115d0aeaa83SSudip Mukherjee 	unsigned int reg_shift;
116d0aeaa83SSudip Mukherjee 	bool has_slave;
117d0aeaa83SSudip Mukherjee 	int	(*setup)(struct exar8250 *, struct pci_dev *,
118d0aeaa83SSudip Mukherjee 			 struct uart_8250_port *, int);
119d0aeaa83SSudip Mukherjee 	void	(*exit)(struct pci_dev *pcidev);
120d0aeaa83SSudip Mukherjee };
121d0aeaa83SSudip Mukherjee 
122d0aeaa83SSudip Mukherjee struct exar8250 {
123d0aeaa83SSudip Mukherjee 	unsigned int		nr;
124d0aeaa83SSudip Mukherjee 	struct exar8250_board	*board;
125c7e1b405SAaron Sierra 	void __iomem		*virt;
126d0aeaa83SSudip Mukherjee 	int			line[0];
127d0aeaa83SSudip Mukherjee };
128d0aeaa83SSudip Mukherjee 
129d0aeaa83SSudip Mukherjee static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
130d0aeaa83SSudip Mukherjee 			 int idx, unsigned int offset,
131d0aeaa83SSudip Mukherjee 			 struct uart_8250_port *port)
132d0aeaa83SSudip Mukherjee {
133d0aeaa83SSudip Mukherjee 	const struct exar8250_board *board = priv->board;
134d0aeaa83SSudip Mukherjee 	unsigned int bar = 0;
135d0aeaa83SSudip Mukherjee 
136d0aeaa83SSudip Mukherjee 	port->port.iotype = UPIO_MEM;
137d0aeaa83SSudip Mukherjee 	port->port.mapbase = pci_resource_start(pcidev, bar) + offset;
138c7e1b405SAaron Sierra 	port->port.membase = priv->virt + offset;
139d0aeaa83SSudip Mukherjee 	port->port.regshift = board->reg_shift;
140d0aeaa83SSudip Mukherjee 
141d0aeaa83SSudip Mukherjee 	return 0;
142d0aeaa83SSudip Mukherjee }
143d0aeaa83SSudip Mukherjee 
144d0aeaa83SSudip Mukherjee static int
145fc6cc961SJan Kiszka pci_fastcom335_setup(struct exar8250 *priv, struct pci_dev *pcidev,
146fc6cc961SJan Kiszka 		     struct uart_8250_port *port, int idx)
147fc6cc961SJan Kiszka {
148fc6cc961SJan Kiszka 	unsigned int offset = idx * 0x200;
149fc6cc961SJan Kiszka 	unsigned int baud = 1843200;
150fc6cc961SJan Kiszka 	u8 __iomem *p;
151fc6cc961SJan Kiszka 	int err;
152fc6cc961SJan Kiszka 
153fc6cc961SJan Kiszka 	port->port.uartclk = baud * 16;
154fc6cc961SJan Kiszka 
155fc6cc961SJan Kiszka 	err = default_setup(priv, pcidev, idx, offset, port);
156fc6cc961SJan Kiszka 	if (err)
157fc6cc961SJan Kiszka 		return err;
158fc6cc961SJan Kiszka 
159fc6cc961SJan Kiszka 	p = port->port.membase;
160fc6cc961SJan Kiszka 
161fc6cc961SJan Kiszka 	writeb(0x00, p + UART_EXAR_8XMODE);
162fc6cc961SJan Kiszka 	writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
163fc6cc961SJan Kiszka 	writeb(32, p + UART_EXAR_TXTRG);
164fc6cc961SJan Kiszka 	writeb(32, p + UART_EXAR_RXTRG);
165fc6cc961SJan Kiszka 
166fc6cc961SJan Kiszka 	/*
167fc6cc961SJan Kiszka 	 * Setup Multipurpose Input/Output pins.
168fc6cc961SJan Kiszka 	 */
169fc6cc961SJan Kiszka 	if (idx == 0) {
170fc6cc961SJan Kiszka 		switch (pcidev->device) {
171fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_4222PCI335:
172fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_4224PCI335:
173fc6cc961SJan Kiszka 			writeb(0x78, p + UART_EXAR_MPIOLVL_7_0);
174fc6cc961SJan Kiszka 			writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
175fc6cc961SJan Kiszka 			writeb(0x00, p + UART_EXAR_MPIOSEL_7_0);
176fc6cc961SJan Kiszka 			break;
177fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_2324PCI335:
178fc6cc961SJan Kiszka 		case PCI_DEVICE_ID_COMMTECH_2328PCI335:
179fc6cc961SJan Kiszka 			writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
180fc6cc961SJan Kiszka 			writeb(0xc0, p + UART_EXAR_MPIOINV_7_0);
181fc6cc961SJan Kiszka 			writeb(0xc0, p + UART_EXAR_MPIOSEL_7_0);
182fc6cc961SJan Kiszka 			break;
183fc6cc961SJan Kiszka 		}
184fc6cc961SJan Kiszka 		writeb(0x00, p + UART_EXAR_MPIOINT_7_0);
185fc6cc961SJan Kiszka 		writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
186fc6cc961SJan Kiszka 		writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
187fc6cc961SJan Kiszka 	}
188fc6cc961SJan Kiszka 
189fc6cc961SJan Kiszka 	return 0;
190fc6cc961SJan Kiszka }
191fc6cc961SJan Kiszka 
192fc6cc961SJan Kiszka static int
193d0aeaa83SSudip Mukherjee pci_connect_tech_setup(struct exar8250 *priv, struct pci_dev *pcidev,
194d0aeaa83SSudip Mukherjee 		       struct uart_8250_port *port, int idx)
195d0aeaa83SSudip Mukherjee {
196d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x200;
197d0aeaa83SSudip Mukherjee 	unsigned int baud = 1843200;
198d0aeaa83SSudip Mukherjee 
199d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
200d0aeaa83SSudip Mukherjee 	return default_setup(priv, pcidev, idx, offset, port);
201d0aeaa83SSudip Mukherjee }
202d0aeaa83SSudip Mukherjee 
203d0aeaa83SSudip Mukherjee static int
204d0aeaa83SSudip Mukherjee pci_xr17c154_setup(struct exar8250 *priv, struct pci_dev *pcidev,
205d0aeaa83SSudip Mukherjee 		   struct uart_8250_port *port, int idx)
206d0aeaa83SSudip Mukherjee {
207d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x200;
208d0aeaa83SSudip Mukherjee 	unsigned int baud = 921600;
209d0aeaa83SSudip Mukherjee 
210d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
211d0aeaa83SSudip Mukherjee 	return default_setup(priv, pcidev, idx, offset, port);
212d0aeaa83SSudip Mukherjee }
213d0aeaa83SSudip Mukherjee 
214bea8be65SJan Kiszka static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
215d0aeaa83SSudip Mukherjee {
216bea8be65SJan Kiszka 	/*
217bea8be65SJan Kiszka 	 * The Commtech adapters required the MPIOs to be driven low. The Exar
218bea8be65SJan Kiszka 	 * devices will export them as GPIOs, so we pre-configure them safely
219bea8be65SJan Kiszka 	 * as inputs.
220bea8be65SJan Kiszka 	 */
221bea8be65SJan Kiszka 	u8 dir = pcidev->vendor == PCI_VENDOR_ID_EXAR ? 0xff : 0x00;
222bea8be65SJan Kiszka 
223d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINT_7_0);
224d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
225d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
226d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
227bea8be65SJan Kiszka 	writeb(dir,  p + UART_EXAR_MPIOSEL_7_0);
228d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
229d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINT_15_8);
230d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOLVL_15_8);
231d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIO3T_15_8);
232d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINV_15_8);
233bea8be65SJan Kiszka 	writeb(dir,  p + UART_EXAR_MPIOSEL_15_8);
234d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOOD_15_8);
235d0aeaa83SSudip Mukherjee }
236d0aeaa83SSudip Mukherjee 
237d0aeaa83SSudip Mukherjee static void *
238380b1e2fSJan Kiszka __xr17v35x_register_gpio(struct pci_dev *pcidev,
239380b1e2fSJan Kiszka 			 const struct property_entry *properties)
240d0aeaa83SSudip Mukherjee {
241d0aeaa83SSudip Mukherjee 	struct platform_device *pdev;
242d0aeaa83SSudip Mukherjee 
243d0aeaa83SSudip Mukherjee 	pdev = platform_device_alloc("gpio_exar", PLATFORM_DEVID_AUTO);
244d0aeaa83SSudip Mukherjee 	if (!pdev)
245d0aeaa83SSudip Mukherjee 		return NULL;
246d0aeaa83SSudip Mukherjee 
247d3936d74SJan Kiszka 	pdev->dev.parent = &pcidev->dev;
2484076cf08SJan Kiszka 	ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pcidev->dev));
249d3936d74SJan Kiszka 
250380b1e2fSJan Kiszka 	if (platform_device_add_properties(pdev, properties) < 0 ||
251380b1e2fSJan Kiszka 	    platform_device_add(pdev) < 0) {
252d0aeaa83SSudip Mukherjee 		platform_device_put(pdev);
253d0aeaa83SSudip Mukherjee 		return NULL;
254d0aeaa83SSudip Mukherjee 	}
255d0aeaa83SSudip Mukherjee 
256d0aeaa83SSudip Mukherjee 	return pdev;
257d0aeaa83SSudip Mukherjee }
258d0aeaa83SSudip Mukherjee 
259380b1e2fSJan Kiszka static const struct property_entry exar_gpio_properties[] = {
260a589e211SJan Kiszka 	PROPERTY_ENTRY_U32("exar,first-pin", 0),
261380b1e2fSJan Kiszka 	PROPERTY_ENTRY_U32("ngpios", 16),
262380b1e2fSJan Kiszka 	{ }
263380b1e2fSJan Kiszka };
264380b1e2fSJan Kiszka 
2650d963ebfSJan Kiszka static int xr17v35x_register_gpio(struct pci_dev *pcidev,
2660d963ebfSJan Kiszka 				  struct uart_8250_port *port)
2670d963ebfSJan Kiszka {
2680d963ebfSJan Kiszka 	if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
2690d963ebfSJan Kiszka 		port->port.private_data =
270380b1e2fSJan Kiszka 			__xr17v35x_register_gpio(pcidev, exar_gpio_properties);
2710d963ebfSJan Kiszka 
2720d963ebfSJan Kiszka 	return 0;
2730d963ebfSJan Kiszka }
2740d963ebfSJan Kiszka 
275*9d939894SDaniel Golle static int generic_rs485_config(struct uart_port *port,
276*9d939894SDaniel Golle 				struct serial_rs485 *rs485)
277*9d939894SDaniel Golle {
278*9d939894SDaniel Golle 	bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
279*9d939894SDaniel Golle 	u8 __iomem *p = port->membase;
280*9d939894SDaniel Golle 	u8 value;
281*9d939894SDaniel Golle 
282*9d939894SDaniel Golle 	value = readb(p + UART_EXAR_FCTR);
283*9d939894SDaniel Golle 	if (is_rs485)
284*9d939894SDaniel Golle 		value |= UART_FCTR_EXAR_485;
285*9d939894SDaniel Golle 	else
286*9d939894SDaniel Golle 		value &= ~UART_FCTR_EXAR_485;
287*9d939894SDaniel Golle 
288*9d939894SDaniel Golle 	writeb(value, p + UART_EXAR_FCTR);
289*9d939894SDaniel Golle 
290*9d939894SDaniel Golle 	if (is_rs485)
291*9d939894SDaniel Golle 		writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
292*9d939894SDaniel Golle 
293*9d939894SDaniel Golle 	port->rs485 = *rs485;
294*9d939894SDaniel Golle 
295*9d939894SDaniel Golle 	return 0;
296*9d939894SDaniel Golle }
297*9d939894SDaniel Golle 
2980d963ebfSJan Kiszka static const struct exar8250_platform exar8250_default_platform = {
2990d963ebfSJan Kiszka 	.register_gpio = xr17v35x_register_gpio,
300*9d939894SDaniel Golle 	.rs485_config = generic_rs485_config,
3010d963ebfSJan Kiszka };
3020d963ebfSJan Kiszka 
303413058dfSJan Kiszka static int iot2040_rs485_config(struct uart_port *port,
304413058dfSJan Kiszka 				struct serial_rs485 *rs485)
305413058dfSJan Kiszka {
306413058dfSJan Kiszka 	bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
307413058dfSJan Kiszka 	u8 __iomem *p = port->membase;
308413058dfSJan Kiszka 	u8 mask = IOT2040_UART1_MASK;
309413058dfSJan Kiszka 	u8 mode, value;
310413058dfSJan Kiszka 
311413058dfSJan Kiszka 	if (is_rs485) {
312413058dfSJan Kiszka 		if (rs485->flags & SER_RS485_RX_DURING_TX)
313413058dfSJan Kiszka 			mode = IOT2040_UART_MODE_RS422;
314413058dfSJan Kiszka 		else
315413058dfSJan Kiszka 			mode = IOT2040_UART_MODE_RS485;
316413058dfSJan Kiszka 
317413058dfSJan Kiszka 		if (rs485->flags & SER_RS485_TERMINATE_BUS)
318413058dfSJan Kiszka 			mode |= IOT2040_UART_TERMINATE_BUS;
319413058dfSJan Kiszka 	} else {
320413058dfSJan Kiszka 		mode = IOT2040_UART_MODE_RS232;
321413058dfSJan Kiszka 	}
322413058dfSJan Kiszka 
323413058dfSJan Kiszka 	if (port->line == 3) {
324413058dfSJan Kiszka 		mask <<= IOT2040_UART2_SHIFT;
325413058dfSJan Kiszka 		mode <<= IOT2040_UART2_SHIFT;
326413058dfSJan Kiszka 	}
327413058dfSJan Kiszka 
328413058dfSJan Kiszka 	value = readb(p + UART_EXAR_MPIOLVL_7_0);
329413058dfSJan Kiszka 	value &= ~mask;
330413058dfSJan Kiszka 	value |= mode;
331413058dfSJan Kiszka 	writeb(value, p + UART_EXAR_MPIOLVL_7_0);
332413058dfSJan Kiszka 
333*9d939894SDaniel Golle 	return generic_rs485_config(port, rs485);
334413058dfSJan Kiszka }
335413058dfSJan Kiszka 
336413058dfSJan Kiszka static const struct property_entry iot2040_gpio_properties[] = {
337a589e211SJan Kiszka 	PROPERTY_ENTRY_U32("exar,first-pin", 10),
338413058dfSJan Kiszka 	PROPERTY_ENTRY_U32("ngpios", 1),
339413058dfSJan Kiszka 	{ }
340413058dfSJan Kiszka };
341413058dfSJan Kiszka 
342413058dfSJan Kiszka static int iot2040_register_gpio(struct pci_dev *pcidev,
343413058dfSJan Kiszka 			      struct uart_8250_port *port)
344413058dfSJan Kiszka {
345413058dfSJan Kiszka 	u8 __iomem *p = port->port.membase;
346413058dfSJan Kiszka 
347413058dfSJan Kiszka 	writeb(IOT2040_UARTS_DEFAULT_MODE, p + UART_EXAR_MPIOLVL_7_0);
348413058dfSJan Kiszka 	writeb(IOT2040_UARTS_GPIO_LO_MODE, p + UART_EXAR_MPIOSEL_7_0);
349413058dfSJan Kiszka 	writeb(IOT2040_UARTS_ENABLE, p + UART_EXAR_MPIOLVL_15_8);
350413058dfSJan Kiszka 	writeb(IOT2040_UARTS_GPIO_HI_MODE, p + UART_EXAR_MPIOSEL_15_8);
351413058dfSJan Kiszka 
352413058dfSJan Kiszka 	port->port.private_data =
353413058dfSJan Kiszka 		__xr17v35x_register_gpio(pcidev, iot2040_gpio_properties);
354413058dfSJan Kiszka 
355413058dfSJan Kiszka 	return 0;
356413058dfSJan Kiszka }
357413058dfSJan Kiszka 
358413058dfSJan Kiszka static const struct exar8250_platform iot2040_platform = {
359413058dfSJan Kiszka 	.rs485_config = iot2040_rs485_config,
360413058dfSJan Kiszka 	.register_gpio = iot2040_register_gpio,
361413058dfSJan Kiszka };
362413058dfSJan Kiszka 
363413058dfSJan Kiszka static const struct dmi_system_id exar_platforms[] = {
364413058dfSJan Kiszka 	{
365413058dfSJan Kiszka 		.matches = {
366413058dfSJan Kiszka 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
367413058dfSJan Kiszka 			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
368413058dfSJan Kiszka 					"6ES7647-0AA00-1YA2"),
369413058dfSJan Kiszka 		},
370413058dfSJan Kiszka 		.driver_data = (void *)&iot2040_platform,
371413058dfSJan Kiszka 	},
372413058dfSJan Kiszka 	{}
373413058dfSJan Kiszka };
374413058dfSJan Kiszka 
375d0aeaa83SSudip Mukherjee static int
376d0aeaa83SSudip Mukherjee pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
377d0aeaa83SSudip Mukherjee 		   struct uart_8250_port *port, int idx)
378d0aeaa83SSudip Mukherjee {
379d0aeaa83SSudip Mukherjee 	const struct exar8250_board *board = priv->board;
3800d963ebfSJan Kiszka 	const struct exar8250_platform *platform;
381413058dfSJan Kiszka 	const struct dmi_system_id *dmi_match;
382d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x400;
383d0aeaa83SSudip Mukherjee 	unsigned int baud = 7812500;
384d0aeaa83SSudip Mukherjee 	u8 __iomem *p;
385d0aeaa83SSudip Mukherjee 	int ret;
386d0aeaa83SSudip Mukherjee 
387413058dfSJan Kiszka 	dmi_match = dmi_first_match(exar_platforms);
388413058dfSJan Kiszka 	if (dmi_match)
389413058dfSJan Kiszka 		platform = dmi_match->driver_data;
390413058dfSJan Kiszka 	else
3910d963ebfSJan Kiszka 		platform = &exar8250_default_platform;
3920d963ebfSJan Kiszka 
393d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
3940d963ebfSJan Kiszka 	port->port.rs485_config = platform->rs485_config;
3950d963ebfSJan Kiszka 
396d0aeaa83SSudip Mukherjee 	/*
397d0aeaa83SSudip Mukherjee 	 * Setup the uart clock for the devices on expansion slot to
398d0aeaa83SSudip Mukherjee 	 * half the clock speed of the main chip (which is 125MHz)
399d0aeaa83SSudip Mukherjee 	 */
400d0aeaa83SSudip Mukherjee 	if (board->has_slave && idx >= 8)
401d0aeaa83SSudip Mukherjee 		port->port.uartclk /= 2;
402d0aeaa83SSudip Mukherjee 
4035b5f252dSJan Kiszka 	ret = default_setup(priv, pcidev, idx, offset, port);
4045b5f252dSJan Kiszka 	if (ret)
4055b5f252dSJan Kiszka 		return ret;
406d0aeaa83SSudip Mukherjee 
4075b5f252dSJan Kiszka 	p = port->port.membase;
408d0aeaa83SSudip Mukherjee 
409d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_8XMODE);
410d0aeaa83SSudip Mukherjee 	writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
411d0aeaa83SSudip Mukherjee 	writeb(128, p + UART_EXAR_TXTRG);
412d0aeaa83SSudip Mukherjee 	writeb(128, p + UART_EXAR_RXTRG);
413d0aeaa83SSudip Mukherjee 
4145b5f252dSJan Kiszka 	if (idx == 0) {
4155b5f252dSJan Kiszka 		/* Setup Multipurpose Input/Output pins. */
416bea8be65SJan Kiszka 		setup_gpio(pcidev, p);
417d0aeaa83SSudip Mukherjee 
4180d963ebfSJan Kiszka 		ret = platform->register_gpio(pcidev, port);
4195b5f252dSJan Kiszka 	}
420d0aeaa83SSudip Mukherjee 
4210d963ebfSJan Kiszka 	return ret;
422d0aeaa83SSudip Mukherjee }
423d0aeaa83SSudip Mukherjee 
424d0aeaa83SSudip Mukherjee static void pci_xr17v35x_exit(struct pci_dev *pcidev)
425d0aeaa83SSudip Mukherjee {
426d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
427d0aeaa83SSudip Mukherjee 	struct uart_8250_port *port = serial8250_get_port(priv->line[0]);
428d0aeaa83SSudip Mukherjee 	struct platform_device *pdev = port->port.private_data;
429d0aeaa83SSudip Mukherjee 
430d0aeaa83SSudip Mukherjee 	platform_device_unregister(pdev);
431d0aeaa83SSudip Mukherjee 	port->port.private_data = NULL;
432d0aeaa83SSudip Mukherjee }
433d0aeaa83SSudip Mukherjee 
434c7e1b405SAaron Sierra /*
435c7e1b405SAaron Sierra  * These Exar UARTs have an extra interrupt indicator that could fire for a
436c7e1b405SAaron Sierra  * few interrupts that are not presented/cleared through IIR.  One of which is
437c7e1b405SAaron Sierra  * a wakeup interrupt when coming out of sleep.  These interrupts are only
438c7e1b405SAaron Sierra  * cleared by reading global INT0 or INT1 registers as interrupts are
439c7e1b405SAaron Sierra  * associated with channel 0. The INT[3:0] registers _are_ accessible from each
440c7e1b405SAaron Sierra  * channel's address space, but for the sake of bus efficiency we register a
441c7e1b405SAaron Sierra  * dedicated handler at the PCI device level to handle them.
442c7e1b405SAaron Sierra  */
443c7e1b405SAaron Sierra static irqreturn_t exar_misc_handler(int irq, void *data)
444c7e1b405SAaron Sierra {
445c7e1b405SAaron Sierra 	struct exar8250 *priv = data;
446c7e1b405SAaron Sierra 
447c7e1b405SAaron Sierra 	/* Clear all PCI interrupts by reading INT0. No effect on IIR */
448c7e1b405SAaron Sierra 	ioread8(priv->virt + UART_EXAR_INT0);
449c7e1b405SAaron Sierra 
450c7e1b405SAaron Sierra 	return IRQ_HANDLED;
451c7e1b405SAaron Sierra }
452c7e1b405SAaron Sierra 
453d0aeaa83SSudip Mukherjee static int
454d0aeaa83SSudip Mukherjee exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
455d0aeaa83SSudip Mukherjee {
456d0aeaa83SSudip Mukherjee 	unsigned int nr_ports, i, bar = 0, maxnr;
457d0aeaa83SSudip Mukherjee 	struct exar8250_board *board;
458d0aeaa83SSudip Mukherjee 	struct uart_8250_port uart;
459d0aeaa83SSudip Mukherjee 	struct exar8250 *priv;
460d0aeaa83SSudip Mukherjee 	int rc;
461d0aeaa83SSudip Mukherjee 
462d0aeaa83SSudip Mukherjee 	board = (struct exar8250_board *)ent->driver_data;
463d0aeaa83SSudip Mukherjee 	if (!board)
464d0aeaa83SSudip Mukherjee 		return -EINVAL;
465d0aeaa83SSudip Mukherjee 
466d0aeaa83SSudip Mukherjee 	rc = pcim_enable_device(pcidev);
467d0aeaa83SSudip Mukherjee 	if (rc)
468d0aeaa83SSudip Mukherjee 		return rc;
469d0aeaa83SSudip Mukherjee 
470d0aeaa83SSudip Mukherjee 	maxnr = pci_resource_len(pcidev, bar) >> (board->reg_shift + 3);
471d0aeaa83SSudip Mukherjee 
472d0aeaa83SSudip Mukherjee 	nr_ports = board->num_ports ? board->num_ports : pcidev->device & 0x0f;
473d0aeaa83SSudip Mukherjee 
474d0aeaa83SSudip Mukherjee 	priv = devm_kzalloc(&pcidev->dev, sizeof(*priv) +
475d0aeaa83SSudip Mukherjee 			    sizeof(unsigned int) * nr_ports,
476d0aeaa83SSudip Mukherjee 			    GFP_KERNEL);
477d0aeaa83SSudip Mukherjee 	if (!priv)
478d0aeaa83SSudip Mukherjee 		return -ENOMEM;
479d0aeaa83SSudip Mukherjee 
480d0aeaa83SSudip Mukherjee 	priv->board = board;
481c7e1b405SAaron Sierra 	priv->virt = pcim_iomap(pcidev, bar, 0);
482c7e1b405SAaron Sierra 	if (!priv->virt)
483c7e1b405SAaron Sierra 		return -ENOMEM;
484d0aeaa83SSudip Mukherjee 
485172c33cbSJan Kiszka 	pci_set_master(pcidev);
486172c33cbSJan Kiszka 
487172c33cbSJan Kiszka 	rc = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
488172c33cbSJan Kiszka 	if (rc < 0)
489172c33cbSJan Kiszka 		return rc;
490172c33cbSJan Kiszka 
491d0aeaa83SSudip Mukherjee 	memset(&uart, 0, sizeof(uart));
492d0aeaa83SSudip Mukherjee 	uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ
493d0aeaa83SSudip Mukherjee 			  | UPF_EXAR_EFR;
494172c33cbSJan Kiszka 	uart.port.irq = pci_irq_vector(pcidev, 0);
495d0aeaa83SSudip Mukherjee 	uart.port.dev = &pcidev->dev;
496d0aeaa83SSudip Mukherjee 
497c7e1b405SAaron Sierra 	rc = devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler,
498c7e1b405SAaron Sierra 			 IRQF_SHARED, "exar_uart", priv);
499c7e1b405SAaron Sierra 	if (rc)
500c7e1b405SAaron Sierra 		return rc;
501c7e1b405SAaron Sierra 
502d0aeaa83SSudip Mukherjee 	for (i = 0; i < nr_ports && i < maxnr; i++) {
503d0aeaa83SSudip Mukherjee 		rc = board->setup(priv, pcidev, &uart, i);
504d0aeaa83SSudip Mukherjee 		if (rc) {
505d0aeaa83SSudip Mukherjee 			dev_err(&pcidev->dev, "Failed to setup port %u\n", i);
506d0aeaa83SSudip Mukherjee 			break;
507d0aeaa83SSudip Mukherjee 		}
508d0aeaa83SSudip Mukherjee 
509d0aeaa83SSudip Mukherjee 		dev_dbg(&pcidev->dev, "Setup PCI port: port %lx, irq %d, type %d\n",
510d0aeaa83SSudip Mukherjee 			uart.port.iobase, uart.port.irq, uart.port.iotype);
511d0aeaa83SSudip Mukherjee 
512d0aeaa83SSudip Mukherjee 		priv->line[i] = serial8250_register_8250_port(&uart);
513d0aeaa83SSudip Mukherjee 		if (priv->line[i] < 0) {
514d0aeaa83SSudip Mukherjee 			dev_err(&pcidev->dev,
515d0aeaa83SSudip Mukherjee 				"Couldn't register serial port %lx, irq %d, type %d, error %d\n",
516d0aeaa83SSudip Mukherjee 				uart.port.iobase, uart.port.irq,
517d0aeaa83SSudip Mukherjee 				uart.port.iotype, priv->line[i]);
518d0aeaa83SSudip Mukherjee 			break;
519d0aeaa83SSudip Mukherjee 		}
520d0aeaa83SSudip Mukherjee 	}
521d0aeaa83SSudip Mukherjee 	priv->nr = i;
522d0aeaa83SSudip Mukherjee 	pci_set_drvdata(pcidev, priv);
523d0aeaa83SSudip Mukherjee 	return 0;
524d0aeaa83SSudip Mukherjee }
525d0aeaa83SSudip Mukherjee 
526d0aeaa83SSudip Mukherjee static void exar_pci_remove(struct pci_dev *pcidev)
527d0aeaa83SSudip Mukherjee {
528d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
529d0aeaa83SSudip Mukherjee 	unsigned int i;
530d0aeaa83SSudip Mukherjee 
531d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
532d0aeaa83SSudip Mukherjee 		serial8250_unregister_port(priv->line[i]);
533d0aeaa83SSudip Mukherjee 
534d0aeaa83SSudip Mukherjee 	if (priv->board->exit)
535d0aeaa83SSudip Mukherjee 		priv->board->exit(pcidev);
536d0aeaa83SSudip Mukherjee }
537d0aeaa83SSudip Mukherjee 
538d0aeaa83SSudip Mukherjee static int __maybe_unused exar_suspend(struct device *dev)
539d0aeaa83SSudip Mukherjee {
540d0aeaa83SSudip Mukherjee 	struct pci_dev *pcidev = to_pci_dev(dev);
541d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
542d0aeaa83SSudip Mukherjee 	unsigned int i;
543d0aeaa83SSudip Mukherjee 
544d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
545d0aeaa83SSudip Mukherjee 		if (priv->line[i] >= 0)
546d0aeaa83SSudip Mukherjee 			serial8250_suspend_port(priv->line[i]);
547d0aeaa83SSudip Mukherjee 
548d0aeaa83SSudip Mukherjee 	/* Ensure that every init quirk is properly torn down */
549d0aeaa83SSudip Mukherjee 	if (priv->board->exit)
550d0aeaa83SSudip Mukherjee 		priv->board->exit(pcidev);
551d0aeaa83SSudip Mukherjee 
552d0aeaa83SSudip Mukherjee 	return 0;
553d0aeaa83SSudip Mukherjee }
554d0aeaa83SSudip Mukherjee 
555d0aeaa83SSudip Mukherjee static int __maybe_unused exar_resume(struct device *dev)
556d0aeaa83SSudip Mukherjee {
557d0aeaa83SSudip Mukherjee 	struct pci_dev *pcidev = to_pci_dev(dev);
558d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
559d0aeaa83SSudip Mukherjee 	unsigned int i;
560d0aeaa83SSudip Mukherjee 
561d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
562d0aeaa83SSudip Mukherjee 		if (priv->line[i] >= 0)
563d0aeaa83SSudip Mukherjee 			serial8250_resume_port(priv->line[i]);
564d0aeaa83SSudip Mukherjee 
565d0aeaa83SSudip Mukherjee 	return 0;
566d0aeaa83SSudip Mukherjee }
567d0aeaa83SSudip Mukherjee 
568d0aeaa83SSudip Mukherjee static SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);
569d0aeaa83SSudip Mukherjee 
570fc6cc961SJan Kiszka static const struct exar8250_board pbn_fastcom335_2 = {
571fc6cc961SJan Kiszka 	.num_ports	= 2,
572fc6cc961SJan Kiszka 	.setup		= pci_fastcom335_setup,
573fc6cc961SJan Kiszka };
574fc6cc961SJan Kiszka 
575fc6cc961SJan Kiszka static const struct exar8250_board pbn_fastcom335_4 = {
576fc6cc961SJan Kiszka 	.num_ports	= 4,
577fc6cc961SJan Kiszka 	.setup		= pci_fastcom335_setup,
578fc6cc961SJan Kiszka };
579fc6cc961SJan Kiszka 
580fc6cc961SJan Kiszka static const struct exar8250_board pbn_fastcom335_8 = {
581fc6cc961SJan Kiszka 	.num_ports	= 8,
582fc6cc961SJan Kiszka 	.setup		= pci_fastcom335_setup,
583fc6cc961SJan Kiszka };
584fc6cc961SJan Kiszka 
585d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_connect = {
586d0aeaa83SSudip Mukherjee 	.setup		= pci_connect_tech_setup,
587d0aeaa83SSudip Mukherjee };
588d0aeaa83SSudip Mukherjee 
589d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_ibm_saturn = {
590d0aeaa83SSudip Mukherjee 	.num_ports	= 1,
591d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17c154_setup,
592d0aeaa83SSudip Mukherjee };
593d0aeaa83SSudip Mukherjee 
594d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17C15x = {
595d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17c154_setup,
596d0aeaa83SSudip Mukherjee };
597d0aeaa83SSudip Mukherjee 
598d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V35x = {
599d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
600d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
601d0aeaa83SSudip Mukherjee };
602d0aeaa83SSudip Mukherjee 
603d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V4358 = {
604d0aeaa83SSudip Mukherjee 	.num_ports	= 12,
605d0aeaa83SSudip Mukherjee 	.has_slave	= true,
606d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
607d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
608d0aeaa83SSudip Mukherjee };
609d0aeaa83SSudip Mukherjee 
610d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V8358 = {
611d0aeaa83SSudip Mukherjee 	.num_ports	= 16,
612d0aeaa83SSudip Mukherjee 	.has_slave	= true,
613d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
614d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
615d0aeaa83SSudip Mukherjee };
616d0aeaa83SSudip Mukherjee 
617d0aeaa83SSudip Mukherjee #define CONNECT_DEVICE(devid, sdevid, bd) {				\
618d0aeaa83SSudip Mukherjee 	PCI_DEVICE_SUB(							\
619d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_EXAR,					\
620d0aeaa83SSudip Mukherjee 		PCI_DEVICE_ID_EXAR_##devid,				\
621d0aeaa83SSudip Mukherjee 		PCI_SUBVENDOR_ID_CONNECT_TECH,				\
622d0aeaa83SSudip Mukherjee 		PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_##sdevid), 0, 0,	\
623d0aeaa83SSudip Mukherjee 		(kernel_ulong_t)&bd					\
624d0aeaa83SSudip Mukherjee 	}
625d0aeaa83SSudip Mukherjee 
626d0aeaa83SSudip Mukherjee #define EXAR_DEVICE(vend, devid, bd) {					\
627d0aeaa83SSudip Mukherjee 	PCI_VDEVICE(vend, PCI_DEVICE_ID_##devid), (kernel_ulong_t)&bd	\
628d0aeaa83SSudip Mukherjee 	}
629d0aeaa83SSudip Mukherjee 
630d0aeaa83SSudip Mukherjee #define IBM_DEVICE(devid, sdevid, bd) {			\
631d0aeaa83SSudip Mukherjee 	PCI_DEVICE_SUB(					\
632d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_EXAR,			\
633d0aeaa83SSudip Mukherjee 		PCI_DEVICE_ID_EXAR_##devid,		\
634d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_IBM,			\
635d0aeaa83SSudip Mukherjee 		PCI_SUBDEVICE_ID_IBM_##sdevid), 0, 0,	\
636d0aeaa83SSudip Mukherjee 		(kernel_ulong_t)&bd			\
637d0aeaa83SSudip Mukherjee 	}
638d0aeaa83SSudip Mukherjee 
6393637c460SArvind Yadav static const struct pci_device_id exar_pci_tbl[] = {
640d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2_232, pbn_connect),
641d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4_232, pbn_connect),
642d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8_232, pbn_connect),
643d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_1_1, pbn_connect),
644d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_2_2, pbn_connect),
645d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_4_4, pbn_connect),
646d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2, pbn_connect),
647d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4, pbn_connect),
648d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8, pbn_connect),
649d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2_485, pbn_connect),
650d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4_485, pbn_connect),
651d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8_485, pbn_connect),
652d0aeaa83SSudip Mukherjee 
653d0aeaa83SSudip Mukherjee 	IBM_DEVICE(XR17C152, SATURN_SERIAL_ONE_PORT, pbn_exar_ibm_saturn),
654d0aeaa83SSudip Mukherjee 
655d0aeaa83SSudip Mukherjee 	/* Exar Corp. XR17C15[248] Dual/Quad/Octal UART */
656d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17C152, pbn_exar_XR17C15x),
657d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17C154, pbn_exar_XR17C15x),
658d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17C158, pbn_exar_XR17C15x),
659d0aeaa83SSudip Mukherjee 
660d0aeaa83SSudip Mukherjee 	/* Exar Corp. XR17V[48]35[248] Dual/Quad/Octal/Hexa PCIe UARTs */
661d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V352, pbn_exar_XR17V35x),
662d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V354, pbn_exar_XR17V35x),
663d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V358, pbn_exar_XR17V35x),
664d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V4358, pbn_exar_XR17V4358),
665d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V8358, pbn_exar_XR17V8358),
666d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(COMMTECH, COMMTECH_4222PCIE, pbn_exar_XR17V35x),
667d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(COMMTECH, COMMTECH_4224PCIE, pbn_exar_XR17V35x),
668d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(COMMTECH, COMMTECH_4228PCIE, pbn_exar_XR17V35x),
669fc6cc961SJan Kiszka 
670fc6cc961SJan Kiszka 	EXAR_DEVICE(COMMTECH, COMMTECH_4222PCI335, pbn_fastcom335_2),
671fc6cc961SJan Kiszka 	EXAR_DEVICE(COMMTECH, COMMTECH_4224PCI335, pbn_fastcom335_4),
672fc6cc961SJan Kiszka 	EXAR_DEVICE(COMMTECH, COMMTECH_2324PCI335, pbn_fastcom335_4),
673fc6cc961SJan Kiszka 	EXAR_DEVICE(COMMTECH, COMMTECH_2328PCI335, pbn_fastcom335_8),
674d0aeaa83SSudip Mukherjee 	{ 0, }
675d0aeaa83SSudip Mukherjee };
676d0aeaa83SSudip Mukherjee MODULE_DEVICE_TABLE(pci, exar_pci_tbl);
677d0aeaa83SSudip Mukherjee 
678d0aeaa83SSudip Mukherjee static struct pci_driver exar_pci_driver = {
679d0aeaa83SSudip Mukherjee 	.name		= "exar_serial",
680d0aeaa83SSudip Mukherjee 	.probe		= exar_pci_probe,
681d0aeaa83SSudip Mukherjee 	.remove		= exar_pci_remove,
682d0aeaa83SSudip Mukherjee 	.driver         = {
683d0aeaa83SSudip Mukherjee 		.pm     = &exar_pci_pm,
684d0aeaa83SSudip Mukherjee 	},
685d0aeaa83SSudip Mukherjee 	.id_table	= exar_pci_tbl,
686d0aeaa83SSudip Mukherjee };
687d0aeaa83SSudip Mukherjee module_pci_driver(exar_pci_driver);
688d0aeaa83SSudip Mukherjee 
689d0aeaa83SSudip Mukherjee MODULE_LICENSE("GPL");
6902b57b7ffSAndy Shevchenko MODULE_DESCRIPTION("Exar Serial Driver");
691d0aeaa83SSudip Mukherjee MODULE_AUTHOR("Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>");
692