2 Keyspan USB to Serial Converter driver
4 (C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org>
5 (C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com>
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.
12 See http://blemings.org/hugh/keyspan.html for more information.
14 Code in this driver inspired by and in a number of places taken
15 from Brian Warner's original Keyspan-PDA driver.
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.
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
26 Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
27 staff in their work on open source projects.
31 #include <linux/kernel.h>
32 #include <linux/jiffies.h>
33 #include <linux/errno.h>
34 #include <linux/init.h>
35 #include <linux/slab.h>
36 #include <linux/tty.h>
37 #include <linux/tty_driver.h>
38 #include <linux/tty_flip.h>
39 #include <linux/module.h>
40 #include <linux/spinlock.h>
41 #include <linux/uaccess.h>
42 #include <linux/usb.h>
43 #include <linux/usb/serial.h>
44 #include <linux/usb/ezusb.h>
47 #define DRIVER_AUTHOR "Hugh Blemings <hugh@misc.nu"
48 #define DRIVER_DESC "Keyspan USB to Serial Converter Driver"
50 #define INSTAT_BUFLEN 32
51 #define GLOCONT_BUFLEN 64
52 #define INDAT49W_BUFLEN 512
54 /* Per device and per port private data */
55 struct keyspan_serial_private {
56 const struct keyspan_device_details *device_details;
58 struct urb *instat_urb;
59 char instat_buf[INSTAT_BUFLEN];
61 /* added to support 49wg, where data from all 4 ports comes in
62 on 1 EP and high-speed supported */
63 struct urb *indat_urb;
64 char indat_buf[INDAT49W_BUFLEN];
66 /* XXX this one probably will need a lock */
67 struct urb *glocont_urb;
68 char glocont_buf[GLOCONT_BUFLEN];
69 char ctrl_buf[8]; /* for EP0 control message */
72 struct keyspan_port_private {
73 /* Keep track of which input & output endpoints to use */
77 /* Keep duplicate of device details in each port
78 structure as well - simplifies some of the
79 callback functions etc. */
80 const struct keyspan_device_details *device_details;
82 /* Input endpoints and buffer for this port */
83 struct urb *in_urbs[2];
84 char in_buffer[2][64];
85 /* Output endpoints and buffer for this port */
86 struct urb *out_urbs[2];
87 char out_buffer[2][64];
89 /* Input ack endpoint */
90 struct urb *inack_urb;
93 /* Output control endpoint */
94 struct urb *outcont_urb;
95 char outcont_buffer[64];
97 /* Settings for the port */
101 unsigned int old_cflag;
102 enum {flow_none, flow_cts, flow_xon} flow_control;
103 int rts_state; /* Handshaking pins (outputs) */
105 int cts_state; /* Handshaking pins (inputs) */
111 unsigned long tx_start_time[2];
112 int resend_cont; /* need to resend control packet */
115 /* Include Keyspan message headers. All current Keyspan Adapters
116 make use of one of five message formats which are referred
117 to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
118 within this driver. */
119 #include "keyspan_usa26msg.h"
120 #include "keyspan_usa28msg.h"
121 #include "keyspan_usa49msg.h"
122 #include "keyspan_usa90msg.h"
123 #include "keyspan_usa67msg.h"
126 module_usb_serial_driver(serial_drivers, keyspan_ids_combined);
128 static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
130 struct usb_serial_port *port = tty->driver_data;
131 struct keyspan_port_private *p_priv;
133 p_priv = usb_get_serial_port_data(port);
135 if (break_state == -1)
136 p_priv->break_on = 1;
138 p_priv->break_on = 0;
140 keyspan_send_setup(port, 0);
144 static void keyspan_set_termios(struct tty_struct *tty,
145 struct usb_serial_port *port, struct ktermios *old_termios)
147 int baud_rate, device_port;
148 struct keyspan_port_private *p_priv;
149 const struct keyspan_device_details *d_details;
152 p_priv = usb_get_serial_port_data(port);
153 d_details = p_priv->device_details;
154 cflag = tty->termios.c_cflag;
155 device_port = port->port_number;
157 /* Baud rate calculation takes baud rate as an integer
158 so other rates can be generated if desired. */
159 baud_rate = tty_get_baud_rate(tty);
160 /* If no match or invalid, don't change */
161 if (d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
162 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
163 /* FIXME - more to do here to ensure rate changes cleanly */
164 /* FIXME - calcuate exact rate from divisor ? */
165 p_priv->baud = baud_rate;
167 baud_rate = tty_termios_baud_rate(old_termios);
169 tty_encode_baud_rate(tty, baud_rate, baud_rate);
170 /* set CTS/RTS handshake etc. */
171 p_priv->cflag = cflag;
172 p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
174 /* Mark/Space not supported */
175 tty->termios.c_cflag &= ~CMSPAR;
177 keyspan_send_setup(port, 0);
180 static int keyspan_tiocmget(struct tty_struct *tty)
182 struct usb_serial_port *port = tty->driver_data;
183 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
186 value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
187 ((p_priv->dtr_state) ? TIOCM_DTR : 0) |
188 ((p_priv->cts_state) ? TIOCM_CTS : 0) |
189 ((p_priv->dsr_state) ? TIOCM_DSR : 0) |
190 ((p_priv->dcd_state) ? TIOCM_CAR : 0) |
191 ((p_priv->ri_state) ? TIOCM_RNG : 0);
196 static int keyspan_tiocmset(struct tty_struct *tty,
197 unsigned int set, unsigned int clear)
199 struct usb_serial_port *port = tty->driver_data;
200 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
203 p_priv->rts_state = 1;
205 p_priv->dtr_state = 1;
206 if (clear & TIOCM_RTS)
207 p_priv->rts_state = 0;
208 if (clear & TIOCM_DTR)
209 p_priv->dtr_state = 0;
210 keyspan_send_setup(port, 0);
214 /* Write function is similar for the four protocols used
215 with only a minor change for usa90 (usa19hs) required */
216 static int keyspan_write(struct tty_struct *tty,
217 struct usb_serial_port *port, const unsigned char *buf, int count)
219 struct keyspan_port_private *p_priv;
220 const struct keyspan_device_details *d_details;
223 struct urb *this_urb;
224 int err, maxDataLen, dataOffset;
226 p_priv = usb_get_serial_port_data(port);
227 d_details = p_priv->device_details;
229 if (d_details->msg_format == msg_usa90) {
237 dev_dbg(&port->dev, "%s - %d chars, flip=%d\n", __func__, count,
240 for (left = count; left > 0; left -= todo) {
242 if (todo > maxDataLen)
245 flip = p_priv->out_flip;
247 /* Check we have a valid urb/endpoint before we use it... */
248 this_urb = p_priv->out_urbs[flip];
249 if (this_urb == NULL) {
250 /* no bulk out, so return 0 bytes written */
251 dev_dbg(&port->dev, "%s - no output urb :(\n", __func__);
255 dev_dbg(&port->dev, "%s - endpoint %d flip %d\n",
256 __func__, usb_pipeendpoint(this_urb->pipe), flip);
258 if (this_urb->status == -EINPROGRESS) {
259 if (time_before(jiffies,
260 p_priv->tx_start_time[flip] + 10 * HZ))
262 usb_unlink_urb(this_urb);
266 /* First byte in buffer is "last flag" (except for usa19hx)
267 - unused so for now so set to zero */
268 ((char *)this_urb->transfer_buffer)[0] = 0;
270 memcpy(this_urb->transfer_buffer + dataOffset, buf, todo);
273 /* send the data out the bulk port */
274 this_urb->transfer_buffer_length = todo + dataOffset;
276 err = usb_submit_urb(this_urb, GFP_ATOMIC);
278 dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed (%d)\n", err);
279 p_priv->tx_start_time[flip] = jiffies;
281 /* Flip for next time if usa26 or usa28 interface
282 (not used on usa49) */
283 p_priv->out_flip = (flip + 1) & d_details->outdat_endp_flip;
289 static void usa26_indat_callback(struct urb *urb)
293 struct usb_serial_port *port;
294 unsigned char *data = urb->transfer_buffer;
295 int status = urb->status;
297 endpoint = usb_pipeendpoint(urb->pipe);
300 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
301 __func__, status, endpoint);
306 if (urb->actual_length) {
307 /* 0x80 bit is error flag */
308 if ((data[0] & 0x80) == 0) {
309 /* no errors on individual bytes, only
310 possible overrun err */
311 if (data[0] & RXERROR_OVERRUN)
315 for (i = 1; i < urb->actual_length ; ++i)
316 tty_insert_flip_char(&port->port, data[i], err);
318 /* some bytes had errors, every byte has status */
319 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
320 for (i = 0; i + 1 < urb->actual_length; i += 2) {
321 int stat = data[i], flag = 0;
322 if (stat & RXERROR_OVERRUN)
324 if (stat & RXERROR_FRAMING)
326 if (stat & RXERROR_PARITY)
328 /* XXX should handle break (0x10) */
329 tty_insert_flip_char(&port->port, data[i+1],
333 tty_flip_buffer_push(&port->port);
336 /* Resubmit urb so we continue receiving */
337 err = usb_submit_urb(urb, GFP_ATOMIC);
339 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
342 /* Outdat handling is common for all devices */
343 static void usa2x_outdat_callback(struct urb *urb)
345 struct usb_serial_port *port;
346 struct keyspan_port_private *p_priv;
349 p_priv = usb_get_serial_port_data(port);
350 dev_dbg(&port->dev, "%s - urb %d\n", __func__, urb == p_priv->out_urbs[1]);
352 usb_serial_port_softint(port);
355 static void usa26_inack_callback(struct urb *urb)
359 static void usa26_outcont_callback(struct urb *urb)
361 struct usb_serial_port *port;
362 struct keyspan_port_private *p_priv;
365 p_priv = usb_get_serial_port_data(port);
367 if (p_priv->resend_cont) {
368 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
369 keyspan_usa26_send_setup(port->serial, port,
370 p_priv->resend_cont - 1);
374 static void usa26_instat_callback(struct urb *urb)
376 unsigned char *data = urb->transfer_buffer;
377 struct keyspan_usa26_portStatusMessage *msg;
378 struct usb_serial *serial;
379 struct usb_serial_port *port;
380 struct keyspan_port_private *p_priv;
381 int old_dcd_state, err;
382 int status = urb->status;
384 serial = urb->context;
387 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
390 if (urb->actual_length != 9) {
391 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
395 msg = (struct keyspan_usa26_portStatusMessage *)data;
398 dev_dbg(&urb->dev->dev,
399 "%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d",
400 __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr,
401 msg->ri, msg->_txOff, msg->_txXoff, msg->rxEnabled,
402 msg->controlResponse);
405 /* Now do something useful with the data */
408 /* Check port number from message and retrieve private data */
409 if (msg->port >= serial->num_ports) {
410 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
413 port = serial->port[msg->port];
414 p_priv = usb_get_serial_port_data(port);
416 /* Update handshaking pin state information */
417 old_dcd_state = p_priv->dcd_state;
418 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
419 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
420 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
421 p_priv->ri_state = ((msg->ri) ? 1 : 0);
423 if (old_dcd_state != p_priv->dcd_state)
424 tty_port_tty_hangup(&port->port, true);
426 /* Resubmit urb so we continue receiving */
427 err = usb_submit_urb(urb, GFP_ATOMIC);
429 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
433 static void usa26_glocont_callback(struct urb *urb)
438 static void usa28_indat_callback(struct urb *urb)
441 struct usb_serial_port *port;
443 struct keyspan_port_private *p_priv;
444 int status = urb->status;
447 p_priv = usb_get_serial_port_data(port);
448 data = urb->transfer_buffer;
450 if (urb != p_priv->in_urbs[p_priv->in_flip])
455 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
456 __func__, status, usb_pipeendpoint(urb->pipe));
461 p_priv = usb_get_serial_port_data(port);
462 data = urb->transfer_buffer;
464 if (urb->actual_length) {
465 tty_insert_flip_string(&port->port, data,
467 tty_flip_buffer_push(&port->port);
470 /* Resubmit urb so we continue receiving */
471 err = usb_submit_urb(urb, GFP_ATOMIC);
473 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n",
475 p_priv->in_flip ^= 1;
477 urb = p_priv->in_urbs[p_priv->in_flip];
478 } while (urb->status != -EINPROGRESS);
481 static void usa28_inack_callback(struct urb *urb)
485 static void usa28_outcont_callback(struct urb *urb)
487 struct usb_serial_port *port;
488 struct keyspan_port_private *p_priv;
491 p_priv = usb_get_serial_port_data(port);
493 if (p_priv->resend_cont) {
494 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
495 keyspan_usa28_send_setup(port->serial, port,
496 p_priv->resend_cont - 1);
500 static void usa28_instat_callback(struct urb *urb)
503 unsigned char *data = urb->transfer_buffer;
504 struct keyspan_usa28_portStatusMessage *msg;
505 struct usb_serial *serial;
506 struct usb_serial_port *port;
507 struct keyspan_port_private *p_priv;
509 int status = urb->status;
511 serial = urb->context;
514 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
518 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) {
519 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
523 /*dev_dbg(&urb->dev->dev, "%s %12ph", __func__, data);*/
525 /* Now do something useful with the data */
526 msg = (struct keyspan_usa28_portStatusMessage *)data;
528 /* Check port number from message and retrieve private data */
529 if (msg->port >= serial->num_ports) {
530 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
533 port = serial->port[msg->port];
534 p_priv = usb_get_serial_port_data(port);
536 /* Update handshaking pin state information */
537 old_dcd_state = p_priv->dcd_state;
538 p_priv->cts_state = ((msg->cts) ? 1 : 0);
539 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
540 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
541 p_priv->ri_state = ((msg->ri) ? 1 : 0);
543 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
544 tty_port_tty_hangup(&port->port, true);
546 /* Resubmit urb so we continue receiving */
547 err = usb_submit_urb(urb, GFP_ATOMIC);
549 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
553 static void usa28_glocont_callback(struct urb *urb)
558 static void usa49_glocont_callback(struct urb *urb)
560 struct usb_serial *serial;
561 struct usb_serial_port *port;
562 struct keyspan_port_private *p_priv;
565 serial = urb->context;
566 for (i = 0; i < serial->num_ports; ++i) {
567 port = serial->port[i];
568 p_priv = usb_get_serial_port_data(port);
570 if (p_priv->resend_cont) {
571 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
572 keyspan_usa49_send_setup(serial, port,
573 p_priv->resend_cont - 1);
579 /* This is actually called glostat in the Keyspan
581 static void usa49_instat_callback(struct urb *urb)
584 unsigned char *data = urb->transfer_buffer;
585 struct keyspan_usa49_portStatusMessage *msg;
586 struct usb_serial *serial;
587 struct usb_serial_port *port;
588 struct keyspan_port_private *p_priv;
590 int status = urb->status;
592 serial = urb->context;
595 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
599 if (urb->actual_length !=
600 sizeof(struct keyspan_usa49_portStatusMessage)) {
601 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
605 /*dev_dbg(&urb->dev->dev, "%s: %11ph", __func__, data);*/
607 /* Now do something useful with the data */
608 msg = (struct keyspan_usa49_portStatusMessage *)data;
610 /* Check port number from message and retrieve private data */
611 if (msg->portNumber >= serial->num_ports) {
612 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
613 __func__, msg->portNumber);
616 port = serial->port[msg->portNumber];
617 p_priv = usb_get_serial_port_data(port);
619 /* Update handshaking pin state information */
620 old_dcd_state = p_priv->dcd_state;
621 p_priv->cts_state = ((msg->cts) ? 1 : 0);
622 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
623 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
624 p_priv->ri_state = ((msg->ri) ? 1 : 0);
626 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
627 tty_port_tty_hangup(&port->port, true);
629 /* Resubmit urb so we continue receiving */
630 err = usb_submit_urb(urb, GFP_ATOMIC);
632 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
636 static void usa49_inack_callback(struct urb *urb)
640 static void usa49_indat_callback(struct urb *urb)
644 struct usb_serial_port *port;
645 unsigned char *data = urb->transfer_buffer;
646 int status = urb->status;
648 endpoint = usb_pipeendpoint(urb->pipe);
651 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
652 __func__, status, endpoint);
657 if (urb->actual_length) {
658 /* 0x80 bit is error flag */
659 if ((data[0] & 0x80) == 0) {
660 /* no error on any byte */
661 tty_insert_flip_string(&port->port, data + 1,
662 urb->actual_length - 1);
664 /* some bytes had errors, every byte has status */
665 for (i = 0; i + 1 < urb->actual_length; i += 2) {
666 int stat = data[i], flag = 0;
667 if (stat & RXERROR_OVERRUN)
669 if (stat & RXERROR_FRAMING)
671 if (stat & RXERROR_PARITY)
673 /* XXX should handle break (0x10) */
674 tty_insert_flip_char(&port->port, data[i+1],
678 tty_flip_buffer_push(&port->port);
681 /* Resubmit urb so we continue receiving */
682 err = usb_submit_urb(urb, GFP_ATOMIC);
684 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
687 static void usa49wg_indat_callback(struct urb *urb)
690 struct usb_serial *serial;
691 struct usb_serial_port *port;
692 unsigned char *data = urb->transfer_buffer;
693 int status = urb->status;
695 serial = urb->context;
698 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
702 /* inbound data is in the form P#, len, status, data */
706 while (i < urb->actual_length) {
708 /* Check port number from message */
709 if (data[i] >= serial->num_ports) {
710 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
714 port = serial->port[data[i++]];
717 /* 0x80 bit is error flag */
718 if ((data[i] & 0x80) == 0) {
719 /* no error on any byte */
721 for (x = 1; x < len && i < urb->actual_length; ++x)
722 tty_insert_flip_char(&port->port,
726 * some bytes had errors, every byte has status
728 for (x = 0; x + 1 < len &&
729 i + 1 < urb->actual_length; x += 2) {
730 int stat = data[i], flag = 0;
732 if (stat & RXERROR_OVERRUN)
734 if (stat & RXERROR_FRAMING)
736 if (stat & RXERROR_PARITY)
738 /* XXX should handle break (0x10) */
739 tty_insert_flip_char(&port->port, data[i+1],
744 tty_flip_buffer_push(&port->port);
747 /* Resubmit urb so we continue receiving */
748 err = usb_submit_urb(urb, GFP_ATOMIC);
750 dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
753 /* not used, usa-49 doesn't have per-port control endpoints */
754 static void usa49_outcont_callback(struct urb *urb)
758 static void usa90_indat_callback(struct urb *urb)
762 struct usb_serial_port *port;
763 struct keyspan_port_private *p_priv;
764 unsigned char *data = urb->transfer_buffer;
765 int status = urb->status;
767 endpoint = usb_pipeendpoint(urb->pipe);
770 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
771 __func__, status, endpoint);
776 p_priv = usb_get_serial_port_data(port);
778 if (urb->actual_length) {
779 /* if current mode is DMA, looks like usa28 format
780 otherwise looks like usa26 data format */
782 if (p_priv->baud > 57600)
783 tty_insert_flip_string(&port->port, data,
786 /* 0x80 bit is error flag */
787 if ((data[0] & 0x80) == 0) {
788 /* no errors on individual bytes, only
789 possible overrun err*/
790 if (data[0] & RXERROR_OVERRUN)
794 for (i = 1; i < urb->actual_length ; ++i)
795 tty_insert_flip_char(&port->port,
798 /* some bytes had errors, every byte has status */
799 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
800 for (i = 0; i + 1 < urb->actual_length; i += 2) {
801 int stat = data[i], flag = 0;
802 if (stat & RXERROR_OVERRUN)
804 if (stat & RXERROR_FRAMING)
806 if (stat & RXERROR_PARITY)
808 /* XXX should handle break (0x10) */
809 tty_insert_flip_char(&port->port,
814 tty_flip_buffer_push(&port->port);
817 /* Resubmit urb so we continue receiving */
818 err = usb_submit_urb(urb, GFP_ATOMIC);
820 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
824 static void usa90_instat_callback(struct urb *urb)
826 unsigned char *data = urb->transfer_buffer;
827 struct keyspan_usa90_portStatusMessage *msg;
828 struct usb_serial *serial;
829 struct usb_serial_port *port;
830 struct keyspan_port_private *p_priv;
831 int old_dcd_state, err;
832 int status = urb->status;
834 serial = urb->context;
837 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
840 if (urb->actual_length < 14) {
841 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
845 msg = (struct keyspan_usa90_portStatusMessage *)data;
847 /* Now do something useful with the data */
849 port = serial->port[0];
850 p_priv = usb_get_serial_port_data(port);
852 /* Update handshaking pin state information */
853 old_dcd_state = p_priv->dcd_state;
854 p_priv->cts_state = ((msg->cts) ? 1 : 0);
855 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
856 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
857 p_priv->ri_state = ((msg->ri) ? 1 : 0);
859 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
860 tty_port_tty_hangup(&port->port, true);
862 /* Resubmit urb so we continue receiving */
863 err = usb_submit_urb(urb, GFP_ATOMIC);
865 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
870 static void usa90_outcont_callback(struct urb *urb)
872 struct usb_serial_port *port;
873 struct keyspan_port_private *p_priv;
876 p_priv = usb_get_serial_port_data(port);
878 if (p_priv->resend_cont) {
879 dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__);
880 keyspan_usa90_send_setup(port->serial, port,
881 p_priv->resend_cont - 1);
885 /* Status messages from the 28xg */
886 static void usa67_instat_callback(struct urb *urb)
889 unsigned char *data = urb->transfer_buffer;
890 struct keyspan_usa67_portStatusMessage *msg;
891 struct usb_serial *serial;
892 struct usb_serial_port *port;
893 struct keyspan_port_private *p_priv;
895 int status = urb->status;
897 serial = urb->context;
900 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
904 if (urb->actual_length !=
905 sizeof(struct keyspan_usa67_portStatusMessage)) {
906 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
911 /* Now do something useful with the data */
912 msg = (struct keyspan_usa67_portStatusMessage *)data;
914 /* Check port number from message and retrieve private data */
915 if (msg->port >= serial->num_ports) {
916 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
920 port = serial->port[msg->port];
921 p_priv = usb_get_serial_port_data(port);
923 /* Update handshaking pin state information */
924 old_dcd_state = p_priv->dcd_state;
925 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
926 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
928 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
929 tty_port_tty_hangup(&port->port, true);
931 /* Resubmit urb so we continue receiving */
932 err = usb_submit_urb(urb, GFP_ATOMIC);
934 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
937 static void usa67_glocont_callback(struct urb *urb)
939 struct usb_serial *serial;
940 struct usb_serial_port *port;
941 struct keyspan_port_private *p_priv;
944 serial = urb->context;
945 for (i = 0; i < serial->num_ports; ++i) {
946 port = serial->port[i];
947 p_priv = usb_get_serial_port_data(port);
949 if (p_priv->resend_cont) {
950 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
951 keyspan_usa67_send_setup(serial, port,
952 p_priv->resend_cont - 1);
958 static int keyspan_write_room(struct tty_struct *tty)
960 struct usb_serial_port *port = tty->driver_data;
961 struct keyspan_port_private *p_priv;
962 const struct keyspan_device_details *d_details;
965 struct urb *this_urb;
967 p_priv = usb_get_serial_port_data(port);
968 d_details = p_priv->device_details;
971 if (d_details->msg_format == msg_usa90)
976 flip = p_priv->out_flip;
978 /* Check both endpoints to see if any are available. */
979 this_urb = p_priv->out_urbs[flip];
980 if (this_urb != NULL) {
981 if (this_urb->status != -EINPROGRESS)
983 flip = (flip + 1) & d_details->outdat_endp_flip;
984 this_urb = p_priv->out_urbs[flip];
985 if (this_urb != NULL) {
986 if (this_urb->status != -EINPROGRESS)
994 static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
996 struct keyspan_port_private *p_priv;
997 const struct keyspan_device_details *d_details;
999 int baud_rate, device_port;
1001 unsigned int cflag = 0;
1003 p_priv = usb_get_serial_port_data(port);
1004 d_details = p_priv->device_details;
1006 /* Set some sane defaults */
1007 p_priv->rts_state = 1;
1008 p_priv->dtr_state = 1;
1009 p_priv->baud = 9600;
1011 /* force baud and lcr to be set on open */
1012 p_priv->old_baud = 0;
1013 p_priv->old_cflag = 0;
1015 p_priv->out_flip = 0;
1016 p_priv->in_flip = 0;
1018 /* Reset low level data toggle and start reading from endpoints */
1019 for (i = 0; i < 2; i++) {
1020 urb = p_priv->in_urbs[i];
1024 /* make sure endpoint data toggle is synchronized
1026 usb_clear_halt(urb->dev, urb->pipe);
1027 err = usb_submit_urb(urb, GFP_KERNEL);
1029 dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err);
1032 /* Reset low level data toggle on out endpoints */
1033 for (i = 0; i < 2; i++) {
1034 urb = p_priv->out_urbs[i];
1037 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
1038 usb_pipeout(urb->pipe), 0); */
1041 /* get the terminal config for the setup message now so we don't
1042 * need to send 2 of them */
1044 device_port = port->port_number;
1046 cflag = tty->termios.c_cflag;
1047 /* Baud rate calculation takes baud rate as an integer
1048 so other rates can be generated if desired. */
1049 baud_rate = tty_get_baud_rate(tty);
1050 /* If no match or invalid, leave as default */
1052 && d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
1053 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1054 p_priv->baud = baud_rate;
1057 /* set CTS/RTS handshake etc. */
1058 p_priv->cflag = cflag;
1059 p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
1061 keyspan_send_setup(port, 1);
1063 /* keyspan_set_termios(port, NULL); */
1068 static inline void stop_urb(struct urb *urb)
1070 if (urb && urb->status == -EINPROGRESS)
1074 static void keyspan_dtr_rts(struct usb_serial_port *port, int on)
1076 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
1078 p_priv->rts_state = on;
1079 p_priv->dtr_state = on;
1080 keyspan_send_setup(port, 0);
1083 static void keyspan_close(struct usb_serial_port *port)
1086 struct keyspan_port_private *p_priv;
1088 p_priv = usb_get_serial_port_data(port);
1090 p_priv->rts_state = 0;
1091 p_priv->dtr_state = 0;
1093 keyspan_send_setup(port, 2);
1094 /* pilot-xfer seems to work best with this delay */
1097 p_priv->out_flip = 0;
1098 p_priv->in_flip = 0;
1100 stop_urb(p_priv->inack_urb);
1101 for (i = 0; i < 2; i++) {
1102 stop_urb(p_priv->in_urbs[i]);
1103 stop_urb(p_priv->out_urbs[i]);
1107 /* download the firmware to a pre-renumeration device */
1108 static int keyspan_fake_startup(struct usb_serial *serial)
1112 dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n",
1113 le16_to_cpu(serial->dev->descriptor.bcdDevice),
1114 le16_to_cpu(serial->dev->descriptor.idProduct));
1116 if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
1118 dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n");
1122 /* Select firmware image on the basis of idProduct */
1123 switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
1124 case keyspan_usa28_pre_product_id:
1125 fw_name = "keyspan/usa28.fw";
1128 case keyspan_usa28x_pre_product_id:
1129 fw_name = "keyspan/usa28x.fw";
1132 case keyspan_usa28xa_pre_product_id:
1133 fw_name = "keyspan/usa28xa.fw";
1136 case keyspan_usa28xb_pre_product_id:
1137 fw_name = "keyspan/usa28xb.fw";
1140 case keyspan_usa19_pre_product_id:
1141 fw_name = "keyspan/usa19.fw";
1144 case keyspan_usa19qi_pre_product_id:
1145 fw_name = "keyspan/usa19qi.fw";
1148 case keyspan_mpr_pre_product_id:
1149 fw_name = "keyspan/mpr.fw";
1152 case keyspan_usa19qw_pre_product_id:
1153 fw_name = "keyspan/usa19qw.fw";
1156 case keyspan_usa18x_pre_product_id:
1157 fw_name = "keyspan/usa18x.fw";
1160 case keyspan_usa19w_pre_product_id:
1161 fw_name = "keyspan/usa19w.fw";
1164 case keyspan_usa49w_pre_product_id:
1165 fw_name = "keyspan/usa49w.fw";
1168 case keyspan_usa49wlc_pre_product_id:
1169 fw_name = "keyspan/usa49wlc.fw";
1173 dev_err(&serial->dev->dev, "Unknown product ID (%04x)\n",
1174 le16_to_cpu(serial->dev->descriptor.idProduct));
1178 dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
1180 if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
1181 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
1186 /* after downloading firmware Renumeration will occur in a
1187 moment and the new device will bind to the real driver */
1189 /* we don't want this device to have a driver assigned to it. */
1193 /* Helper functions used by keyspan_setup_urbs */
1194 static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *serial,
1197 struct usb_host_interface *iface_desc;
1198 struct usb_endpoint_descriptor *ep;
1201 iface_desc = serial->interface->cur_altsetting;
1202 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
1203 ep = &iface_desc->endpoint[i].desc;
1204 if (ep->bEndpointAddress == endpoint)
1207 dev_warn(&serial->interface->dev, "found no endpoint descriptor for "
1208 "endpoint %x\n", endpoint);
1212 static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1213 int dir, void *ctx, char *buf, int len,
1214 void (*callback)(struct urb *))
1217 struct usb_endpoint_descriptor const *ep_desc;
1218 char const *ep_type_name;
1221 return NULL; /* endpoint not needed */
1223 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d.\n", __func__, endpoint);
1224 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
1226 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d failed.\n", __func__, endpoint);
1230 if (endpoint == 0) {
1231 /* control EP filled in when used */
1235 ep_desc = find_ep(serial, endpoint);
1237 /* leak the urb, something's wrong and the callers don't care */
1240 if (usb_endpoint_xfer_int(ep_desc)) {
1241 ep_type_name = "INT";
1242 usb_fill_int_urb(urb, serial->dev,
1243 usb_sndintpipe(serial->dev, endpoint) | dir,
1244 buf, len, callback, ctx,
1245 ep_desc->bInterval);
1246 } else if (usb_endpoint_xfer_bulk(ep_desc)) {
1247 ep_type_name = "BULK";
1248 usb_fill_bulk_urb(urb, serial->dev,
1249 usb_sndbulkpipe(serial->dev, endpoint) | dir,
1250 buf, len, callback, ctx);
1252 dev_warn(&serial->interface->dev,
1253 "unsupported endpoint type %x\n",
1254 usb_endpoint_type(ep_desc));
1259 dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n",
1260 __func__, urb, ep_type_name, endpoint);
1264 static struct callbacks {
1265 void (*instat_callback)(struct urb *);
1266 void (*glocont_callback)(struct urb *);
1267 void (*indat_callback)(struct urb *);
1268 void (*outdat_callback)(struct urb *);
1269 void (*inack_callback)(struct urb *);
1270 void (*outcont_callback)(struct urb *);
1271 } keyspan_callbacks[] = {
1273 /* msg_usa26 callbacks */
1274 .instat_callback = usa26_instat_callback,
1275 .glocont_callback = usa26_glocont_callback,
1276 .indat_callback = usa26_indat_callback,
1277 .outdat_callback = usa2x_outdat_callback,
1278 .inack_callback = usa26_inack_callback,
1279 .outcont_callback = usa26_outcont_callback,
1281 /* msg_usa28 callbacks */
1282 .instat_callback = usa28_instat_callback,
1283 .glocont_callback = usa28_glocont_callback,
1284 .indat_callback = usa28_indat_callback,
1285 .outdat_callback = usa2x_outdat_callback,
1286 .inack_callback = usa28_inack_callback,
1287 .outcont_callback = usa28_outcont_callback,
1289 /* msg_usa49 callbacks */
1290 .instat_callback = usa49_instat_callback,
1291 .glocont_callback = usa49_glocont_callback,
1292 .indat_callback = usa49_indat_callback,
1293 .outdat_callback = usa2x_outdat_callback,
1294 .inack_callback = usa49_inack_callback,
1295 .outcont_callback = usa49_outcont_callback,
1297 /* msg_usa90 callbacks */
1298 .instat_callback = usa90_instat_callback,
1299 .glocont_callback = usa28_glocont_callback,
1300 .indat_callback = usa90_indat_callback,
1301 .outdat_callback = usa2x_outdat_callback,
1302 .inack_callback = usa28_inack_callback,
1303 .outcont_callback = usa90_outcont_callback,
1305 /* msg_usa67 callbacks */
1306 .instat_callback = usa67_instat_callback,
1307 .glocont_callback = usa67_glocont_callback,
1308 .indat_callback = usa26_indat_callback,
1309 .outdat_callback = usa2x_outdat_callback,
1310 .inack_callback = usa26_inack_callback,
1311 .outcont_callback = usa26_outcont_callback,
1315 /* Generic setup urbs function that uses
1316 data in device_details */
1317 static void keyspan_setup_urbs(struct usb_serial *serial)
1319 struct keyspan_serial_private *s_priv;
1320 const struct keyspan_device_details *d_details;
1321 struct callbacks *cback;
1323 s_priv = usb_get_serial_data(serial);
1324 d_details = s_priv->device_details;
1326 /* Setup values for the various callback routines */
1327 cback = &keyspan_callbacks[d_details->msg_format];
1329 /* Allocate and set up urbs for each one that is in use,
1330 starting with instat endpoints */
1331 s_priv->instat_urb = keyspan_setup_urb
1332 (serial, d_details->instat_endpoint, USB_DIR_IN,
1333 serial, s_priv->instat_buf, INSTAT_BUFLEN,
1334 cback->instat_callback);
1336 s_priv->indat_urb = keyspan_setup_urb
1337 (serial, d_details->indat_endpoint, USB_DIR_IN,
1338 serial, s_priv->indat_buf, INDAT49W_BUFLEN,
1339 usa49wg_indat_callback);
1341 s_priv->glocont_urb = keyspan_setup_urb
1342 (serial, d_details->glocont_endpoint, USB_DIR_OUT,
1343 serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
1344 cback->glocont_callback);
1347 /* usa19 function doesn't require prescaler */
1348 static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
1349 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1350 u8 *rate_low, u8 *prescaler, int portnum)
1352 u32 b16, /* baud rate times 16 (actual rate used internally) */
1354 cnt; /* inverse of divisor (programmed into 8051) */
1356 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1358 /* prevent divide by zero... */
1359 b16 = baud_rate * 16L;
1361 return KEYSPAN_INVALID_BAUD_RATE;
1362 /* Any "standard" rate over 57k6 is marginal on the USA-19
1363 as we run out of divisor resolution. */
1364 if (baud_rate > 57600)
1365 return KEYSPAN_INVALID_BAUD_RATE;
1367 /* calculate the divisor and the counter (its inverse) */
1368 div = baudclk / b16;
1370 return KEYSPAN_INVALID_BAUD_RATE;
1375 return KEYSPAN_INVALID_BAUD_RATE;
1377 /* return the counter values if non-null */
1379 *rate_low = (u8) (cnt & 0xff);
1381 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1382 if (rate_low && rate_hi)
1383 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1384 __func__, baud_rate, *rate_hi, *rate_low);
1385 return KEYSPAN_BAUD_RATE_OK;
1388 /* usa19hs function doesn't require prescaler */
1389 static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port,
1390 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1391 u8 *rate_low, u8 *prescaler, int portnum)
1393 u32 b16, /* baud rate times 16 (actual rate used internally) */
1396 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1398 /* prevent divide by zero... */
1399 b16 = baud_rate * 16L;
1401 return KEYSPAN_INVALID_BAUD_RATE;
1403 /* calculate the divisor */
1404 div = baudclk / b16;
1406 return KEYSPAN_INVALID_BAUD_RATE;
1409 return KEYSPAN_INVALID_BAUD_RATE;
1411 /* return the counter values if non-null */
1413 *rate_low = (u8) (div & 0xff);
1416 *rate_hi = (u8) ((div >> 8) & 0xff);
1418 if (rate_low && rate_hi)
1419 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1420 __func__, baud_rate, *rate_hi, *rate_low);
1422 return KEYSPAN_BAUD_RATE_OK;
1425 static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
1426 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1427 u8 *rate_low, u8 *prescaler, int portnum)
1429 u32 b16, /* baud rate times 16 (actual rate used internally) */
1430 clk, /* clock with 13/8 prescaler */
1431 div, /* divisor using 13/8 prescaler */
1432 res, /* resulting baud rate using 13/8 prescaler */
1433 diff, /* error using 13/8 prescaler */
1438 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1440 /* prevent divide by zero */
1441 b16 = baud_rate * 16L;
1443 return KEYSPAN_INVALID_BAUD_RATE;
1445 /* Calculate prescaler by trying them all and looking
1448 /* start with largest possible difference */
1449 smallest_diff = 0xffffffff;
1451 /* 0 is an invalid prescaler, used as a flag */
1454 for (i = 8; i <= 0xff; ++i) {
1455 clk = (baudclk * 8) / (u32) i;
1462 diff = (res > b16) ? (res-b16) : (b16-res);
1464 if (diff < smallest_diff) {
1466 smallest_diff = diff;
1470 if (best_prescaler == 0)
1471 return KEYSPAN_INVALID_BAUD_RATE;
1473 clk = (baudclk * 8) / (u32) best_prescaler;
1476 /* return the divisor and prescaler if non-null */
1478 *rate_low = (u8) (div & 0xff);
1480 *rate_hi = (u8) ((div >> 8) & 0xff);
1482 *prescaler = best_prescaler;
1483 /* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */
1485 return KEYSPAN_BAUD_RATE_OK;
1488 /* USA-28 supports different maximum baud rates on each port */
1489 static int keyspan_usa28_calc_baud(struct usb_serial_port *port,
1490 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1491 u8 *rate_low, u8 *prescaler, int portnum)
1493 u32 b16, /* baud rate times 16 (actual rate used internally) */
1495 cnt; /* inverse of divisor (programmed into 8051) */
1497 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1499 /* prevent divide by zero */
1500 b16 = baud_rate * 16L;
1502 return KEYSPAN_INVALID_BAUD_RATE;
1504 /* calculate the divisor and the counter (its inverse) */
1505 div = KEYSPAN_USA28_BAUDCLK / b16;
1507 return KEYSPAN_INVALID_BAUD_RATE;
1511 /* check for out of range, based on portnum,
1512 and return result */
1515 return KEYSPAN_INVALID_BAUD_RATE;
1519 return KEYSPAN_INVALID_BAUD_RATE;
1521 return KEYSPAN_INVALID_BAUD_RATE;
1524 /* return the counter values if not NULL
1525 (port 1 will ignore retHi) */
1527 *rate_low = (u8) (cnt & 0xff);
1529 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1530 dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate);
1531 return KEYSPAN_BAUD_RATE_OK;
1534 static int keyspan_usa26_send_setup(struct usb_serial *serial,
1535 struct usb_serial_port *port,
1538 struct keyspan_usa26_portControlMessage msg;
1539 struct keyspan_serial_private *s_priv;
1540 struct keyspan_port_private *p_priv;
1541 const struct keyspan_device_details *d_details;
1542 struct urb *this_urb;
1543 int device_port, err;
1545 dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port);
1547 s_priv = usb_get_serial_data(serial);
1548 p_priv = usb_get_serial_port_data(port);
1549 d_details = s_priv->device_details;
1550 device_port = port->port_number;
1552 this_urb = p_priv->outcont_urb;
1554 dev_dbg(&port->dev, "%s - endpoint %d\n", __func__, usb_pipeendpoint(this_urb->pipe));
1556 /* Make sure we have an urb then send the message */
1557 if (this_urb == NULL) {
1558 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1562 /* Save reset port val for resend.
1563 Don't overwrite resend for open/close condition. */
1564 if ((reset_port + 1) > p_priv->resend_cont)
1565 p_priv->resend_cont = reset_port + 1;
1566 if (this_urb->status == -EINPROGRESS) {
1567 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1572 memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
1574 /* Only set baud rate if it's changed */
1575 if (p_priv->old_baud != p_priv->baud) {
1576 p_priv->old_baud = p_priv->baud;
1577 msg.setClocking = 0xff;
1578 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1579 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1580 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1581 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1582 __func__, p_priv->baud);
1584 msg.baudHi = 125; /* Values for 9600 baud */
1587 msg.setPrescaler = 0xff;
1590 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
1591 switch (p_priv->cflag & CSIZE) {
1593 msg.lcr |= USA_DATABITS_5;
1596 msg.lcr |= USA_DATABITS_6;
1599 msg.lcr |= USA_DATABITS_7;
1602 msg.lcr |= USA_DATABITS_8;
1605 if (p_priv->cflag & PARENB) {
1606 /* note USA_PARITY_NONE == 0 */
1607 msg.lcr |= (p_priv->cflag & PARODD) ?
1608 USA_PARITY_ODD : USA_PARITY_EVEN;
1612 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1613 msg.xonFlowControl = 0;
1614 msg.setFlowControl = 0xff;
1615 msg.forwardingLength = 16;
1620 if (reset_port == 1) {
1629 msg.returnStatus = 0;
1630 msg.resetDataToggle = 0xff;
1634 else if (reset_port == 2) {
1643 msg.returnStatus = 0;
1644 msg.resetDataToggle = 0;
1647 /* Sending intermediate configs */
1649 msg._txOn = (!p_priv->break_on);
1652 msg.txBreak = (p_priv->break_on);
1657 msg.returnStatus = 0;
1658 msg.resetDataToggle = 0x0;
1661 /* Do handshaking outputs */
1662 msg.setTxTriState_setRts = 0xff;
1663 msg.txTriState_rts = p_priv->rts_state;
1665 msg.setHskoa_setDtr = 0xff;
1666 msg.hskoa_dtr = p_priv->dtr_state;
1668 p_priv->resend_cont = 0;
1669 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1671 /* send the data out the device on control endpoint */
1672 this_urb->transfer_buffer_length = sizeof(msg);
1674 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1676 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
1680 static int keyspan_usa28_send_setup(struct usb_serial *serial,
1681 struct usb_serial_port *port,
1684 struct keyspan_usa28_portControlMessage msg;
1685 struct keyspan_serial_private *s_priv;
1686 struct keyspan_port_private *p_priv;
1687 const struct keyspan_device_details *d_details;
1688 struct urb *this_urb;
1689 int device_port, err;
1691 s_priv = usb_get_serial_data(serial);
1692 p_priv = usb_get_serial_port_data(port);
1693 d_details = s_priv->device_details;
1694 device_port = port->port_number;
1696 /* only do something if we have a bulk out endpoint */
1697 this_urb = p_priv->outcont_urb;
1698 if (this_urb == NULL) {
1699 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1703 /* Save reset port val for resend.
1704 Don't overwrite resend for open/close condition. */
1705 if ((reset_port + 1) > p_priv->resend_cont)
1706 p_priv->resend_cont = reset_port + 1;
1707 if (this_urb->status == -EINPROGRESS) {
1708 dev_dbg(&port->dev, "%s already writing\n", __func__);
1713 memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
1715 msg.setBaudRate = 1;
1716 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1717 &msg.baudHi, &msg.baudLo, NULL,
1718 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1719 dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n",
1720 __func__, p_priv->baud);
1722 msg.baudHi = 0xb2; /* Values for 9600 baud */
1725 /* If parity is enabled, we must calculate it ourselves. */
1726 msg.parity = 0; /* XXX for now */
1728 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1729 msg.xonFlowControl = 0;
1731 /* Do handshaking outputs, DTR is inverted relative to RTS */
1732 msg.rts = p_priv->rts_state;
1733 msg.dtr = p_priv->dtr_state;
1735 msg.forwardingLength = 16;
1737 msg.breakThreshold = 45;
1741 /*msg.returnStatus = 1;
1742 msg.resetDataToggle = 0xff;*/
1744 if (reset_port == 1) {
1748 msg.txForceXoff = 0;
1754 msg.returnStatus = 0;
1755 msg.resetDataToggle = 0xff;
1758 else if (reset_port == 2) {
1762 msg.txForceXoff = 0;
1768 msg.returnStatus = 0;
1769 msg.resetDataToggle = 0;
1771 /* Sending intermediate configs */
1773 msg._txOn = (!p_priv->break_on);
1776 msg.txForceXoff = 0;
1777 msg.txBreak = (p_priv->break_on);
1782 msg.returnStatus = 0;
1783 msg.resetDataToggle = 0x0;
1786 p_priv->resend_cont = 0;
1787 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1789 /* send the data out the device on control endpoint */
1790 this_urb->transfer_buffer_length = sizeof(msg);
1792 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1794 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__);
1797 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) OK %d bytes\n", __func__,
1798 this_urb->transfer_buffer_length);
1805 static int keyspan_usa49_send_setup(struct usb_serial *serial,
1806 struct usb_serial_port *port,
1809 struct keyspan_usa49_portControlMessage msg;
1810 struct usb_ctrlrequest *dr = NULL;
1811 struct keyspan_serial_private *s_priv;
1812 struct keyspan_port_private *p_priv;
1813 const struct keyspan_device_details *d_details;
1814 struct urb *this_urb;
1815 int err, device_port;
1817 s_priv = usb_get_serial_data(serial);
1818 p_priv = usb_get_serial_port_data(port);
1819 d_details = s_priv->device_details;
1821 this_urb = s_priv->glocont_urb;
1823 /* Work out which port within the device is being setup */
1824 device_port = port->port_number;
1826 /* Make sure we have an urb then send the message */
1827 if (this_urb == NULL) {
1828 dev_dbg(&port->dev, "%s - oops no urb for port.\n", __func__);
1832 dev_dbg(&port->dev, "%s - endpoint %d (%d)\n",
1833 __func__, usb_pipeendpoint(this_urb->pipe), device_port);
1835 /* Save reset port val for resend.
1836 Don't overwrite resend for open/close condition. */
1837 if ((reset_port + 1) > p_priv->resend_cont)
1838 p_priv->resend_cont = reset_port + 1;
1840 if (this_urb->status == -EINPROGRESS) {
1841 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1846 memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));
1848 msg.portNumber = device_port;
1850 /* Only set baud rate if it's changed */
1851 if (p_priv->old_baud != p_priv->baud) {
1852 p_priv->old_baud = p_priv->baud;
1853 msg.setClocking = 0xff;
1854 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1855 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1856 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1857 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1858 __func__, p_priv->baud);
1860 msg.baudHi = 125; /* Values for 9600 baud */
1863 /* msg.setPrescaler = 0xff; */
1866 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
1867 switch (p_priv->cflag & CSIZE) {
1869 msg.lcr |= USA_DATABITS_5;
1872 msg.lcr |= USA_DATABITS_6;
1875 msg.lcr |= USA_DATABITS_7;
1878 msg.lcr |= USA_DATABITS_8;
1881 if (p_priv->cflag & PARENB) {
1882 /* note USA_PARITY_NONE == 0 */
1883 msg.lcr |= (p_priv->cflag & PARODD) ?
1884 USA_PARITY_ODD : USA_PARITY_EVEN;
1888 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1889 msg.xonFlowControl = 0;
1890 msg.setFlowControl = 0xff;
1892 msg.forwardingLength = 16;
1897 if (reset_port == 1) {
1906 msg.returnStatus = 0;
1907 msg.resetDataToggle = 0xff;
1909 msg.disablePort = 0;
1912 else if (reset_port == 2) {
1921 msg.returnStatus = 0;
1922 msg.resetDataToggle = 0;
1924 msg.disablePort = 1;
1926 /* Sending intermediate configs */
1928 msg._txOn = (!p_priv->break_on);
1931 msg.txBreak = (p_priv->break_on);
1936 msg.returnStatus = 0;
1937 msg.resetDataToggle = 0x0;
1939 msg.disablePort = 0;
1942 /* Do handshaking outputs */
1944 msg.rts = p_priv->rts_state;
1947 msg.dtr = p_priv->dtr_state;
1949 p_priv->resend_cont = 0;
1951 /* if the device is a 49wg, we send control message on usb
1954 if (d_details->product_id == keyspan_usa49wg_product_id) {
1955 dr = (void *)(s_priv->ctrl_buf);
1956 dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT;
1957 dr->bRequest = 0xB0; /* 49wg control message */;
1960 dr->wLength = cpu_to_le16(sizeof(msg));
1962 memcpy(s_priv->glocont_buf, &msg, sizeof(msg));
1964 usb_fill_control_urb(this_urb, serial->dev,
1965 usb_sndctrlpipe(serial->dev, 0),
1966 (unsigned char *)dr, s_priv->glocont_buf,
1967 sizeof(msg), usa49_glocont_callback, serial);
1970 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1972 /* send the data out the device on control endpoint */
1973 this_urb->transfer_buffer_length = sizeof(msg);
1975 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1977 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
1980 dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__,
1981 outcont_urb, this_urb->transfer_buffer_length,
1982 usb_pipeendpoint(this_urb->pipe));
1989 static int keyspan_usa90_send_setup(struct usb_serial *serial,
1990 struct usb_serial_port *port,
1993 struct keyspan_usa90_portControlMessage msg;
1994 struct keyspan_serial_private *s_priv;
1995 struct keyspan_port_private *p_priv;
1996 const struct keyspan_device_details *d_details;
1997 struct urb *this_urb;
2001 s_priv = usb_get_serial_data(serial);
2002 p_priv = usb_get_serial_port_data(port);
2003 d_details = s_priv->device_details;
2005 /* only do something if we have a bulk out endpoint */
2006 this_urb = p_priv->outcont_urb;
2007 if (this_urb == NULL) {
2008 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
2012 /* Save reset port val for resend.
2013 Don't overwrite resend for open/close condition. */
2014 if ((reset_port + 1) > p_priv->resend_cont)
2015 p_priv->resend_cont = reset_port + 1;
2016 if (this_urb->status == -EINPROGRESS) {
2017 dev_dbg(&port->dev, "%s already writing\n", __func__);
2022 memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));
2024 /* Only set baud rate if it's changed */
2025 if (p_priv->old_baud != p_priv->baud) {
2026 p_priv->old_baud = p_priv->baud;
2027 msg.setClocking = 0x01;
2028 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2029 &msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
2030 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2031 __func__, p_priv->baud);
2032 p_priv->baud = 9600;
2033 d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2034 &msg.baudHi, &msg.baudLo, &prescaler, 0);
2040 /* modes must always be correctly specified */
2041 if (p_priv->baud > 57600) {
2042 msg.rxMode = RXMODE_DMA;
2043 msg.txMode = TXMODE_DMA;
2045 msg.rxMode = RXMODE_BYHAND;
2046 msg.txMode = TXMODE_BYHAND;
2049 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
2050 switch (p_priv->cflag & CSIZE) {
2052 msg.lcr |= USA_DATABITS_5;
2055 msg.lcr |= USA_DATABITS_6;
2058 msg.lcr |= USA_DATABITS_7;
2061 msg.lcr |= USA_DATABITS_8;
2064 if (p_priv->cflag & PARENB) {
2065 /* note USA_PARITY_NONE == 0 */
2066 msg.lcr |= (p_priv->cflag & PARODD) ?
2067 USA_PARITY_ODD : USA_PARITY_EVEN;
2069 if (p_priv->old_cflag != p_priv->cflag) {
2070 p_priv->old_cflag = p_priv->cflag;
2074 if (p_priv->flow_control == flow_cts)
2075 msg.txFlowControl = TXFLOW_CTS;
2076 msg.setTxFlowControl = 0x01;
2077 msg.setRxFlowControl = 0x01;
2079 msg.rxForwardingLength = 16;
2080 msg.rxForwardingTimeout = 16;
2081 msg.txAckSetting = 0;
2086 if (reset_port == 1) {
2087 msg.portEnabled = 1;
2089 msg.txBreak = (p_priv->break_on);
2092 else if (reset_port == 2)
2093 msg.portEnabled = 0;
2094 /* Sending intermediate configs */
2096 msg.portEnabled = 1;
2097 msg.txBreak = (p_priv->break_on);
2100 /* Do handshaking outputs */
2102 msg.rts = p_priv->rts_state;
2105 msg.dtr = p_priv->dtr_state;
2107 p_priv->resend_cont = 0;
2108 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2110 /* send the data out the device on control endpoint */
2111 this_urb->transfer_buffer_length = sizeof(msg);
2113 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2115 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2119 static int keyspan_usa67_send_setup(struct usb_serial *serial,
2120 struct usb_serial_port *port,
2123 struct keyspan_usa67_portControlMessage msg;
2124 struct keyspan_serial_private *s_priv;
2125 struct keyspan_port_private *p_priv;
2126 const struct keyspan_device_details *d_details;
2127 struct urb *this_urb;
2128 int err, device_port;
2130 s_priv = usb_get_serial_data(serial);
2131 p_priv = usb_get_serial_port_data(port);
2132 d_details = s_priv->device_details;
2134 this_urb = s_priv->glocont_urb;
2136 /* Work out which port within the device is being setup */
2137 device_port = port->port_number;
2139 /* Make sure we have an urb then send the message */
2140 if (this_urb == NULL) {
2141 dev_dbg(&port->dev, "%s - oops no urb for port.\n", __func__);
2145 /* Save reset port val for resend.
2146 Don't overwrite resend for open/close condition. */
2147 if ((reset_port + 1) > p_priv->resend_cont)
2148 p_priv->resend_cont = reset_port + 1;
2149 if (this_urb->status == -EINPROGRESS) {
2150 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
2155 memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
2157 msg.port = device_port;
2159 /* Only set baud rate if it's changed */
2160 if (p_priv->old_baud != p_priv->baud) {
2161 p_priv->old_baud = p_priv->baud;
2162 msg.setClocking = 0xff;
2163 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2164 &msg.baudHi, &msg.baudLo, &msg.prescaler,
2165 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
2166 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2167 __func__, p_priv->baud);
2169 msg.baudHi = 125; /* Values for 9600 baud */
2172 msg.setPrescaler = 0xff;
2175 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
2176 switch (p_priv->cflag & CSIZE) {
2178 msg.lcr |= USA_DATABITS_5;
2181 msg.lcr |= USA_DATABITS_6;
2184 msg.lcr |= USA_DATABITS_7;
2187 msg.lcr |= USA_DATABITS_8;
2190 if (p_priv->cflag & PARENB) {
2191 /* note USA_PARITY_NONE == 0 */
2192 msg.lcr |= (p_priv->cflag & PARODD) ?
2193 USA_PARITY_ODD : USA_PARITY_EVEN;
2197 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
2198 msg.xonFlowControl = 0;
2199 msg.setFlowControl = 0xff;
2200 msg.forwardingLength = 16;
2204 if (reset_port == 1) {
2214 msg.returnStatus = 0;
2215 msg.resetDataToggle = 0xff;
2216 } else if (reset_port == 2) {
2226 msg.returnStatus = 0;
2227 msg.resetDataToggle = 0;
2229 /* Sending intermediate configs */
2230 msg._txOn = (!p_priv->break_on);
2233 msg.txBreak = (p_priv->break_on);
2238 msg.returnStatus = 0;
2239 msg.resetDataToggle = 0x0;
2242 /* Do handshaking outputs */
2243 msg.setTxTriState_setRts = 0xff;
2244 msg.txTriState_rts = p_priv->rts_state;
2246 msg.setHskoa_setDtr = 0xff;
2247 msg.hskoa_dtr = p_priv->dtr_state;
2249 p_priv->resend_cont = 0;
2251 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2253 /* send the data out the device on control endpoint */
2254 this_urb->transfer_buffer_length = sizeof(msg);
2256 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2258 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2262 static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
2264 struct usb_serial *serial = port->serial;
2265 struct keyspan_serial_private *s_priv;
2266 const struct keyspan_device_details *d_details;
2268 s_priv = usb_get_serial_data(serial);
2269 d_details = s_priv->device_details;
2271 switch (d_details->msg_format) {
2273 keyspan_usa26_send_setup(serial, port, reset_port);
2276 keyspan_usa28_send_setup(serial, port, reset_port);
2279 keyspan_usa49_send_setup(serial, port, reset_port);
2282 keyspan_usa90_send_setup(serial, port, reset_port);
2285 keyspan_usa67_send_setup(serial, port, reset_port);
2291 /* Gets called by the "real" driver (ie once firmware is loaded
2292 and renumeration has taken place. */
2293 static int keyspan_startup(struct usb_serial *serial)
2296 struct keyspan_serial_private *s_priv;
2297 const struct keyspan_device_details *d_details;
2299 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
2300 if (d_details->product_id ==
2301 le16_to_cpu(serial->dev->descriptor.idProduct))
2303 if (d_details == NULL) {
2304 dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
2305 __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
2309 /* Setup private data for serial driver */
2310 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
2312 dev_dbg(&serial->dev->dev, "%s - kmalloc for keyspan_serial_private failed.\n", __func__);
2316 s_priv->device_details = d_details;
2317 usb_set_serial_data(serial, s_priv);
2319 keyspan_setup_urbs(serial);
2321 if (s_priv->instat_urb != NULL) {
2322 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL);
2324 dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err);
2326 if (s_priv->indat_urb != NULL) {
2327 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL);
2329 dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err);
2335 static void keyspan_disconnect(struct usb_serial *serial)
2337 struct keyspan_serial_private *s_priv;
2339 s_priv = usb_get_serial_data(serial);
2341 stop_urb(s_priv->instat_urb);
2342 stop_urb(s_priv->glocont_urb);
2343 stop_urb(s_priv->indat_urb);
2346 static void keyspan_release(struct usb_serial *serial)
2348 struct keyspan_serial_private *s_priv;
2350 s_priv = usb_get_serial_data(serial);
2352 usb_free_urb(s_priv->instat_urb);
2353 usb_free_urb(s_priv->indat_urb);
2354 usb_free_urb(s_priv->glocont_urb);
2359 static int keyspan_port_probe(struct usb_serial_port *port)
2361 struct usb_serial *serial = port->serial;
2362 struct keyspan_serial_private *s_priv;
2363 struct keyspan_port_private *p_priv;
2364 const struct keyspan_device_details *d_details;
2365 struct callbacks *cback;
2370 s_priv = usb_get_serial_data(serial);
2371 d_details = s_priv->device_details;
2373 p_priv = kzalloc(sizeof(*p_priv), GFP_KERNEL);
2377 p_priv->device_details = d_details;
2379 /* Setup values for the various callback routines */
2380 cback = &keyspan_callbacks[d_details->msg_format];
2382 port_num = port->port_number;
2384 /* Do indat endpoints first, once for each flip */
2385 endp = d_details->indat_endpoints[port_num];
2386 for (i = 0; i <= d_details->indat_endp_flip; ++i, ++endp) {
2387 p_priv->in_urbs[i] = keyspan_setup_urb(serial, endp,
2389 p_priv->in_buffer[i], 64,
2390 cback->indat_callback);
2392 /* outdat endpoints also have flip */
2393 endp = d_details->outdat_endpoints[port_num];
2394 for (i = 0; i <= d_details->outdat_endp_flip; ++i, ++endp) {
2395 p_priv->out_urbs[i] = keyspan_setup_urb(serial, endp,
2397 p_priv->out_buffer[i], 64,
2398 cback->outdat_callback);
2400 /* inack endpoint */
2401 p_priv->inack_urb = keyspan_setup_urb(serial,
2402 d_details->inack_endpoints[port_num],
2404 p_priv->inack_buffer, 1,
2405 cback->inack_callback);
2406 /* outcont endpoint */
2407 p_priv->outcont_urb = keyspan_setup_urb(serial,
2408 d_details->outcont_endpoints[port_num],
2410 p_priv->outcont_buffer, 64,
2411 cback->outcont_callback);
2413 usb_set_serial_port_data(port, p_priv);
2418 static int keyspan_port_remove(struct usb_serial_port *port)
2420 struct keyspan_port_private *p_priv;
2423 p_priv = usb_get_serial_port_data(port);
2425 stop_urb(p_priv->inack_urb);
2426 stop_urb(p_priv->outcont_urb);
2427 for (i = 0; i < 2; i++) {
2428 stop_urb(p_priv->in_urbs[i]);
2429 stop_urb(p_priv->out_urbs[i]);
2432 usb_free_urb(p_priv->inack_urb);
2433 usb_free_urb(p_priv->outcont_urb);
2434 for (i = 0; i < 2; i++) {
2435 usb_free_urb(p_priv->in_urbs[i]);
2436 usb_free_urb(p_priv->out_urbs[i]);
2444 MODULE_AUTHOR(DRIVER_AUTHOR);
2445 MODULE_DESCRIPTION(DRIVER_DESC);
2446 MODULE_LICENSE("GPL");
2448 MODULE_FIRMWARE("keyspan/usa28.fw");
2449 MODULE_FIRMWARE("keyspan/usa28x.fw");
2450 MODULE_FIRMWARE("keyspan/usa28xa.fw");
2451 MODULE_FIRMWARE("keyspan/usa28xb.fw");
2452 MODULE_FIRMWARE("keyspan/usa19.fw");
2453 MODULE_FIRMWARE("keyspan/usa19qi.fw");
2454 MODULE_FIRMWARE("keyspan/mpr.fw");
2455 MODULE_FIRMWARE("keyspan/usa19qw.fw");
2456 MODULE_FIRMWARE("keyspan/usa18x.fw");
2457 MODULE_FIRMWARE("keyspan/usa19w.fw");
2458 MODULE_FIRMWARE("keyspan/usa49w.fw");
2459 MODULE_FIRMWARE("keyspan/usa49wlc.fw");