keyspan.h revision 822470537d0fc1dee38a2a9c8b8c398bfbb332bb
1/*
2  Keyspan USB to Serial Converter driver
3
4  (C) Copyright (C) 2000-2001
5      Hugh Blemings <hugh@blemings.org>
6
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11
12  See http://misc.nu/hugh/keyspan.html for more information.
13
14  Code in this driver inspired by and in a number of places taken
15  from Brian Warner's original Keyspan-PDA driver.
16
17  This driver has been put together with the support of Innosys, Inc.
18  and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
19  Thanks Guys :)
20
21  Thanks to Paulus for miscellaneous tidy ups, some largish chunks
22  of much nicer and/or completely new code and (perhaps most uniquely)
23  having the patience to sit down and explain why and where he'd changed
24  stuff.
25
26  Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
27  staff in their work on open source projects.
28
29  See keyspan.c for update history.
30
31*/
32
33#ifndef __LINUX_USB_SERIAL_KEYSPAN_H
34#define __LINUX_USB_SERIAL_KEYSPAN_H
35
36
37/* Function prototypes for Keyspan serial converter */
38static int  keyspan_open		(struct usb_serial_port *port,
39					 struct file *filp);
40static void keyspan_close		(struct usb_serial_port *port,
41					 struct file *filp);
42static int  keyspan_startup		(struct usb_serial *serial);
43static void keyspan_shutdown		(struct usb_serial *serial);
44static void keyspan_rx_throttle		(struct usb_serial_port *port);
45static void keyspan_rx_unthrottle	(struct usb_serial_port *port);
46static int  keyspan_write_room		(struct usb_serial_port *port);
47
48static int  keyspan_write		(struct usb_serial_port *port,
49					 const unsigned char *buf,
50					 int count);
51
52static void keyspan_send_setup		(struct usb_serial_port *port,
53					 int reset_port);
54
55
56static int  keyspan_chars_in_buffer 	(struct usb_serial_port *port);
57static int  keyspan_ioctl		(struct usb_serial_port *port,
58					 struct file *file,
59					 unsigned int cmd,
60					 unsigned long arg);
61static void keyspan_set_termios		(struct usb_serial_port *port,
62					 struct ktermios *old);
63static void keyspan_break_ctl		(struct usb_serial_port *port,
64					 int break_state);
65static int  keyspan_tiocmget		(struct usb_serial_port *port,
66					 struct file *file);
67static int  keyspan_tiocmset		(struct usb_serial_port *port,
68					 struct file *file, unsigned int set,
69					 unsigned int clear);
70static int  keyspan_fake_startup	(struct usb_serial *serial);
71
72static int  keyspan_usa19_calc_baud	(u32 baud_rate, u32 baudclk,
73					 u8 *rate_hi, u8 *rate_low,
74					 u8 *prescaler, int portnum);
75
76static int  keyspan_usa19w_calc_baud	(u32 baud_rate, u32 baudclk,
77					 u8 *rate_hi, u8 *rate_low,
78					 u8 *prescaler, int portnum);
79
80static int  keyspan_usa28_calc_baud	(u32 baud_rate, u32 baudclk,
81					 u8 *rate_hi, u8 *rate_low,
82					 u8 *prescaler, int portnum);
83
84static int  keyspan_usa19hs_calc_baud	(u32 baud_rate, u32 baudclk,
85					 u8 *rate_hi, u8 *rate_low,
86					 u8 *prescaler, int portnum);
87
88static int  keyspan_usa28_send_setup	(struct usb_serial *serial,
89					 struct usb_serial_port *port,
90					 int reset_port);
91static int  keyspan_usa26_send_setup	(struct usb_serial *serial,
92	       				 struct usb_serial_port *port,
93					 int reset_port);
94static int  keyspan_usa49_send_setup	(struct usb_serial *serial,
95					 struct usb_serial_port *port,
96					 int reset_port);
97
98static int  keyspan_usa90_send_setup	(struct usb_serial *serial,
99					 struct usb_serial_port *port,
100					 int reset_port);
101
102static int  keyspan_usa67_send_setup	(struct usb_serial *serial,
103					 struct usb_serial_port *port,
104					 int reset_port);
105
106/* Struct used for firmware - increased size of data section
107   to allow Keyspan's 'C' firmware struct to be used unmodified */
108struct ezusb_hex_record {
109	__u16 address;
110	__u8 data_size;
111	__u8 data[64];
112};
113
114/* Conditionally include firmware images, if they aren't
115   included create a null pointer instead.  Current
116   firmware images aren't optimised to remove duplicate
117   addresses in the image itself. */
118#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28
119	#include "keyspan_usa28_fw.h"
120#else
121	static const struct ezusb_hex_record *keyspan_usa28_firmware = NULL;
122#endif
123
124#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28X
125	#include "keyspan_usa28x_fw.h"
126#else
127	static const struct ezusb_hex_record *keyspan_usa28x_firmware = NULL;
128#endif
129
130#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28XA
131	#include "keyspan_usa28xa_fw.h"
132#else
133	static const struct ezusb_hex_record *keyspan_usa28xa_firmware = NULL;
134#endif
135
136#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA28XB
137	#include "keyspan_usa28xb_fw.h"
138#else
139	static const struct ezusb_hex_record *keyspan_usa28xb_firmware = NULL;
140#endif
141
142#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19
143	#include "keyspan_usa19_fw.h"
144#else
145	static const struct ezusb_hex_record *keyspan_usa19_firmware = NULL;
146#endif
147
148#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19QI
149	#include "keyspan_usa19qi_fw.h"
150#else
151	static const struct ezusb_hex_record *keyspan_usa19qi_firmware = NULL;
152#endif
153
154#ifdef CONFIG_USB_SERIAL_KEYSPAN_MPR
155        #include "keyspan_mpr_fw.h"
156#else
157	static const struct ezusb_hex_record *keyspan_mpr_firmware = NULL;
158#endif
159
160#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19QW
161	#include "keyspan_usa19qw_fw.h"
162#else
163	static const struct ezusb_hex_record *keyspan_usa19qw_firmware = NULL;
164#endif
165
166#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA18X
167	#include "keyspan_usa18x_fw.h"
168#else
169	static const struct ezusb_hex_record *keyspan_usa18x_firmware = NULL;
170#endif
171
172#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA19W
173	#include "keyspan_usa19w_fw.h"
174#else
175	static const struct ezusb_hex_record *keyspan_usa19w_firmware = NULL;
176#endif
177
178#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA49W
179	#include "keyspan_usa49w_fw.h"
180#else
181	static const struct ezusb_hex_record *keyspan_usa49w_firmware = NULL;
182#endif
183
184#ifdef CONFIG_USB_SERIAL_KEYSPAN_USA49WLC
185        #include "keyspan_usa49wlc_fw.h"
186#else
187	static const struct ezusb_hex_record *keyspan_usa49wlc_firmware = NULL;
188#endif
189
190/* Values used for baud rate calculation - device specific */
191#define	KEYSPAN_INVALID_BAUD_RATE		(-1)
192#define	KEYSPAN_BAUD_RATE_OK			(0)
193#define	KEYSPAN_USA18X_BAUDCLK			(12000000L)	/* a guess */
194#define	KEYSPAN_USA19_BAUDCLK			(12000000L)
195#define	KEYSPAN_USA19W_BAUDCLK			(24000000L)
196#define	KEYSPAN_USA19HS_BAUDCLK			(14769231L)
197#define	KEYSPAN_USA28_BAUDCLK			(1843200L)
198#define	KEYSPAN_USA28X_BAUDCLK			(12000000L)
199#define	KEYSPAN_USA49W_BAUDCLK			(48000000L)
200
201/* Some constants used to characterise each device.  */
202#define		KEYSPAN_MAX_NUM_PORTS		(4)
203#define		KEYSPAN_MAX_FLIPS		(2)
204
205/* Device info for the Keyspan serial converter, used
206   by the overall usb-serial probe function */
207#define KEYSPAN_VENDOR_ID			(0x06cd)
208
209/* Product IDs for the products supported, pre-renumeration */
210#define	keyspan_usa18x_pre_product_id		0x0105
211#define	keyspan_usa19_pre_product_id		0x0103
212#define	keyspan_usa19qi_pre_product_id		0x010b
213#define	keyspan_mpr_pre_product_id		0x011b
214#define	keyspan_usa19qw_pre_product_id		0x0118
215#define	keyspan_usa19w_pre_product_id		0x0106
216#define	keyspan_usa28_pre_product_id		0x0101
217#define	keyspan_usa28x_pre_product_id		0x0102
218#define	keyspan_usa28xa_pre_product_id		0x0114
219#define	keyspan_usa28xb_pre_product_id		0x0113
220#define	keyspan_usa49w_pre_product_id		0x0109
221#define	keyspan_usa49wlc_pre_product_id		0x011a
222
223/* Product IDs post-renumeration.  Note that the 28x and 28xb
224   have the same id's post-renumeration but behave identically
225   so it's not an issue. */
226#define	keyspan_usa18x_product_id		0x0112
227#define	keyspan_usa19_product_id		0x0107
228#define	keyspan_usa19qi_product_id		0x010c
229#define	keyspan_usa19hs_product_id		0x0121
230#define	keyspan_mpr_product_id			0x011c
231#define	keyspan_usa19qw_product_id		0x0119
232#define	keyspan_usa19w_product_id		0x0108
233#define	keyspan_usa28_product_id		0x010f
234#define	keyspan_usa28x_product_id		0x0110
235#define	keyspan_usa28xa_product_id		0x0115
236#define	keyspan_usa28xb_product_id		0x0110
237#define	keyspan_usa28xg_product_id		0x0135
238#define	keyspan_usa49w_product_id		0x010a
239#define	keyspan_usa49wlc_product_id		0x012a
240#define	keyspan_usa49wg_product_id		0x0131
241
242struct keyspan_device_details {
243	/* product ID value */
244	int	product_id;
245
246	enum	{msg_usa26, msg_usa28, msg_usa49, msg_usa90, msg_usa67} msg_format;
247
248		/* Number of physical ports */
249	int	num_ports;
250
251		/* 1 if endpoint flipping used on input, 0 if not */
252	int	indat_endp_flip;
253
254		/* 1 if endpoint flipping used on output, 0 if not */
255	int 	outdat_endp_flip;
256
257		/* Table mapping input data endpoint IDs to physical
258		   port number and flip if used */
259	int	indat_endpoints[KEYSPAN_MAX_NUM_PORTS];
260
261		/* Same for output endpoints */
262	int	outdat_endpoints[KEYSPAN_MAX_NUM_PORTS];
263
264		/* Input acknowledge endpoints */
265	int	inack_endpoints[KEYSPAN_MAX_NUM_PORTS];
266
267		/* Output control endpoints */
268	int	outcont_endpoints[KEYSPAN_MAX_NUM_PORTS];
269
270		/* Endpoint used for input status */
271	int	instat_endpoint;
272
273		/* Endpoint used for input data 49WG only */
274	int	indat_endpoint;
275
276		/* Endpoint used for global control functions */
277	int	glocont_endpoint;
278
279	int	(*calculate_baud_rate) (u32 baud_rate, u32 baudclk,
280			u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum);
281	u32	baudclk;
282};
283
284/* Now for each device type we setup the device detail
285   structure with the appropriate information (provided
286   in Keyspan's documentation) */
287
288static const struct keyspan_device_details usa18x_device_details = {
289	.product_id		= keyspan_usa18x_product_id,
290	.msg_format		= msg_usa26,
291	.num_ports		= 1,
292	.indat_endp_flip	= 0,
293	.outdat_endp_flip	= 1,
294	.indat_endpoints	= {0x81},
295	.outdat_endpoints	= {0x01},
296	.inack_endpoints	= {0x85},
297	.outcont_endpoints	= {0x05},
298	.instat_endpoint	= 0x87,
299	.indat_endpoint		= -1,
300	.glocont_endpoint	= 0x07,
301	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
302	.baudclk		= KEYSPAN_USA18X_BAUDCLK,
303};
304
305static const struct keyspan_device_details usa19_device_details = {
306	.product_id		= keyspan_usa19_product_id,
307	.msg_format		= msg_usa28,
308	.num_ports		= 1,
309	.indat_endp_flip	= 1,
310	.outdat_endp_flip	= 1,
311	.indat_endpoints	= {0x81},
312	.outdat_endpoints	= {0x01},
313	.inack_endpoints	= {0x83},
314	.outcont_endpoints	= {0x03},
315	.instat_endpoint	= 0x84,
316	.indat_endpoint		= -1,
317	.glocont_endpoint	= -1,
318	.calculate_baud_rate	= keyspan_usa19_calc_baud,
319	.baudclk		= KEYSPAN_USA19_BAUDCLK,
320};
321
322static const struct keyspan_device_details usa19qi_device_details = {
323	.product_id		= keyspan_usa19qi_product_id,
324	.msg_format		= msg_usa28,
325	.num_ports		= 1,
326	.indat_endp_flip	= 1,
327	.outdat_endp_flip	= 1,
328	.indat_endpoints	= {0x81},
329	.outdat_endpoints	= {0x01},
330	.inack_endpoints	= {0x83},
331	.outcont_endpoints	= {0x03},
332	.instat_endpoint	= 0x84,
333	.indat_endpoint		= -1,
334	.glocont_endpoint	= -1,
335	.calculate_baud_rate	= keyspan_usa28_calc_baud,
336	.baudclk		= KEYSPAN_USA19_BAUDCLK,
337};
338
339static const struct keyspan_device_details mpr_device_details = {
340	.product_id		= keyspan_mpr_product_id,
341	.msg_format		= msg_usa28,
342	.num_ports		= 1,
343	.indat_endp_flip	= 1,
344	.outdat_endp_flip	= 1,
345	.indat_endpoints	= {0x81},
346	.outdat_endpoints	= {0x01},
347	.inack_endpoints	= {0x83},
348	.outcont_endpoints	= {0x03},
349	.instat_endpoint	= 0x84,
350	.indat_endpoint		= -1,
351	.glocont_endpoint	= -1,
352	.calculate_baud_rate	= keyspan_usa28_calc_baud,
353	.baudclk		= KEYSPAN_USA19_BAUDCLK,
354};
355
356static const struct keyspan_device_details usa19qw_device_details = {
357	.product_id		= keyspan_usa19qw_product_id,
358	.msg_format		= msg_usa26,
359	.num_ports		= 1,
360	.indat_endp_flip	= 0,
361	.outdat_endp_flip	= 1,
362	.indat_endpoints	= {0x81},
363	.outdat_endpoints	= {0x01},
364	.inack_endpoints	= {0x85},
365	.outcont_endpoints	= {0x05},
366	.instat_endpoint	= 0x87,
367	.indat_endpoint		= -1,
368	.glocont_endpoint	= 0x07,
369	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
370	.baudclk		= KEYSPAN_USA19W_BAUDCLK,
371};
372
373static const struct keyspan_device_details usa19w_device_details = {
374	.product_id		= keyspan_usa19w_product_id,
375	.msg_format		= msg_usa26,
376	.num_ports		= 1,
377	.indat_endp_flip	= 0,
378	.outdat_endp_flip	= 1,
379	.indat_endpoints	= {0x81},
380	.outdat_endpoints	= {0x01},
381	.inack_endpoints	= {0x85},
382	.outcont_endpoints	= {0x05},
383	.instat_endpoint	= 0x87,
384	.indat_endpoint		= -1,
385	.glocont_endpoint	= 0x07,
386	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
387	.baudclk		= KEYSPAN_USA19W_BAUDCLK,
388};
389
390static const struct keyspan_device_details usa19hs_device_details = {
391	.product_id		= keyspan_usa19hs_product_id,
392	.msg_format		= msg_usa90,
393	.num_ports		= 1,
394	.indat_endp_flip	= 0,
395	.outdat_endp_flip	= 0,
396	.indat_endpoints	= {0x81},
397	.outdat_endpoints	= {0x01},
398	.inack_endpoints	= {-1},
399	.outcont_endpoints	= {0x02},
400	.instat_endpoint	= 0x82,
401	.indat_endpoint		= -1,
402	.glocont_endpoint	= -1,
403	.calculate_baud_rate	= keyspan_usa19hs_calc_baud,
404	.baudclk		= KEYSPAN_USA19HS_BAUDCLK,
405};
406
407static const struct keyspan_device_details usa28_device_details = {
408	.product_id		= keyspan_usa28_product_id,
409	.msg_format		= msg_usa28,
410	.num_ports		= 2,
411	.indat_endp_flip	= 1,
412	.outdat_endp_flip	= 1,
413	.indat_endpoints	= {0x81, 0x83},
414	.outdat_endpoints	= {0x01, 0x03},
415	.inack_endpoints	= {0x85, 0x86},
416	.outcont_endpoints	= {0x05, 0x06},
417	.instat_endpoint	= 0x87,
418	.indat_endpoint		= -1,
419	.glocont_endpoint	= 0x07,
420	.calculate_baud_rate	= keyspan_usa28_calc_baud,
421	.baudclk		= KEYSPAN_USA28_BAUDCLK,
422};
423
424static const struct keyspan_device_details usa28x_device_details = {
425	.product_id		= keyspan_usa28x_product_id,
426	.msg_format		= msg_usa26,
427	.num_ports		= 2,
428	.indat_endp_flip	= 0,
429	.outdat_endp_flip	= 1,
430	.indat_endpoints	= {0x81, 0x83},
431	.outdat_endpoints	= {0x01, 0x03},
432	.inack_endpoints	= {0x85, 0x86},
433	.outcont_endpoints	= {0x05, 0x06},
434	.instat_endpoint	= 0x87,
435	.indat_endpoint		= -1,
436	.glocont_endpoint	= 0x07,
437	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
438	.baudclk		= KEYSPAN_USA28X_BAUDCLK,
439};
440
441static const struct keyspan_device_details usa28xa_device_details = {
442	.product_id		= keyspan_usa28xa_product_id,
443	.msg_format		= msg_usa26,
444	.num_ports		= 2,
445	.indat_endp_flip	= 0,
446	.outdat_endp_flip	= 1,
447	.indat_endpoints	= {0x81, 0x83},
448	.outdat_endpoints	= {0x01, 0x03},
449	.inack_endpoints	= {0x85, 0x86},
450	.outcont_endpoints	= {0x05, 0x06},
451	.instat_endpoint	= 0x87,
452	.indat_endpoint		= -1,
453	.glocont_endpoint	= 0x07,
454	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
455	.baudclk		= KEYSPAN_USA28X_BAUDCLK,
456};
457
458static const struct keyspan_device_details usa28xg_device_details = {
459	.product_id		= keyspan_usa28xg_product_id,
460	.msg_format		= msg_usa67,
461	.num_ports		= 2,
462	.indat_endp_flip	= 0,
463	.outdat_endp_flip	= 0,
464	.indat_endpoints	= {0x84, 0x88},
465	.outdat_endpoints	= {0x02, 0x06},
466	.inack_endpoints	= {-1, -1},
467	.outcont_endpoints	= {-1, -1},
468	.instat_endpoint	= 0x81,
469	.indat_endpoint		= -1,
470	.glocont_endpoint	= 0x01,
471	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
472	.baudclk		= KEYSPAN_USA28X_BAUDCLK,
473};
474/* We don't need a separate entry for the usa28xb as it appears as a 28x anyway */
475
476static const struct keyspan_device_details usa49w_device_details = {
477	.product_id		= keyspan_usa49w_product_id,
478	.msg_format		= msg_usa49,
479	.num_ports		= 4,
480	.indat_endp_flip	= 0,
481	.outdat_endp_flip	= 0,
482	.indat_endpoints	= {0x81, 0x82, 0x83, 0x84},
483	.outdat_endpoints	= {0x01, 0x02, 0x03, 0x04},
484	.inack_endpoints	= {-1, -1, -1, -1},
485	.outcont_endpoints	= {-1, -1, -1, -1},
486	.instat_endpoint	= 0x87,
487	.indat_endpoint		= -1,
488	.glocont_endpoint	= 0x07,
489	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
490	.baudclk		= KEYSPAN_USA49W_BAUDCLK,
491};
492
493static const struct keyspan_device_details usa49wlc_device_details = {
494	.product_id		= keyspan_usa49wlc_product_id,
495	.msg_format		= msg_usa49,
496	.num_ports		= 4,
497	.indat_endp_flip	= 0,
498	.outdat_endp_flip	= 0,
499	.indat_endpoints	= {0x81, 0x82, 0x83, 0x84},
500	.outdat_endpoints	= {0x01, 0x02, 0x03, 0x04},
501	.inack_endpoints	= {-1, -1, -1, -1},
502	.outcont_endpoints	= {-1, -1, -1, -1},
503	.instat_endpoint	= 0x87,
504	.indat_endpoint		= -1,
505	.glocont_endpoint	= 0x07,
506	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
507	.baudclk		= KEYSPAN_USA19W_BAUDCLK,
508};
509
510static const struct keyspan_device_details usa49wg_device_details = {
511	.product_id		= keyspan_usa49wg_product_id,
512	.msg_format		= msg_usa49,
513	.num_ports		= 4,
514	.indat_endp_flip	= 0,
515	.outdat_endp_flip	= 0,
516	.indat_endpoints	= {-1, -1, -1, -1},		/* single 'global' data in EP */
517	.outdat_endpoints	= {0x01, 0x02, 0x04, 0x06},
518	.inack_endpoints	= {-1, -1, -1, -1},
519	.outcont_endpoints	= {-1, -1, -1, -1},
520	.instat_endpoint	= 0x81,
521	.indat_endpoint		= 0x88,
522	.glocont_endpoint	= 0x00,				/* uses control EP */
523	.calculate_baud_rate	= keyspan_usa19w_calc_baud,
524	.baudclk		= KEYSPAN_USA19W_BAUDCLK,
525};
526
527static const struct keyspan_device_details *keyspan_devices[] = {
528	&usa18x_device_details,
529	&usa19_device_details,
530	&usa19qi_device_details,
531	&mpr_device_details,
532	&usa19qw_device_details,
533	&usa19w_device_details,
534	&usa19hs_device_details,
535	&usa28_device_details,
536	&usa28x_device_details,
537	&usa28xa_device_details,
538	&usa28xg_device_details,
539	/* 28xb not required as it renumerates as a 28x */
540	&usa49w_device_details,
541	&usa49wlc_device_details,
542	&usa49wg_device_details,
543	NULL,
544};
545
546static struct usb_device_id keyspan_ids_combined[] = {
547	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
548	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
549	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
550	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
551	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) },
552	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) },
553	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) },
554	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) },
555	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) },
556	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) },
557	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) },
558	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) },
559	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
560	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
561	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
562	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
563	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
564	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
565	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
566	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
567	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
568	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
569	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) },
570	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) },
571	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)},
572	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
573	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
574	{ } /* Terminating entry */
575};
576
577MODULE_DEVICE_TABLE(usb, keyspan_ids_combined);
578
579static struct usb_driver keyspan_driver = {
580	.name =		"keyspan",
581	.probe =	usb_serial_probe,
582	.disconnect =	usb_serial_disconnect,
583	.id_table =	keyspan_ids_combined,
584	.no_dynamic_id = 	1,
585};
586
587/* usb_device_id table for the pre-firmware download keyspan devices */
588static struct usb_device_id keyspan_pre_ids[] = {
589	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
590	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
591	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
592	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) },
593	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
594	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) },
595	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) },
596	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) },
597	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) },
598	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) },
599	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) },
600	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) },
601	{ } /* Terminating entry */
602};
603
604static struct usb_device_id keyspan_1port_ids[] = {
605	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
606	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
607	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
608	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
609	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
610	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
611	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
612	{ } /* Terminating entry */
613};
614
615static struct usb_device_id keyspan_2port_ids[] = {
616	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
617	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
618	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
619	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) },
620	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) },
621	{ } /* Terminating entry */
622};
623
624static struct usb_device_id keyspan_4port_ids[] = {
625	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) },
626	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
627	{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
628	{ } /* Terminating entry */
629};
630
631/* Structs for the devices, pre and post renumeration. */
632static struct usb_serial_driver keyspan_pre_device = {
633	.driver = {
634		.owner		= THIS_MODULE,
635		.name		= "keyspan_no_firm",
636	},
637	.description		= "Keyspan - (without firmware)",
638	.id_table		= keyspan_pre_ids,
639	.num_interrupt_in	= NUM_DONT_CARE,
640	.num_interrupt_out	= NUM_DONT_CARE,
641	.num_bulk_in		= NUM_DONT_CARE,
642	.num_bulk_out		= NUM_DONT_CARE,
643	.num_ports		= 1,
644	.attach			= keyspan_fake_startup,
645};
646
647static struct usb_serial_driver keyspan_1port_device = {
648	.driver = {
649		.owner		= THIS_MODULE,
650		.name		= "keyspan_1",
651	},
652	.description		= "Keyspan 1 port adapter",
653	.id_table		= keyspan_1port_ids,
654	.num_interrupt_in	= NUM_DONT_CARE,
655	.num_interrupt_out	= NUM_DONT_CARE,
656	.num_bulk_in		= NUM_DONT_CARE,
657	.num_bulk_out		= NUM_DONT_CARE,
658	.num_ports		= 1,
659	.open			= keyspan_open,
660	.close			= keyspan_close,
661	.write			= keyspan_write,
662	.write_room		= keyspan_write_room,
663	.chars_in_buffer	= keyspan_chars_in_buffer,
664	.throttle		= keyspan_rx_throttle,
665	.unthrottle		= keyspan_rx_unthrottle,
666	.ioctl			= keyspan_ioctl,
667	.set_termios		= keyspan_set_termios,
668	.break_ctl		= keyspan_break_ctl,
669	.tiocmget		= keyspan_tiocmget,
670	.tiocmset		= keyspan_tiocmset,
671	.attach			= keyspan_startup,
672	.shutdown		= keyspan_shutdown,
673};
674
675static struct usb_serial_driver keyspan_2port_device = {
676	.driver = {
677		.owner		= THIS_MODULE,
678		.name		= "keyspan_2",
679	},
680	.description		= "Keyspan 2 port adapter",
681	.id_table		= keyspan_2port_ids,
682	.num_interrupt_in	= NUM_DONT_CARE,
683	.num_interrupt_out	= NUM_DONT_CARE,
684	.num_bulk_in		= NUM_DONT_CARE,
685	.num_bulk_out		= NUM_DONT_CARE,
686	.num_ports		= 2,
687	.open			= keyspan_open,
688	.close			= keyspan_close,
689	.write			= keyspan_write,
690	.write_room		= keyspan_write_room,
691	.chars_in_buffer	= keyspan_chars_in_buffer,
692	.throttle		= keyspan_rx_throttle,
693	.unthrottle		= keyspan_rx_unthrottle,
694	.ioctl			= keyspan_ioctl,
695	.set_termios		= keyspan_set_termios,
696	.break_ctl		= keyspan_break_ctl,
697	.tiocmget		= keyspan_tiocmget,
698	.tiocmset		= keyspan_tiocmset,
699	.attach			= keyspan_startup,
700	.shutdown		= keyspan_shutdown,
701};
702
703static struct usb_serial_driver keyspan_4port_device = {
704	.driver = {
705		.owner		= THIS_MODULE,
706		.name		= "keyspan_4",
707	},
708	.description		= "Keyspan 4 port adapter",
709	.id_table		= keyspan_4port_ids,
710	.num_interrupt_in	= NUM_DONT_CARE,
711	.num_interrupt_out	= NUM_DONT_CARE,
712	.num_bulk_in		= NUM_DONT_CARE,
713	.num_bulk_out		= NUM_DONT_CARE,
714	.num_ports		= 4,
715	.open			= keyspan_open,
716	.close			= keyspan_close,
717	.write			= keyspan_write,
718	.write_room		= keyspan_write_room,
719	.chars_in_buffer	= keyspan_chars_in_buffer,
720	.throttle		= keyspan_rx_throttle,
721	.unthrottle		= keyspan_rx_unthrottle,
722	.ioctl			= keyspan_ioctl,
723	.set_termios		= keyspan_set_termios,
724	.break_ctl		= keyspan_break_ctl,
725	.tiocmget		= keyspan_tiocmget,
726	.tiocmset		= keyspan_tiocmset,
727	.attach			= keyspan_startup,
728	.shutdown		= keyspan_shutdown,
729};
730
731#endif
732