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);
422 /* Update handshaking pin state information */
423 old_dcd_state = p_priv->dcd_state;
424 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
425 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
426 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
427 p_priv->ri_state = ((msg->ri) ? 1 : 0);
429 if (old_dcd_state != p_priv->dcd_state)
430 tty_port_tty_hangup(&port->port, true);
432 /* Resubmit urb so we continue receiving */
433 err = usb_submit_urb(urb, GFP_ATOMIC);
435 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
439 static void usa26_glocont_callback(struct urb *urb)
444 static void usa28_indat_callback(struct urb *urb)
447 struct usb_serial_port *port;
449 struct keyspan_port_private *p_priv;
450 int status = urb->status;
453 p_priv = usb_get_serial_port_data(port);
454 data = urb->transfer_buffer;
456 if (urb != p_priv->in_urbs[p_priv->in_flip])
461 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
462 __func__, status, usb_pipeendpoint(urb->pipe));
467 p_priv = usb_get_serial_port_data(port);
468 data = urb->transfer_buffer;
470 if (urb->actual_length) {
471 tty_insert_flip_string(&port->port, data,
473 tty_flip_buffer_push(&port->port);
476 /* Resubmit urb so we continue receiving */
477 err = usb_submit_urb(urb, GFP_ATOMIC);
479 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n",
481 p_priv->in_flip ^= 1;
483 urb = p_priv->in_urbs[p_priv->in_flip];
484 } while (urb->status != -EINPROGRESS);
487 static void usa28_inack_callback(struct urb *urb)
491 static void usa28_outcont_callback(struct urb *urb)
493 struct usb_serial_port *port;
494 struct keyspan_port_private *p_priv;
497 p_priv = usb_get_serial_port_data(port);
499 if (p_priv->resend_cont) {
500 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
501 keyspan_usa28_send_setup(port->serial, port,
502 p_priv->resend_cont - 1);
506 static void usa28_instat_callback(struct urb *urb)
509 unsigned char *data = urb->transfer_buffer;
510 struct keyspan_usa28_portStatusMessage *msg;
511 struct usb_serial *serial;
512 struct usb_serial_port *port;
513 struct keyspan_port_private *p_priv;
515 int status = urb->status;
517 serial = urb->context;
520 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
524 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) {
525 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
530 dev_dbg(&urb->dev->dev,
531 "%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__,
532 data[0], data[1], data[2], data[3], data[4], data[5],
533 data[6], data[7], data[8], data[9], data[10], data[11]);
536 /* Now do something useful with the data */
537 msg = (struct keyspan_usa28_portStatusMessage *)data;
539 /* Check port number from message and retrieve private data */
540 if (msg->port >= serial->num_ports) {
541 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
544 port = serial->port[msg->port];
545 p_priv = usb_get_serial_port_data(port);
547 /* Update handshaking pin state information */
548 old_dcd_state = p_priv->dcd_state;
549 p_priv->cts_state = ((msg->cts) ? 1 : 0);
550 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
551 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
552 p_priv->ri_state = ((msg->ri) ? 1 : 0);
554 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
555 tty_port_tty_hangup(&port->port, true);
557 /* Resubmit urb so we continue receiving */
558 err = usb_submit_urb(urb, GFP_ATOMIC);
560 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
564 static void usa28_glocont_callback(struct urb *urb)
569 static void usa49_glocont_callback(struct urb *urb)
571 struct usb_serial *serial;
572 struct usb_serial_port *port;
573 struct keyspan_port_private *p_priv;
576 serial = urb->context;
577 for (i = 0; i < serial->num_ports; ++i) {
578 port = serial->port[i];
579 p_priv = usb_get_serial_port_data(port);
581 if (p_priv->resend_cont) {
582 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
583 keyspan_usa49_send_setup(serial, port,
584 p_priv->resend_cont - 1);
590 /* This is actually called glostat in the Keyspan
592 static void usa49_instat_callback(struct urb *urb)
595 unsigned char *data = urb->transfer_buffer;
596 struct keyspan_usa49_portStatusMessage *msg;
597 struct usb_serial *serial;
598 struct usb_serial_port *port;
599 struct keyspan_port_private *p_priv;
601 int status = urb->status;
603 serial = urb->context;
606 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
610 if (urb->actual_length !=
611 sizeof(struct keyspan_usa49_portStatusMessage)) {
612 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
617 dev_dbg(&urb->dev->dev, "%s: %x %x %x %x %x %x %x %x %x %x %x",
618 __func__, data[0], data[1], data[2], data[3], data[4],
619 data[5], data[6], data[7], data[8], data[9], data[10]);
622 /* Now do something useful with the data */
623 msg = (struct keyspan_usa49_portStatusMessage *)data;
625 /* Check port number from message and retrieve private data */
626 if (msg->portNumber >= serial->num_ports) {
627 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
628 __func__, msg->portNumber);
631 port = serial->port[msg->portNumber];
632 p_priv = usb_get_serial_port_data(port);
634 /* Update handshaking pin state information */
635 old_dcd_state = p_priv->dcd_state;
636 p_priv->cts_state = ((msg->cts) ? 1 : 0);
637 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
638 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
639 p_priv->ri_state = ((msg->ri) ? 1 : 0);
641 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
642 tty_port_tty_hangup(&port->port, true);
644 /* Resubmit urb so we continue receiving */
645 err = usb_submit_urb(urb, GFP_ATOMIC);
647 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
651 static void usa49_inack_callback(struct urb *urb)
655 static void usa49_indat_callback(struct urb *urb)
659 struct usb_serial_port *port;
660 unsigned char *data = urb->transfer_buffer;
661 int status = urb->status;
663 endpoint = usb_pipeendpoint(urb->pipe);
666 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
667 __func__, status, endpoint);
672 if (urb->actual_length) {
673 /* 0x80 bit is error flag */
674 if ((data[0] & 0x80) == 0) {
675 /* no error on any byte */
676 tty_insert_flip_string(&port->port, data + 1,
677 urb->actual_length - 1);
679 /* some bytes had errors, every byte has status */
680 for (i = 0; i + 1 < urb->actual_length; i += 2) {
682 int flag = TTY_NORMAL;
684 if (stat & RXERROR_OVERRUN) {
685 tty_insert_flip_char(&port->port, 0,
688 /* XXX should handle break (0x10) */
689 if (stat & RXERROR_PARITY)
691 else if (stat & RXERROR_FRAMING)
694 tty_insert_flip_char(&port->port, data[i+1],
698 tty_flip_buffer_push(&port->port);
701 /* Resubmit urb so we continue receiving */
702 err = usb_submit_urb(urb, GFP_ATOMIC);
704 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
707 static void usa49wg_indat_callback(struct urb *urb)
710 struct usb_serial *serial;
711 struct usb_serial_port *port;
712 unsigned char *data = urb->transfer_buffer;
713 int status = urb->status;
715 serial = urb->context;
718 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
722 /* inbound data is in the form P#, len, status, data */
726 while (i < urb->actual_length) {
728 /* Check port number from message */
729 if (data[i] >= serial->num_ports) {
730 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
734 port = serial->port[data[i++]];
737 /* 0x80 bit is error flag */
738 if ((data[i] & 0x80) == 0) {
739 /* no error on any byte */
741 for (x = 1; x < len && i < urb->actual_length; ++x)
742 tty_insert_flip_char(&port->port,
746 * some bytes had errors, every byte has status
748 for (x = 0; x + 1 < len &&
749 i + 1 < urb->actual_length; x += 2) {
751 int flag = TTY_NORMAL;
753 if (stat & RXERROR_OVERRUN) {
754 tty_insert_flip_char(&port->port, 0,
757 /* XXX should handle break (0x10) */
758 if (stat & RXERROR_PARITY)
760 else if (stat & RXERROR_FRAMING)
763 tty_insert_flip_char(&port->port, data[i+1],
768 tty_flip_buffer_push(&port->port);
771 /* Resubmit urb so we continue receiving */
772 err = usb_submit_urb(urb, GFP_ATOMIC);
774 dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
777 /* not used, usa-49 doesn't have per-port control endpoints */
778 static void usa49_outcont_callback(struct urb *urb)
782 static void usa90_indat_callback(struct urb *urb)
786 struct usb_serial_port *port;
787 struct keyspan_port_private *p_priv;
788 unsigned char *data = urb->transfer_buffer;
789 int status = urb->status;
791 endpoint = usb_pipeendpoint(urb->pipe);
794 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
795 __func__, status, endpoint);
800 p_priv = usb_get_serial_port_data(port);
802 if (urb->actual_length) {
803 /* if current mode is DMA, looks like usa28 format
804 otherwise looks like usa26 data format */
806 if (p_priv->baud > 57600)
807 tty_insert_flip_string(&port->port, data,
810 /* 0x80 bit is error flag */
811 if ((data[0] & 0x80) == 0) {
812 /* no errors on individual bytes, only
813 possible overrun err*/
814 if (data[0] & RXERROR_OVERRUN) {
815 tty_insert_flip_char(&port->port, 0,
818 for (i = 1; i < urb->actual_length ; ++i)
819 tty_insert_flip_char(&port->port,
820 data[i], TTY_NORMAL);
822 /* some bytes had errors, every byte has status */
823 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
824 for (i = 0; i + 1 < urb->actual_length; i += 2) {
826 int flag = TTY_NORMAL;
828 if (stat & RXERROR_OVERRUN) {
829 tty_insert_flip_char(
833 /* XXX should handle break (0x10) */
834 if (stat & RXERROR_PARITY)
836 else if (stat & RXERROR_FRAMING)
839 tty_insert_flip_char(&port->port,
844 tty_flip_buffer_push(&port->port);
847 /* Resubmit urb so we continue receiving */
848 err = usb_submit_urb(urb, GFP_ATOMIC);
850 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
854 static void usa90_instat_callback(struct urb *urb)
856 unsigned char *data = urb->transfer_buffer;
857 struct keyspan_usa90_portStatusMessage *msg;
858 struct usb_serial *serial;
859 struct usb_serial_port *port;
860 struct keyspan_port_private *p_priv;
861 int old_dcd_state, err;
862 int status = urb->status;
864 serial = urb->context;
867 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
870 if (urb->actual_length < 14) {
871 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
875 msg = (struct keyspan_usa90_portStatusMessage *)data;
877 /* Now do something useful with the data */
879 port = serial->port[0];
880 p_priv = usb_get_serial_port_data(port);
882 /* Update handshaking pin state information */
883 old_dcd_state = p_priv->dcd_state;
884 p_priv->cts_state = ((msg->cts) ? 1 : 0);
885 p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
886 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
887 p_priv->ri_state = ((msg->ri) ? 1 : 0);
889 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
890 tty_port_tty_hangup(&port->port, true);
892 /* Resubmit urb so we continue receiving */
893 err = usb_submit_urb(urb, GFP_ATOMIC);
895 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
900 static void usa90_outcont_callback(struct urb *urb)
902 struct usb_serial_port *port;
903 struct keyspan_port_private *p_priv;
906 p_priv = usb_get_serial_port_data(port);
908 if (p_priv->resend_cont) {
909 dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__);
910 keyspan_usa90_send_setup(port->serial, port,
911 p_priv->resend_cont - 1);
915 /* Status messages from the 28xg */
916 static void usa67_instat_callback(struct urb *urb)
919 unsigned char *data = urb->transfer_buffer;
920 struct keyspan_usa67_portStatusMessage *msg;
921 struct usb_serial *serial;
922 struct usb_serial_port *port;
923 struct keyspan_port_private *p_priv;
925 int status = urb->status;
927 serial = urb->context;
930 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
934 if (urb->actual_length !=
935 sizeof(struct keyspan_usa67_portStatusMessage)) {
936 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
941 /* Now do something useful with the data */
942 msg = (struct keyspan_usa67_portStatusMessage *)data;
944 /* Check port number from message and retrieve private data */
945 if (msg->port >= serial->num_ports) {
946 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
950 port = serial->port[msg->port];
951 p_priv = usb_get_serial_port_data(port);
953 /* Update handshaking pin state information */
954 old_dcd_state = p_priv->dcd_state;
955 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
956 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
958 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
959 tty_port_tty_hangup(&port->port, true);
961 /* Resubmit urb so we continue receiving */
962 err = usb_submit_urb(urb, GFP_ATOMIC);
964 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
967 static void usa67_glocont_callback(struct urb *urb)
969 struct usb_serial *serial;
970 struct usb_serial_port *port;
971 struct keyspan_port_private *p_priv;
974 serial = urb->context;
975 for (i = 0; i < serial->num_ports; ++i) {
976 port = serial->port[i];
977 p_priv = usb_get_serial_port_data(port);
979 if (p_priv->resend_cont) {
980 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
981 keyspan_usa67_send_setup(serial, port,
982 p_priv->resend_cont - 1);
988 static int keyspan_write_room(struct tty_struct *tty)
990 struct usb_serial_port *port = tty->driver_data;
991 struct keyspan_port_private *p_priv;
992 const struct keyspan_device_details *d_details;
995 struct urb *this_urb;
997 p_priv = usb_get_serial_port_data(port);
998 d_details = p_priv->device_details;
1000 /* FIXME: locking */
1001 if (d_details->msg_format == msg_usa90)
1006 flip = p_priv->out_flip;
1008 /* Check both endpoints to see if any are available. */
1009 this_urb = p_priv->out_urbs[flip];
1010 if (this_urb != NULL) {
1011 if (this_urb->status != -EINPROGRESS)
1013 flip = (flip + 1) & d_details->outdat_endp_flip;
1014 this_urb = p_priv->out_urbs[flip];
1015 if (this_urb != NULL) {
1016 if (this_urb->status != -EINPROGRESS)
1024 static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
1026 struct keyspan_port_private *p_priv;
1027 const struct keyspan_device_details *d_details;
1029 int baud_rate, device_port;
1031 unsigned int cflag = 0;
1033 p_priv = usb_get_serial_port_data(port);
1034 d_details = p_priv->device_details;
1036 /* Set some sane defaults */
1037 p_priv->rts_state = 1;
1038 p_priv->dtr_state = 1;
1039 p_priv->baud = 9600;
1041 /* force baud and lcr to be set on open */
1042 p_priv->old_baud = 0;
1043 p_priv->old_cflag = 0;
1045 p_priv->out_flip = 0;
1046 p_priv->in_flip = 0;
1048 /* Reset low level data toggle and start reading from endpoints */
1049 for (i = 0; i < 2; i++) {
1050 urb = p_priv->in_urbs[i];
1054 /* make sure endpoint data toggle is synchronized
1056 usb_clear_halt(urb->dev, urb->pipe);
1057 err = usb_submit_urb(urb, GFP_KERNEL);
1059 dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err);
1062 /* Reset low level data toggle on out endpoints */
1063 for (i = 0; i < 2; i++) {
1064 urb = p_priv->out_urbs[i];
1067 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
1068 usb_pipeout(urb->pipe), 0); */
1071 /* get the terminal config for the setup message now so we don't
1072 * need to send 2 of them */
1074 device_port = port->number - port->serial->minor;
1076 cflag = tty->termios.c_cflag;
1077 /* Baud rate calculation takes baud rate as an integer
1078 so other rates can be generated if desired. */
1079 baud_rate = tty_get_baud_rate(tty);
1080 /* If no match or invalid, leave as default */
1082 && d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
1083 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1084 p_priv->baud = baud_rate;
1087 /* set CTS/RTS handshake etc. */
1088 p_priv->cflag = cflag;
1089 p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
1091 keyspan_send_setup(port, 1);
1093 /* keyspan_set_termios(port, NULL); */
1098 static inline void stop_urb(struct urb *urb)
1100 if (urb && urb->status == -EINPROGRESS)
1104 static void keyspan_dtr_rts(struct usb_serial_port *port, int on)
1106 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
1108 p_priv->rts_state = on;
1109 p_priv->dtr_state = on;
1110 keyspan_send_setup(port, 0);
1113 static void keyspan_close(struct usb_serial_port *port)
1116 struct keyspan_port_private *p_priv;
1118 p_priv = usb_get_serial_port_data(port);
1120 p_priv->rts_state = 0;
1121 p_priv->dtr_state = 0;
1123 keyspan_send_setup(port, 2);
1124 /* pilot-xfer seems to work best with this delay */
1127 p_priv->out_flip = 0;
1128 p_priv->in_flip = 0;
1130 stop_urb(p_priv->inack_urb);
1131 for (i = 0; i < 2; i++) {
1132 stop_urb(p_priv->in_urbs[i]);
1133 stop_urb(p_priv->out_urbs[i]);
1137 /* download the firmware to a pre-renumeration device */
1138 static int keyspan_fake_startup(struct usb_serial *serial)
1142 dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n",
1143 le16_to_cpu(serial->dev->descriptor.bcdDevice),
1144 le16_to_cpu(serial->dev->descriptor.idProduct));
1146 if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
1148 dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n");
1152 /* Select firmware image on the basis of idProduct */
1153 switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
1154 case keyspan_usa28_pre_product_id:
1155 fw_name = "keyspan/usa28.fw";
1158 case keyspan_usa28x_pre_product_id:
1159 fw_name = "keyspan/usa28x.fw";
1162 case keyspan_usa28xa_pre_product_id:
1163 fw_name = "keyspan/usa28xa.fw";
1166 case keyspan_usa28xb_pre_product_id:
1167 fw_name = "keyspan/usa28xb.fw";
1170 case keyspan_usa19_pre_product_id:
1171 fw_name = "keyspan/usa19.fw";
1174 case keyspan_usa19qi_pre_product_id:
1175 fw_name = "keyspan/usa19qi.fw";
1178 case keyspan_mpr_pre_product_id:
1179 fw_name = "keyspan/mpr.fw";
1182 case keyspan_usa19qw_pre_product_id:
1183 fw_name = "keyspan/usa19qw.fw";
1186 case keyspan_usa18x_pre_product_id:
1187 fw_name = "keyspan/usa18x.fw";
1190 case keyspan_usa19w_pre_product_id:
1191 fw_name = "keyspan/usa19w.fw";
1194 case keyspan_usa49w_pre_product_id:
1195 fw_name = "keyspan/usa49w.fw";
1198 case keyspan_usa49wlc_pre_product_id:
1199 fw_name = "keyspan/usa49wlc.fw";
1203 dev_err(&serial->dev->dev, "Unknown product ID (%04x)\n",
1204 le16_to_cpu(serial->dev->descriptor.idProduct));
1208 dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
1210 if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
1211 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
1216 /* after downloading firmware Renumeration will occur in a
1217 moment and the new device will bind to the real driver */
1219 /* we don't want this device to have a driver assigned to it. */
1223 /* Helper functions used by keyspan_setup_urbs */
1224 static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *serial,
1227 struct usb_host_interface *iface_desc;
1228 struct usb_endpoint_descriptor *ep;
1231 iface_desc = serial->interface->cur_altsetting;
1232 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
1233 ep = &iface_desc->endpoint[i].desc;
1234 if (ep->bEndpointAddress == endpoint)
1237 dev_warn(&serial->interface->dev, "found no endpoint descriptor for "
1238 "endpoint %x\n", endpoint);
1242 static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1243 int dir, void *ctx, char *buf, int len,
1244 void (*callback)(struct urb *))
1247 struct usb_endpoint_descriptor const *ep_desc;
1248 char const *ep_type_name;
1251 return NULL; /* endpoint not needed */
1253 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d.\n", __func__, endpoint);
1254 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
1256 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d failed.\n", __func__, endpoint);
1260 if (endpoint == 0) {
1261 /* control EP filled in when used */
1265 ep_desc = find_ep(serial, endpoint);
1267 /* leak the urb, something's wrong and the callers don't care */
1270 if (usb_endpoint_xfer_int(ep_desc)) {
1271 ep_type_name = "INT";
1272 usb_fill_int_urb(urb, serial->dev,
1273 usb_sndintpipe(serial->dev, endpoint) | dir,
1274 buf, len, callback, ctx,
1275 ep_desc->bInterval);
1276 } else if (usb_endpoint_xfer_bulk(ep_desc)) {
1277 ep_type_name = "BULK";
1278 usb_fill_bulk_urb(urb, serial->dev,
1279 usb_sndbulkpipe(serial->dev, endpoint) | dir,
1280 buf, len, callback, ctx);
1282 dev_warn(&serial->interface->dev,
1283 "unsupported endpoint type %x\n",
1284 usb_endpoint_type(ep_desc));
1289 dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n",
1290 __func__, urb, ep_type_name, endpoint);
1294 static struct callbacks {
1295 void (*instat_callback)(struct urb *);
1296 void (*glocont_callback)(struct urb *);
1297 void (*indat_callback)(struct urb *);
1298 void (*outdat_callback)(struct urb *);
1299 void (*inack_callback)(struct urb *);
1300 void (*outcont_callback)(struct urb *);
1301 } keyspan_callbacks[] = {
1303 /* msg_usa26 callbacks */
1304 .instat_callback = usa26_instat_callback,
1305 .glocont_callback = usa26_glocont_callback,
1306 .indat_callback = usa26_indat_callback,
1307 .outdat_callback = usa2x_outdat_callback,
1308 .inack_callback = usa26_inack_callback,
1309 .outcont_callback = usa26_outcont_callback,
1311 /* msg_usa28 callbacks */
1312 .instat_callback = usa28_instat_callback,
1313 .glocont_callback = usa28_glocont_callback,
1314 .indat_callback = usa28_indat_callback,
1315 .outdat_callback = usa2x_outdat_callback,
1316 .inack_callback = usa28_inack_callback,
1317 .outcont_callback = usa28_outcont_callback,
1319 /* msg_usa49 callbacks */
1320 .instat_callback = usa49_instat_callback,
1321 .glocont_callback = usa49_glocont_callback,
1322 .indat_callback = usa49_indat_callback,
1323 .outdat_callback = usa2x_outdat_callback,
1324 .inack_callback = usa49_inack_callback,
1325 .outcont_callback = usa49_outcont_callback,
1327 /* msg_usa90 callbacks */
1328 .instat_callback = usa90_instat_callback,
1329 .glocont_callback = usa28_glocont_callback,
1330 .indat_callback = usa90_indat_callback,
1331 .outdat_callback = usa2x_outdat_callback,
1332 .inack_callback = usa28_inack_callback,
1333 .outcont_callback = usa90_outcont_callback,
1335 /* msg_usa67 callbacks */
1336 .instat_callback = usa67_instat_callback,
1337 .glocont_callback = usa67_glocont_callback,
1338 .indat_callback = usa26_indat_callback,
1339 .outdat_callback = usa2x_outdat_callback,
1340 .inack_callback = usa26_inack_callback,
1341 .outcont_callback = usa26_outcont_callback,
1345 /* Generic setup urbs function that uses
1346 data in device_details */
1347 static void keyspan_setup_urbs(struct usb_serial *serial)
1349 struct keyspan_serial_private *s_priv;
1350 const struct keyspan_device_details *d_details;
1351 struct callbacks *cback;
1353 s_priv = usb_get_serial_data(serial);
1354 d_details = s_priv->device_details;
1356 /* Setup values for the various callback routines */
1357 cback = &keyspan_callbacks[d_details->msg_format];
1359 /* Allocate and set up urbs for each one that is in use,
1360 starting with instat endpoints */
1361 s_priv->instat_urb = keyspan_setup_urb
1362 (serial, d_details->instat_endpoint, USB_DIR_IN,
1363 serial, s_priv->instat_buf, INSTAT_BUFLEN,
1364 cback->instat_callback);
1366 s_priv->indat_urb = keyspan_setup_urb
1367 (serial, d_details->indat_endpoint, USB_DIR_IN,
1368 serial, s_priv->indat_buf, INDAT49W_BUFLEN,
1369 usa49wg_indat_callback);
1371 s_priv->glocont_urb = keyspan_setup_urb
1372 (serial, d_details->glocont_endpoint, USB_DIR_OUT,
1373 serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
1374 cback->glocont_callback);
1377 /* usa19 function doesn't require prescaler */
1378 static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
1379 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1380 u8 *rate_low, u8 *prescaler, int portnum)
1382 u32 b16, /* baud rate times 16 (actual rate used internally) */
1384 cnt; /* inverse of divisor (programmed into 8051) */
1386 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1388 /* prevent divide by zero... */
1389 b16 = baud_rate * 16L;
1391 return KEYSPAN_INVALID_BAUD_RATE;
1392 /* Any "standard" rate over 57k6 is marginal on the USA-19
1393 as we run out of divisor resolution. */
1394 if (baud_rate > 57600)
1395 return KEYSPAN_INVALID_BAUD_RATE;
1397 /* calculate the divisor and the counter (its inverse) */
1398 div = baudclk / b16;
1400 return KEYSPAN_INVALID_BAUD_RATE;
1405 return KEYSPAN_INVALID_BAUD_RATE;
1407 /* return the counter values if non-null */
1409 *rate_low = (u8) (cnt & 0xff);
1411 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1412 if (rate_low && rate_hi)
1413 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1414 __func__, baud_rate, *rate_hi, *rate_low);
1415 return KEYSPAN_BAUD_RATE_OK;
1418 /* usa19hs function doesn't require prescaler */
1419 static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port,
1420 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1421 u8 *rate_low, u8 *prescaler, int portnum)
1423 u32 b16, /* baud rate times 16 (actual rate used internally) */
1426 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1428 /* prevent divide by zero... */
1429 b16 = baud_rate * 16L;
1431 return KEYSPAN_INVALID_BAUD_RATE;
1433 /* calculate the divisor */
1434 div = baudclk / b16;
1436 return KEYSPAN_INVALID_BAUD_RATE;
1439 return KEYSPAN_INVALID_BAUD_RATE;
1441 /* return the counter values if non-null */
1443 *rate_low = (u8) (div & 0xff);
1446 *rate_hi = (u8) ((div >> 8) & 0xff);
1448 if (rate_low && rate_hi)
1449 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1450 __func__, baud_rate, *rate_hi, *rate_low);
1452 return KEYSPAN_BAUD_RATE_OK;
1455 static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
1456 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1457 u8 *rate_low, u8 *prescaler, int portnum)
1459 u32 b16, /* baud rate times 16 (actual rate used internally) */
1460 clk, /* clock with 13/8 prescaler */
1461 div, /* divisor using 13/8 prescaler */
1462 res, /* resulting baud rate using 13/8 prescaler */
1463 diff, /* error using 13/8 prescaler */
1468 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1470 /* prevent divide by zero */
1471 b16 = baud_rate * 16L;
1473 return KEYSPAN_INVALID_BAUD_RATE;
1475 /* Calculate prescaler by trying them all and looking
1478 /* start with largest possible difference */
1479 smallest_diff = 0xffffffff;
1481 /* 0 is an invalid prescaler, used as a flag */
1484 for (i = 8; i <= 0xff; ++i) {
1485 clk = (baudclk * 8) / (u32) i;
1492 diff = (res > b16) ? (res-b16) : (b16-res);
1494 if (diff < smallest_diff) {
1496 smallest_diff = diff;
1500 if (best_prescaler == 0)
1501 return KEYSPAN_INVALID_BAUD_RATE;
1503 clk = (baudclk * 8) / (u32) best_prescaler;
1506 /* return the divisor and prescaler if non-null */
1508 *rate_low = (u8) (div & 0xff);
1510 *rate_hi = (u8) ((div >> 8) & 0xff);
1512 *prescaler = best_prescaler;
1513 /* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */
1515 return KEYSPAN_BAUD_RATE_OK;
1518 /* USA-28 supports different maximum baud rates on each port */
1519 static int keyspan_usa28_calc_baud(struct usb_serial_port *port,
1520 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1521 u8 *rate_low, u8 *prescaler, int portnum)
1523 u32 b16, /* baud rate times 16 (actual rate used internally) */
1525 cnt; /* inverse of divisor (programmed into 8051) */
1527 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1529 /* prevent divide by zero */
1530 b16 = baud_rate * 16L;
1532 return KEYSPAN_INVALID_BAUD_RATE;
1534 /* calculate the divisor and the counter (its inverse) */
1535 div = KEYSPAN_USA28_BAUDCLK / b16;
1537 return KEYSPAN_INVALID_BAUD_RATE;
1541 /* check for out of range, based on portnum,
1542 and return result */
1545 return KEYSPAN_INVALID_BAUD_RATE;
1549 return KEYSPAN_INVALID_BAUD_RATE;
1551 return KEYSPAN_INVALID_BAUD_RATE;
1554 /* return the counter values if not NULL
1555 (port 1 will ignore retHi) */
1557 *rate_low = (u8) (cnt & 0xff);
1559 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1560 dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate);
1561 return KEYSPAN_BAUD_RATE_OK;
1564 static int keyspan_usa26_send_setup(struct usb_serial *serial,
1565 struct usb_serial_port *port,
1568 struct keyspan_usa26_portControlMessage msg;
1569 struct keyspan_serial_private *s_priv;
1570 struct keyspan_port_private *p_priv;
1571 const struct keyspan_device_details *d_details;
1572 struct urb *this_urb;
1573 int device_port, err;
1575 dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port);
1577 s_priv = usb_get_serial_data(serial);
1578 p_priv = usb_get_serial_port_data(port);
1579 d_details = s_priv->device_details;
1580 device_port = port->number - port->serial->minor;
1582 this_urb = p_priv->outcont_urb;
1584 dev_dbg(&port->dev, "%s - endpoint %d\n", __func__, usb_pipeendpoint(this_urb->pipe));
1586 /* Make sure we have an urb then send the message */
1587 if (this_urb == NULL) {
1588 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1592 /* Save reset port val for resend.
1593 Don't overwrite resend for open/close condition. */
1594 if ((reset_port + 1) > p_priv->resend_cont)
1595 p_priv->resend_cont = reset_port + 1;
1596 if (this_urb->status == -EINPROGRESS) {
1597 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1602 memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
1604 /* Only set baud rate if it's changed */
1605 if (p_priv->old_baud != p_priv->baud) {
1606 p_priv->old_baud = p_priv->baud;
1607 msg.setClocking = 0xff;
1608 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1609 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1610 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1611 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1612 __func__, p_priv->baud);
1614 msg.baudHi = 125; /* Values for 9600 baud */
1617 msg.setPrescaler = 0xff;
1620 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
1621 switch (p_priv->cflag & CSIZE) {
1623 msg.lcr |= USA_DATABITS_5;
1626 msg.lcr |= USA_DATABITS_6;
1629 msg.lcr |= USA_DATABITS_7;
1632 msg.lcr |= USA_DATABITS_8;
1635 if (p_priv->cflag & PARENB) {
1636 /* note USA_PARITY_NONE == 0 */
1637 msg.lcr |= (p_priv->cflag & PARODD) ?
1638 USA_PARITY_ODD : USA_PARITY_EVEN;
1642 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1643 msg.xonFlowControl = 0;
1644 msg.setFlowControl = 0xff;
1645 msg.forwardingLength = 16;
1650 if (reset_port == 1) {
1659 msg.returnStatus = 0;
1660 msg.resetDataToggle = 0xff;
1664 else if (reset_port == 2) {
1673 msg.returnStatus = 0;
1674 msg.resetDataToggle = 0;
1677 /* Sending intermediate configs */
1679 msg._txOn = (!p_priv->break_on);
1682 msg.txBreak = (p_priv->break_on);
1687 msg.returnStatus = 0;
1688 msg.resetDataToggle = 0x0;
1691 /* Do handshaking outputs */
1692 msg.setTxTriState_setRts = 0xff;
1693 msg.txTriState_rts = p_priv->rts_state;
1695 msg.setHskoa_setDtr = 0xff;
1696 msg.hskoa_dtr = p_priv->dtr_state;
1698 p_priv->resend_cont = 0;
1699 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1701 /* send the data out the device on control endpoint */
1702 this_urb->transfer_buffer_length = sizeof(msg);
1704 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1706 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
1710 static int keyspan_usa28_send_setup(struct usb_serial *serial,
1711 struct usb_serial_port *port,
1714 struct keyspan_usa28_portControlMessage msg;
1715 struct keyspan_serial_private *s_priv;
1716 struct keyspan_port_private *p_priv;
1717 const struct keyspan_device_details *d_details;
1718 struct urb *this_urb;
1719 int device_port, err;
1721 s_priv = usb_get_serial_data(serial);
1722 p_priv = usb_get_serial_port_data(port);
1723 d_details = s_priv->device_details;
1724 device_port = port->number - port->serial->minor;
1726 /* only do something if we have a bulk out endpoint */
1727 this_urb = p_priv->outcont_urb;
1728 if (this_urb == NULL) {
1729 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1733 /* Save reset port val for resend.
1734 Don't overwrite resend for open/close condition. */
1735 if ((reset_port + 1) > p_priv->resend_cont)
1736 p_priv->resend_cont = reset_port + 1;
1737 if (this_urb->status == -EINPROGRESS) {
1738 dev_dbg(&port->dev, "%s already writing\n", __func__);
1743 memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
1745 msg.setBaudRate = 1;
1746 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1747 &msg.baudHi, &msg.baudLo, NULL,
1748 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1749 dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n",
1750 __func__, p_priv->baud);
1752 msg.baudHi = 0xb2; /* Values for 9600 baud */
1755 /* If parity is enabled, we must calculate it ourselves. */
1756 msg.parity = 0; /* XXX for now */
1758 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1759 msg.xonFlowControl = 0;
1761 /* Do handshaking outputs, DTR is inverted relative to RTS */
1762 msg.rts = p_priv->rts_state;
1763 msg.dtr = p_priv->dtr_state;
1765 msg.forwardingLength = 16;
1767 msg.breakThreshold = 45;
1771 /*msg.returnStatus = 1;
1772 msg.resetDataToggle = 0xff;*/
1774 if (reset_port == 1) {
1778 msg.txForceXoff = 0;
1784 msg.returnStatus = 0;
1785 msg.resetDataToggle = 0xff;
1788 else if (reset_port == 2) {
1792 msg.txForceXoff = 0;
1798 msg.returnStatus = 0;
1799 msg.resetDataToggle = 0;
1801 /* Sending intermediate configs */
1803 msg._txOn = (!p_priv->break_on);
1806 msg.txForceXoff = 0;
1807 msg.txBreak = (p_priv->break_on);
1812 msg.returnStatus = 0;
1813 msg.resetDataToggle = 0x0;
1816 p_priv->resend_cont = 0;
1817 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
1819 /* send the data out the device on control endpoint */
1820 this_urb->transfer_buffer_length = sizeof(msg);
1822 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1824 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__);
1827 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) OK %d bytes\n", __func__,
1828 this_urb->transfer_buffer_length);
1835 static int keyspan_usa49_send_setup(struct usb_serial *serial,
1836 struct usb_serial_port *port,
1839 struct keyspan_usa49_portControlMessage msg;
1840 struct usb_ctrlrequest *dr = NULL;
1841 struct keyspan_serial_private *s_priv;
1842 struct keyspan_port_private *p_priv;
1843 const struct keyspan_device_details *d_details;
1844 struct urb *this_urb;
1845 int err, device_port;
1847 s_priv = usb_get_serial_data(serial);
1848 p_priv = usb_get_serial_port_data(port);
1849 d_details = s_priv->device_details;
1851 this_urb = s_priv->glocont_urb;
1853 /* Work out which port within the device is being setup */
1854 device_port = port->number - port->serial->minor;
1856 /* Make sure we have an urb then send the message */
1857 if (this_urb == NULL) {
1858 dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__, port->number);
1862 dev_dbg(&port->dev, "%s - endpoint %d port %d (%d)\n",
1863 __func__, usb_pipeendpoint(this_urb->pipe),
1864 port->number, device_port);
1866 /* Save reset port val for resend.
1867 Don't overwrite resend for open/close condition. */
1868 if ((reset_port + 1) > p_priv->resend_cont)
1869 p_priv->resend_cont = reset_port + 1;
1871 if (this_urb->status == -EINPROGRESS) {
1872 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1877 memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));
1879 /*msg.portNumber = port->number;*/
1880 msg.portNumber = device_port;
1882 /* Only set baud rate if it's changed */
1883 if (p_priv->old_baud != p_priv->baud) {
1884 p_priv->old_baud = p_priv->baud;
1885 msg.setClocking = 0xff;
1886 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1887 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1888 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1889 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1890 __func__, p_priv->baud);
1892 msg.baudHi = 125; /* Values for 9600 baud */
1895 /* msg.setPrescaler = 0xff; */
1898 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
1899 switch (p_priv->cflag & CSIZE) {
1901 msg.lcr |= USA_DATABITS_5;
1904 msg.lcr |= USA_DATABITS_6;
1907 msg.lcr |= USA_DATABITS_7;
1910 msg.lcr |= USA_DATABITS_8;
1913 if (p_priv->cflag & PARENB) {
1914 /* note USA_PARITY_NONE == 0 */
1915 msg.lcr |= (p_priv->cflag & PARODD) ?
1916 USA_PARITY_ODD : USA_PARITY_EVEN;
1920 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
1921 msg.xonFlowControl = 0;
1922 msg.setFlowControl = 0xff;
1924 msg.forwardingLength = 16;
1929 if (reset_port == 1) {
1938 msg.returnStatus = 0;
1939 msg.resetDataToggle = 0xff;
1941 msg.disablePort = 0;
1944 else if (reset_port == 2) {
1953 msg.returnStatus = 0;
1954 msg.resetDataToggle = 0;
1956 msg.disablePort = 1;
1958 /* Sending intermediate configs */
1960 msg._txOn = (!p_priv->break_on);
1963 msg.txBreak = (p_priv->break_on);
1968 msg.returnStatus = 0;
1969 msg.resetDataToggle = 0x0;
1971 msg.disablePort = 0;
1974 /* Do handshaking outputs */
1976 msg.rts = p_priv->rts_state;
1979 msg.dtr = p_priv->dtr_state;
1981 p_priv->resend_cont = 0;
1983 /* if the device is a 49wg, we send control message on usb
1986 if (d_details->product_id == keyspan_usa49wg_product_id) {
1987 dr = (void *)(s_priv->ctrl_buf);
1988 dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT;
1989 dr->bRequest = 0xB0; /* 49wg control message */;
1992 dr->wLength = cpu_to_le16(sizeof(msg));
1994 memcpy(s_priv->glocont_buf, &msg, sizeof(msg));
1996 usb_fill_control_urb(this_urb, serial->dev,
1997 usb_sndctrlpipe(serial->dev, 0),
1998 (unsigned char *)dr, s_priv->glocont_buf,
1999 sizeof(msg), usa49_glocont_callback, serial);
2002 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2004 /* send the data out the device on control endpoint */
2005 this_urb->transfer_buffer_length = sizeof(msg);
2007 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2009 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2012 dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__,
2013 outcont_urb, this_urb->transfer_buffer_length,
2014 usb_pipeendpoint(this_urb->pipe));
2021 static int keyspan_usa90_send_setup(struct usb_serial *serial,
2022 struct usb_serial_port *port,
2025 struct keyspan_usa90_portControlMessage msg;
2026 struct keyspan_serial_private *s_priv;
2027 struct keyspan_port_private *p_priv;
2028 const struct keyspan_device_details *d_details;
2029 struct urb *this_urb;
2033 s_priv = usb_get_serial_data(serial);
2034 p_priv = usb_get_serial_port_data(port);
2035 d_details = s_priv->device_details;
2037 /* only do something if we have a bulk out endpoint */
2038 this_urb = p_priv->outcont_urb;
2039 if (this_urb == NULL) {
2040 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
2044 /* Save reset port val for resend.
2045 Don't overwrite resend for open/close condition. */
2046 if ((reset_port + 1) > p_priv->resend_cont)
2047 p_priv->resend_cont = reset_port + 1;
2048 if (this_urb->status == -EINPROGRESS) {
2049 dev_dbg(&port->dev, "%s already writing\n", __func__);
2054 memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));
2056 /* Only set baud rate if it's changed */
2057 if (p_priv->old_baud != p_priv->baud) {
2058 p_priv->old_baud = p_priv->baud;
2059 msg.setClocking = 0x01;
2060 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2061 &msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
2062 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2063 __func__, p_priv->baud);
2064 p_priv->baud = 9600;
2065 d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2066 &msg.baudHi, &msg.baudLo, &prescaler, 0);
2072 /* modes must always be correctly specified */
2073 if (p_priv->baud > 57600) {
2074 msg.rxMode = RXMODE_DMA;
2075 msg.txMode = TXMODE_DMA;
2077 msg.rxMode = RXMODE_BYHAND;
2078 msg.txMode = TXMODE_BYHAND;
2081 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
2082 switch (p_priv->cflag & CSIZE) {
2084 msg.lcr |= USA_DATABITS_5;
2087 msg.lcr |= USA_DATABITS_6;
2090 msg.lcr |= USA_DATABITS_7;
2093 msg.lcr |= USA_DATABITS_8;
2096 if (p_priv->cflag & PARENB) {
2097 /* note USA_PARITY_NONE == 0 */
2098 msg.lcr |= (p_priv->cflag & PARODD) ?
2099 USA_PARITY_ODD : USA_PARITY_EVEN;
2101 if (p_priv->old_cflag != p_priv->cflag) {
2102 p_priv->old_cflag = p_priv->cflag;
2106 if (p_priv->flow_control == flow_cts)
2107 msg.txFlowControl = TXFLOW_CTS;
2108 msg.setTxFlowControl = 0x01;
2109 msg.setRxFlowControl = 0x01;
2111 msg.rxForwardingLength = 16;
2112 msg.rxForwardingTimeout = 16;
2113 msg.txAckSetting = 0;
2118 if (reset_port == 1) {
2119 msg.portEnabled = 1;
2121 msg.txBreak = (p_priv->break_on);
2124 else if (reset_port == 2)
2125 msg.portEnabled = 0;
2126 /* Sending intermediate configs */
2128 msg.portEnabled = 1;
2129 msg.txBreak = (p_priv->break_on);
2132 /* Do handshaking outputs */
2134 msg.rts = p_priv->rts_state;
2137 msg.dtr = p_priv->dtr_state;
2139 p_priv->resend_cont = 0;
2140 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2142 /* send the data out the device on control endpoint */
2143 this_urb->transfer_buffer_length = sizeof(msg);
2145 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2147 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2151 static int keyspan_usa67_send_setup(struct usb_serial *serial,
2152 struct usb_serial_port *port,
2155 struct keyspan_usa67_portControlMessage msg;
2156 struct keyspan_serial_private *s_priv;
2157 struct keyspan_port_private *p_priv;
2158 const struct keyspan_device_details *d_details;
2159 struct urb *this_urb;
2160 int err, device_port;
2162 s_priv = usb_get_serial_data(serial);
2163 p_priv = usb_get_serial_port_data(port);
2164 d_details = s_priv->device_details;
2166 this_urb = s_priv->glocont_urb;
2168 /* Work out which port within the device is being setup */
2169 device_port = port->number - port->serial->minor;
2171 /* Make sure we have an urb then send the message */
2172 if (this_urb == NULL) {
2173 dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__,
2178 /* Save reset port val for resend.
2179 Don't overwrite resend for open/close condition. */
2180 if ((reset_port + 1) > p_priv->resend_cont)
2181 p_priv->resend_cont = reset_port + 1;
2182 if (this_urb->status == -EINPROGRESS) {
2183 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
2188 memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
2190 msg.port = device_port;
2192 /* Only set baud rate if it's changed */
2193 if (p_priv->old_baud != p_priv->baud) {
2194 p_priv->old_baud = p_priv->baud;
2195 msg.setClocking = 0xff;
2196 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2197 &msg.baudHi, &msg.baudLo, &msg.prescaler,
2198 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
2199 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2200 __func__, p_priv->baud);
2202 msg.baudHi = 125; /* Values for 9600 baud */
2205 msg.setPrescaler = 0xff;
2208 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
2209 switch (p_priv->cflag & CSIZE) {
2211 msg.lcr |= USA_DATABITS_5;
2214 msg.lcr |= USA_DATABITS_6;
2217 msg.lcr |= USA_DATABITS_7;
2220 msg.lcr |= USA_DATABITS_8;
2223 if (p_priv->cflag & PARENB) {
2224 /* note USA_PARITY_NONE == 0 */
2225 msg.lcr |= (p_priv->cflag & PARODD) ?
2226 USA_PARITY_ODD : USA_PARITY_EVEN;
2230 msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
2231 msg.xonFlowControl = 0;
2232 msg.setFlowControl = 0xff;
2233 msg.forwardingLength = 16;
2237 if (reset_port == 1) {
2247 msg.returnStatus = 0;
2248 msg.resetDataToggle = 0xff;
2249 } else if (reset_port == 2) {
2259 msg.returnStatus = 0;
2260 msg.resetDataToggle = 0;
2262 /* Sending intermediate configs */
2263 msg._txOn = (!p_priv->break_on);
2266 msg.txBreak = (p_priv->break_on);
2271 msg.returnStatus = 0;
2272 msg.resetDataToggle = 0x0;
2275 /* Do handshaking outputs */
2276 msg.setTxTriState_setRts = 0xff;
2277 msg.txTriState_rts = p_priv->rts_state;
2279 msg.setHskoa_setDtr = 0xff;
2280 msg.hskoa_dtr = p_priv->dtr_state;
2282 p_priv->resend_cont = 0;
2284 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
2286 /* send the data out the device on control endpoint */
2287 this_urb->transfer_buffer_length = sizeof(msg);
2289 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2291 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2295 static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
2297 struct usb_serial *serial = port->serial;
2298 struct keyspan_serial_private *s_priv;
2299 const struct keyspan_device_details *d_details;
2301 s_priv = usb_get_serial_data(serial);
2302 d_details = s_priv->device_details;
2304 switch (d_details->msg_format) {
2306 keyspan_usa26_send_setup(serial, port, reset_port);
2309 keyspan_usa28_send_setup(serial, port, reset_port);
2312 keyspan_usa49_send_setup(serial, port, reset_port);
2315 keyspan_usa90_send_setup(serial, port, reset_port);
2318 keyspan_usa67_send_setup(serial, port, reset_port);
2324 /* Gets called by the "real" driver (ie once firmware is loaded
2325 and renumeration has taken place. */
2326 static int keyspan_startup(struct usb_serial *serial)
2329 struct keyspan_serial_private *s_priv;
2330 const struct keyspan_device_details *d_details;
2332 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
2333 if (d_details->product_id ==
2334 le16_to_cpu(serial->dev->descriptor.idProduct))
2336 if (d_details == NULL) {
2337 dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
2338 __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
2342 /* Setup private data for serial driver */
2343 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
2345 dev_dbg(&serial->dev->dev, "%s - kmalloc for keyspan_serial_private failed.\n", __func__);
2349 s_priv->device_details = d_details;
2350 usb_set_serial_data(serial, s_priv);
2352 keyspan_setup_urbs(serial);
2354 if (s_priv->instat_urb != NULL) {
2355 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL);
2357 dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err);
2359 if (s_priv->indat_urb != NULL) {
2360 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL);
2362 dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err);
2368 static void keyspan_disconnect(struct usb_serial *serial)
2370 struct keyspan_serial_private *s_priv;
2372 s_priv = usb_get_serial_data(serial);
2374 stop_urb(s_priv->instat_urb);
2375 stop_urb(s_priv->glocont_urb);
2376 stop_urb(s_priv->indat_urb);
2379 static void keyspan_release(struct usb_serial *serial)
2381 struct keyspan_serial_private *s_priv;
2383 s_priv = usb_get_serial_data(serial);
2385 usb_free_urb(s_priv->instat_urb);
2386 usb_free_urb(s_priv->indat_urb);
2387 usb_free_urb(s_priv->glocont_urb);
2392 static int keyspan_port_probe(struct usb_serial_port *port)
2394 struct usb_serial *serial = port->serial;
2395 struct keyspan_serial_private *s_priv;
2396 struct keyspan_port_private *p_priv;
2397 const struct keyspan_device_details *d_details;
2398 struct callbacks *cback;
2403 s_priv = usb_get_serial_data(serial);
2404 d_details = s_priv->device_details;
2406 p_priv = kzalloc(sizeof(*p_priv), GFP_KERNEL);
2410 p_priv->device_details = d_details;
2412 /* Setup values for the various callback routines */
2413 cback = &keyspan_callbacks[d_details->msg_format];
2415 port_num = port->number - port->serial->minor;
2417 /* Do indat endpoints first, once for each flip */
2418 endp = d_details->indat_endpoints[port_num];
2419 for (i = 0; i <= d_details->indat_endp_flip; ++i, ++endp) {
2420 p_priv->in_urbs[i] = keyspan_setup_urb(serial, endp,
2422 p_priv->in_buffer[i], 64,
2423 cback->indat_callback);
2425 /* outdat endpoints also have flip */
2426 endp = d_details->outdat_endpoints[port_num];
2427 for (i = 0; i <= d_details->outdat_endp_flip; ++i, ++endp) {
2428 p_priv->out_urbs[i] = keyspan_setup_urb(serial, endp,
2430 p_priv->out_buffer[i], 64,
2431 cback->outdat_callback);
2433 /* inack endpoint */
2434 p_priv->inack_urb = keyspan_setup_urb(serial,
2435 d_details->inack_endpoints[port_num],
2437 p_priv->inack_buffer, 1,
2438 cback->inack_callback);
2439 /* outcont endpoint */
2440 p_priv->outcont_urb = keyspan_setup_urb(serial,
2441 d_details->outcont_endpoints[port_num],
2443 p_priv->outcont_buffer, 64,
2444 cback->outcont_callback);
2446 usb_set_serial_port_data(port, p_priv);
2451 static int keyspan_port_remove(struct usb_serial_port *port)
2453 struct keyspan_port_private *p_priv;
2456 p_priv = usb_get_serial_port_data(port);
2458 stop_urb(p_priv->inack_urb);
2459 stop_urb(p_priv->outcont_urb);
2460 for (i = 0; i < 2; i++) {
2461 stop_urb(p_priv->in_urbs[i]);
2462 stop_urb(p_priv->out_urbs[i]);
2465 usb_free_urb(p_priv->inack_urb);
2466 usb_free_urb(p_priv->outcont_urb);
2467 for (i = 0; i < 2; i++) {
2468 usb_free_urb(p_priv->in_urbs[i]);
2469 usb_free_urb(p_priv->out_urbs[i]);
2477 MODULE_AUTHOR(DRIVER_AUTHOR);
2478 MODULE_DESCRIPTION(DRIVER_DESC);
2479 MODULE_LICENSE("GPL");
2481 MODULE_FIRMWARE("keyspan/usa28.fw");
2482 MODULE_FIRMWARE("keyspan/usa28x.fw");
2483 MODULE_FIRMWARE("keyspan/usa28xa.fw");
2484 MODULE_FIRMWARE("keyspan/usa28xb.fw");
2485 MODULE_FIRMWARE("keyspan/usa19.fw");
2486 MODULE_FIRMWARE("keyspan/usa19qi.fw");
2487 MODULE_FIRMWARE("keyspan/mpr.fw");
2488 MODULE_FIRMWARE("keyspan/usa19qw.fw");
2489 MODULE_FIRMWARE("keyspan/usa18x.fw");
2490 MODULE_FIRMWARE("keyspan/usa19w.fw");
2491 MODULE_FIRMWARE("keyspan/usa49w.fw");
2492 MODULE_FIRMWARE("keyspan/usa49wlc.fw");