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->number - port->serial->minor;
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 - for port %d (%d chars), flip=%d\n",
238 __func__, port->number, count, p_priv->out_flip);
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) {
312 tty_insert_flip_char(&port->port, 0,
315 for (i = 1; i < urb->actual_length ; ++i)
316 tty_insert_flip_char(&port->port, data[i],
319 /* some bytes had errors, every byte has status */
320 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
321 for (i = 0; i + 1 < urb->actual_length; i += 2) {
323 int flag = TTY_NORMAL;
325 if (stat & RXERROR_OVERRUN) {
326 tty_insert_flip_char(&port->port, 0,
329 /* XXX should handle break (0x10) */
330 if (stat & RXERROR_PARITY)
332 else if (stat & RXERROR_FRAMING)
335 tty_insert_flip_char(&port->port, data[i+1],
339 tty_flip_buffer_push(&port->port);
342 /* Resubmit urb so we continue receiving */
343 err = usb_submit_urb(urb, GFP_ATOMIC);
345 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
348 /* Outdat handling is common for all devices */
349 static void usa2x_outdat_callback(struct urb *urb)
351 struct usb_serial_port *port;
352 struct keyspan_port_private *p_priv;
355 p_priv = usb_get_serial_port_data(port);
356 dev_dbg(&port->dev, "%s - urb %d\n", __func__, urb == p_priv->out_urbs[1]);
358 usb_serial_port_softint(port);
361 static void usa26_inack_callback(struct urb *urb)
365 static void usa26_outcont_callback(struct urb *urb)
367 struct usb_serial_port *port;
368 struct keyspan_port_private *p_priv;
371 p_priv = usb_get_serial_port_data(port);
373 if (p_priv->resend_cont) {
374 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
375 keyspan_usa26_send_setup(port->serial, port,
376 p_priv->resend_cont - 1);
380 static void usa26_instat_callback(struct urb *urb)
382 unsigned char *data = urb->transfer_buffer;
383 struct keyspan_usa26_portStatusMessage *msg;
384 struct usb_serial *serial;
385 struct usb_serial_port *port;
386 struct keyspan_port_private *p_priv;
387 int old_dcd_state, err;
388 int status = urb->status;
390 serial = urb->context;
393 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
396 if (urb->actual_length != 9) {
397 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
401 msg = (struct keyspan_usa26_portStatusMessage *)data;
404 dev_dbg(&urb->dev->dev,
405 "%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d",
406 __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr,
407 msg->ri, msg->_txOff, msg->_txXoff, msg->rxEnabled,
408 msg->controlResponse);
411 /* Now do something useful with the data */
414 /* Check port number from message and retrieve private data */
415 if (msg->port >= serial->num_ports) {
416 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
419 port = serial->port[msg->port];
420 p_priv = usb_get_serial_port_data(port);
424 /* Update handshaking pin state information */
425 old_dcd_state = p_priv->dcd_state;
426 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
427 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
428 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
429 p_priv->ri_state = ((msg->ri) ? 1 : 0);
431 if (old_dcd_state != p_priv->dcd_state)
432 tty_port_tty_hangup(&port->port, true);
434 /* Resubmit urb so we continue receiving */
435 err = usb_submit_urb(urb, GFP_ATOMIC);
437 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
441 static void usa26_glocont_callback(struct urb *urb)
446 static void usa28_indat_callback(struct urb *urb)
449 struct usb_serial_port *port;
451 struct keyspan_port_private *p_priv;
452 int status = urb->status;
455 p_priv = usb_get_serial_port_data(port);
456 data = urb->transfer_buffer;
458 if (urb != p_priv->in_urbs[p_priv->in_flip])
463 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
464 __func__, status, usb_pipeendpoint(urb->pipe));
469 p_priv = usb_get_serial_port_data(port);
470 data = urb->transfer_buffer;
472 if (urb->actual_length) {
473 tty_insert_flip_string(&port->port, data,
475 tty_flip_buffer_push(&port->port);
478 /* Resubmit urb so we continue receiving */
479 err = usb_submit_urb(urb, GFP_ATOMIC);
481 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n",
483 p_priv->in_flip ^= 1;
485 urb = p_priv->in_urbs[p_priv->in_flip];
486 } while (urb->status != -EINPROGRESS);
489 static void usa28_inack_callback(struct urb *urb)
493 static void usa28_outcont_callback(struct urb *urb)
495 struct usb_serial_port *port;
496 struct keyspan_port_private *p_priv;
499 p_priv = usb_get_serial_port_data(port);
501 if (p_priv->resend_cont) {
502 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
503 keyspan_usa28_send_setup(port->serial, port,
504 p_priv->resend_cont - 1);
508 static void usa28_instat_callback(struct urb *urb)
511 unsigned char *data = urb->transfer_buffer;
512 struct keyspan_usa28_portStatusMessage *msg;
513 struct usb_serial *serial;
514 struct usb_serial_port *port;
515 struct keyspan_port_private *p_priv;
517 int status = urb->status;
519 serial = urb->context;
522 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
526 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) {
527 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
532 dev_dbg(&urb->dev->dev,
533 "%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__,
534 data[0], data[1], data[2], data[3], data[4], data[5],
535 data[6], data[7], data[8], data[9], data[10], data[11]);
538 /* Now do something useful with the data */
539 msg = (struct keyspan_usa28_portStatusMessage *)data;
541 /* Check port number from message and retrieve private data */
542 if (msg->port >= serial->num_ports) {
543 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
546 port = serial->port[msg->port];
547 p_priv = usb_get_serial_port_data(port);
551 /* Update handshaking pin state information */
552 old_dcd_state = p_priv->dcd_state;
553 p_priv->cts_state = ((msg->cts) ? 1 : 0);
554 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
555 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
556 p_priv->ri_state = ((msg->ri) ? 1 : 0);
558 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
559 tty_port_tty_hangup(&port->port, true);
561 /* Resubmit urb so we continue receiving */
562 err = usb_submit_urb(urb, GFP_ATOMIC);
564 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
568 static void usa28_glocont_callback(struct urb *urb)
573 static void usa49_glocont_callback(struct urb *urb)
575 struct usb_serial *serial;
576 struct usb_serial_port *port;
577 struct keyspan_port_private *p_priv;
580 serial = urb->context;
581 for (i = 0; i < serial->num_ports; ++i) {
582 port = serial->port[i];
583 p_priv = usb_get_serial_port_data(port);
585 if (p_priv->resend_cont) {
586 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
587 keyspan_usa49_send_setup(serial, port,
588 p_priv->resend_cont - 1);
594 /* This is actually called glostat in the Keyspan
596 static void usa49_instat_callback(struct urb *urb)
599 unsigned char *data = urb->transfer_buffer;
600 struct keyspan_usa49_portStatusMessage *msg;
601 struct usb_serial *serial;
602 struct usb_serial_port *port;
603 struct keyspan_port_private *p_priv;
605 int status = urb->status;
607 serial = urb->context;
610 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
614 if (urb->actual_length !=
615 sizeof(struct keyspan_usa49_portStatusMessage)) {
616 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
621 dev_dbg(&urb->dev->dev, "%s: %x %x %x %x %x %x %x %x %x %x %x",
622 __func__, data[0], data[1], data[2], data[3], data[4],
623 data[5], data[6], data[7], data[8], data[9], data[10]);
626 /* Now do something useful with the data */
627 msg = (struct keyspan_usa49_portStatusMessage *)data;
629 /* Check port number from message and retrieve private data */
630 if (msg->portNumber >= serial->num_ports) {
631 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
632 __func__, msg->portNumber);
635 port = serial->port[msg->portNumber];
636 p_priv = usb_get_serial_port_data(port);
640 /* Update handshaking pin state information */
641 old_dcd_state = p_priv->dcd_state;
642 p_priv->cts_state = ((msg->cts) ? 1 : 0);
643 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
644 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
645 p_priv->ri_state = ((msg->ri) ? 1 : 0);
647 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
648 tty_port_tty_hangup(&port->port, true);
650 /* Resubmit urb so we continue receiving */
651 err = usb_submit_urb(urb, GFP_ATOMIC);
653 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
657 static void usa49_inack_callback(struct urb *urb)
661 static void usa49_indat_callback(struct urb *urb)
665 struct usb_serial_port *port;
666 unsigned char *data = urb->transfer_buffer;
667 int status = urb->status;
669 endpoint = usb_pipeendpoint(urb->pipe);
672 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
673 __func__, status, endpoint);
678 if (urb->actual_length) {
679 /* 0x80 bit is error flag */
680 if ((data[0] & 0x80) == 0) {
681 /* no error on any byte */
682 tty_insert_flip_string(&port->port, data + 1,
683 urb->actual_length - 1);
685 /* some bytes had errors, every byte has status */
686 for (i = 0; i + 1 < urb->actual_length; i += 2) {
688 int flag = TTY_NORMAL;
690 if (stat & RXERROR_OVERRUN) {
691 tty_insert_flip_char(&port->port, 0,
694 /* XXX should handle break (0x10) */
695 if (stat & RXERROR_PARITY)
697 else if (stat & RXERROR_FRAMING)
700 tty_insert_flip_char(&port->port, data[i+1],
704 tty_flip_buffer_push(&port->port);
707 /* Resubmit urb so we continue receiving */
708 err = usb_submit_urb(urb, GFP_ATOMIC);
710 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
713 static void usa49wg_indat_callback(struct urb *urb)
716 struct usb_serial *serial;
717 struct usb_serial_port *port;
718 unsigned char *data = urb->transfer_buffer;
719 int status = urb->status;
721 serial = urb->context;
724 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
728 /* inbound data is in the form P#, len, status, data */
732 while (i < urb->actual_length) {
734 /* Check port number from message */
735 if (data[i] >= serial->num_ports) {
736 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
740 port = serial->port[data[i++]];
743 /* 0x80 bit is error flag */
744 if ((data[i] & 0x80) == 0) {
745 /* no error on any byte */
747 for (x = 1; x < len && i < urb->actual_length; ++x)
748 tty_insert_flip_char(&port->port,
752 * some bytes had errors, every byte has status
754 for (x = 0; x + 1 < len &&
755 i + 1 < urb->actual_length; x += 2) {
757 int flag = TTY_NORMAL;
759 if (stat & RXERROR_OVERRUN) {
760 tty_insert_flip_char(&port->port, 0,
763 /* XXX should handle break (0x10) */
764 if (stat & RXERROR_PARITY)
766 else if (stat & RXERROR_FRAMING)
769 tty_insert_flip_char(&port->port, data[i+1],
774 tty_flip_buffer_push(&port->port);
777 /* Resubmit urb so we continue receiving */
778 err = usb_submit_urb(urb, GFP_ATOMIC);
780 dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
783 /* not used, usa-49 doesn't have per-port control endpoints */
784 static void usa49_outcont_callback(struct urb *urb)
788 static void usa90_indat_callback(struct urb *urb)
792 struct usb_serial_port *port;
793 struct keyspan_port_private *p_priv;
794 unsigned char *data = urb->transfer_buffer;
795 int status = urb->status;
797 endpoint = usb_pipeendpoint(urb->pipe);
800 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
801 __func__, status, endpoint);
806 p_priv = usb_get_serial_port_data(port);
808 if (urb->actual_length) {
809 /* if current mode is DMA, looks like usa28 format
810 otherwise looks like usa26 data format */
812 if (p_priv->baud > 57600)
813 tty_insert_flip_string(&port->port, data,
816 /* 0x80 bit is error flag */
817 if ((data[0] & 0x80) == 0) {
818 /* no errors on individual bytes, only
819 possible overrun err*/
820 if (data[0] & RXERROR_OVERRUN) {
821 tty_insert_flip_char(&port->port, 0,
824 for (i = 1; i < urb->actual_length ; ++i)
825 tty_insert_flip_char(&port->port,
826 data[i], TTY_NORMAL);
828 /* some bytes had errors, every byte has status */
829 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
830 for (i = 0; i + 1 < urb->actual_length; i += 2) {
832 int flag = TTY_NORMAL;
834 if (stat & RXERROR_OVERRUN) {
835 tty_insert_flip_char(
839 /* XXX should handle break (0x10) */
840 if (stat & RXERROR_PARITY)
842 else if (stat & RXERROR_FRAMING)
845 tty_insert_flip_char(&port->port,
850 tty_flip_buffer_push(&port->port);
853 /* Resubmit urb so we continue receiving */
854 err = usb_submit_urb(urb, GFP_ATOMIC);
856 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
860 static void usa90_instat_callback(struct urb *urb)
862 unsigned char *data = urb->transfer_buffer;
863 struct keyspan_usa90_portStatusMessage *msg;
864 struct usb_serial *serial;
865 struct usb_serial_port *port;
866 struct keyspan_port_private *p_priv;
867 int old_dcd_state, err;
868 int status = urb->status;
870 serial = urb->context;
873 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
876 if (urb->actual_length < 14) {
877 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
881 msg = (struct keyspan_usa90_portStatusMessage *)data;
883 /* Now do something useful with the data */
885 port = serial->port[0];
886 p_priv = usb_get_serial_port_data(port);
890 /* Update handshaking pin state information */
891 old_dcd_state = p_priv->dcd_state;
892 p_priv->cts_state = ((msg->cts) ? 1 : 0);
893 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
894 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
895 p_priv->ri_state = ((msg->ri) ? 1 : 0);
897 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
898 tty_port_tty_hangup(&port->port, true);
900 /* Resubmit urb so we continue receiving */
901 err = usb_submit_urb(urb, GFP_ATOMIC);
903 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
908 static void usa90_outcont_callback(struct urb *urb)
910 struct usb_serial_port *port;
911 struct keyspan_port_private *p_priv;
914 p_priv = usb_get_serial_port_data(port);
916 if (p_priv->resend_cont) {
917 dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__);
918 keyspan_usa90_send_setup(port->serial, port,
919 p_priv->resend_cont - 1);
923 /* Status messages from the 28xg */
924 static void usa67_instat_callback(struct urb *urb)
927 unsigned char *data = urb->transfer_buffer;
928 struct keyspan_usa67_portStatusMessage *msg;
929 struct usb_serial *serial;
930 struct usb_serial_port *port;
931 struct keyspan_port_private *p_priv;
933 int status = urb->status;
935 serial = urb->context;
938 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
942 if (urb->actual_length !=
943 sizeof(struct keyspan_usa67_portStatusMessage)) {
944 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
949 /* Now do something useful with the data */
950 msg = (struct keyspan_usa67_portStatusMessage *)data;
952 /* Check port number from message and retrieve private data */
953 if (msg->port >= serial->num_ports) {
954 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
958 port = serial->port[msg->port];
959 p_priv = usb_get_serial_port_data(port);
963 /* Update handshaking pin state information */
964 old_dcd_state = p_priv->dcd_state;
965 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
966 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
968 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
969 tty_port_tty_hangup(&port->port, true);
971 /* Resubmit urb so we continue receiving */
972 err = usb_submit_urb(urb, GFP_ATOMIC);
974 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
977 static void usa67_glocont_callback(struct urb *urb)
979 struct usb_serial *serial;
980 struct usb_serial_port *port;
981 struct keyspan_port_private *p_priv;
984 serial = urb->context;
985 for (i = 0; i < serial->num_ports; ++i) {
986 port = serial->port[i];
987 p_priv = usb_get_serial_port_data(port);
989 if (p_priv->resend_cont) {
990 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
991 keyspan_usa67_send_setup(serial, port,
992 p_priv->resend_cont - 1);
998 static int keyspan_write_room(struct tty_struct *tty)
1000 struct usb_serial_port *port = tty->driver_data;
1001 struct keyspan_port_private *p_priv;
1002 const struct keyspan_device_details *d_details;
1005 struct urb *this_urb;
1007 p_priv = usb_get_serial_port_data(port);
1008 d_details = p_priv->device_details;
1010 /* FIXME: locking */
1011 if (d_details->msg_format == msg_usa90)
1016 flip = p_priv->out_flip;
1018 /* Check both endpoints to see if any are available. */
1019 this_urb = p_priv->out_urbs[flip];
1020 if (this_urb != NULL) {
1021 if (this_urb->status != -EINPROGRESS)
1023 flip = (flip + 1) & d_details->outdat_endp_flip;
1024 this_urb = p_priv->out_urbs[flip];
1025 if (this_urb != NULL) {
1026 if (this_urb->status != -EINPROGRESS)
1034 static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
1036 struct keyspan_port_private *p_priv;
1037 const struct keyspan_device_details *d_details;
1039 int baud_rate, device_port;
1041 unsigned int cflag = 0;
1043 p_priv = usb_get_serial_port_data(port);
1044 d_details = p_priv->device_details;
1046 /* Set some sane defaults */
1047 p_priv->rts_state = 1;
1048 p_priv->dtr_state = 1;
1049 p_priv->baud = 9600;
1051 /* force baud and lcr to be set on open */
1052 p_priv->old_baud = 0;
1053 p_priv->old_cflag = 0;
1055 p_priv->out_flip = 0;
1056 p_priv->in_flip = 0;
1058 /* Reset low level data toggle and start reading from endpoints */
1059 for (i = 0; i < 2; i++) {
1060 urb = p_priv->in_urbs[i];
1064 /* make sure endpoint data toggle is synchronized
1066 usb_clear_halt(urb->dev, urb->pipe);
1067 err = usb_submit_urb(urb, GFP_KERNEL);
1069 dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err);
1072 /* Reset low level data toggle on out endpoints */
1073 for (i = 0; i < 2; i++) {
1074 urb = p_priv->out_urbs[i];
1077 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
1078 usb_pipeout(urb->pipe), 0); */
1081 /* get the terminal config for the setup message now so we don't
1082 * need to send 2 of them */
1084 device_port = port->number - port->serial->minor;
1086 cflag = tty->termios.c_cflag;
1087 /* Baud rate calculation takes baud rate as an integer
1088 so other rates can be generated if desired. */
1089 baud_rate = tty_get_baud_rate(tty);
1090 /* If no match or invalid, leave as default */
1092 && d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
1093 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1094 p_priv->baud = baud_rate;
1097 /* set CTS/RTS handshake etc. */
1098 p_priv->cflag = cflag;
1099 p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
1101 keyspan_send_setup(port, 1);
1103 /* keyspan_set_termios(port, NULL); */
1108 static inline void stop_urb(struct urb *urb)
1110 if (urb && urb->status == -EINPROGRESS)
1114 static void keyspan_dtr_rts(struct usb_serial_port *port, int on)
1116 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
1118 p_priv->rts_state = on;
1119 p_priv->dtr_state = on;
1120 keyspan_send_setup(port, 0);
1123 static void keyspan_close(struct usb_serial_port *port)
1126 struct keyspan_port_private *p_priv;
1128 p_priv = usb_get_serial_port_data(port);
1130 p_priv->rts_state = 0;
1131 p_priv->dtr_state = 0;
1133 keyspan_send_setup(port, 2);
1134 /* pilot-xfer seems to work best with this delay */
1137 p_priv->out_flip = 0;
1138 p_priv->in_flip = 0;
1140 stop_urb(p_priv->inack_urb);
1141 for (i = 0; i < 2; i++) {
1142 stop_urb(p_priv->in_urbs[i]);
1143 stop_urb(p_priv->out_urbs[i]);
1147 /* download the firmware to a pre-renumeration device */
1148 static int keyspan_fake_startup(struct usb_serial *serial)
1152 dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n",
1153 le16_to_cpu(serial->dev->descriptor.bcdDevice),
1154 le16_to_cpu(serial->dev->descriptor.idProduct));
1156 if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
1158 dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n");
1162 /* Select firmware image on the basis of idProduct */
1163 switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
1164 case keyspan_usa28_pre_product_id:
1165 fw_name = "keyspan/usa28.fw";
1168 case keyspan_usa28x_pre_product_id:
1169 fw_name = "keyspan/usa28x.fw";
1172 case keyspan_usa28xa_pre_product_id:
1173 fw_name = "keyspan/usa28xa.fw";
1176 case keyspan_usa28xb_pre_product_id:
1177 fw_name = "keyspan/usa28xb.fw";
1180 case keyspan_usa19_pre_product_id:
1181 fw_name = "keyspan/usa19.fw";
1184 case keyspan_usa19qi_pre_product_id:
1185 fw_name = "keyspan/usa19qi.fw";
1188 case keyspan_mpr_pre_product_id:
1189 fw_name = "keyspan/mpr.fw";
1192 case keyspan_usa19qw_pre_product_id:
1193 fw_name = "keyspan/usa19qw.fw";
1196 case keyspan_usa18x_pre_product_id:
1197 fw_name = "keyspan/usa18x.fw";
1200 case keyspan_usa19w_pre_product_id:
1201 fw_name = "keyspan/usa19w.fw";
1204 case keyspan_usa49w_pre_product_id:
1205 fw_name = "keyspan/usa49w.fw";
1208 case keyspan_usa49wlc_pre_product_id:
1209 fw_name = "keyspan/usa49wlc.fw";
1213 dev_err(&serial->dev->dev, "Unknown product ID (%04x)\n",
1214 le16_to_cpu(serial->dev->descriptor.idProduct));
1218 dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
1220 if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
1221 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
1226 /* after downloading firmware Renumeration will occur in a
1227 moment and the new device will bind to the real driver */
1229 /* we don't want this device to have a driver assigned to it. */
1233 /* Helper functions used by keyspan_setup_urbs */
1234 static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *serial,
1237 struct usb_host_interface *iface_desc;
1238 struct usb_endpoint_descriptor *ep;
1241 iface_desc = serial->interface->cur_altsetting;
1242 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
1243 ep = &iface_desc->endpoint[i].desc;
1244 if (ep->bEndpointAddress == endpoint)
1247 dev_warn(&serial->interface->dev, "found no endpoint descriptor for "
1248 "endpoint %x\n", endpoint);
1252 static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1253 int dir, void *ctx, char *buf, int len,
1254 void (*callback)(struct urb *))
1257 struct usb_endpoint_descriptor const *ep_desc;
1258 char const *ep_type_name;
1261 return NULL; /* endpoint not needed */
1263 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d.\n", __func__, endpoint);
1264 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
1266 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d failed.\n", __func__, endpoint);
1270 if (endpoint == 0) {
1271 /* control EP filled in when used */
1275 ep_desc = find_ep(serial, endpoint);
1277 /* leak the urb, something's wrong and the callers don't care */
1280 if (usb_endpoint_xfer_int(ep_desc)) {
1281 ep_type_name = "INT";
1282 usb_fill_int_urb(urb, serial->dev,
1283 usb_sndintpipe(serial->dev, endpoint) | dir,
1284 buf, len, callback, ctx,
1285 ep_desc->bInterval);
1286 } else if (usb_endpoint_xfer_bulk(ep_desc)) {
1287 ep_type_name = "BULK";
1288 usb_fill_bulk_urb(urb, serial->dev,
1289 usb_sndbulkpipe(serial->dev, endpoint) | dir,
1290 buf, len, callback, ctx);
1292 dev_warn(&serial->interface->dev,
1293 "unsupported endpoint type %x\n",
1294 usb_endpoint_type(ep_desc));
1299 dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n",
1300 __func__, urb, ep_type_name, endpoint);
1304 static struct callbacks {
1305 void (*instat_callback)(struct urb *);
1306 void (*glocont_callback)(struct urb *);
1307 void (*indat_callback)(struct urb *);
1308 void (*outdat_callback)(struct urb *);
1309 void (*inack_callback)(struct urb *);
1310 void (*outcont_callback)(struct urb *);
1311 } keyspan_callbacks[] = {
1313 /* msg_usa26 callbacks */
1314 .instat_callback = usa26_instat_callback,
1315 .glocont_callback = usa26_glocont_callback,
1316 .indat_callback = usa26_indat_callback,
1317 .outdat_callback = usa2x_outdat_callback,
1318 .inack_callback = usa26_inack_callback,
1319 .outcont_callback = usa26_outcont_callback,
1321 /* msg_usa28 callbacks */
1322 .instat_callback = usa28_instat_callback,
1323 .glocont_callback = usa28_glocont_callback,
1324 .indat_callback = usa28_indat_callback,
1325 .outdat_callback = usa2x_outdat_callback,
1326 .inack_callback = usa28_inack_callback,
1327 .outcont_callback = usa28_outcont_callback,
1329 /* msg_usa49 callbacks */
1330 .instat_callback = usa49_instat_callback,
1331 .glocont_callback = usa49_glocont_callback,
1332 .indat_callback = usa49_indat_callback,
1333 .outdat_callback = usa2x_outdat_callback,
1334 .inack_callback = usa49_inack_callback,
1335 .outcont_callback = usa49_outcont_callback,
1337 /* msg_usa90 callbacks */
1338 .instat_callback = usa90_instat_callback,
1339 .glocont_callback = usa28_glocont_callback,
1340 .indat_callback = usa90_indat_callback,
1341 .outdat_callback = usa2x_outdat_callback,
1342 .inack_callback = usa28_inack_callback,
1343 .outcont_callback = usa90_outcont_callback,
1345 /* msg_usa67 callbacks */
1346 .instat_callback = usa67_instat_callback,
1347 .glocont_callback = usa67_glocont_callback,
1348 .indat_callback = usa26_indat_callback,
1349 .outdat_callback = usa2x_outdat_callback,
1350 .inack_callback = usa26_inack_callback,
1351 .outcont_callback = usa26_outcont_callback,
1355 /* Generic setup urbs function that uses
1356 data in device_details */
1357 static void keyspan_setup_urbs(struct usb_serial *serial)
1359 struct keyspan_serial_private *s_priv;
1360 const struct keyspan_device_details *d_details;
1361 struct callbacks *cback;
1363 s_priv = usb_get_serial_data(serial);
1364 d_details = s_priv->device_details;
1366 /* Setup values for the various callback routines */
1367 cback = &keyspan_callbacks[d_details->msg_format];
1369 /* Allocate and set up urbs for each one that is in use,
1370 starting with instat endpoints */
1371 s_priv->instat_urb = keyspan_setup_urb
1372 (serial, d_details->instat_endpoint, USB_DIR_IN,
1373 serial, s_priv->instat_buf, INSTAT_BUFLEN,
1374 cback->instat_callback);
1376 s_priv->indat_urb = keyspan_setup_urb
1377 (serial, d_details->indat_endpoint, USB_DIR_IN,
1378 serial, s_priv->indat_buf, INDAT49W_BUFLEN,
1379 usa49wg_indat_callback);
1381 s_priv->glocont_urb = keyspan_setup_urb
1382 (serial, d_details->glocont_endpoint, USB_DIR_OUT,
1383 serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
1384 cback->glocont_callback);
1387 /* usa19 function doesn't require prescaler */
1388 static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
1389 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1390 u8 *rate_low, u8 *prescaler, int portnum)
1392 u32 b16, /* baud rate times 16 (actual rate used internally) */
1394 cnt; /* inverse of divisor (programmed into 8051) */
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;
1402 /* Any "standard" rate over 57k6 is marginal on the USA-19
1403 as we run out of divisor resolution. */
1404 if (baud_rate > 57600)
1405 return KEYSPAN_INVALID_BAUD_RATE;
1407 /* calculate the divisor and the counter (its inverse) */
1408 div = baudclk / b16;
1410 return KEYSPAN_INVALID_BAUD_RATE;
1415 return KEYSPAN_INVALID_BAUD_RATE;
1417 /* return the counter values if non-null */
1419 *rate_low = (u8) (cnt & 0xff);
1421 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1422 if (rate_low && rate_hi)
1423 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1424 __func__, baud_rate, *rate_hi, *rate_low);
1425 return KEYSPAN_BAUD_RATE_OK;
1428 /* usa19hs function doesn't require prescaler */
1429 static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port,
1430 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1431 u8 *rate_low, u8 *prescaler, int portnum)
1433 u32 b16, /* baud rate times 16 (actual rate used internally) */
1436 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1438 /* prevent divide by zero... */
1439 b16 = baud_rate * 16L;
1441 return KEYSPAN_INVALID_BAUD_RATE;
1443 /* calculate the divisor */
1444 div = baudclk / b16;
1446 return KEYSPAN_INVALID_BAUD_RATE;
1449 return KEYSPAN_INVALID_BAUD_RATE;
1451 /* return the counter values if non-null */
1453 *rate_low = (u8) (div & 0xff);
1456 *rate_hi = (u8) ((div >> 8) & 0xff);
1458 if (rate_low && rate_hi)
1459 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1460 __func__, baud_rate, *rate_hi, *rate_low);
1462 return KEYSPAN_BAUD_RATE_OK;
1465 static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
1466 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1467 u8 *rate_low, u8 *prescaler, int portnum)
1469 u32 b16, /* baud rate times 16 (actual rate used internally) */
1470 clk, /* clock with 13/8 prescaler */
1471 div, /* divisor using 13/8 prescaler */
1472 res, /* resulting baud rate using 13/8 prescaler */
1473 diff, /* error using 13/8 prescaler */
1478 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1480 /* prevent divide by zero */
1481 b16 = baud_rate * 16L;
1483 return KEYSPAN_INVALID_BAUD_RATE;
1485 /* Calculate prescaler by trying them all and looking
1488 /* start with largest possible difference */
1489 smallest_diff = 0xffffffff;
1491 /* 0 is an invalid prescaler, used as a flag */
1494 for (i = 8; i <= 0xff; ++i) {
1495 clk = (baudclk * 8) / (u32) i;
1502 diff = (res > b16) ? (res-b16) : (b16-res);
1504 if (diff < smallest_diff) {
1506 smallest_diff = diff;
1510 if (best_prescaler == 0)
1511 return KEYSPAN_INVALID_BAUD_RATE;
1513 clk = (baudclk * 8) / (u32) best_prescaler;
1516 /* return the divisor and prescaler if non-null */
1518 *rate_low = (u8) (div & 0xff);
1520 *rate_hi = (u8) ((div >> 8) & 0xff);
1522 *prescaler = best_prescaler;
1523 /* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */
1525 return KEYSPAN_BAUD_RATE_OK;
1528 /* USA-28 supports different maximum baud rates on each port */
1529 static int keyspan_usa28_calc_baud(struct usb_serial_port *port,
1530 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1531 u8 *rate_low, u8 *prescaler, int portnum)
1533 u32 b16, /* baud rate times 16 (actual rate used internally) */
1535 cnt; /* inverse of divisor (programmed into 8051) */
1537 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1539 /* prevent divide by zero */
1540 b16 = baud_rate * 16L;
1542 return KEYSPAN_INVALID_BAUD_RATE;
1544 /* calculate the divisor and the counter (its inverse) */
1545 div = KEYSPAN_USA28_BAUDCLK / b16;
1547 return KEYSPAN_INVALID_BAUD_RATE;
1551 /* check for out of range, based on portnum,
1552 and return result */
1555 return KEYSPAN_INVALID_BAUD_RATE;
1559 return KEYSPAN_INVALID_BAUD_RATE;
1561 return KEYSPAN_INVALID_BAUD_RATE;
1564 /* return the counter values if not NULL
1565 (port 1 will ignore retHi) */
1567 *rate_low = (u8) (cnt & 0xff);
1569 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1570 dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate);
1571 return KEYSPAN_BAUD_RATE_OK;
1574 static int keyspan_usa26_send_setup(struct usb_serial *serial,
1575 struct usb_serial_port *port,
1578 struct keyspan_usa26_portControlMessage msg;
1579 struct keyspan_serial_private *s_priv;
1580 struct keyspan_port_private *p_priv;
1581 const struct keyspan_device_details *d_details;
1582 struct urb *this_urb;
1583 int device_port, err;
1585 dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port);
1587 s_priv = usb_get_serial_data(serial);
1588 p_priv = usb_get_serial_port_data(port);
1589 d_details = s_priv->device_details;
1590 device_port = port->number - port->serial->minor;
1592 this_urb = p_priv->outcont_urb;
1594 dev_dbg(&port->dev, "%s - endpoint %d\n", __func__, usb_pipeendpoint(this_urb->pipe));
1596 /* Make sure we have an urb then send the message */
1597 if (this_urb == NULL) {
1598 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1602 /* Save reset port val for resend.
1603 Don't overwrite resend for open/close condition. */
1604 if ((reset_port + 1) > p_priv->resend_cont)
1605 p_priv->resend_cont = reset_port + 1;
1606 if (this_urb->status == -EINPROGRESS) {
1607 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1612 memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
1614 /* Only set baud rate if it's changed */
1615 if (p_priv->old_baud != p_priv->baud) {
1616 p_priv->old_baud = p_priv->baud;
1617 msg.setClocking = 0xff;
1618 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1619 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1620 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1621 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1622 __func__, p_priv->baud);
1624 msg.baudHi = 125; /* Values for 9600 baud */
1627 msg.setPrescaler = 0xff;
1630 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
1631 switch (p_priv->cflag & CSIZE) {
1633 msg.lcr |= USA_DATABITS_5;
1636 msg.lcr |= USA_DATABITS_6;
1639 msg.lcr |= USA_DATABITS_7;
1642 msg.lcr |= USA_DATABITS_8;
1645 if (p_priv->cflag & PARENB) {
1646 /* note USA_PARITY_NONE == 0 */
1647 msg.lcr |= (p_priv->cflag & PARODD) ?
1648 USA_PARITY_ODD : USA_PARITY_EVEN;
1652 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1653 msg.xonFlowControl = 0;
1654 msg.setFlowControl = 0xff;
1655 msg.forwardingLength = 16;
1660 if (reset_port == 1) {
1669 msg.returnStatus = 0;
1670 msg.resetDataToggle = 0xff;
1674 else if (reset_port == 2) {
1683 msg.returnStatus = 0;
1684 msg.resetDataToggle = 0;
1687 /* Sending intermediate configs */
1689 msg._txOn = (!p_priv->break_on);
1692 msg.txBreak = (p_priv->break_on);
1697 msg.returnStatus = 0;
1698 msg.resetDataToggle = 0x0;
1701 /* Do handshaking outputs */
1702 msg.setTxTriState_setRts = 0xff;
1703 msg.txTriState_rts = p_priv->rts_state;
1705 msg.setHskoa_setDtr = 0xff;
1706 msg.hskoa_dtr = p_priv->dtr_state;
1708 p_priv->resend_cont = 0;
1709 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1711 /* send the data out the device on control endpoint */
1712 this_urb->transfer_buffer_length = sizeof(msg);
1714 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1716 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
1720 static int keyspan_usa28_send_setup(struct usb_serial *serial,
1721 struct usb_serial_port *port,
1724 struct keyspan_usa28_portControlMessage msg;
1725 struct keyspan_serial_private *s_priv;
1726 struct keyspan_port_private *p_priv;
1727 const struct keyspan_device_details *d_details;
1728 struct urb *this_urb;
1729 int device_port, err;
1731 s_priv = usb_get_serial_data(serial);
1732 p_priv = usb_get_serial_port_data(port);
1733 d_details = s_priv->device_details;
1734 device_port = port->number - port->serial->minor;
1736 /* only do something if we have a bulk out endpoint */
1737 this_urb = p_priv->outcont_urb;
1738 if (this_urb == NULL) {
1739 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1743 /* Save reset port val for resend.
1744 Don't overwrite resend for open/close condition. */
1745 if ((reset_port + 1) > p_priv->resend_cont)
1746 p_priv->resend_cont = reset_port + 1;
1747 if (this_urb->status == -EINPROGRESS) {
1748 dev_dbg(&port->dev, "%s already writing\n", __func__);
1753 memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
1755 msg.setBaudRate = 1;
1756 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1757 &msg.baudHi, &msg.baudLo, NULL,
1758 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1759 dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n",
1760 __func__, p_priv->baud);
1762 msg.baudHi = 0xb2; /* Values for 9600 baud */
1765 /* If parity is enabled, we must calculate it ourselves. */
1766 msg.parity = 0; /* XXX for now */
1768 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1769 msg.xonFlowControl = 0;
1771 /* Do handshaking outputs, DTR is inverted relative to RTS */
1772 msg.rts = p_priv->rts_state;
1773 msg.dtr = p_priv->dtr_state;
1775 msg.forwardingLength = 16;
1777 msg.breakThreshold = 45;
1781 /*msg.returnStatus = 1;
1782 msg.resetDataToggle = 0xff;*/
1784 if (reset_port == 1) {
1788 msg.txForceXoff = 0;
1794 msg.returnStatus = 0;
1795 msg.resetDataToggle = 0xff;
1798 else if (reset_port == 2) {
1802 msg.txForceXoff = 0;
1808 msg.returnStatus = 0;
1809 msg.resetDataToggle = 0;
1811 /* Sending intermediate configs */
1813 msg._txOn = (!p_priv->break_on);
1816 msg.txForceXoff = 0;
1817 msg.txBreak = (p_priv->break_on);
1822 msg.returnStatus = 0;
1823 msg.resetDataToggle = 0x0;
1826 p_priv->resend_cont = 0;
1827 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1829 /* send the data out the device on control endpoint */
1830 this_urb->transfer_buffer_length = sizeof(msg);
1832 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1834 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__);
1837 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) OK %d bytes\n", __func__,
1838 this_urb->transfer_buffer_length);
1845 static int keyspan_usa49_send_setup(struct usb_serial *serial,
1846 struct usb_serial_port *port,
1849 struct keyspan_usa49_portControlMessage msg;
1850 struct usb_ctrlrequest *dr = NULL;
1851 struct keyspan_serial_private *s_priv;
1852 struct keyspan_port_private *p_priv;
1853 const struct keyspan_device_details *d_details;
1854 struct urb *this_urb;
1855 int err, device_port;
1857 s_priv = usb_get_serial_data(serial);
1858 p_priv = usb_get_serial_port_data(port);
1859 d_details = s_priv->device_details;
1861 this_urb = s_priv->glocont_urb;
1863 /* Work out which port within the device is being setup */
1864 device_port = port->number - port->serial->minor;
1866 /* Make sure we have an urb then send the message */
1867 if (this_urb == NULL) {
1868 dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__, port->number);
1872 dev_dbg(&port->dev, "%s - endpoint %d port %d (%d)\n",
1873 __func__, usb_pipeendpoint(this_urb->pipe),
1874 port->number, device_port);
1876 /* Save reset port val for resend.
1877 Don't overwrite resend for open/close condition. */
1878 if ((reset_port + 1) > p_priv->resend_cont)
1879 p_priv->resend_cont = reset_port + 1;
1881 if (this_urb->status == -EINPROGRESS) {
1882 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1887 memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));
1889 /*msg.portNumber = port->number;*/
1890 msg.portNumber = device_port;
1892 /* Only set baud rate if it's changed */
1893 if (p_priv->old_baud != p_priv->baud) {
1894 p_priv->old_baud = p_priv->baud;
1895 msg.setClocking = 0xff;
1896 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1897 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1898 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1899 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1900 __func__, p_priv->baud);
1902 msg.baudHi = 125; /* Values for 9600 baud */
1905 /* msg.setPrescaler = 0xff; */
1908 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
1909 switch (p_priv->cflag & CSIZE) {
1911 msg.lcr |= USA_DATABITS_5;
1914 msg.lcr |= USA_DATABITS_6;
1917 msg.lcr |= USA_DATABITS_7;
1920 msg.lcr |= USA_DATABITS_8;
1923 if (p_priv->cflag & PARENB) {
1924 /* note USA_PARITY_NONE == 0 */
1925 msg.lcr |= (p_priv->cflag & PARODD) ?
1926 USA_PARITY_ODD : USA_PARITY_EVEN;
1930 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1931 msg.xonFlowControl = 0;
1932 msg.setFlowControl = 0xff;
1934 msg.forwardingLength = 16;
1939 if (reset_port == 1) {
1948 msg.returnStatus = 0;
1949 msg.resetDataToggle = 0xff;
1951 msg.disablePort = 0;
1954 else if (reset_port == 2) {
1963 msg.returnStatus = 0;
1964 msg.resetDataToggle = 0;
1966 msg.disablePort = 1;
1968 /* Sending intermediate configs */
1970 msg._txOn = (!p_priv->break_on);
1973 msg.txBreak = (p_priv->break_on);
1978 msg.returnStatus = 0;
1979 msg.resetDataToggle = 0x0;
1981 msg.disablePort = 0;
1984 /* Do handshaking outputs */
1986 msg.rts = p_priv->rts_state;
1989 msg.dtr = p_priv->dtr_state;
1991 p_priv->resend_cont = 0;
1993 /* if the device is a 49wg, we send control message on usb
1996 if (d_details->product_id == keyspan_usa49wg_product_id) {
1997 dr = (void *)(s_priv->ctrl_buf);
1998 dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT;
1999 dr->bRequest = 0xB0; /* 49wg control message */;
2002 dr->wLength = cpu_to_le16(sizeof(msg));
2004 memcpy(s_priv->glocont_buf, &msg, sizeof(msg));
2006 usb_fill_control_urb(this_urb, serial->dev,
2007 usb_sndctrlpipe(serial->dev, 0),
2008 (unsigned char *)dr, s_priv->glocont_buf,
2009 sizeof(msg), usa49_glocont_callback, serial);
2012 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2014 /* send the data out the device on control endpoint */
2015 this_urb->transfer_buffer_length = sizeof(msg);
2017 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2019 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2022 dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__,
2023 outcont_urb, this_urb->transfer_buffer_length,
2024 usb_pipeendpoint(this_urb->pipe));
2031 static int keyspan_usa90_send_setup(struct usb_serial *serial,
2032 struct usb_serial_port *port,
2035 struct keyspan_usa90_portControlMessage msg;
2036 struct keyspan_serial_private *s_priv;
2037 struct keyspan_port_private *p_priv;
2038 const struct keyspan_device_details *d_details;
2039 struct urb *this_urb;
2043 s_priv = usb_get_serial_data(serial);
2044 p_priv = usb_get_serial_port_data(port);
2045 d_details = s_priv->device_details;
2047 /* only do something if we have a bulk out endpoint */
2048 this_urb = p_priv->outcont_urb;
2049 if (this_urb == NULL) {
2050 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
2054 /* Save reset port val for resend.
2055 Don't overwrite resend for open/close condition. */
2056 if ((reset_port + 1) > p_priv->resend_cont)
2057 p_priv->resend_cont = reset_port + 1;
2058 if (this_urb->status == -EINPROGRESS) {
2059 dev_dbg(&port->dev, "%s already writing\n", __func__);
2064 memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));
2066 /* Only set baud rate if it's changed */
2067 if (p_priv->old_baud != p_priv->baud) {
2068 p_priv->old_baud = p_priv->baud;
2069 msg.setClocking = 0x01;
2070 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2071 &msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
2072 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2073 __func__, p_priv->baud);
2074 p_priv->baud = 9600;
2075 d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2076 &msg.baudHi, &msg.baudLo, &prescaler, 0);
2082 /* modes must always be correctly specified */
2083 if (p_priv->baud > 57600) {
2084 msg.rxMode = RXMODE_DMA;
2085 msg.txMode = TXMODE_DMA;
2087 msg.rxMode = RXMODE_BYHAND;
2088 msg.txMode = TXMODE_BYHAND;
2091 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
2092 switch (p_priv->cflag & CSIZE) {
2094 msg.lcr |= USA_DATABITS_5;
2097 msg.lcr |= USA_DATABITS_6;
2100 msg.lcr |= USA_DATABITS_7;
2103 msg.lcr |= USA_DATABITS_8;
2106 if (p_priv->cflag & PARENB) {
2107 /* note USA_PARITY_NONE == 0 */
2108 msg.lcr |= (p_priv->cflag & PARODD) ?
2109 USA_PARITY_ODD : USA_PARITY_EVEN;
2111 if (p_priv->old_cflag != p_priv->cflag) {
2112 p_priv->old_cflag = p_priv->cflag;
2116 if (p_priv->flow_control == flow_cts)
2117 msg.txFlowControl = TXFLOW_CTS;
2118 msg.setTxFlowControl = 0x01;
2119 msg.setRxFlowControl = 0x01;
2121 msg.rxForwardingLength = 16;
2122 msg.rxForwardingTimeout = 16;
2123 msg.txAckSetting = 0;
2128 if (reset_port == 1) {
2129 msg.portEnabled = 1;
2131 msg.txBreak = (p_priv->break_on);
2134 else if (reset_port == 2)
2135 msg.portEnabled = 0;
2136 /* Sending intermediate configs */
2138 msg.portEnabled = 1;
2139 msg.txBreak = (p_priv->break_on);
2142 /* Do handshaking outputs */
2144 msg.rts = p_priv->rts_state;
2147 msg.dtr = p_priv->dtr_state;
2149 p_priv->resend_cont = 0;
2150 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2152 /* send the data out the device on control endpoint */
2153 this_urb->transfer_buffer_length = sizeof(msg);
2155 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2157 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2161 static int keyspan_usa67_send_setup(struct usb_serial *serial,
2162 struct usb_serial_port *port,
2165 struct keyspan_usa67_portControlMessage msg;
2166 struct keyspan_serial_private *s_priv;
2167 struct keyspan_port_private *p_priv;
2168 const struct keyspan_device_details *d_details;
2169 struct urb *this_urb;
2170 int err, device_port;
2172 s_priv = usb_get_serial_data(serial);
2173 p_priv = usb_get_serial_port_data(port);
2174 d_details = s_priv->device_details;
2176 this_urb = s_priv->glocont_urb;
2178 /* Work out which port within the device is being setup */
2179 device_port = port->number - port->serial->minor;
2181 /* Make sure we have an urb then send the message */
2182 if (this_urb == NULL) {
2183 dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__,
2188 /* Save reset port val for resend.
2189 Don't overwrite resend for open/close condition. */
2190 if ((reset_port + 1) > p_priv->resend_cont)
2191 p_priv->resend_cont = reset_port + 1;
2192 if (this_urb->status == -EINPROGRESS) {
2193 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
2198 memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
2200 msg.port = device_port;
2202 /* Only set baud rate if it's changed */
2203 if (p_priv->old_baud != p_priv->baud) {
2204 p_priv->old_baud = p_priv->baud;
2205 msg.setClocking = 0xff;
2206 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2207 &msg.baudHi, &msg.baudLo, &msg.prescaler,
2208 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
2209 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2210 __func__, p_priv->baud);
2212 msg.baudHi = 125; /* Values for 9600 baud */
2215 msg.setPrescaler = 0xff;
2218 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
2219 switch (p_priv->cflag & CSIZE) {
2221 msg.lcr |= USA_DATABITS_5;
2224 msg.lcr |= USA_DATABITS_6;
2227 msg.lcr |= USA_DATABITS_7;
2230 msg.lcr |= USA_DATABITS_8;
2233 if (p_priv->cflag & PARENB) {
2234 /* note USA_PARITY_NONE == 0 */
2235 msg.lcr |= (p_priv->cflag & PARODD) ?
2236 USA_PARITY_ODD : USA_PARITY_EVEN;
2240 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
2241 msg.xonFlowControl = 0;
2242 msg.setFlowControl = 0xff;
2243 msg.forwardingLength = 16;
2247 if (reset_port == 1) {
2257 msg.returnStatus = 0;
2258 msg.resetDataToggle = 0xff;
2259 } else if (reset_port == 2) {
2269 msg.returnStatus = 0;
2270 msg.resetDataToggle = 0;
2272 /* Sending intermediate configs */
2273 msg._txOn = (!p_priv->break_on);
2276 msg.txBreak = (p_priv->break_on);
2281 msg.returnStatus = 0;
2282 msg.resetDataToggle = 0x0;
2285 /* Do handshaking outputs */
2286 msg.setTxTriState_setRts = 0xff;
2287 msg.txTriState_rts = p_priv->rts_state;
2289 msg.setHskoa_setDtr = 0xff;
2290 msg.hskoa_dtr = p_priv->dtr_state;
2292 p_priv->resend_cont = 0;
2294 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2296 /* send the data out the device on control endpoint */
2297 this_urb->transfer_buffer_length = sizeof(msg);
2299 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2301 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2305 static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
2307 struct usb_serial *serial = port->serial;
2308 struct keyspan_serial_private *s_priv;
2309 const struct keyspan_device_details *d_details;
2311 s_priv = usb_get_serial_data(serial);
2312 d_details = s_priv->device_details;
2314 switch (d_details->msg_format) {
2316 keyspan_usa26_send_setup(serial, port, reset_port);
2319 keyspan_usa28_send_setup(serial, port, reset_port);
2322 keyspan_usa49_send_setup(serial, port, reset_port);
2325 keyspan_usa90_send_setup(serial, port, reset_port);
2328 keyspan_usa67_send_setup(serial, port, reset_port);
2334 /* Gets called by the "real" driver (ie once firmware is loaded
2335 and renumeration has taken place. */
2336 static int keyspan_startup(struct usb_serial *serial)
2339 struct keyspan_serial_private *s_priv;
2340 const struct keyspan_device_details *d_details;
2342 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
2343 if (d_details->product_id ==
2344 le16_to_cpu(serial->dev->descriptor.idProduct))
2346 if (d_details == NULL) {
2347 dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
2348 __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
2352 /* Setup private data for serial driver */
2353 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
2355 dev_dbg(&serial->dev->dev, "%s - kmalloc for keyspan_serial_private failed.\n", __func__);
2359 s_priv->device_details = d_details;
2360 usb_set_serial_data(serial, s_priv);
2362 keyspan_setup_urbs(serial);
2364 if (s_priv->instat_urb != NULL) {
2365 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL);
2367 dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err);
2369 if (s_priv->indat_urb != NULL) {
2370 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL);
2372 dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err);
2378 static void keyspan_disconnect(struct usb_serial *serial)
2380 struct keyspan_serial_private *s_priv;
2382 s_priv = usb_get_serial_data(serial);
2384 stop_urb(s_priv->instat_urb);
2385 stop_urb(s_priv->glocont_urb);
2386 stop_urb(s_priv->indat_urb);
2389 static void keyspan_release(struct usb_serial *serial)
2391 struct keyspan_serial_private *s_priv;
2393 s_priv = usb_get_serial_data(serial);
2395 usb_free_urb(s_priv->instat_urb);
2396 usb_free_urb(s_priv->indat_urb);
2397 usb_free_urb(s_priv->glocont_urb);
2402 static int keyspan_port_probe(struct usb_serial_port *port)
2404 struct usb_serial *serial = port->serial;
2405 struct keyspan_serial_private *s_priv;
2406 struct keyspan_port_private *p_priv;
2407 const struct keyspan_device_details *d_details;
2408 struct callbacks *cback;
2413 s_priv = usb_get_serial_data(serial);
2414 d_details = s_priv->device_details;
2416 p_priv = kzalloc(sizeof(*p_priv), GFP_KERNEL);
2420 p_priv->device_details = d_details;
2422 /* Setup values for the various callback routines */
2423 cback = &keyspan_callbacks[d_details->msg_format];
2425 port_num = port->number - port->serial->minor;
2427 /* Do indat endpoints first, once for each flip */
2428 endp = d_details->indat_endpoints[port_num];
2429 for (i = 0; i <= d_details->indat_endp_flip; ++i, ++endp) {
2430 p_priv->in_urbs[i] = keyspan_setup_urb(serial, endp,
2432 p_priv->in_buffer[i], 64,
2433 cback->indat_callback);
2435 /* outdat endpoints also have flip */
2436 endp = d_details->outdat_endpoints[port_num];
2437 for (i = 0; i <= d_details->outdat_endp_flip; ++i, ++endp) {
2438 p_priv->out_urbs[i] = keyspan_setup_urb(serial, endp,
2440 p_priv->out_buffer[i], 64,
2441 cback->outdat_callback);
2443 /* inack endpoint */
2444 p_priv->inack_urb = keyspan_setup_urb(serial,
2445 d_details->inack_endpoints[port_num],
2447 p_priv->inack_buffer, 1,
2448 cback->inack_callback);
2449 /* outcont endpoint */
2450 p_priv->outcont_urb = keyspan_setup_urb(serial,
2451 d_details->outcont_endpoints[port_num],
2453 p_priv->outcont_buffer, 64,
2454 cback->outcont_callback);
2456 usb_set_serial_port_data(port, p_priv);
2461 static int keyspan_port_remove(struct usb_serial_port *port)
2463 struct keyspan_port_private *p_priv;
2466 p_priv = usb_get_serial_port_data(port);
2468 stop_urb(p_priv->inack_urb);
2469 stop_urb(p_priv->outcont_urb);
2470 for (i = 0; i < 2; i++) {
2471 stop_urb(p_priv->in_urbs[i]);
2472 stop_urb(p_priv->out_urbs[i]);
2475 usb_free_urb(p_priv->inack_urb);
2476 usb_free_urb(p_priv->outcont_urb);
2477 for (i = 0; i < 2; i++) {
2478 usb_free_urb(p_priv->in_urbs[i]);
2479 usb_free_urb(p_priv->out_urbs[i]);
2487 MODULE_AUTHOR(DRIVER_AUTHOR);
2488 MODULE_DESCRIPTION(DRIVER_DESC);
2489 MODULE_LICENSE("GPL");
2491 MODULE_FIRMWARE("keyspan/usa28.fw");
2492 MODULE_FIRMWARE("keyspan/usa28x.fw");
2493 MODULE_FIRMWARE("keyspan/usa28xa.fw");
2494 MODULE_FIRMWARE("keyspan/usa28xb.fw");
2495 MODULE_FIRMWARE("keyspan/usa19.fw");
2496 MODULE_FIRMWARE("keyspan/usa19qi.fw");
2497 MODULE_FIRMWARE("keyspan/mpr.fw");
2498 MODULE_FIRMWARE("keyspan/usa19qw.fw");
2499 MODULE_FIRMWARE("keyspan/usa18x.fw");
2500 MODULE_FIRMWARE("keyspan/usa19w.fw");
2501 MODULE_FIRMWARE("keyspan/usa49w.fw");
2502 MODULE_FIRMWARE("keyspan/usa49wlc.fw");