xref: /linux/drivers/tty/serial/8250/8250_exar.c (revision d0aeaa83f0b0f7a92615bbdd6b1f96812f7dcfd2)
1*d0aeaa83SSudip Mukherjee /*
2*d0aeaa83SSudip Mukherjee  *  Probe module for 8250/16550-type Exar chips PCI serial ports.
3*d0aeaa83SSudip Mukherjee  *
4*d0aeaa83SSudip Mukherjee  *  Based on drivers/tty/serial/8250/8250_pci.c,
5*d0aeaa83SSudip Mukherjee  *
6*d0aeaa83SSudip Mukherjee  *  Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved.
7*d0aeaa83SSudip Mukherjee  *
8*d0aeaa83SSudip Mukherjee  * This program is free software; you can redistribute it and/or modify
9*d0aeaa83SSudip Mukherjee  * it under the terms of the GNU General Public License as published by
10*d0aeaa83SSudip Mukherjee  * the Free Software Foundation; either version 2 of the License.
11*d0aeaa83SSudip Mukherjee  */
12*d0aeaa83SSudip Mukherjee #include <linux/io.h>
13*d0aeaa83SSudip Mukherjee #include <linux/kernel.h>
14*d0aeaa83SSudip Mukherjee #include <linux/module.h>
15*d0aeaa83SSudip Mukherjee #include <linux/pci.h>
16*d0aeaa83SSudip Mukherjee #include <linux/serial_core.h>
17*d0aeaa83SSudip Mukherjee #include <linux/serial_reg.h>
18*d0aeaa83SSudip Mukherjee #include <linux/slab.h>
19*d0aeaa83SSudip Mukherjee #include <linux/string.h>
20*d0aeaa83SSudip Mukherjee #include <linux/tty.h>
21*d0aeaa83SSudip Mukherjee #include <linux/8250_pci.h>
22*d0aeaa83SSudip Mukherjee 
23*d0aeaa83SSudip Mukherjee #include <asm/byteorder.h>
24*d0aeaa83SSudip Mukherjee 
25*d0aeaa83SSudip Mukherjee #include "8250.h"
26*d0aeaa83SSudip Mukherjee 
27*d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4224PCIE	0x0020
28*d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4228PCIE	0x0021
29*d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_COMMTECH_4222PCIE	0x0022
30*d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_EXAR_XR17V4358	0x4358
31*d0aeaa83SSudip Mukherjee #define PCI_DEVICE_ID_EXAR_XR17V8358	0x8358
32*d0aeaa83SSudip Mukherjee 
33*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINT_7_0	0x8f	/* MPIOINT[7:0] */
34*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOLVL_7_0	0x90	/* MPIOLVL[7:0] */
35*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIO3T_7_0	0x91	/* MPIO3T[7:0] */
36*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINV_7_0	0x92	/* MPIOINV[7:0] */
37*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOSEL_7_0	0x93	/* MPIOSEL[7:0] */
38*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOOD_7_0	0x94	/* MPIOOD[7:0] */
39*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINT_15_8	0x95	/* MPIOINT[15:8] */
40*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOLVL_15_8	0x96	/* MPIOLVL[15:8] */
41*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIO3T_15_8	0x97	/* MPIO3T[15:8] */
42*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOINV_15_8	0x98	/* MPIOINV[15:8] */
43*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOSEL_15_8	0x99	/* MPIOSEL[15:8] */
44*d0aeaa83SSudip Mukherjee #define UART_EXAR_MPIOOD_15_8	0x9a	/* MPIOOD[15:8] */
45*d0aeaa83SSudip Mukherjee 
46*d0aeaa83SSudip Mukherjee struct exar8250;
47*d0aeaa83SSudip Mukherjee 
48*d0aeaa83SSudip Mukherjee /**
49*d0aeaa83SSudip Mukherjee  * struct exar8250_board - board information
50*d0aeaa83SSudip Mukherjee  * @num_ports: number of serial ports
51*d0aeaa83SSudip Mukherjee  * @reg_shift: describes UART register mapping in PCI memory
52*d0aeaa83SSudip Mukherjee  */
53*d0aeaa83SSudip Mukherjee struct exar8250_board {
54*d0aeaa83SSudip Mukherjee 	unsigned int num_ports;
55*d0aeaa83SSudip Mukherjee 	unsigned int reg_shift;
56*d0aeaa83SSudip Mukherjee 	bool has_slave;
57*d0aeaa83SSudip Mukherjee 	int	(*setup)(struct exar8250 *, struct pci_dev *,
58*d0aeaa83SSudip Mukherjee 			 struct uart_8250_port *, int);
59*d0aeaa83SSudip Mukherjee 	void	(*exit)(struct pci_dev *pcidev);
60*d0aeaa83SSudip Mukherjee };
61*d0aeaa83SSudip Mukherjee 
62*d0aeaa83SSudip Mukherjee struct exar8250 {
63*d0aeaa83SSudip Mukherjee 	unsigned int		nr;
64*d0aeaa83SSudip Mukherjee 	struct exar8250_board	*board;
65*d0aeaa83SSudip Mukherjee 	int			line[0];
66*d0aeaa83SSudip Mukherjee };
67*d0aeaa83SSudip Mukherjee 
68*d0aeaa83SSudip Mukherjee static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
69*d0aeaa83SSudip Mukherjee 			 int idx, unsigned int offset,
70*d0aeaa83SSudip Mukherjee 			 struct uart_8250_port *port)
71*d0aeaa83SSudip Mukherjee {
72*d0aeaa83SSudip Mukherjee 	const struct exar8250_board *board = priv->board;
73*d0aeaa83SSudip Mukherjee 	unsigned int bar = 0;
74*d0aeaa83SSudip Mukherjee 
75*d0aeaa83SSudip Mukherjee 	port->port.iotype = UPIO_MEM;
76*d0aeaa83SSudip Mukherjee 	port->port.mapbase = pci_resource_start(pcidev, bar) + offset;
77*d0aeaa83SSudip Mukherjee 	port->port.membase = pcim_iomap_table(pcidev)[bar] + offset;
78*d0aeaa83SSudip Mukherjee 	port->port.regshift = board->reg_shift;
79*d0aeaa83SSudip Mukherjee 
80*d0aeaa83SSudip Mukherjee 	return 0;
81*d0aeaa83SSudip Mukherjee }
82*d0aeaa83SSudip Mukherjee 
83*d0aeaa83SSudip Mukherjee static int
84*d0aeaa83SSudip Mukherjee pci_connect_tech_setup(struct exar8250 *priv, struct pci_dev *pcidev,
85*d0aeaa83SSudip Mukherjee 		       struct uart_8250_port *port, int idx)
86*d0aeaa83SSudip Mukherjee {
87*d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x200;
88*d0aeaa83SSudip Mukherjee 	unsigned int baud = 1843200;
89*d0aeaa83SSudip Mukherjee 
90*d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
91*d0aeaa83SSudip Mukherjee 	return default_setup(priv, pcidev, idx, offset, port);
92*d0aeaa83SSudip Mukherjee }
93*d0aeaa83SSudip Mukherjee 
94*d0aeaa83SSudip Mukherjee static int
95*d0aeaa83SSudip Mukherjee pci_xr17c154_setup(struct exar8250 *priv, struct pci_dev *pcidev,
96*d0aeaa83SSudip Mukherjee 		   struct uart_8250_port *port, int idx)
97*d0aeaa83SSudip Mukherjee {
98*d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x200;
99*d0aeaa83SSudip Mukherjee 	unsigned int baud = 921600;
100*d0aeaa83SSudip Mukherjee 
101*d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
102*d0aeaa83SSudip Mukherjee 	return default_setup(priv, pcidev, idx, offset, port);
103*d0aeaa83SSudip Mukherjee }
104*d0aeaa83SSudip Mukherjee 
105*d0aeaa83SSudip Mukherjee static void setup_gpio(u8 __iomem *p)
106*d0aeaa83SSudip Mukherjee {
107*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINT_7_0);
108*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
109*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
110*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
111*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOSEL_7_0);
112*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
113*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINT_15_8);
114*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOLVL_15_8);
115*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIO3T_15_8);
116*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOINV_15_8);
117*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOSEL_15_8);
118*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_MPIOOD_15_8);
119*d0aeaa83SSudip Mukherjee }
120*d0aeaa83SSudip Mukherjee 
121*d0aeaa83SSudip Mukherjee static void *
122*d0aeaa83SSudip Mukherjee xr17v35x_register_gpio(struct pci_dev *pcidev)
123*d0aeaa83SSudip Mukherjee {
124*d0aeaa83SSudip Mukherjee 	struct platform_device *pdev;
125*d0aeaa83SSudip Mukherjee 
126*d0aeaa83SSudip Mukherjee 	pdev = platform_device_alloc("gpio_exar", PLATFORM_DEVID_AUTO);
127*d0aeaa83SSudip Mukherjee 	if (!pdev)
128*d0aeaa83SSudip Mukherjee 		return NULL;
129*d0aeaa83SSudip Mukherjee 
130*d0aeaa83SSudip Mukherjee 	platform_set_drvdata(pdev, pcidev);
131*d0aeaa83SSudip Mukherjee 	if (platform_device_add(pdev) < 0) {
132*d0aeaa83SSudip Mukherjee 		platform_device_put(pdev);
133*d0aeaa83SSudip Mukherjee 		return NULL;
134*d0aeaa83SSudip Mukherjee 	}
135*d0aeaa83SSudip Mukherjee 
136*d0aeaa83SSudip Mukherjee 	return pdev;
137*d0aeaa83SSudip Mukherjee }
138*d0aeaa83SSudip Mukherjee 
139*d0aeaa83SSudip Mukherjee static int
140*d0aeaa83SSudip Mukherjee pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
141*d0aeaa83SSudip Mukherjee 		   struct uart_8250_port *port, int idx)
142*d0aeaa83SSudip Mukherjee {
143*d0aeaa83SSudip Mukherjee 	const struct exar8250_board *board = priv->board;
144*d0aeaa83SSudip Mukherjee 	unsigned int offset = idx * 0x400;
145*d0aeaa83SSudip Mukherjee 	unsigned int baud = 7812500;
146*d0aeaa83SSudip Mukherjee 	u8 __iomem *p;
147*d0aeaa83SSudip Mukherjee 	int ret;
148*d0aeaa83SSudip Mukherjee 
149*d0aeaa83SSudip Mukherjee 	port->port.uartclk = baud * 16;
150*d0aeaa83SSudip Mukherjee 	/*
151*d0aeaa83SSudip Mukherjee 	 * Setup the uart clock for the devices on expansion slot to
152*d0aeaa83SSudip Mukherjee 	 * half the clock speed of the main chip (which is 125MHz)
153*d0aeaa83SSudip Mukherjee 	 */
154*d0aeaa83SSudip Mukherjee 	if (board->has_slave && idx >= 8)
155*d0aeaa83SSudip Mukherjee 		port->port.uartclk /= 2;
156*d0aeaa83SSudip Mukherjee 
157*d0aeaa83SSudip Mukherjee 	p = pci_ioremap_bar(pcidev, 0);
158*d0aeaa83SSudip Mukherjee 	if (!p)
159*d0aeaa83SSudip Mukherjee 		return -ENOMEM;
160*d0aeaa83SSudip Mukherjee 
161*d0aeaa83SSudip Mukherjee 	/* Setup Multipurpose Input/Output pins. */
162*d0aeaa83SSudip Mukherjee 	if (idx == 0)
163*d0aeaa83SSudip Mukherjee 		setup_gpio(p);
164*d0aeaa83SSudip Mukherjee 
165*d0aeaa83SSudip Mukherjee 	writeb(0x00, p + UART_EXAR_8XMODE);
166*d0aeaa83SSudip Mukherjee 	writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
167*d0aeaa83SSudip Mukherjee 	writeb(128, p + UART_EXAR_TXTRG);
168*d0aeaa83SSudip Mukherjee 	writeb(128, p + UART_EXAR_RXTRG);
169*d0aeaa83SSudip Mukherjee 	iounmap(p);
170*d0aeaa83SSudip Mukherjee 
171*d0aeaa83SSudip Mukherjee 	ret = default_setup(priv, pcidev, idx, offset, port);
172*d0aeaa83SSudip Mukherjee 	if (ret)
173*d0aeaa83SSudip Mukherjee 		return ret;
174*d0aeaa83SSudip Mukherjee 
175*d0aeaa83SSudip Mukherjee 	if (idx == 0)
176*d0aeaa83SSudip Mukherjee 		port->port.private_data =
177*d0aeaa83SSudip Mukherjee 			xr17v35x_register_gpio(pcidev);
178*d0aeaa83SSudip Mukherjee 
179*d0aeaa83SSudip Mukherjee 	return 0;
180*d0aeaa83SSudip Mukherjee }
181*d0aeaa83SSudip Mukherjee 
182*d0aeaa83SSudip Mukherjee static void pci_xr17v35x_exit(struct pci_dev *pcidev)
183*d0aeaa83SSudip Mukherjee {
184*d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
185*d0aeaa83SSudip Mukherjee 	struct uart_8250_port *port = serial8250_get_port(priv->line[0]);
186*d0aeaa83SSudip Mukherjee 	struct platform_device *pdev = port->port.private_data;
187*d0aeaa83SSudip Mukherjee 
188*d0aeaa83SSudip Mukherjee 	platform_device_unregister(pdev);
189*d0aeaa83SSudip Mukherjee 	port->port.private_data = NULL;
190*d0aeaa83SSudip Mukherjee }
191*d0aeaa83SSudip Mukherjee 
192*d0aeaa83SSudip Mukherjee static int
193*d0aeaa83SSudip Mukherjee exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
194*d0aeaa83SSudip Mukherjee {
195*d0aeaa83SSudip Mukherjee 	unsigned int nr_ports, i, bar = 0, maxnr;
196*d0aeaa83SSudip Mukherjee 	struct exar8250_board *board;
197*d0aeaa83SSudip Mukherjee 	struct uart_8250_port uart;
198*d0aeaa83SSudip Mukherjee 	struct exar8250 *priv;
199*d0aeaa83SSudip Mukherjee 	int rc;
200*d0aeaa83SSudip Mukherjee 
201*d0aeaa83SSudip Mukherjee 	board = (struct exar8250_board *)ent->driver_data;
202*d0aeaa83SSudip Mukherjee 	if (!board)
203*d0aeaa83SSudip Mukherjee 		return -EINVAL;
204*d0aeaa83SSudip Mukherjee 
205*d0aeaa83SSudip Mukherjee 	rc = pcim_enable_device(pcidev);
206*d0aeaa83SSudip Mukherjee 	if (rc)
207*d0aeaa83SSudip Mukherjee 		return rc;
208*d0aeaa83SSudip Mukherjee 
209*d0aeaa83SSudip Mukherjee 	maxnr = pci_resource_len(pcidev, bar) >> (board->reg_shift + 3);
210*d0aeaa83SSudip Mukherjee 
211*d0aeaa83SSudip Mukherjee 	nr_ports = board->num_ports ? board->num_ports : pcidev->device & 0x0f;
212*d0aeaa83SSudip Mukherjee 
213*d0aeaa83SSudip Mukherjee 	priv = devm_kzalloc(&pcidev->dev, sizeof(*priv) +
214*d0aeaa83SSudip Mukherjee 			    sizeof(unsigned int) * nr_ports,
215*d0aeaa83SSudip Mukherjee 			    GFP_KERNEL);
216*d0aeaa83SSudip Mukherjee 	if (!priv)
217*d0aeaa83SSudip Mukherjee 		return -ENOMEM;
218*d0aeaa83SSudip Mukherjee 
219*d0aeaa83SSudip Mukherjee 	priv->board = board;
220*d0aeaa83SSudip Mukherjee 
221*d0aeaa83SSudip Mukherjee 	memset(&uart, 0, sizeof(uart));
222*d0aeaa83SSudip Mukherjee 	uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ
223*d0aeaa83SSudip Mukherjee 			  | UPF_EXAR_EFR;
224*d0aeaa83SSudip Mukherjee 	uart.port.irq = pcidev->irq;
225*d0aeaa83SSudip Mukherjee 	uart.port.dev = &pcidev->dev;
226*d0aeaa83SSudip Mukherjee 
227*d0aeaa83SSudip Mukherjee 	for (i = 0; i < nr_ports && i < maxnr; i++) {
228*d0aeaa83SSudip Mukherjee 		rc = board->setup(priv, pcidev, &uart, i);
229*d0aeaa83SSudip Mukherjee 		if (rc) {
230*d0aeaa83SSudip Mukherjee 			dev_err(&pcidev->dev, "Failed to setup port %u\n", i);
231*d0aeaa83SSudip Mukherjee 			break;
232*d0aeaa83SSudip Mukherjee 		}
233*d0aeaa83SSudip Mukherjee 
234*d0aeaa83SSudip Mukherjee 		dev_dbg(&pcidev->dev, "Setup PCI port: port %lx, irq %d, type %d\n",
235*d0aeaa83SSudip Mukherjee 			uart.port.iobase, uart.port.irq, uart.port.iotype);
236*d0aeaa83SSudip Mukherjee 
237*d0aeaa83SSudip Mukherjee 		priv->line[i] = serial8250_register_8250_port(&uart);
238*d0aeaa83SSudip Mukherjee 		if (priv->line[i] < 0) {
239*d0aeaa83SSudip Mukherjee 			dev_err(&pcidev->dev,
240*d0aeaa83SSudip Mukherjee 				"Couldn't register serial port %lx, irq %d, type %d, error %d\n",
241*d0aeaa83SSudip Mukherjee 				uart.port.iobase, uart.port.irq,
242*d0aeaa83SSudip Mukherjee 				uart.port.iotype, priv->line[i]);
243*d0aeaa83SSudip Mukherjee 			break;
244*d0aeaa83SSudip Mukherjee 		}
245*d0aeaa83SSudip Mukherjee 	}
246*d0aeaa83SSudip Mukherjee 	priv->nr = i;
247*d0aeaa83SSudip Mukherjee 	pci_set_drvdata(pcidev, priv);
248*d0aeaa83SSudip Mukherjee 	return 0;
249*d0aeaa83SSudip Mukherjee }
250*d0aeaa83SSudip Mukherjee 
251*d0aeaa83SSudip Mukherjee static void exar_pci_remove(struct pci_dev *pcidev)
252*d0aeaa83SSudip Mukherjee {
253*d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
254*d0aeaa83SSudip Mukherjee 	unsigned int i;
255*d0aeaa83SSudip Mukherjee 
256*d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
257*d0aeaa83SSudip Mukherjee 		serial8250_unregister_port(priv->line[i]);
258*d0aeaa83SSudip Mukherjee 
259*d0aeaa83SSudip Mukherjee 	if (priv->board->exit)
260*d0aeaa83SSudip Mukherjee 		priv->board->exit(pcidev);
261*d0aeaa83SSudip Mukherjee }
262*d0aeaa83SSudip Mukherjee 
263*d0aeaa83SSudip Mukherjee static int __maybe_unused exar_suspend(struct device *dev)
264*d0aeaa83SSudip Mukherjee {
265*d0aeaa83SSudip Mukherjee 	struct pci_dev *pcidev = to_pci_dev(dev);
266*d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
267*d0aeaa83SSudip Mukherjee 	unsigned int i;
268*d0aeaa83SSudip Mukherjee 
269*d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
270*d0aeaa83SSudip Mukherjee 		if (priv->line[i] >= 0)
271*d0aeaa83SSudip Mukherjee 			serial8250_suspend_port(priv->line[i]);
272*d0aeaa83SSudip Mukherjee 
273*d0aeaa83SSudip Mukherjee 	/* Ensure that every init quirk is properly torn down */
274*d0aeaa83SSudip Mukherjee 	if (priv->board->exit)
275*d0aeaa83SSudip Mukherjee 		priv->board->exit(pcidev);
276*d0aeaa83SSudip Mukherjee 
277*d0aeaa83SSudip Mukherjee 	return 0;
278*d0aeaa83SSudip Mukherjee }
279*d0aeaa83SSudip Mukherjee 
280*d0aeaa83SSudip Mukherjee static int __maybe_unused exar_resume(struct device *dev)
281*d0aeaa83SSudip Mukherjee {
282*d0aeaa83SSudip Mukherjee 	struct pci_dev *pcidev = to_pci_dev(dev);
283*d0aeaa83SSudip Mukherjee 	struct exar8250 *priv = pci_get_drvdata(pcidev);
284*d0aeaa83SSudip Mukherjee 	unsigned int i;
285*d0aeaa83SSudip Mukherjee 
286*d0aeaa83SSudip Mukherjee 	for (i = 0; i < priv->nr; i++)
287*d0aeaa83SSudip Mukherjee 		if (priv->line[i] >= 0)
288*d0aeaa83SSudip Mukherjee 			serial8250_resume_port(priv->line[i]);
289*d0aeaa83SSudip Mukherjee 
290*d0aeaa83SSudip Mukherjee 	return 0;
291*d0aeaa83SSudip Mukherjee }
292*d0aeaa83SSudip Mukherjee 
293*d0aeaa83SSudip Mukherjee static SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);
294*d0aeaa83SSudip Mukherjee 
295*d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_connect = {
296*d0aeaa83SSudip Mukherjee 	.setup		= pci_connect_tech_setup,
297*d0aeaa83SSudip Mukherjee };
298*d0aeaa83SSudip Mukherjee 
299*d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_ibm_saturn = {
300*d0aeaa83SSudip Mukherjee 	.num_ports	= 1,
301*d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17c154_setup,
302*d0aeaa83SSudip Mukherjee };
303*d0aeaa83SSudip Mukherjee 
304*d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17C15x = {
305*d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17c154_setup,
306*d0aeaa83SSudip Mukherjee };
307*d0aeaa83SSudip Mukherjee 
308*d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V35x = {
309*d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
310*d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
311*d0aeaa83SSudip Mukherjee };
312*d0aeaa83SSudip Mukherjee 
313*d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V4358 = {
314*d0aeaa83SSudip Mukherjee 	.num_ports	= 12,
315*d0aeaa83SSudip Mukherjee 	.has_slave	= true,
316*d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
317*d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
318*d0aeaa83SSudip Mukherjee };
319*d0aeaa83SSudip Mukherjee 
320*d0aeaa83SSudip Mukherjee static const struct exar8250_board pbn_exar_XR17V8358 = {
321*d0aeaa83SSudip Mukherjee 	.num_ports	= 16,
322*d0aeaa83SSudip Mukherjee 	.has_slave	= true,
323*d0aeaa83SSudip Mukherjee 	.setup		= pci_xr17v35x_setup,
324*d0aeaa83SSudip Mukherjee 	.exit		= pci_xr17v35x_exit,
325*d0aeaa83SSudip Mukherjee };
326*d0aeaa83SSudip Mukherjee 
327*d0aeaa83SSudip Mukherjee #define CONNECT_DEVICE(devid, sdevid, bd) {				\
328*d0aeaa83SSudip Mukherjee 	PCI_DEVICE_SUB(							\
329*d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_EXAR,					\
330*d0aeaa83SSudip Mukherjee 		PCI_DEVICE_ID_EXAR_##devid,				\
331*d0aeaa83SSudip Mukherjee 		PCI_SUBVENDOR_ID_CONNECT_TECH,				\
332*d0aeaa83SSudip Mukherjee 		PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_##sdevid), 0, 0,	\
333*d0aeaa83SSudip Mukherjee 		(kernel_ulong_t)&bd					\
334*d0aeaa83SSudip Mukherjee 	}
335*d0aeaa83SSudip Mukherjee 
336*d0aeaa83SSudip Mukherjee #define EXAR_DEVICE(vend, devid, bd) {					\
337*d0aeaa83SSudip Mukherjee 	PCI_VDEVICE(vend, PCI_DEVICE_ID_##devid), (kernel_ulong_t)&bd	\
338*d0aeaa83SSudip Mukherjee 	}
339*d0aeaa83SSudip Mukherjee 
340*d0aeaa83SSudip Mukherjee #define IBM_DEVICE(devid, sdevid, bd) {			\
341*d0aeaa83SSudip Mukherjee 	PCI_DEVICE_SUB(					\
342*d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_EXAR,			\
343*d0aeaa83SSudip Mukherjee 		PCI_DEVICE_ID_EXAR_##devid,		\
344*d0aeaa83SSudip Mukherjee 		PCI_VENDOR_ID_IBM,			\
345*d0aeaa83SSudip Mukherjee 		PCI_SUBDEVICE_ID_IBM_##sdevid), 0, 0,	\
346*d0aeaa83SSudip Mukherjee 		(kernel_ulong_t)&bd			\
347*d0aeaa83SSudip Mukherjee 	}
348*d0aeaa83SSudip Mukherjee 
349*d0aeaa83SSudip Mukherjee static struct pci_device_id exar_pci_tbl[] = {
350*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2_232, pbn_connect),
351*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4_232, pbn_connect),
352*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8_232, pbn_connect),
353*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_1_1, pbn_connect),
354*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_2_2, pbn_connect),
355*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_4_4, pbn_connect),
356*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2, pbn_connect),
357*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4, pbn_connect),
358*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8, pbn_connect),
359*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C152, UART_2_485, pbn_connect),
360*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C154, UART_4_485, pbn_connect),
361*d0aeaa83SSudip Mukherjee 	CONNECT_DEVICE(XR17C158, UART_8_485, pbn_connect),
362*d0aeaa83SSudip Mukherjee 
363*d0aeaa83SSudip Mukherjee 	IBM_DEVICE(XR17C152, SATURN_SERIAL_ONE_PORT, pbn_exar_ibm_saturn),
364*d0aeaa83SSudip Mukherjee 
365*d0aeaa83SSudip Mukherjee 	/* Exar Corp. XR17C15[248] Dual/Quad/Octal UART */
366*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17C152, pbn_exar_XR17C15x),
367*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17C154, pbn_exar_XR17C15x),
368*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17C158, pbn_exar_XR17C15x),
369*d0aeaa83SSudip Mukherjee 
370*d0aeaa83SSudip Mukherjee 	/* Exar Corp. XR17V[48]35[248] Dual/Quad/Octal/Hexa PCIe UARTs */
371*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V352, pbn_exar_XR17V35x),
372*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V354, pbn_exar_XR17V35x),
373*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V358, pbn_exar_XR17V35x),
374*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V4358, pbn_exar_XR17V4358),
375*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(EXAR, EXAR_XR17V8358, pbn_exar_XR17V8358),
376*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(COMMTECH, COMMTECH_4222PCIE, pbn_exar_XR17V35x),
377*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(COMMTECH, COMMTECH_4224PCIE, pbn_exar_XR17V35x),
378*d0aeaa83SSudip Mukherjee 	EXAR_DEVICE(COMMTECH, COMMTECH_4228PCIE, pbn_exar_XR17V35x),
379*d0aeaa83SSudip Mukherjee 	{ 0, }
380*d0aeaa83SSudip Mukherjee };
381*d0aeaa83SSudip Mukherjee MODULE_DEVICE_TABLE(pci, exar_pci_tbl);
382*d0aeaa83SSudip Mukherjee 
383*d0aeaa83SSudip Mukherjee static struct pci_driver exar_pci_driver = {
384*d0aeaa83SSudip Mukherjee 	.name		= "exar_serial",
385*d0aeaa83SSudip Mukherjee 	.probe		= exar_pci_probe,
386*d0aeaa83SSudip Mukherjee 	.remove		= exar_pci_remove,
387*d0aeaa83SSudip Mukherjee 	.driver         = {
388*d0aeaa83SSudip Mukherjee 		.pm     = &exar_pci_pm,
389*d0aeaa83SSudip Mukherjee 	},
390*d0aeaa83SSudip Mukherjee 	.id_table	= exar_pci_tbl,
391*d0aeaa83SSudip Mukherjee };
392*d0aeaa83SSudip Mukherjee module_pci_driver(exar_pci_driver);
393*d0aeaa83SSudip Mukherjee 
394*d0aeaa83SSudip Mukherjee MODULE_LICENSE("GPL");
395*d0aeaa83SSudip Mukherjee MODULE_DESCRIPTION("Exar Serial Dricer");
396*d0aeaa83SSudip Mukherjee MODULE_AUTHOR("Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>");
397