Lines Matching +full:serial +full:- +full:clk +full:- +full:low

1 // SPDX-License-Identifier: GPL-2.0+
3 Keyspan USB to Serial Converter driver
5 (C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org>
6 (C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com>
11 from Brian Warner's original Keyspan-PDA driver.
14 and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
38 #include <linux/usb/serial.h>
42 #define DRIVER_DESC "Keyspan USB to Serial Converter Driver"
63 static int keyspan_usa28_send_setup(struct usb_serial *serial,
66 static int keyspan_usa26_send_setup(struct usb_serial *serial,
69 static int keyspan_usa49_send_setup(struct usb_serial *serial,
72 static int keyspan_usa90_send_setup(struct usb_serial *serial,
75 static int keyspan_usa67_send_setup(struct usb_serial *serial,
79 /* Values used for baud rate calculation - device specific */
80 #define KEYSPAN_INVALID_BAUD_RATE (-1)
95 * Device info for the Keyspan serial converter, used by the overall
96 * usb-serial probe function.
100 /* Product IDs for the products supported, pre-renumeration */
115 * Product IDs post-renumeration. Note that the 28x and 28xb have the same
116 * id's post-renumeration but behave identically so it's not an issue. As
197 .indat_endpoint = -1,
214 .indat_endpoint = -1,
215 .glocont_endpoint = -1,
231 .indat_endpoint = -1,
232 .glocont_endpoint = -1,
248 .indat_endpoint = -1,
249 .glocont_endpoint = -1,
265 .indat_endpoint = -1,
282 .indat_endpoint = -1,
296 .inack_endpoints = {-1},
299 .indat_endpoint = -1,
300 .glocont_endpoint = -1,
316 .indat_endpoint = -1,
333 .indat_endpoint = -1,
350 .indat_endpoint = -1,
364 .inack_endpoints = {-1, -1},
365 .outcont_endpoints = {-1, -1},
367 .indat_endpoint = -1,
385 .inack_endpoints = {-1, -1, -1, -1},
386 .outcont_endpoints = {-1, -1, -1, -1},
388 .indat_endpoint = -1,
402 .inack_endpoints = {-1, -1, -1, -1},
403 .outcont_endpoints = {-1, -1, -1, -1},
405 .indat_endpoint = -1,
417 .indat_endpoints = {-1, -1, -1, -1}, /* single 'global' data in EP */
419 .inack_endpoints = {-1, -1, -1, -1},
420 .outcont_endpoints = {-1, -1, -1, -1},
479 /* usb_device_id table for the pre-firmware download keyspan devices */
538 on 1 EP and high-speed supported */
554 structure as well - simplifies some of the
593 to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
604 struct usb_serial_port *port = tty->driver_data; in keyspan_break_ctl()
609 if (break_state == -1) in keyspan_break_ctl()
610 p_priv->break_on = 1; in keyspan_break_ctl()
612 p_priv->break_on = 0; in keyspan_break_ctl()
631 d_details = p_priv->device_details; in keyspan_set_termios()
632 cflag = tty->termios.c_cflag; in keyspan_set_termios()
633 device_port = port->port_number; in keyspan_set_termios()
639 if (d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk, in keyspan_set_termios()
641 /* FIXME - more to do here to ensure rate changes cleanly */ in keyspan_set_termios()
642 /* FIXME - calculate exact rate from divisor ? */ in keyspan_set_termios()
643 p_priv->baud = baud_rate; in keyspan_set_termios()
649 p_priv->cflag = cflag; in keyspan_set_termios()
650 p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none; in keyspan_set_termios()
653 tty->termios.c_cflag &= ~CMSPAR; in keyspan_set_termios()
660 struct usb_serial_port *port = tty->driver_data; in keyspan_tiocmget()
664 value = ((p_priv->rts_state) ? TIOCM_RTS : 0) | in keyspan_tiocmget()
665 ((p_priv->dtr_state) ? TIOCM_DTR : 0) | in keyspan_tiocmget()
666 ((p_priv->cts_state) ? TIOCM_CTS : 0) | in keyspan_tiocmget()
667 ((p_priv->dsr_state) ? TIOCM_DSR : 0) | in keyspan_tiocmget()
668 ((p_priv->dcd_state) ? TIOCM_CAR : 0) | in keyspan_tiocmget()
669 ((p_priv->ri_state) ? TIOCM_RNG : 0); in keyspan_tiocmget()
677 struct usb_serial_port *port = tty->driver_data; in keyspan_tiocmset()
681 p_priv->rts_state = 1; in keyspan_tiocmset()
683 p_priv->dtr_state = 1; in keyspan_tiocmset()
685 p_priv->rts_state = 0; in keyspan_tiocmset()
687 p_priv->dtr_state = 0; in keyspan_tiocmset()
705 d_details = p_priv->device_details; in keyspan_write()
707 if (d_details->msg_format == msg_usa90) { in keyspan_write()
715 dev_dbg(&port->dev, "%s - %d chars, flip=%d\n", __func__, count, in keyspan_write()
716 p_priv->out_flip); in keyspan_write()
718 for (left = count; left > 0; left -= todo) { in keyspan_write()
723 flip = p_priv->out_flip; in keyspan_write()
726 this_urb = p_priv->out_urbs[flip]; in keyspan_write()
729 dev_dbg(&port->dev, "%s - no output urb :(\n", __func__); in keyspan_write()
733 dev_dbg(&port->dev, "%s - endpoint %x flip %d\n", in keyspan_write()
734 __func__, usb_pipeendpoint(this_urb->pipe), flip); in keyspan_write()
736 if (this_urb->status == -EINPROGRESS) { in keyspan_write()
738 p_priv->tx_start_time[flip] + 10 * HZ)) in keyspan_write()
745 - unused so for now so set to zero */ in keyspan_write()
746 ((char *)this_urb->transfer_buffer)[0] = 0; in keyspan_write()
748 memcpy(this_urb->transfer_buffer + dataOffset, buf, todo); in keyspan_write()
752 this_urb->transfer_buffer_length = todo + dataOffset; in keyspan_write()
756 dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed (%d)\n", err); in keyspan_write()
757 p_priv->tx_start_time[flip] = jiffies; in keyspan_write()
761 p_priv->out_flip = (flip + 1) & d_details->outdat_endp_flip; in keyspan_write()
764 return count - left; in keyspan_write()
772 unsigned char *data = urb->transfer_buffer; in usa26_indat_callback()
773 int status = urb->status; in usa26_indat_callback()
775 endpoint = usb_pipeendpoint(urb->pipe); in usa26_indat_callback()
778 dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", in usa26_indat_callback()
783 port = urb->context; in usa26_indat_callback()
784 if (urb->actual_length) { in usa26_indat_callback()
790 tty_insert_flip_char(&port->port, 0, in usa26_indat_callback()
793 for (i = 1; i < urb->actual_length ; ++i) in usa26_indat_callback()
794 tty_insert_flip_char(&port->port, data[i], in usa26_indat_callback()
798 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); in usa26_indat_callback()
799 for (i = 0; i + 1 < urb->actual_length; i += 2) { in usa26_indat_callback()
804 tty_insert_flip_char(&port->port, 0, in usa26_indat_callback()
813 tty_insert_flip_char(&port->port, data[i+1], in usa26_indat_callback()
817 tty_flip_buffer_push(&port->port); in usa26_indat_callback()
823 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa26_indat_callback()
832 port = urb->context; in usa2x_outdat_callback()
834 dev_dbg(&port->dev, "%s - urb %d\n", __func__, urb == p_priv->out_urbs[1]); in usa2x_outdat_callback()
848 port = urb->context; in usa26_outcont_callback()
851 if (p_priv->resend_cont) { in usa26_outcont_callback()
852 dev_dbg(&port->dev, "%s - sending setup\n", __func__); in usa26_outcont_callback()
853 keyspan_usa26_send_setup(port->serial, port, in usa26_outcont_callback()
854 p_priv->resend_cont - 1); in usa26_outcont_callback()
860 unsigned char *data = urb->transfer_buffer; in usa26_instat_callback()
862 struct usb_serial *serial; in usa26_instat_callback() local
866 int status = urb->status; in usa26_instat_callback()
868 serial = urb->context; in usa26_instat_callback()
871 dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", in usa26_instat_callback()
875 if (urb->actual_length != 9) { in usa26_instat_callback()
876 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length); in usa26_instat_callback()
883 if (msg->port >= serial->num_ports) { in usa26_instat_callback()
884 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port); in usa26_instat_callback()
887 port = serial->port[msg->port]; in usa26_instat_callback()
893 old_dcd_state = p_priv->dcd_state; in usa26_instat_callback()
894 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); in usa26_instat_callback()
895 p_priv->dsr_state = ((msg->dsr) ? 1 : 0); in usa26_instat_callback()
896 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); in usa26_instat_callback()
897 p_priv->ri_state = ((msg->ri) ? 1 : 0); in usa26_instat_callback()
899 if (old_dcd_state != p_priv->dcd_state) in usa26_instat_callback()
900 tty_port_tty_hangup(&port->port, true); in usa26_instat_callback()
905 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa26_instat_callback()
920 int status = urb->status; in usa28_indat_callback()
922 port = urb->context; in usa28_indat_callback()
925 if (urb != p_priv->in_urbs[p_priv->in_flip]) in usa28_indat_callback()
930 dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", in usa28_indat_callback()
931 __func__, status, usb_pipeendpoint(urb->pipe)); in usa28_indat_callback()
935 port = urb->context; in usa28_indat_callback()
937 data = urb->transfer_buffer; in usa28_indat_callback()
939 if (urb->actual_length) { in usa28_indat_callback()
940 tty_insert_flip_string(&port->port, data, in usa28_indat_callback()
941 urb->actual_length); in usa28_indat_callback()
942 tty_flip_buffer_push(&port->port); in usa28_indat_callback()
948 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", in usa28_indat_callback()
950 p_priv->in_flip ^= 1; in usa28_indat_callback()
952 urb = p_priv->in_urbs[p_priv->in_flip]; in usa28_indat_callback()
953 } while (urb->status != -EINPROGRESS); in usa28_indat_callback()
965 port = urb->context; in usa28_outcont_callback()
968 if (p_priv->resend_cont) { in usa28_outcont_callback()
969 dev_dbg(&port->dev, "%s - sending setup\n", __func__); in usa28_outcont_callback()
970 keyspan_usa28_send_setup(port->serial, port, in usa28_outcont_callback()
971 p_priv->resend_cont - 1); in usa28_outcont_callback()
978 unsigned char *data = urb->transfer_buffer; in usa28_instat_callback()
980 struct usb_serial *serial; in usa28_instat_callback() local
984 int status = urb->status; in usa28_instat_callback()
986 serial = urb->context; in usa28_instat_callback()
989 dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", in usa28_instat_callback()
994 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) { in usa28_instat_callback()
995 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length); in usa28_instat_callback()
1002 if (msg->port >= serial->num_ports) { in usa28_instat_callback()
1003 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port); in usa28_instat_callback()
1006 port = serial->port[msg->port]; in usa28_instat_callback()
1012 old_dcd_state = p_priv->dcd_state; in usa28_instat_callback()
1013 p_priv->cts_state = ((msg->cts) ? 1 : 0); in usa28_instat_callback()
1014 p_priv->dsr_state = ((msg->dsr) ? 1 : 0); in usa28_instat_callback()
1015 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); in usa28_instat_callback()
1016 p_priv->ri_state = ((msg->ri) ? 1 : 0); in usa28_instat_callback()
1018 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) in usa28_instat_callback()
1019 tty_port_tty_hangup(&port->port, true); in usa28_instat_callback()
1024 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa28_instat_callback()
1035 struct usb_serial *serial; in usa49_glocont_callback() local
1040 serial = urb->context; in usa49_glocont_callback()
1041 for (i = 0; i < serial->num_ports; ++i) { in usa49_glocont_callback()
1042 port = serial->port[i]; in usa49_glocont_callback()
1047 if (p_priv->resend_cont) { in usa49_glocont_callback()
1048 dev_dbg(&port->dev, "%s - sending setup\n", __func__); in usa49_glocont_callback()
1049 keyspan_usa49_send_setup(serial, port, in usa49_glocont_callback()
1050 p_priv->resend_cont - 1); in usa49_glocont_callback()
1061 unsigned char *data = urb->transfer_buffer; in usa49_instat_callback()
1063 struct usb_serial *serial; in usa49_instat_callback() local
1067 int status = urb->status; in usa49_instat_callback()
1069 serial = urb->context; in usa49_instat_callback()
1072 dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", in usa49_instat_callback()
1077 if (urb->actual_length != in usa49_instat_callback()
1079 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length); in usa49_instat_callback()
1086 if (msg->portNumber >= serial->num_ports) { in usa49_instat_callback()
1087 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", in usa49_instat_callback()
1088 __func__, msg->portNumber); in usa49_instat_callback()
1091 port = serial->port[msg->portNumber]; in usa49_instat_callback()
1097 old_dcd_state = p_priv->dcd_state; in usa49_instat_callback()
1098 p_priv->cts_state = ((msg->cts) ? 1 : 0); in usa49_instat_callback()
1099 p_priv->dsr_state = ((msg->dsr) ? 1 : 0); in usa49_instat_callback()
1100 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); in usa49_instat_callback()
1101 p_priv->ri_state = ((msg->ri) ? 1 : 0); in usa49_instat_callback()
1103 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) in usa49_instat_callback()
1104 tty_port_tty_hangup(&port->port, true); in usa49_instat_callback()
1109 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa49_instat_callback()
1122 unsigned char *data = urb->transfer_buffer; in usa49_indat_callback()
1123 int status = urb->status; in usa49_indat_callback()
1125 endpoint = usb_pipeendpoint(urb->pipe); in usa49_indat_callback()
1128 dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", in usa49_indat_callback()
1133 port = urb->context; in usa49_indat_callback()
1134 if (urb->actual_length) { in usa49_indat_callback()
1138 tty_insert_flip_string(&port->port, data + 1, in usa49_indat_callback()
1139 urb->actual_length - 1); in usa49_indat_callback()
1142 for (i = 0; i + 1 < urb->actual_length; i += 2) { in usa49_indat_callback()
1147 tty_insert_flip_char(&port->port, 0, in usa49_indat_callback()
1156 tty_insert_flip_char(&port->port, data[i+1], in usa49_indat_callback()
1160 tty_flip_buffer_push(&port->port); in usa49_indat_callback()
1166 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa49_indat_callback()
1172 struct usb_serial *serial; in usa49wg_indat_callback() local
1174 unsigned char *data = urb->transfer_buffer; in usa49wg_indat_callback()
1175 int status = urb->status; in usa49wg_indat_callback()
1177 serial = urb->context; in usa49wg_indat_callback()
1180 dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", in usa49wg_indat_callback()
1189 while (i < urb->actual_length) { in usa49wg_indat_callback()
1192 if (data[i] >= serial->num_ports) { in usa49wg_indat_callback()
1193 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", in usa49wg_indat_callback()
1197 port = serial->port[data[i++]]; in usa49wg_indat_callback()
1204 for (x = 1; x < len && i < urb->actual_length; ++x) in usa49wg_indat_callback()
1205 tty_insert_flip_char(&port->port, in usa49wg_indat_callback()
1212 i + 1 < urb->actual_length; x += 2) { in usa49wg_indat_callback()
1217 tty_insert_flip_char(&port->port, 0, in usa49wg_indat_callback()
1226 tty_insert_flip_char(&port->port, data[i+1], in usa49wg_indat_callback()
1231 tty_flip_buffer_push(&port->port); in usa49wg_indat_callback()
1237 dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa49wg_indat_callback()
1240 /* not used, usa-49 doesn't have per-port control endpoints */
1251 unsigned char *data = urb->transfer_buffer; in usa90_indat_callback()
1252 int status = urb->status; in usa90_indat_callback()
1254 endpoint = usb_pipeendpoint(urb->pipe); in usa90_indat_callback()
1257 dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n", in usa90_indat_callback()
1262 port = urb->context; in usa90_indat_callback()
1265 if (urb->actual_length) { in usa90_indat_callback()
1269 if (p_priv->baud > 57600) in usa90_indat_callback()
1270 tty_insert_flip_string(&port->port, data, in usa90_indat_callback()
1271 urb->actual_length); in usa90_indat_callback()
1278 tty_insert_flip_char(&port->port, 0, in usa90_indat_callback()
1281 for (i = 1; i < urb->actual_length ; ++i) in usa90_indat_callback()
1282 tty_insert_flip_char(&port->port, in usa90_indat_callback()
1286 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); in usa90_indat_callback()
1287 for (i = 0; i + 1 < urb->actual_length; i += 2) { in usa90_indat_callback()
1293 &port->port, 0, in usa90_indat_callback()
1302 tty_insert_flip_char(&port->port, in usa90_indat_callback()
1307 tty_flip_buffer_push(&port->port); in usa90_indat_callback()
1313 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa90_indat_callback()
1319 unsigned char *data = urb->transfer_buffer; in usa90_instat_callback()
1321 struct usb_serial *serial; in usa90_instat_callback() local
1325 int status = urb->status; in usa90_instat_callback()
1327 serial = urb->context; in usa90_instat_callback()
1330 dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", in usa90_instat_callback()
1334 if (urb->actual_length < 14) { in usa90_instat_callback()
1335 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length); in usa90_instat_callback()
1343 port = serial->port[0]; in usa90_instat_callback()
1349 old_dcd_state = p_priv->dcd_state; in usa90_instat_callback()
1350 p_priv->cts_state = ((msg->cts) ? 1 : 0); in usa90_instat_callback()
1351 p_priv->dsr_state = ((msg->dsr) ? 1 : 0); in usa90_instat_callback()
1352 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); in usa90_instat_callback()
1353 p_priv->ri_state = ((msg->ri) ? 1 : 0); in usa90_instat_callback()
1355 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) in usa90_instat_callback()
1356 tty_port_tty_hangup(&port->port, true); in usa90_instat_callback()
1361 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa90_instat_callback()
1371 port = urb->context; in usa90_outcont_callback()
1374 if (p_priv->resend_cont) { in usa90_outcont_callback()
1375 dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__); in usa90_outcont_callback()
1376 keyspan_usa90_send_setup(port->serial, port, in usa90_outcont_callback()
1377 p_priv->resend_cont - 1); in usa90_outcont_callback()
1385 unsigned char *data = urb->transfer_buffer; in usa67_instat_callback()
1387 struct usb_serial *serial; in usa67_instat_callback() local
1391 int status = urb->status; in usa67_instat_callback()
1393 serial = urb->context; in usa67_instat_callback()
1396 dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n", in usa67_instat_callback()
1401 if (urb->actual_length != in usa67_instat_callback()
1403 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length); in usa67_instat_callback()
1412 if (msg->port >= serial->num_ports) { in usa67_instat_callback()
1413 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port); in usa67_instat_callback()
1417 port = serial->port[msg->port]; in usa67_instat_callback()
1423 old_dcd_state = p_priv->dcd_state; in usa67_instat_callback()
1424 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); in usa67_instat_callback()
1425 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); in usa67_instat_callback()
1427 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) in usa67_instat_callback()
1428 tty_port_tty_hangup(&port->port, true); in usa67_instat_callback()
1433 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); in usa67_instat_callback()
1438 struct usb_serial *serial; in usa67_glocont_callback() local
1443 serial = urb->context; in usa67_glocont_callback()
1444 for (i = 0; i < serial->num_ports; ++i) { in usa67_glocont_callback()
1445 port = serial->port[i]; in usa67_glocont_callback()
1450 if (p_priv->resend_cont) { in usa67_glocont_callback()
1451 dev_dbg(&port->dev, "%s - sending setup\n", __func__); in usa67_glocont_callback()
1452 keyspan_usa67_send_setup(serial, port, in usa67_glocont_callback()
1453 p_priv->resend_cont - 1); in usa67_glocont_callback()
1461 struct usb_serial_port *port = tty->driver_data; in keyspan_write_room()
1469 d_details = p_priv->device_details; in keyspan_write_room()
1472 if (d_details->msg_format == msg_usa90) in keyspan_write_room()
1477 flip = p_priv->out_flip; in keyspan_write_room()
1480 this_urb = p_priv->out_urbs[flip]; in keyspan_write_room()
1482 if (this_urb->status != -EINPROGRESS) in keyspan_write_room()
1484 flip = (flip + 1) & d_details->outdat_endp_flip; in keyspan_write_room()
1485 this_urb = p_priv->out_urbs[flip]; in keyspan_write_room()
1487 if (this_urb->status != -EINPROGRESS) in keyspan_write_room()
1505 d_details = p_priv->device_details; in keyspan_open()
1508 p_priv->rts_state = 1; in keyspan_open()
1509 p_priv->dtr_state = 1; in keyspan_open()
1510 p_priv->baud = 9600; in keyspan_open()
1513 p_priv->old_baud = 0; in keyspan_open()
1514 p_priv->old_cflag = 0; in keyspan_open()
1516 p_priv->out_flip = 0; in keyspan_open()
1517 p_priv->in_flip = 0; in keyspan_open()
1519 /* Reset low level data toggle and start reading from endpoints */ in keyspan_open()
1521 urb = p_priv->in_urbs[i]; in keyspan_open()
1527 usb_clear_halt(urb->dev, urb->pipe); in keyspan_open()
1530 dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err); in keyspan_open()
1533 /* Reset low level data toggle on out endpoints */ in keyspan_open()
1535 urb = p_priv->out_urbs[i]; in keyspan_open()
1538 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), in keyspan_open()
1539 usb_pipeout(urb->pipe), 0); */ in keyspan_open()
1545 device_port = port->port_number; in keyspan_open()
1547 cflag = tty->termios.c_cflag; in keyspan_open()
1553 && d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk, in keyspan_open()
1555 p_priv->baud = baud_rate; in keyspan_open()
1559 p_priv->cflag = cflag; in keyspan_open()
1560 p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none; in keyspan_open()
1573 p_priv->rts_state = on; in keyspan_dtr_rts()
1574 p_priv->dtr_state = on; in keyspan_dtr_rts()
1585 p_priv->rts_state = 0; in keyspan_close()
1586 p_priv->dtr_state = 0; in keyspan_close()
1589 /* pilot-xfer seems to work best with this delay */ in keyspan_close()
1592 p_priv->out_flip = 0; in keyspan_close()
1593 p_priv->in_flip = 0; in keyspan_close()
1595 usb_kill_urb(p_priv->inack_urb); in keyspan_close()
1597 usb_kill_urb(p_priv->in_urbs[i]); in keyspan_close()
1598 usb_kill_urb(p_priv->out_urbs[i]); in keyspan_close()
1602 /* download the firmware to a pre-renumeration device */
1603 static int keyspan_fake_startup(struct usb_serial *serial) in keyspan_fake_startup() argument
1607 dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n", in keyspan_fake_startup()
1608 le16_to_cpu(serial->dev->descriptor.bcdDevice), in keyspan_fake_startup()
1609 le16_to_cpu(serial->dev->descriptor.idProduct)); in keyspan_fake_startup()
1611 if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) in keyspan_fake_startup()
1613 dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n"); in keyspan_fake_startup()
1618 switch (le16_to_cpu(serial->dev->descriptor.idProduct)) { in keyspan_fake_startup()
1668 dev_err(&serial->dev->dev, "Unknown product ID (%04x)\n", in keyspan_fake_startup()
1669 le16_to_cpu(serial->dev->descriptor.idProduct)); in keyspan_fake_startup()
1673 dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name); in keyspan_fake_startup()
1675 if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) { in keyspan_fake_startup()
1676 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", in keyspan_fake_startup()
1678 return -ENOENT; in keyspan_fake_startup()
1689 static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *serial, in find_ep() argument
1696 iface_desc = serial->interface->cur_altsetting; in find_ep()
1697 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { in find_ep()
1698 ep = &iface_desc->endpoint[i].desc; in find_ep()
1699 if (ep->bEndpointAddress == endpoint) in find_ep()
1702 dev_warn(&serial->interface->dev, "found no endpoint descriptor for endpoint %x\n", in find_ep()
1707 static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, in keyspan_setup_urb() argument
1715 if (endpoint == -1) in keyspan_setup_urb()
1718 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %x\n", in keyspan_setup_urb()
1729 ep_desc = find_ep(serial, endpoint); in keyspan_setup_urb()
1736 usb_fill_int_urb(urb, serial->dev, in keyspan_setup_urb()
1737 usb_sndintpipe(serial->dev, endpoint) | dir, in keyspan_setup_urb()
1739 ep_desc->bInterval); in keyspan_setup_urb()
1742 usb_fill_bulk_urb(urb, serial->dev, in keyspan_setup_urb()
1743 usb_sndbulkpipe(serial->dev, endpoint) | dir, in keyspan_setup_urb()
1746 dev_warn(&serial->interface->dev, in keyspan_setup_urb()
1753 dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n", in keyspan_setup_urb()
1811 static void keyspan_setup_urbs(struct usb_serial *serial) in keyspan_setup_urbs() argument
1817 s_priv = usb_get_serial_data(serial); in keyspan_setup_urbs()
1818 d_details = s_priv->device_details; in keyspan_setup_urbs()
1821 cback = &keyspan_callbacks[d_details->msg_format]; in keyspan_setup_urbs()
1825 s_priv->instat_urb = keyspan_setup_urb in keyspan_setup_urbs()
1826 (serial, d_details->instat_endpoint, USB_DIR_IN, in keyspan_setup_urbs()
1827 serial, s_priv->instat_buf, INSTAT_BUFLEN, in keyspan_setup_urbs()
1828 cback->instat_callback); in keyspan_setup_urbs()
1830 s_priv->indat_urb = keyspan_setup_urb in keyspan_setup_urbs()
1831 (serial, d_details->indat_endpoint, USB_DIR_IN, in keyspan_setup_urbs()
1832 serial, s_priv->indat_buf, INDAT49W_BUFLEN, in keyspan_setup_urbs()
1835 s_priv->glocont_urb = keyspan_setup_urb in keyspan_setup_urbs()
1836 (serial, d_details->glocont_endpoint, USB_DIR_OUT, in keyspan_setup_urbs()
1837 serial, s_priv->glocont_buf, GLOCONT_BUFLEN, in keyspan_setup_urbs()
1838 cback->glocont_callback); in keyspan_setup_urbs()
1850 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); in keyspan_usa19_calc_baud()
1856 /* Any "standard" rate over 57k6 is marginal on the USA-19 in keyspan_usa19_calc_baud()
1866 cnt = 0 - div; in keyspan_usa19_calc_baud()
1871 /* return the counter values if non-null */ in keyspan_usa19_calc_baud()
1877 dev_dbg(&port->dev, "%s - %d %02x %02x.\n", in keyspan_usa19_calc_baud()
1890 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); in keyspan_usa19hs_calc_baud()
1905 /* return the counter values if non-null */ in keyspan_usa19hs_calc_baud()
1913 dev_dbg(&port->dev, "%s - %d %02x %02x.\n", in keyspan_usa19hs_calc_baud()
1924 clk, /* clock with 13/8 prescaler */ in keyspan_usa19w_calc_baud() local
1932 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); in keyspan_usa19w_calc_baud()
1949 clk = (baudclk * 8) / (u32) i; in keyspan_usa19w_calc_baud()
1951 div = clk / b16; in keyspan_usa19w_calc_baud()
1955 res = clk / div; in keyspan_usa19w_calc_baud()
1956 diff = (res > b16) ? (res-b16) : (b16-res); in keyspan_usa19w_calc_baud()
1967 clk = (baudclk * 8) / (u32) best_prescaler; in keyspan_usa19w_calc_baud()
1968 div = clk / b16; in keyspan_usa19w_calc_baud()
1970 /* return the divisor and prescaler if non-null */ in keyspan_usa19w_calc_baud()
1977 /* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */ in keyspan_usa19w_calc_baud()
1982 /* USA-28 supports different maximum baud rates on each port */
1991 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); in keyspan_usa28_calc_baud()
2003 cnt = 0 - div; in keyspan_usa28_calc_baud()
2024 dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate); in keyspan_usa28_calc_baud()
2028 static int keyspan_usa26_send_setup(struct usb_serial *serial, in keyspan_usa26_send_setup() argument
2039 dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port); in keyspan_usa26_send_setup()
2041 s_priv = usb_get_serial_data(serial); in keyspan_usa26_send_setup()
2043 d_details = s_priv->device_details; in keyspan_usa26_send_setup()
2044 device_port = port->port_number; in keyspan_usa26_send_setup()
2046 this_urb = p_priv->outcont_urb; in keyspan_usa26_send_setup()
2050 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__); in keyspan_usa26_send_setup()
2051 return -1; in keyspan_usa26_send_setup()
2054 dev_dbg(&port->dev, "%s - endpoint %x\n", in keyspan_usa26_send_setup()
2055 __func__, usb_pipeendpoint(this_urb->pipe)); in keyspan_usa26_send_setup()
2059 if ((reset_port + 1) > p_priv->resend_cont) in keyspan_usa26_send_setup()
2060 p_priv->resend_cont = reset_port + 1; in keyspan_usa26_send_setup()
2061 if (this_urb->status == -EINPROGRESS) { in keyspan_usa26_send_setup()
2062 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */ in keyspan_usa26_send_setup()
2064 return -1; in keyspan_usa26_send_setup()
2070 if (p_priv->old_baud != p_priv->baud) { in keyspan_usa26_send_setup()
2071 p_priv->old_baud = p_priv->baud; in keyspan_usa26_send_setup()
2073 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, in keyspan_usa26_send_setup()
2076 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", in keyspan_usa26_send_setup()
2077 __func__, p_priv->baud); in keyspan_usa26_send_setup()
2085 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1; in keyspan_usa26_send_setup()
2086 switch (p_priv->cflag & CSIZE) { in keyspan_usa26_send_setup()
2100 if (p_priv->cflag & PARENB) { in keyspan_usa26_send_setup()
2102 msg.lcr |= (p_priv->cflag & PARODD) ? in keyspan_usa26_send_setup()
2107 msg.ctsFlowControl = (p_priv->flow_control == flow_cts); in keyspan_usa26_send_setup()
2144 msg._txOn = (!p_priv->break_on); in keyspan_usa26_send_setup()
2147 msg.txBreak = (p_priv->break_on); in keyspan_usa26_send_setup()
2158 msg.txTriState_rts = p_priv->rts_state; in keyspan_usa26_send_setup()
2161 msg.hskoa_dtr = p_priv->dtr_state; in keyspan_usa26_send_setup()
2163 p_priv->resend_cont = 0; in keyspan_usa26_send_setup()
2164 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); in keyspan_usa26_send_setup()
2167 this_urb->transfer_buffer_length = sizeof(msg); in keyspan_usa26_send_setup()
2171 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); in keyspan_usa26_send_setup()
2175 static int keyspan_usa28_send_setup(struct usb_serial *serial, in keyspan_usa28_send_setup() argument
2186 s_priv = usb_get_serial_data(serial); in keyspan_usa28_send_setup()
2188 d_details = s_priv->device_details; in keyspan_usa28_send_setup()
2189 device_port = port->port_number; in keyspan_usa28_send_setup()
2192 this_urb = p_priv->outcont_urb; in keyspan_usa28_send_setup()
2194 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__); in keyspan_usa28_send_setup()
2195 return -1; in keyspan_usa28_send_setup()
2200 if ((reset_port + 1) > p_priv->resend_cont) in keyspan_usa28_send_setup()
2201 p_priv->resend_cont = reset_port + 1; in keyspan_usa28_send_setup()
2202 if (this_urb->status == -EINPROGRESS) { in keyspan_usa28_send_setup()
2203 dev_dbg(&port->dev, "%s already writing\n", __func__); in keyspan_usa28_send_setup()
2205 return -1; in keyspan_usa28_send_setup()
2211 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, in keyspan_usa28_send_setup()
2214 dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n", in keyspan_usa28_send_setup()
2215 __func__, p_priv->baud); in keyspan_usa28_send_setup()
2223 msg.ctsFlowControl = (p_priv->flow_control == flow_cts); in keyspan_usa28_send_setup()
2227 msg.rts = p_priv->rts_state; in keyspan_usa28_send_setup()
2228 msg.dtr = p_priv->dtr_state; in keyspan_usa28_send_setup()
2268 msg._txOn = (!p_priv->break_on); in keyspan_usa28_send_setup()
2272 msg.txBreak = (p_priv->break_on); in keyspan_usa28_send_setup()
2281 p_priv->resend_cont = 0; in keyspan_usa28_send_setup()
2282 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); in keyspan_usa28_send_setup()
2285 this_urb->transfer_buffer_length = sizeof(msg); in keyspan_usa28_send_setup()
2289 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__); in keyspan_usa28_send_setup()
2294 static int keyspan_usa49_send_setup(struct usb_serial *serial, in keyspan_usa49_send_setup() argument
2306 s_priv = usb_get_serial_data(serial); in keyspan_usa49_send_setup()
2308 d_details = s_priv->device_details; in keyspan_usa49_send_setup()
2310 this_urb = s_priv->glocont_urb; in keyspan_usa49_send_setup()
2313 device_port = port->port_number; in keyspan_usa49_send_setup()
2317 dev_dbg(&port->dev, "%s - oops no urb for port.\n", __func__); in keyspan_usa49_send_setup()
2318 return -1; in keyspan_usa49_send_setup()
2321 dev_dbg(&port->dev, "%s - endpoint %x (%d)\n", in keyspan_usa49_send_setup()
2322 __func__, usb_pipeendpoint(this_urb->pipe), device_port); in keyspan_usa49_send_setup()
2326 if ((reset_port + 1) > p_priv->resend_cont) in keyspan_usa49_send_setup()
2327 p_priv->resend_cont = reset_port + 1; in keyspan_usa49_send_setup()
2329 if (this_urb->status == -EINPROGRESS) { in keyspan_usa49_send_setup()
2330 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */ in keyspan_usa49_send_setup()
2332 return -1; in keyspan_usa49_send_setup()
2340 if (p_priv->old_baud != p_priv->baud) { in keyspan_usa49_send_setup()
2341 p_priv->old_baud = p_priv->baud; in keyspan_usa49_send_setup()
2343 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, in keyspan_usa49_send_setup()
2346 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", in keyspan_usa49_send_setup()
2347 __func__, p_priv->baud); in keyspan_usa49_send_setup()
2355 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1; in keyspan_usa49_send_setup()
2356 switch (p_priv->cflag & CSIZE) { in keyspan_usa49_send_setup()
2370 if (p_priv->cflag & PARENB) { in keyspan_usa49_send_setup()
2372 msg.lcr |= (p_priv->cflag & PARODD) ? in keyspan_usa49_send_setup()
2377 msg.ctsFlowControl = (p_priv->flow_control == flow_cts); in keyspan_usa49_send_setup()
2417 msg._txOn = (!p_priv->break_on); in keyspan_usa49_send_setup()
2420 msg.txBreak = (p_priv->break_on); in keyspan_usa49_send_setup()
2433 msg.rts = p_priv->rts_state; in keyspan_usa49_send_setup()
2436 msg.dtr = p_priv->dtr_state; in keyspan_usa49_send_setup()
2438 p_priv->resend_cont = 0; in keyspan_usa49_send_setup()
2443 if (d_details->product_id == keyspan_usa49wg_product_id) { in keyspan_usa49_send_setup()
2444 dr = (void *)(s_priv->ctrl_buf); in keyspan_usa49_send_setup()
2445 dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT; in keyspan_usa49_send_setup()
2446 dr->bRequest = 0xB0; /* 49wg control message */ in keyspan_usa49_send_setup()
2447 dr->wValue = 0; in keyspan_usa49_send_setup()
2448 dr->wIndex = 0; in keyspan_usa49_send_setup()
2449 dr->wLength = cpu_to_le16(sizeof(msg)); in keyspan_usa49_send_setup()
2451 memcpy(s_priv->glocont_buf, &msg, sizeof(msg)); in keyspan_usa49_send_setup()
2453 usb_fill_control_urb(this_urb, serial->dev, in keyspan_usa49_send_setup()
2454 usb_sndctrlpipe(serial->dev, 0), in keyspan_usa49_send_setup()
2455 (unsigned char *)dr, s_priv->glocont_buf, in keyspan_usa49_send_setup()
2456 sizeof(msg), usa49_glocont_callback, serial); in keyspan_usa49_send_setup()
2459 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); in keyspan_usa49_send_setup()
2462 this_urb->transfer_buffer_length = sizeof(msg); in keyspan_usa49_send_setup()
2466 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); in keyspan_usa49_send_setup()
2471 static int keyspan_usa90_send_setup(struct usb_serial *serial, in keyspan_usa90_send_setup() argument
2483 s_priv = usb_get_serial_data(serial); in keyspan_usa90_send_setup()
2485 d_details = s_priv->device_details; in keyspan_usa90_send_setup()
2488 this_urb = p_priv->outcont_urb; in keyspan_usa90_send_setup()
2490 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__); in keyspan_usa90_send_setup()
2491 return -1; in keyspan_usa90_send_setup()
2496 if ((reset_port + 1) > p_priv->resend_cont) in keyspan_usa90_send_setup()
2497 p_priv->resend_cont = reset_port + 1; in keyspan_usa90_send_setup()
2498 if (this_urb->status == -EINPROGRESS) { in keyspan_usa90_send_setup()
2499 dev_dbg(&port->dev, "%s already writing\n", __func__); in keyspan_usa90_send_setup()
2501 return -1; in keyspan_usa90_send_setup()
2507 if (p_priv->old_baud != p_priv->baud) { in keyspan_usa90_send_setup()
2508 p_priv->old_baud = p_priv->baud; in keyspan_usa90_send_setup()
2510 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, in keyspan_usa90_send_setup()
2512 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", in keyspan_usa90_send_setup()
2513 __func__, p_priv->baud); in keyspan_usa90_send_setup()
2514 p_priv->baud = 9600; in keyspan_usa90_send_setup()
2515 d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, in keyspan_usa90_send_setup()
2523 if (p_priv->baud > 57600) { in keyspan_usa90_send_setup()
2531 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1; in keyspan_usa90_send_setup()
2532 switch (p_priv->cflag & CSIZE) { in keyspan_usa90_send_setup()
2546 if (p_priv->cflag & PARENB) { in keyspan_usa90_send_setup()
2548 msg.lcr |= (p_priv->cflag & PARODD) ? in keyspan_usa90_send_setup()
2551 if (p_priv->old_cflag != p_priv->cflag) { in keyspan_usa90_send_setup()
2552 p_priv->old_cflag = p_priv->cflag; in keyspan_usa90_send_setup()
2556 if (p_priv->flow_control == flow_cts) in keyspan_usa90_send_setup()
2571 msg.txBreak = (p_priv->break_on); in keyspan_usa90_send_setup()
2579 msg.txBreak = (p_priv->break_on); in keyspan_usa90_send_setup()
2584 msg.rts = p_priv->rts_state; in keyspan_usa90_send_setup()
2587 msg.dtr = p_priv->dtr_state; in keyspan_usa90_send_setup()
2589 p_priv->resend_cont = 0; in keyspan_usa90_send_setup()
2590 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); in keyspan_usa90_send_setup()
2593 this_urb->transfer_buffer_length = sizeof(msg); in keyspan_usa90_send_setup()
2597 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); in keyspan_usa90_send_setup()
2601 static int keyspan_usa67_send_setup(struct usb_serial *serial, in keyspan_usa67_send_setup() argument
2612 s_priv = usb_get_serial_data(serial); in keyspan_usa67_send_setup()
2614 d_details = s_priv->device_details; in keyspan_usa67_send_setup()
2616 this_urb = s_priv->glocont_urb; in keyspan_usa67_send_setup()
2619 device_port = port->port_number; in keyspan_usa67_send_setup()
2623 dev_dbg(&port->dev, "%s - oops no urb for port.\n", __func__); in keyspan_usa67_send_setup()
2624 return -1; in keyspan_usa67_send_setup()
2629 if ((reset_port + 1) > p_priv->resend_cont) in keyspan_usa67_send_setup()
2630 p_priv->resend_cont = reset_port + 1; in keyspan_usa67_send_setup()
2631 if (this_urb->status == -EINPROGRESS) { in keyspan_usa67_send_setup()
2632 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */ in keyspan_usa67_send_setup()
2634 return -1; in keyspan_usa67_send_setup()
2642 if (p_priv->old_baud != p_priv->baud) { in keyspan_usa67_send_setup()
2643 p_priv->old_baud = p_priv->baud; in keyspan_usa67_send_setup()
2645 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, in keyspan_usa67_send_setup()
2648 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", in keyspan_usa67_send_setup()
2649 __func__, p_priv->baud); in keyspan_usa67_send_setup()
2657 msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1; in keyspan_usa67_send_setup()
2658 switch (p_priv->cflag & CSIZE) { in keyspan_usa67_send_setup()
2672 if (p_priv->cflag & PARENB) { in keyspan_usa67_send_setup()
2674 msg.lcr |= (p_priv->cflag & PARODD) ? in keyspan_usa67_send_setup()
2679 msg.ctsFlowControl = (p_priv->flow_control == flow_cts); in keyspan_usa67_send_setup()
2712 msg._txOn = (!p_priv->break_on); in keyspan_usa67_send_setup()
2715 msg.txBreak = (p_priv->break_on); in keyspan_usa67_send_setup()
2726 msg.txTriState_rts = p_priv->rts_state; in keyspan_usa67_send_setup()
2729 msg.hskoa_dtr = p_priv->dtr_state; in keyspan_usa67_send_setup()
2731 p_priv->resend_cont = 0; in keyspan_usa67_send_setup()
2733 memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); in keyspan_usa67_send_setup()
2736 this_urb->transfer_buffer_length = sizeof(msg); in keyspan_usa67_send_setup()
2740 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); in keyspan_usa67_send_setup()
2746 struct usb_serial *serial = port->serial; in keyspan_send_setup() local
2750 s_priv = usb_get_serial_data(serial); in keyspan_send_setup()
2751 d_details = s_priv->device_details; in keyspan_send_setup()
2753 switch (d_details->msg_format) { in keyspan_send_setup()
2755 keyspan_usa26_send_setup(serial, port, reset_port); in keyspan_send_setup()
2758 keyspan_usa28_send_setup(serial, port, reset_port); in keyspan_send_setup()
2761 keyspan_usa49_send_setup(serial, port, reset_port); in keyspan_send_setup()
2764 keyspan_usa90_send_setup(serial, port, reset_port); in keyspan_send_setup()
2767 keyspan_usa67_send_setup(serial, port, reset_port); in keyspan_send_setup()
2775 static int keyspan_startup(struct usb_serial *serial) in keyspan_startup() argument
2782 if (d_details->product_id == in keyspan_startup()
2783 le16_to_cpu(serial->dev->descriptor.idProduct)) in keyspan_startup()
2786 dev_err(&serial->dev->dev, "%s - unknown product id %x\n", in keyspan_startup()
2787 __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); in keyspan_startup()
2788 return -ENODEV; in keyspan_startup()
2791 /* Setup private data for serial driver */ in keyspan_startup()
2794 return -ENOMEM; in keyspan_startup()
2796 s_priv->instat_buf = kzalloc(INSTAT_BUFLEN, GFP_KERNEL); in keyspan_startup()
2797 if (!s_priv->instat_buf) in keyspan_startup()
2800 s_priv->indat_buf = kzalloc(INDAT49W_BUFLEN, GFP_KERNEL); in keyspan_startup()
2801 if (!s_priv->indat_buf) in keyspan_startup()
2804 s_priv->glocont_buf = kzalloc(GLOCONT_BUFLEN, GFP_KERNEL); in keyspan_startup()
2805 if (!s_priv->glocont_buf) in keyspan_startup()
2808 s_priv->ctrl_buf = kzalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); in keyspan_startup()
2809 if (!s_priv->ctrl_buf) in keyspan_startup()
2812 s_priv->device_details = d_details; in keyspan_startup()
2813 usb_set_serial_data(serial, s_priv); in keyspan_startup()
2815 keyspan_setup_urbs(serial); in keyspan_startup()
2817 if (s_priv->instat_urb != NULL) { in keyspan_startup()
2818 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); in keyspan_startup()
2820 dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err); in keyspan_startup()
2822 if (s_priv->indat_urb != NULL) { in keyspan_startup()
2823 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); in keyspan_startup()
2825 dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err); in keyspan_startup()
2831 kfree(s_priv->glocont_buf); in keyspan_startup()
2833 kfree(s_priv->indat_buf); in keyspan_startup()
2835 kfree(s_priv->instat_buf); in keyspan_startup()
2839 return -ENOMEM; in keyspan_startup()
2842 static void keyspan_disconnect(struct usb_serial *serial) in keyspan_disconnect() argument
2846 s_priv = usb_get_serial_data(serial); in keyspan_disconnect()
2848 usb_kill_urb(s_priv->instat_urb); in keyspan_disconnect()
2849 usb_kill_urb(s_priv->glocont_urb); in keyspan_disconnect()
2850 usb_kill_urb(s_priv->indat_urb); in keyspan_disconnect()
2853 static void keyspan_release(struct usb_serial *serial) in keyspan_release() argument
2857 s_priv = usb_get_serial_data(serial); in keyspan_release()
2860 usb_kill_urb(s_priv->instat_urb); in keyspan_release()
2861 usb_kill_urb(s_priv->indat_urb); in keyspan_release()
2863 usb_free_urb(s_priv->instat_urb); in keyspan_release()
2864 usb_free_urb(s_priv->indat_urb); in keyspan_release()
2865 usb_free_urb(s_priv->glocont_urb); in keyspan_release()
2867 kfree(s_priv->ctrl_buf); in keyspan_release()
2868 kfree(s_priv->glocont_buf); in keyspan_release()
2869 kfree(s_priv->indat_buf); in keyspan_release()
2870 kfree(s_priv->instat_buf); in keyspan_release()
2877 struct usb_serial *serial = port->serial; in keyspan_port_probe() local
2886 s_priv = usb_get_serial_data(serial); in keyspan_port_probe()
2887 d_details = s_priv->device_details; in keyspan_port_probe()
2891 return -ENOMEM; in keyspan_port_probe()
2893 for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) { in keyspan_port_probe()
2894 p_priv->in_buffer[i] = kzalloc(IN_BUFLEN, GFP_KERNEL); in keyspan_port_probe()
2895 if (!p_priv->in_buffer[i]) in keyspan_port_probe()
2899 for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) { in keyspan_port_probe()
2900 p_priv->out_buffer[i] = kzalloc(OUT_BUFLEN, GFP_KERNEL); in keyspan_port_probe()
2901 if (!p_priv->out_buffer[i]) in keyspan_port_probe()
2905 p_priv->inack_buffer = kzalloc(INACK_BUFLEN, GFP_KERNEL); in keyspan_port_probe()
2906 if (!p_priv->inack_buffer) in keyspan_port_probe()
2909 p_priv->outcont_buffer = kzalloc(OUTCONT_BUFLEN, GFP_KERNEL); in keyspan_port_probe()
2910 if (!p_priv->outcont_buffer) in keyspan_port_probe()
2913 p_priv->device_details = d_details; in keyspan_port_probe()
2916 cback = &keyspan_callbacks[d_details->msg_format]; in keyspan_port_probe()
2918 port_num = port->port_number; in keyspan_port_probe()
2921 endp = d_details->indat_endpoints[port_num]; in keyspan_port_probe()
2922 for (i = 0; i <= d_details->indat_endp_flip; ++i, ++endp) { in keyspan_port_probe()
2923 p_priv->in_urbs[i] = keyspan_setup_urb(serial, endp, in keyspan_port_probe()
2925 p_priv->in_buffer[i], in keyspan_port_probe()
2927 cback->indat_callback); in keyspan_port_probe()
2930 endp = d_details->outdat_endpoints[port_num]; in keyspan_port_probe()
2931 for (i = 0; i <= d_details->outdat_endp_flip; ++i, ++endp) { in keyspan_port_probe()
2932 p_priv->out_urbs[i] = keyspan_setup_urb(serial, endp, in keyspan_port_probe()
2934 p_priv->out_buffer[i], in keyspan_port_probe()
2936 cback->outdat_callback); in keyspan_port_probe()
2939 p_priv->inack_urb = keyspan_setup_urb(serial, in keyspan_port_probe()
2940 d_details->inack_endpoints[port_num], in keyspan_port_probe()
2942 p_priv->inack_buffer, in keyspan_port_probe()
2944 cback->inack_callback); in keyspan_port_probe()
2946 p_priv->outcont_urb = keyspan_setup_urb(serial, in keyspan_port_probe()
2947 d_details->outcont_endpoints[port_num], in keyspan_port_probe()
2949 p_priv->outcont_buffer, in keyspan_port_probe()
2951 cback->outcont_callback); in keyspan_port_probe()
2958 kfree(p_priv->inack_buffer); in keyspan_port_probe()
2960 for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) in keyspan_port_probe()
2961 kfree(p_priv->out_buffer[i]); in keyspan_port_probe()
2963 for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) in keyspan_port_probe()
2964 kfree(p_priv->in_buffer[i]); in keyspan_port_probe()
2967 return -ENOMEM; in keyspan_port_probe()
2977 usb_kill_urb(p_priv->inack_urb); in keyspan_port_remove()
2978 usb_kill_urb(p_priv->outcont_urb); in keyspan_port_remove()
2980 usb_kill_urb(p_priv->in_urbs[i]); in keyspan_port_remove()
2981 usb_kill_urb(p_priv->out_urbs[i]); in keyspan_port_remove()
2984 usb_free_urb(p_priv->inack_urb); in keyspan_port_remove()
2985 usb_free_urb(p_priv->outcont_urb); in keyspan_port_remove()
2987 usb_free_urb(p_priv->in_urbs[i]); in keyspan_port_remove()
2988 usb_free_urb(p_priv->out_urbs[i]); in keyspan_port_remove()
2991 kfree(p_priv->outcont_buffer); in keyspan_port_remove()
2992 kfree(p_priv->inack_buffer); in keyspan_port_remove()
2993 for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) in keyspan_port_remove()
2994 kfree(p_priv->out_buffer[i]); in keyspan_port_remove()
2995 for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) in keyspan_port_remove()
2996 kfree(p_priv->in_buffer[i]); in keyspan_port_remove()
3006 .description = "Keyspan - (without firmware)",