2 * USB ConnectTech WhiteHEAT driver
7 * Copyright (C) 1999 - 2001
8 * Greg Kroah-Hartman (greg@kroah.com)
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * See Documentation/usb/usb-serial.txt for more information on using this
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/tty.h>
24 #include <linux/tty_driver.h>
25 #include <linux/tty_flip.h>
26 #include <linux/module.h>
27 #include <linux/spinlock.h>
28 #include <linux/mutex.h>
29 #include <linux/uaccess.h>
30 #include <asm/termbits.h>
31 #include <linux/usb.h>
32 #include <linux/serial_reg.h>
33 #include <linux/serial.h>
34 #include <linux/usb/serial.h>
35 #include <linux/usb/ezusb.h>
36 #include "whiteheat.h" /* WhiteHEAT specific commands */
45 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Stuart MacDonald <stuartm@connecttech.com>"
46 #define DRIVER_DESC "USB ConnectTech WhiteHEAT driver"
48 #define CONNECT_TECH_VENDOR_ID 0x0710
49 #define CONNECT_TECH_FAKE_WHITE_HEAT_ID 0x0001
50 #define CONNECT_TECH_WHITE_HEAT_ID 0x8001
53 ID tables for whiteheat are unusual, because we want to different
54 things for different versions of the device. Eventually, this
55 will be doable from a single table. But, for now, we define two
56 separate ID tables, and then a third table that combines them
57 just for the purpose of exporting the autoloading information.
59 static const struct usb_device_id id_table_std[] = {
60 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) },
61 { } /* Terminating entry */
64 static const struct usb_device_id id_table_prerenumeration[] = {
65 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) },
66 { } /* Terminating entry */
69 static const struct usb_device_id id_table_combined[] = {
70 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) },
71 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) },
72 { } /* Terminating entry */
75 MODULE_DEVICE_TABLE(usb, id_table_combined);
78 /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
79 static int whiteheat_firmware_download(struct usb_serial *serial,
80 const struct usb_device_id *id);
81 static int whiteheat_firmware_attach(struct usb_serial *serial);
83 /* function prototypes for the Connect Tech WhiteHEAT serial converter */
84 static int whiteheat_attach(struct usb_serial *serial);
85 static void whiteheat_release(struct usb_serial *serial);
86 static int whiteheat_open(struct tty_struct *tty,
87 struct usb_serial_port *port);
88 static void whiteheat_close(struct usb_serial_port *port);
89 static int whiteheat_ioctl(struct tty_struct *tty,
90 unsigned int cmd, unsigned long arg);
91 static void whiteheat_set_termios(struct tty_struct *tty,
92 struct usb_serial_port *port, struct ktermios *old);
93 static int whiteheat_tiocmget(struct tty_struct *tty);
94 static int whiteheat_tiocmset(struct tty_struct *tty,
95 unsigned int set, unsigned int clear);
96 static void whiteheat_break_ctl(struct tty_struct *tty, int break_state);
98 static struct usb_serial_driver whiteheat_fake_device = {
100 .owner = THIS_MODULE,
101 .name = "whiteheatnofirm",
103 .description = "Connect Tech - WhiteHEAT - (prerenumeration)",
104 .id_table = id_table_prerenumeration,
106 .probe = whiteheat_firmware_download,
107 .attach = whiteheat_firmware_attach,
110 static struct usb_serial_driver whiteheat_device = {
112 .owner = THIS_MODULE,
115 .description = "Connect Tech - WhiteHEAT",
116 .id_table = id_table_std,
118 .attach = whiteheat_attach,
119 .release = whiteheat_release,
120 .open = whiteheat_open,
121 .close = whiteheat_close,
122 .ioctl = whiteheat_ioctl,
123 .set_termios = whiteheat_set_termios,
124 .break_ctl = whiteheat_break_ctl,
125 .tiocmget = whiteheat_tiocmget,
126 .tiocmset = whiteheat_tiocmset,
127 .throttle = usb_serial_generic_throttle,
128 .unthrottle = usb_serial_generic_unthrottle,
131 static struct usb_serial_driver * const serial_drivers[] = {
132 &whiteheat_fake_device, &whiteheat_device, NULL
135 struct whiteheat_command_private {
138 __u8 command_finished;
139 wait_queue_head_t wait_command; /* for handling sleeping whilst
140 waiting for a command to
142 __u8 result_buffer[64];
145 struct whiteheat_private {
146 __u8 mcr; /* FIXME: no locking on mcr */
150 /* local function prototypes */
151 static int start_command_port(struct usb_serial *serial);
152 static void stop_command_port(struct usb_serial *serial);
153 static void command_port_write_callback(struct urb *urb);
154 static void command_port_read_callback(struct urb *urb);
156 static int firm_send_command(struct usb_serial_port *port, __u8 command,
157 __u8 *data, __u8 datasize);
158 static int firm_open(struct usb_serial_port *port);
159 static int firm_close(struct usb_serial_port *port);
160 static void firm_setup_port(struct tty_struct *tty);
161 static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
162 static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
163 static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
164 static int firm_purge(struct usb_serial_port *port, __u8 rxtx);
165 static int firm_get_dtr_rts(struct usb_serial_port *port);
166 static int firm_report_tx_done(struct usb_serial_port *port);
169 #define COMMAND_PORT 4
170 #define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */
171 #define COMMAND_TIMEOUT_MS 2000
172 #define CLOSING_DELAY (30 * HZ)
175 /*****************************************************************************
176 * Connect Tech's White Heat prerenumeration driver functions
177 *****************************************************************************/
179 /* steps to download the firmware to the WhiteHEAT device:
180 - hold the reset (by writing to the reset bit of the CPUCS register)
181 - download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD
182 - release the reset (by writing to the CPUCS register)
183 - download the WH.HEX file for all addresses greater than 0x1b3f using
184 VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
186 - download the WH.HEX file for all addresses less than 0x1b40 using
187 VENDOR_REQUEST_ANCHOR_LOAD
189 - device renumerated itself and comes up as new device id with all
190 firmware download completed.
192 static int whiteheat_firmware_download(struct usb_serial *serial,
193 const struct usb_device_id *id)
197 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw");
199 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw");
207 static int whiteheat_firmware_attach(struct usb_serial *serial)
209 /* We want this device to fail to have a driver assigned to it */
214 /*****************************************************************************
215 * Connect Tech's White Heat serial driver functions
216 *****************************************************************************/
217 static int whiteheat_attach(struct usb_serial *serial)
219 struct usb_serial_port *command_port;
220 struct whiteheat_command_private *command_info;
221 struct usb_serial_port *port;
222 struct whiteheat_private *info;
223 struct whiteheat_hw_info *hw_info;
231 command_port = serial->port[COMMAND_PORT];
233 pipe = usb_sndbulkpipe(serial->dev,
234 command_port->bulk_out_endpointAddress);
235 command = kmalloc(2, GFP_KERNEL);
237 goto no_command_buffer;
238 command[0] = WHITEHEAT_GET_HW_INFO;
241 result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL);
243 goto no_result_buffer;
245 * When the module is reloaded the firmware is still there and
246 * the endpoints are still in the usb core unchanged. This is the
247 * unlinking bug in disguise. Same for the call below.
249 usb_clear_halt(serial->dev, pipe);
250 ret = usb_bulk_msg(serial->dev, pipe, command, 2,
251 &alen, COMMAND_TIMEOUT_MS);
253 dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n",
254 serial->type->description, ret);
256 } else if (alen != 2) {
257 dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n",
258 serial->type->description, alen);
262 pipe = usb_rcvbulkpipe(serial->dev,
263 command_port->bulk_in_endpointAddress);
264 /* See the comment on the usb_clear_halt() above */
265 usb_clear_halt(serial->dev, pipe);
266 ret = usb_bulk_msg(serial->dev, pipe, result,
267 sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS);
269 dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n",
270 serial->type->description, ret);
272 } else if (alen != sizeof(*hw_info) + 1) {
273 dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n",
274 serial->type->description, alen);
276 } else if (result[0] != command[0]) {
277 dev_err(&serial->dev->dev, "%s: Command failed [%d]\n",
278 serial->type->description, result[0]);
282 hw_info = (struct whiteheat_hw_info *)&result[1];
284 dev_info(&serial->dev->dev, "%s: Firmware v%d.%02d\n",
285 serial->type->description,
286 hw_info->sw_major_rev, hw_info->sw_minor_rev);
288 for (i = 0; i < serial->num_ports; i++) {
289 port = serial->port[i];
291 info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
294 "%s: Out of memory for port structures\n",
295 serial->type->description);
301 usb_set_serial_port_data(port, info);
304 command_info = kmalloc(sizeof(struct whiteheat_command_private),
306 if (command_info == NULL) {
307 dev_err(&serial->dev->dev,
308 "%s: Out of memory for port structures\n",
309 serial->type->description);
310 goto no_command_private;
313 mutex_init(&command_info->mutex);
314 command_info->port_running = 0;
315 init_waitqueue_head(&command_info->wait_command);
316 usb_set_serial_port_data(command_port, command_info);
317 command_port->write_urb->complete = command_port_write_callback;
318 command_port->read_urb->complete = command_port_read_callback;
325 /* Firmware likely not running */
326 dev_err(&serial->dev->dev,
327 "%s: Unable to retrieve firmware version, try replugging\n",
328 serial->type->description);
329 dev_err(&serial->dev->dev,
330 "%s: If the firmware is not running (status led not blinking)\n",
331 serial->type->description);
332 dev_err(&serial->dev->dev,
333 "%s: please contact support@connecttech.com\n",
334 serial->type->description);
339 for (i = serial->num_ports - 1; i >= 0; i--) {
340 port = serial->port[i];
341 info = usb_get_serial_port_data(port);
354 static void whiteheat_release(struct usb_serial *serial)
356 struct usb_serial_port *command_port;
357 struct whiteheat_private *info;
360 /* free up our private data for our command port */
361 command_port = serial->port[COMMAND_PORT];
362 kfree(usb_get_serial_port_data(command_port));
364 for (i = 0; i < serial->num_ports; i++) {
365 info = usb_get_serial_port_data(serial->port[i]);
370 static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port)
374 retval = start_command_port(port->serial);
378 /* send an open port command */
379 retval = firm_open(port);
381 stop_command_port(port->serial);
385 retval = firm_purge(port, WHITEHEAT_PURGE_RX | WHITEHEAT_PURGE_TX);
388 stop_command_port(port->serial);
393 firm_setup_port(tty);
395 /* Work around HCD bugs */
396 usb_clear_halt(port->serial->dev, port->read_urb->pipe);
397 usb_clear_halt(port->serial->dev, port->write_urb->pipe);
399 retval = usb_serial_generic_open(tty, port);
402 stop_command_port(port->serial);
410 static void whiteheat_close(struct usb_serial_port *port)
412 firm_report_tx_done(port);
415 usb_serial_generic_close(port);
417 stop_command_port(port->serial);
420 static int whiteheat_tiocmget(struct tty_struct *tty)
422 struct usb_serial_port *port = tty->driver_data;
423 struct whiteheat_private *info = usb_get_serial_port_data(port);
424 unsigned int modem_signals = 0;
426 firm_get_dtr_rts(port);
427 if (info->mcr & UART_MCR_DTR)
428 modem_signals |= TIOCM_DTR;
429 if (info->mcr & UART_MCR_RTS)
430 modem_signals |= TIOCM_RTS;
432 return modem_signals;
435 static int whiteheat_tiocmset(struct tty_struct *tty,
436 unsigned int set, unsigned int clear)
438 struct usb_serial_port *port = tty->driver_data;
439 struct whiteheat_private *info = usb_get_serial_port_data(port);
442 info->mcr |= UART_MCR_RTS;
444 info->mcr |= UART_MCR_DTR;
446 if (clear & TIOCM_RTS)
447 info->mcr &= ~UART_MCR_RTS;
448 if (clear & TIOCM_DTR)
449 info->mcr &= ~UART_MCR_DTR;
451 firm_set_dtr(port, info->mcr & UART_MCR_DTR);
452 firm_set_rts(port, info->mcr & UART_MCR_RTS);
457 static int whiteheat_ioctl(struct tty_struct *tty,
458 unsigned int cmd, unsigned long arg)
460 struct usb_serial_port *port = tty->driver_data;
461 struct serial_struct serstruct;
462 void __user *user_arg = (void __user *)arg;
464 dev_dbg(&port->dev, "%s - cmd 0x%.4x\n", __func__, cmd);
468 memset(&serstruct, 0, sizeof(serstruct));
469 serstruct.type = PORT_16654;
470 serstruct.line = port->serial->minor;
471 serstruct.port = port->number;
472 serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
473 serstruct.xmit_fifo_size = kfifo_size(&port->write_fifo);
474 serstruct.custom_divisor = 0;
475 serstruct.baud_base = 460800;
476 serstruct.close_delay = CLOSING_DELAY;
477 serstruct.closing_wait = CLOSING_DELAY;
479 if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
490 static void whiteheat_set_termios(struct tty_struct *tty,
491 struct usb_serial_port *port, struct ktermios *old_termios)
493 firm_setup_port(tty);
496 static void whiteheat_break_ctl(struct tty_struct *tty, int break_state)
498 struct usb_serial_port *port = tty->driver_data;
499 firm_set_break(port, break_state);
503 /*****************************************************************************
504 * Connect Tech's White Heat callback routines
505 *****************************************************************************/
506 static void command_port_write_callback(struct urb *urb)
508 int status = urb->status;
511 dev_dbg(&urb->dev->dev, "nonzero urb status: %d\n", status);
517 static void command_port_read_callback(struct urb *urb)
519 struct usb_serial_port *command_port = urb->context;
520 struct whiteheat_command_private *command_info;
521 int status = urb->status;
522 unsigned char *data = urb->transfer_buffer;
525 command_info = usb_get_serial_port_data(command_port);
527 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);
531 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);
532 if (status != -ENOENT)
533 command_info->command_finished = WHITEHEAT_CMD_FAILURE;
534 wake_up(&command_info->wait_command);
538 usb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data);
540 if (data[0] == WHITEHEAT_CMD_COMPLETE) {
541 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
542 wake_up(&command_info->wait_command);
543 } else if (data[0] == WHITEHEAT_CMD_FAILURE) {
544 command_info->command_finished = WHITEHEAT_CMD_FAILURE;
545 wake_up(&command_info->wait_command);
546 } else if (data[0] == WHITEHEAT_EVENT) {
547 /* These are unsolicited reports from the firmware, hence no
548 waiting command to wakeup */
549 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__);
550 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
551 memcpy(command_info->result_buffer, &data[1],
552 urb->actual_length - 1);
553 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
554 wake_up(&command_info->wait_command);
556 dev_dbg(&urb->dev->dev, "%s - bad reply from firmware\n", __func__);
558 /* Continue trying to always read */
559 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
561 dev_dbg(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n",
566 /*****************************************************************************
567 * Connect Tech's White Heat firmware interface
568 *****************************************************************************/
569 static int firm_send_command(struct usb_serial_port *port, __u8 command,
570 __u8 *data, __u8 datasize)
572 struct usb_serial_port *command_port;
573 struct whiteheat_command_private *command_info;
574 struct whiteheat_private *info;
575 struct device *dev = &port->dev;
576 __u8 *transfer_buffer;
580 dev_dbg(dev, "%s - command %d\n", __func__, command);
582 command_port = port->serial->port[COMMAND_PORT];
583 command_info = usb_get_serial_port_data(command_port);
584 mutex_lock(&command_info->mutex);
585 command_info->command_finished = false;
587 transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer;
588 transfer_buffer[0] = command;
589 memcpy(&transfer_buffer[1], data, datasize);
590 command_port->write_urb->transfer_buffer_length = datasize + 1;
591 retval = usb_submit_urb(command_port->write_urb, GFP_NOIO);
593 dev_dbg(dev, "%s - submit urb failed\n", __func__);
597 /* wait for the command to complete */
598 t = wait_event_timeout(command_info->wait_command,
599 (bool)command_info->command_finished, COMMAND_TIMEOUT);
601 usb_kill_urb(command_port->write_urb);
603 if (command_info->command_finished == false) {
604 dev_dbg(dev, "%s - command timed out.\n", __func__);
609 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) {
610 dev_dbg(dev, "%s - command failed.\n", __func__);
615 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) {
616 dev_dbg(dev, "%s - command completed.\n", __func__);
618 case WHITEHEAT_GET_DTR_RTS:
619 info = usb_get_serial_port_data(port);
620 memcpy(&info->mcr, command_info->result_buffer,
621 sizeof(struct whiteheat_dr_info));
626 mutex_unlock(&command_info->mutex);
631 static int firm_open(struct usb_serial_port *port)
633 struct whiteheat_simple open_command;
635 open_command.port = port->number - port->serial->minor + 1;
636 return firm_send_command(port, WHITEHEAT_OPEN,
637 (__u8 *)&open_command, sizeof(open_command));
641 static int firm_close(struct usb_serial_port *port)
643 struct whiteheat_simple close_command;
645 close_command.port = port->number - port->serial->minor + 1;
646 return firm_send_command(port, WHITEHEAT_CLOSE,
647 (__u8 *)&close_command, sizeof(close_command));
651 static void firm_setup_port(struct tty_struct *tty)
653 struct usb_serial_port *port = tty->driver_data;
654 struct device *dev = &port->dev;
655 struct whiteheat_port_settings port_settings;
656 unsigned int cflag = tty->termios.c_cflag;
658 port_settings.port = port->number + 1;
660 /* get the byte size */
661 switch (cflag & CSIZE) {
662 case CS5: port_settings.bits = 5; break;
663 case CS6: port_settings.bits = 6; break;
664 case CS7: port_settings.bits = 7; break;
666 case CS8: port_settings.bits = 8; break;
668 dev_dbg(dev, "%s - data bits = %d\n", __func__, port_settings.bits);
670 /* determine the parity */
674 port_settings.parity = WHITEHEAT_PAR_MARK;
676 port_settings.parity = WHITEHEAT_PAR_SPACE;
679 port_settings.parity = WHITEHEAT_PAR_ODD;
681 port_settings.parity = WHITEHEAT_PAR_EVEN;
683 port_settings.parity = WHITEHEAT_PAR_NONE;
684 dev_dbg(dev, "%s - parity = %c\n", __func__, port_settings.parity);
686 /* figure out the stop bits requested */
688 port_settings.stop = 2;
690 port_settings.stop = 1;
691 dev_dbg(dev, "%s - stop bits = %d\n", __func__, port_settings.stop);
693 /* figure out the flow control settings */
695 port_settings.hflow = (WHITEHEAT_HFLOW_CTS |
696 WHITEHEAT_HFLOW_RTS);
698 port_settings.hflow = WHITEHEAT_HFLOW_NONE;
699 dev_dbg(dev, "%s - hardware flow control = %s %s %s %s\n", __func__,
700 (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "",
701 (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "",
702 (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "",
703 (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : "");
705 /* determine software flow control */
707 port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
709 port_settings.sflow = WHITEHEAT_SFLOW_NONE;
710 dev_dbg(dev, "%s - software flow control = %c\n", __func__, port_settings.sflow);
712 port_settings.xon = START_CHAR(tty);
713 port_settings.xoff = STOP_CHAR(tty);
714 dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff);
716 /* get the baud rate wanted */
717 port_settings.baud = tty_get_baud_rate(tty);
718 dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud);
720 /* fixme: should set validated settings */
721 tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud);
722 /* handle any settings that aren't specified in the tty structure */
723 port_settings.lloop = 0;
725 /* now send the message to the device */
726 firm_send_command(port, WHITEHEAT_SETUP_PORT,
727 (__u8 *)&port_settings, sizeof(port_settings));
731 static int firm_set_rts(struct usb_serial_port *port, __u8 onoff)
733 struct whiteheat_set_rdb rts_command;
735 rts_command.port = port->number - port->serial->minor + 1;
736 rts_command.state = onoff;
737 return firm_send_command(port, WHITEHEAT_SET_RTS,
738 (__u8 *)&rts_command, sizeof(rts_command));
742 static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff)
744 struct whiteheat_set_rdb dtr_command;
746 dtr_command.port = port->number - port->serial->minor + 1;
747 dtr_command.state = onoff;
748 return firm_send_command(port, WHITEHEAT_SET_DTR,
749 (__u8 *)&dtr_command, sizeof(dtr_command));
753 static int firm_set_break(struct usb_serial_port *port, __u8 onoff)
755 struct whiteheat_set_rdb break_command;
757 break_command.port = port->number - port->serial->minor + 1;
758 break_command.state = onoff;
759 return firm_send_command(port, WHITEHEAT_SET_BREAK,
760 (__u8 *)&break_command, sizeof(break_command));
764 static int firm_purge(struct usb_serial_port *port, __u8 rxtx)
766 struct whiteheat_purge purge_command;
768 purge_command.port = port->number - port->serial->minor + 1;
769 purge_command.what = rxtx;
770 return firm_send_command(port, WHITEHEAT_PURGE,
771 (__u8 *)&purge_command, sizeof(purge_command));
775 static int firm_get_dtr_rts(struct usb_serial_port *port)
777 struct whiteheat_simple get_dr_command;
779 get_dr_command.port = port->number - port->serial->minor + 1;
780 return firm_send_command(port, WHITEHEAT_GET_DTR_RTS,
781 (__u8 *)&get_dr_command, sizeof(get_dr_command));
785 static int firm_report_tx_done(struct usb_serial_port *port)
787 struct whiteheat_simple close_command;
789 close_command.port = port->number - port->serial->minor + 1;
790 return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE,
791 (__u8 *)&close_command, sizeof(close_command));
795 /*****************************************************************************
796 * Connect Tech's White Heat utility functions
797 *****************************************************************************/
798 static int start_command_port(struct usb_serial *serial)
800 struct usb_serial_port *command_port;
801 struct whiteheat_command_private *command_info;
804 command_port = serial->port[COMMAND_PORT];
805 command_info = usb_get_serial_port_data(command_port);
806 mutex_lock(&command_info->mutex);
807 if (!command_info->port_running) {
808 /* Work around HCD bugs */
809 usb_clear_halt(serial->dev, command_port->read_urb->pipe);
811 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL);
813 dev_err(&serial->dev->dev,
814 "%s - failed submitting read urb, error %d\n",
819 command_info->port_running++;
822 mutex_unlock(&command_info->mutex);
827 static void stop_command_port(struct usb_serial *serial)
829 struct usb_serial_port *command_port;
830 struct whiteheat_command_private *command_info;
832 command_port = serial->port[COMMAND_PORT];
833 command_info = usb_get_serial_port_data(command_port);
834 mutex_lock(&command_info->mutex);
835 command_info->port_running--;
836 if (!command_info->port_running)
837 usb_kill_urb(command_port->read_urb);
838 mutex_unlock(&command_info->mutex);
841 module_usb_serial_driver(serial_drivers, id_table_combined);
843 MODULE_AUTHOR(DRIVER_AUTHOR);
844 MODULE_DESCRIPTION(DRIVER_DESC);
845 MODULE_LICENSE("GPL");
847 MODULE_FIRMWARE("whiteheat.fw");
848 MODULE_FIRMWARE("whiteheat_loader.fw");