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