Merge branch 'linus' into x86/urgent
[pandora-kernel.git] / drivers / usb / serial / keyspan.h
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 */
38 static int  keyspan_open                (struct usb_serial_port *port,
39                                          struct file *filp);
40 static void keyspan_close               (struct usb_serial_port *port,
41                                          struct file *filp);
42 static int  keyspan_startup             (struct usb_serial *serial);
43 static void keyspan_shutdown            (struct usb_serial *serial);
44 static void keyspan_rx_throttle         (struct usb_serial_port *port);
45 static void keyspan_rx_unthrottle       (struct usb_serial_port *port);
46 static int  keyspan_write_room          (struct usb_serial_port *port);
47
48 static int  keyspan_write               (struct usb_serial_port *port,
49                                          const unsigned char *buf,
50                                          int count);
51
52 static void keyspan_send_setup          (struct usb_serial_port *port,
53                                          int reset_port);
54
55
56 static int  keyspan_chars_in_buffer     (struct usb_serial_port *port);
57 static int  keyspan_ioctl               (struct usb_serial_port *port,
58                                          struct file *file,
59                                          unsigned int cmd,
60                                          unsigned long arg);
61 static void keyspan_set_termios         (struct usb_serial_port *port,
62                                          struct ktermios *old);
63 static void keyspan_break_ctl           (struct usb_serial_port *port,
64                                          int break_state);
65 static int  keyspan_tiocmget            (struct usb_serial_port *port,
66                                          struct file *file);
67 static int  keyspan_tiocmset            (struct usb_serial_port *port,
68                                          struct file *file, unsigned int set,
69                                          unsigned int clear);
70 static int  keyspan_fake_startup        (struct usb_serial *serial);
71
72 static int  keyspan_usa19_calc_baud     (u32 baud_rate, u32 baudclk, 
73                                          u8 *rate_hi, u8 *rate_low,
74                                          u8 *prescaler, int portnum);
75
76 static int  keyspan_usa19w_calc_baud    (u32 baud_rate, u32 baudclk,
77                                          u8 *rate_hi, u8 *rate_low,
78                                          u8 *prescaler, int portnum);
79
80 static int  keyspan_usa28_calc_baud     (u32 baud_rate, u32 baudclk,
81                                          u8 *rate_hi, u8 *rate_low,
82                                          u8 *prescaler, int portnum);
83
84 static int  keyspan_usa19hs_calc_baud   (u32 baud_rate, u32 baudclk,
85                                          u8 *rate_hi, u8 *rate_low,
86                                          u8 *prescaler, int portnum);
87
88 static int  keyspan_usa28_send_setup    (struct usb_serial *serial,
89                                          struct usb_serial_port *port,
90                                          int reset_port);
91 static int  keyspan_usa26_send_setup    (struct usb_serial *serial,
92                                          struct usb_serial_port *port,
93                                          int reset_port);
94 static int  keyspan_usa49_send_setup    (struct usb_serial *serial,
95                                          struct usb_serial_port *port,
96                                          int reset_port);
97
98 static int  keyspan_usa90_send_setup    (struct usb_serial *serial,
99                                          struct usb_serial_port *port,
100                                          int reset_port);
101
102 static int  keyspan_usa67_send_setup    (struct usb_serial *serial,
103                                          struct usb_serial_port *port,
104                                          int reset_port);
105
106 /* Values used for baud rate calculation - device specific */
107 #define KEYSPAN_INVALID_BAUD_RATE               (-1)
108 #define KEYSPAN_BAUD_RATE_OK                    (0)
109 #define KEYSPAN_USA18X_BAUDCLK                  (12000000L)     /* a guess */
110 #define KEYSPAN_USA19_BAUDCLK                   (12000000L)
111 #define KEYSPAN_USA19W_BAUDCLK                  (24000000L)
112 #define KEYSPAN_USA19HS_BAUDCLK                 (14769231L)
113 #define KEYSPAN_USA28_BAUDCLK                   (1843200L)
114 #define KEYSPAN_USA28X_BAUDCLK                  (12000000L)
115 #define KEYSPAN_USA49W_BAUDCLK                  (48000000L)
116
117 /* Some constants used to characterise each device.  */
118 #define         KEYSPAN_MAX_NUM_PORTS           (4)
119 #define         KEYSPAN_MAX_FLIPS               (2)
120
121 /* Device info for the Keyspan serial converter, used
122    by the overall usb-serial probe function */
123 #define KEYSPAN_VENDOR_ID                       (0x06cd)
124
125 /* Product IDs for the products supported, pre-renumeration */
126 #define keyspan_usa18x_pre_product_id           0x0105
127 #define keyspan_usa19_pre_product_id            0x0103
128 #define keyspan_usa19qi_pre_product_id          0x010b
129 #define keyspan_mpr_pre_product_id              0x011b
130 #define keyspan_usa19qw_pre_product_id          0x0118
131 #define keyspan_usa19w_pre_product_id           0x0106
132 #define keyspan_usa28_pre_product_id            0x0101
133 #define keyspan_usa28x_pre_product_id           0x0102
134 #define keyspan_usa28xa_pre_product_id          0x0114
135 #define keyspan_usa28xb_pre_product_id          0x0113
136 #define keyspan_usa49w_pre_product_id           0x0109
137 #define keyspan_usa49wlc_pre_product_id         0x011a
138
139 /* Product IDs post-renumeration.  Note that the 28x and 28xb
140    have the same id's post-renumeration but behave identically
141    so it's not an issue. */
142 #define keyspan_usa18x_product_id               0x0112
143 #define keyspan_usa19_product_id                0x0107
144 #define keyspan_usa19qi_product_id              0x010c
145 #define keyspan_usa19hs_product_id              0x0121
146 #define keyspan_mpr_product_id                  0x011c
147 #define keyspan_usa19qw_product_id              0x0119
148 #define keyspan_usa19w_product_id               0x0108
149 #define keyspan_usa28_product_id                0x010f
150 #define keyspan_usa28x_product_id               0x0110
151 #define keyspan_usa28xa_product_id              0x0115
152 #define keyspan_usa28xb_product_id              0x0110
153 #define keyspan_usa28xg_product_id              0x0135
154 #define keyspan_usa49w_product_id               0x010a
155 #define keyspan_usa49wlc_product_id             0x012a
156 #define keyspan_usa49wg_product_id              0x0131
157
158 struct keyspan_device_details {
159         /* product ID value */
160         int     product_id;
161
162         enum    {msg_usa26, msg_usa28, msg_usa49, msg_usa90, msg_usa67} msg_format;
163
164                 /* Number of physical ports */
165         int     num_ports;
166
167                 /* 1 if endpoint flipping used on input, 0 if not */
168         int     indat_endp_flip;
169
170                 /* 1 if endpoint flipping used on output, 0 if not */
171         int     outdat_endp_flip;
172
173                 /* Table mapping input data endpoint IDs to physical
174                    port number and flip if used */
175         int     indat_endpoints[KEYSPAN_MAX_NUM_PORTS];
176
177                 /* Same for output endpoints */
178         int     outdat_endpoints[KEYSPAN_MAX_NUM_PORTS];
179
180                 /* Input acknowledge endpoints */
181         int     inack_endpoints[KEYSPAN_MAX_NUM_PORTS];
182
183                 /* Output control endpoints */
184         int     outcont_endpoints[KEYSPAN_MAX_NUM_PORTS];
185
186                 /* Endpoint used for input status */
187         int     instat_endpoint;
188
189                 /* Endpoint used for input data 49WG only */
190         int     indat_endpoint;
191
192                 /* Endpoint used for global control functions */
193         int     glocont_endpoint;
194
195         int     (*calculate_baud_rate) (u32 baud_rate, u32 baudclk,
196                         u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum);
197         u32     baudclk;
198 }; 
199
200 /* Now for each device type we setup the device detail
201    structure with the appropriate information (provided
202    in Keyspan's documentation) */
203
204 static const struct keyspan_device_details usa18x_device_details = {
205         .product_id             = keyspan_usa18x_product_id,
206         .msg_format             = msg_usa26,
207         .num_ports              = 1,
208         .indat_endp_flip        = 0,
209         .outdat_endp_flip       = 1,
210         .indat_endpoints        = {0x81},
211         .outdat_endpoints       = {0x01},
212         .inack_endpoints        = {0x85},
213         .outcont_endpoints      = {0x05},
214         .instat_endpoint        = 0x87,
215         .indat_endpoint         = -1,
216         .glocont_endpoint       = 0x07,
217         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
218         .baudclk                = KEYSPAN_USA18X_BAUDCLK,
219 };
220
221 static const struct keyspan_device_details usa19_device_details = {
222         .product_id             = keyspan_usa19_product_id,
223         .msg_format             = msg_usa28,
224         .num_ports              = 1,
225         .indat_endp_flip        = 1,
226         .outdat_endp_flip       = 1,
227         .indat_endpoints        = {0x81},
228         .outdat_endpoints       = {0x01},
229         .inack_endpoints        = {0x83},
230         .outcont_endpoints      = {0x03},
231         .instat_endpoint        = 0x84,
232         .indat_endpoint         = -1,
233         .glocont_endpoint       = -1,
234         .calculate_baud_rate    = keyspan_usa19_calc_baud,
235         .baudclk                = KEYSPAN_USA19_BAUDCLK,
236 };
237
238 static const struct keyspan_device_details usa19qi_device_details = {
239         .product_id             = keyspan_usa19qi_product_id,
240         .msg_format             = msg_usa28,
241         .num_ports              = 1,
242         .indat_endp_flip        = 1,
243         .outdat_endp_flip       = 1,
244         .indat_endpoints        = {0x81},
245         .outdat_endpoints       = {0x01},
246         .inack_endpoints        = {0x83},
247         .outcont_endpoints      = {0x03},
248         .instat_endpoint        = 0x84,
249         .indat_endpoint         = -1,
250         .glocont_endpoint       = -1,
251         .calculate_baud_rate    = keyspan_usa28_calc_baud,
252         .baudclk                = KEYSPAN_USA19_BAUDCLK,
253 };
254
255 static const struct keyspan_device_details mpr_device_details = {
256         .product_id             = keyspan_mpr_product_id,
257         .msg_format             = msg_usa28,
258         .num_ports              = 1,
259         .indat_endp_flip        = 1,
260         .outdat_endp_flip       = 1,
261         .indat_endpoints        = {0x81},
262         .outdat_endpoints       = {0x01},
263         .inack_endpoints        = {0x83},
264         .outcont_endpoints      = {0x03},
265         .instat_endpoint        = 0x84,
266         .indat_endpoint         = -1,
267         .glocont_endpoint       = -1,
268         .calculate_baud_rate    = keyspan_usa28_calc_baud,
269         .baudclk                = KEYSPAN_USA19_BAUDCLK,
270 };
271
272 static const struct keyspan_device_details usa19qw_device_details = {
273         .product_id             = keyspan_usa19qw_product_id,
274         .msg_format             = msg_usa26,
275         .num_ports              = 1,
276         .indat_endp_flip        = 0,
277         .outdat_endp_flip       = 1,
278         .indat_endpoints        = {0x81},
279         .outdat_endpoints       = {0x01},
280         .inack_endpoints        = {0x85},
281         .outcont_endpoints      = {0x05},
282         .instat_endpoint        = 0x87,
283         .indat_endpoint         = -1,
284         .glocont_endpoint       = 0x07,
285         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
286         .baudclk                = KEYSPAN_USA19W_BAUDCLK,
287 };
288
289 static const struct keyspan_device_details usa19w_device_details = {
290         .product_id             = keyspan_usa19w_product_id,
291         .msg_format             = msg_usa26,
292         .num_ports              = 1,
293         .indat_endp_flip        = 0,
294         .outdat_endp_flip       = 1,
295         .indat_endpoints        = {0x81},
296         .outdat_endpoints       = {0x01},
297         .inack_endpoints        = {0x85},
298         .outcont_endpoints      = {0x05},
299         .instat_endpoint        = 0x87,
300         .indat_endpoint         = -1,
301         .glocont_endpoint       = 0x07,
302         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
303         .baudclk                = KEYSPAN_USA19W_BAUDCLK,
304 };
305
306 static const struct keyspan_device_details usa19hs_device_details = {
307         .product_id             = keyspan_usa19hs_product_id,
308         .msg_format             = msg_usa90,
309         .num_ports              = 1,
310         .indat_endp_flip        = 0,
311         .outdat_endp_flip       = 0,
312         .indat_endpoints        = {0x81},
313         .outdat_endpoints       = {0x01},
314         .inack_endpoints        = {-1},
315         .outcont_endpoints      = {0x02},
316         .instat_endpoint        = 0x82,
317         .indat_endpoint         = -1,
318         .glocont_endpoint       = -1,
319         .calculate_baud_rate    = keyspan_usa19hs_calc_baud,
320         .baudclk                = KEYSPAN_USA19HS_BAUDCLK,
321 };
322
323 static const struct keyspan_device_details usa28_device_details = {
324         .product_id             = keyspan_usa28_product_id,
325         .msg_format             = msg_usa28,
326         .num_ports              = 2,
327         .indat_endp_flip        = 1,
328         .outdat_endp_flip       = 1,
329         .indat_endpoints        = {0x81, 0x83},
330         .outdat_endpoints       = {0x01, 0x03},
331         .inack_endpoints        = {0x85, 0x86},
332         .outcont_endpoints      = {0x05, 0x06},
333         .instat_endpoint        = 0x87,
334         .indat_endpoint         = -1,
335         .glocont_endpoint       = 0x07,
336         .calculate_baud_rate    = keyspan_usa28_calc_baud,
337         .baudclk                = KEYSPAN_USA28_BAUDCLK,                
338 };
339
340 static const struct keyspan_device_details usa28x_device_details = {
341         .product_id             = keyspan_usa28x_product_id,
342         .msg_format             = msg_usa26,
343         .num_ports              = 2,
344         .indat_endp_flip        = 0,
345         .outdat_endp_flip       = 1,
346         .indat_endpoints        = {0x81, 0x83},
347         .outdat_endpoints       = {0x01, 0x03},
348         .inack_endpoints        = {0x85, 0x86},
349         .outcont_endpoints      = {0x05, 0x06},
350         .instat_endpoint        = 0x87,
351         .indat_endpoint         = -1,
352         .glocont_endpoint       = 0x07,
353         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
354         .baudclk                = KEYSPAN_USA28X_BAUDCLK,
355 };
356
357 static const struct keyspan_device_details usa28xa_device_details = {
358         .product_id             = keyspan_usa28xa_product_id,
359         .msg_format             = msg_usa26,
360         .num_ports              = 2,
361         .indat_endp_flip        = 0,
362         .outdat_endp_flip       = 1,
363         .indat_endpoints        = {0x81, 0x83},
364         .outdat_endpoints       = {0x01, 0x03},
365         .inack_endpoints        = {0x85, 0x86},
366         .outcont_endpoints      = {0x05, 0x06},
367         .instat_endpoint        = 0x87,
368         .indat_endpoint         = -1,
369         .glocont_endpoint       = 0x07,
370         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
371         .baudclk                = KEYSPAN_USA28X_BAUDCLK,
372 };
373
374 static const struct keyspan_device_details usa28xg_device_details = {
375         .product_id             = keyspan_usa28xg_product_id,
376         .msg_format             = msg_usa67,
377         .num_ports              = 2,
378         .indat_endp_flip        = 0,
379         .outdat_endp_flip       = 0,
380         .indat_endpoints        = {0x84, 0x88},
381         .outdat_endpoints       = {0x02, 0x06},
382         .inack_endpoints        = {-1, -1},
383         .outcont_endpoints      = {-1, -1},
384         .instat_endpoint        = 0x81,
385         .indat_endpoint         = -1,
386         .glocont_endpoint       = 0x01,
387         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
388         .baudclk                = KEYSPAN_USA28X_BAUDCLK,
389 };
390 /* We don't need a separate entry for the usa28xb as it appears as a 28x anyway */
391
392 static const struct keyspan_device_details usa49w_device_details = {
393         .product_id             = keyspan_usa49w_product_id,
394         .msg_format             = msg_usa49,
395         .num_ports              = 4,
396         .indat_endp_flip        = 0,
397         .outdat_endp_flip       = 0,
398         .indat_endpoints        = {0x81, 0x82, 0x83, 0x84},
399         .outdat_endpoints       = {0x01, 0x02, 0x03, 0x04},
400         .inack_endpoints        = {-1, -1, -1, -1},
401         .outcont_endpoints      = {-1, -1, -1, -1},
402         .instat_endpoint        = 0x87,
403         .indat_endpoint         = -1,
404         .glocont_endpoint       = 0x07,
405         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
406         .baudclk                = KEYSPAN_USA49W_BAUDCLK,
407 };
408
409 static const struct keyspan_device_details usa49wlc_device_details = {
410         .product_id             = keyspan_usa49wlc_product_id,
411         .msg_format             = msg_usa49,
412         .num_ports              = 4,
413         .indat_endp_flip        = 0,
414         .outdat_endp_flip       = 0,
415         .indat_endpoints        = {0x81, 0x82, 0x83, 0x84},
416         .outdat_endpoints       = {0x01, 0x02, 0x03, 0x04},
417         .inack_endpoints        = {-1, -1, -1, -1},
418         .outcont_endpoints      = {-1, -1, -1, -1},
419         .instat_endpoint        = 0x87,
420         .indat_endpoint         = -1,
421         .glocont_endpoint       = 0x07,
422         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
423         .baudclk                = KEYSPAN_USA19W_BAUDCLK,
424 };
425
426 static const struct keyspan_device_details usa49wg_device_details = {
427         .product_id             = keyspan_usa49wg_product_id,
428         .msg_format             = msg_usa49,
429         .num_ports              = 4,
430         .indat_endp_flip        = 0,
431         .outdat_endp_flip       = 0,
432         .indat_endpoints        = {-1, -1, -1, -1},             /* single 'global' data in EP */
433         .outdat_endpoints       = {0x01, 0x02, 0x04, 0x06},
434         .inack_endpoints        = {-1, -1, -1, -1},
435         .outcont_endpoints      = {-1, -1, -1, -1},
436         .instat_endpoint        = 0x81,
437         .indat_endpoint         = 0x88,
438         .glocont_endpoint       = 0x00,                         /* uses control EP */
439         .calculate_baud_rate    = keyspan_usa19w_calc_baud,
440         .baudclk                = KEYSPAN_USA19W_BAUDCLK,
441 };
442
443 static const struct keyspan_device_details *keyspan_devices[] = {
444         &usa18x_device_details,
445         &usa19_device_details,
446         &usa19qi_device_details,
447         &mpr_device_details,
448         &usa19qw_device_details,
449         &usa19w_device_details,
450         &usa19hs_device_details,
451         &usa28_device_details,
452         &usa28x_device_details,
453         &usa28xa_device_details,
454         &usa28xg_device_details,
455         /* 28xb not required as it renumerates as a 28x */
456         &usa49w_device_details,
457         &usa49wlc_device_details,
458         &usa49wg_device_details,
459         NULL,
460 };
461
462 static struct usb_device_id keyspan_ids_combined[] = {
463         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
464         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
465         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
466         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
467         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) },
468         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) },
469         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) },
470         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) },
471         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) },
472         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) },
473         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) },
474         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) },
475         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
476         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
477         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
478         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
479         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
480         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
481         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
482         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
483         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
484         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
485         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) },
486         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) },
487         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)},
488         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
489         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
490         { } /* Terminating entry */
491 };
492
493 MODULE_DEVICE_TABLE(usb, keyspan_ids_combined);
494
495 static struct usb_driver keyspan_driver = {
496         .name =         "keyspan",                
497         .probe =        usb_serial_probe,
498         .disconnect =   usb_serial_disconnect,
499         .id_table =     keyspan_ids_combined,
500         .no_dynamic_id =        1,
501 };
502
503 /* usb_device_id table for the pre-firmware download keyspan devices */
504 static struct usb_device_id keyspan_pre_ids[] = {
505         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
506         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
507         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
508         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) },
509         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
510         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) },
511         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) },
512         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) },
513         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) },
514         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) },
515         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) },
516         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) },
517         { } /* Terminating entry */
518 };
519
520 static struct usb_device_id keyspan_1port_ids[] = {
521         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
522         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
523         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
524         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
525         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
526         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
527         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
528         { } /* Terminating entry */
529 };
530
531 static struct usb_device_id keyspan_2port_ids[] = {
532         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
533         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
534         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
535         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) },
536         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) },
537         { } /* Terminating entry */
538 };
539
540 static struct usb_device_id keyspan_4port_ids[] = {
541         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) },
542         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
543         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
544         { } /* Terminating entry */
545 };
546
547 /* Structs for the devices, pre and post renumeration. */
548 static struct usb_serial_driver keyspan_pre_device = {
549         .driver = {
550                 .owner          = THIS_MODULE,
551                 .name           = "keyspan_no_firm",
552         },
553         .description            = "Keyspan - (without firmware)",
554         .id_table               = keyspan_pre_ids,
555         .num_ports              = 1,
556         .attach                 = keyspan_fake_startup,
557 };
558
559 static struct usb_serial_driver keyspan_1port_device = {
560         .driver = {
561                 .owner          = THIS_MODULE,
562                 .name           = "keyspan_1",
563         },
564         .description            = "Keyspan 1 port adapter",
565         .id_table               = keyspan_1port_ids,
566         .num_ports              = 1,
567         .open                   = keyspan_open,
568         .close                  = keyspan_close,
569         .write                  = keyspan_write,
570         .write_room             = keyspan_write_room,
571         .chars_in_buffer        = keyspan_chars_in_buffer,
572         .throttle               = keyspan_rx_throttle,
573         .unthrottle             = keyspan_rx_unthrottle,
574         .ioctl                  = keyspan_ioctl,
575         .set_termios            = keyspan_set_termios,
576         .break_ctl              = keyspan_break_ctl,
577         .tiocmget               = keyspan_tiocmget,
578         .tiocmset               = keyspan_tiocmset,
579         .attach                 = keyspan_startup,
580         .shutdown               = keyspan_shutdown,
581 };
582
583 static struct usb_serial_driver keyspan_2port_device = {
584         .driver = {
585                 .owner          = THIS_MODULE,
586                 .name           = "keyspan_2",
587         },
588         .description            = "Keyspan 2 port adapter",
589         .id_table               = keyspan_2port_ids,
590         .num_ports              = 2,
591         .open                   = keyspan_open,
592         .close                  = keyspan_close,
593         .write                  = keyspan_write,
594         .write_room             = keyspan_write_room,
595         .chars_in_buffer        = keyspan_chars_in_buffer,
596         .throttle               = keyspan_rx_throttle,
597         .unthrottle             = keyspan_rx_unthrottle,
598         .ioctl                  = keyspan_ioctl,
599         .set_termios            = keyspan_set_termios,
600         .break_ctl              = keyspan_break_ctl,
601         .tiocmget               = keyspan_tiocmget,
602         .tiocmset               = keyspan_tiocmset,
603         .attach                 = keyspan_startup,
604         .shutdown               = keyspan_shutdown,
605 };
606
607 static struct usb_serial_driver keyspan_4port_device = {
608         .driver = {
609                 .owner          = THIS_MODULE,
610                 .name           = "keyspan_4",
611         },
612         .description            = "Keyspan 4 port adapter",
613         .id_table               = keyspan_4port_ids,
614         .num_ports              = 4,
615         .open                   = keyspan_open,
616         .close                  = keyspan_close,
617         .write                  = keyspan_write,
618         .write_room             = keyspan_write_room,
619         .chars_in_buffer        = keyspan_chars_in_buffer,
620         .throttle               = keyspan_rx_throttle,
621         .unthrottle             = keyspan_rx_unthrottle,
622         .ioctl                  = keyspan_ioctl,
623         .set_termios            = keyspan_set_termios,
624         .break_ctl              = keyspan_break_ctl,
625         .tiocmget               = keyspan_tiocmget,
626         .tiocmset               = keyspan_tiocmset,
627         .attach                 = keyspan_startup,
628         .shutdown               = keyspan_shutdown,
629 };
630
631 #endif