2 * USB Cypress M8 driver
5 * Lonnie Mendez (dignome@gmail.com)
6 * Copyright (C) 2003,2004
7 * Neil Whelchel (koyama@firstlight.net)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * See Documentation/usb/usb-serial.txt for more information on using this driver
16 * See http://geocities.com/i0xox0i for information on this driver and the
17 * earthmate usb device.
19 * Lonnie Mendez <dignome@gmail.com>
21 * Fixed problem where setting or retreiving the serial config would fail with
22 * EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial
23 * adapters. Issued new interval of 1ms instead of the default 10ms. As a
24 * result, transfer speed has been substantially increased. From avg. 850bps to
25 * avg. 3300bps. initial termios has also been modified. Cleaned up code and
26 * formatting issues so it is more readable. Replaced the C++ style comments.
28 * Lonnie Mendez <dignome@gmail.com>
30 * Incorporated write buffering from pl2303 driver. Fixed bug with line
31 * handling so both lines are raised in cypress_open. (was dropping rts)
32 * Various code cleanups made as well along with other misc bug fixes.
34 * Lonnie Mendez <dignome@gmail.com>
36 * Driver modified to support dynamic line settings. Various improvments
41 * Driver first released.
45 /* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */
46 /* Thanks to cypress for providing references for the hid reports. */
47 /* Thanks to Jiang Zhang for providing links and for general help. */
48 /* Code originates and was built up from ftdi_sio, belkin, pl2303 and others. */
51 #include <linux/config.h>
52 #include <linux/kernel.h>
53 #include <linux/errno.h>
54 #include <linux/init.h>
55 #include <linux/slab.h>
56 #include <linux/tty.h>
57 #include <linux/tty_driver.h>
58 #include <linux/tty_flip.h>
59 #include <linux/module.h>
60 #include <linux/moduleparam.h>
61 #include <linux/spinlock.h>
62 #include <linux/usb.h>
63 #include <linux/serial.h>
64 #include <linux/delay.h>
65 #include <asm/uaccess.h>
67 #include "usb-serial.h"
68 #include "cypress_m8.h"
71 #ifdef CONFIG_USB_SERIAL_DEBUG
82 #define DRIVER_VERSION "v1.09"
83 #define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
84 #define DRIVER_DESC "Cypress USB to Serial Driver"
86 /* write buffer size defines */
87 #define CYPRESS_BUF_SIZE 1024
88 #define CYPRESS_CLOSING_WAIT (30*HZ)
90 static struct usb_device_id id_table_earthmate [] = {
91 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
92 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
93 { } /* Terminating entry */
96 static struct usb_device_id id_table_cyphidcomrs232 [] = {
97 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
98 { } /* Terminating entry */
101 static struct usb_device_id id_table_nokiaca42v2 [] = {
102 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
103 { } /* Terminating entry */
106 static struct usb_device_id id_table_combined [] = {
107 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
108 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
109 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
110 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
111 { } /* Terminating entry */
114 MODULE_DEVICE_TABLE (usb, id_table_combined);
116 static struct usb_driver cypress_driver = {
118 .probe = usb_serial_probe,
119 .disconnect = usb_serial_disconnect,
120 .id_table = id_table_combined,
124 struct cypress_private {
125 spinlock_t lock; /* private lock */
126 int chiptype; /* identifier of device, for quirks/etc */
127 int bytes_in; /* used for statistics */
128 int bytes_out; /* used for statistics */
129 int cmd_count; /* used for statistics */
130 int cmd_ctrl; /* always set this to 1 before issuing a command */
131 struct cypress_buf *buf; /* write buffer */
132 int write_urb_in_use; /* write urb in use indicator */
133 int termios_initialized;
134 __u8 line_control; /* holds dtr / rts value */
135 __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */
136 __u8 current_config; /* stores the current configuration byte */
137 __u8 rx_flags; /* throttling - used from whiteheat/ftdi_sio */
138 int baud_rate; /* stores current baud rate in integer form */
139 int cbr_mask; /* stores current baud rate in masked form */
140 int isthrottled; /* if throttled, discard reads */
141 wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */
142 char prev_status, diff_status; /* used for TIOCMIWAIT */
143 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
144 struct termios tmp_termios; /* stores the old termios settings */
147 /* write buffer structure */
149 unsigned int buf_size;
155 /* function prototypes for the Cypress USB to serial device */
156 static int cypress_earthmate_startup (struct usb_serial *serial);
157 static int cypress_hidcom_startup (struct usb_serial *serial);
158 static int cypress_ca42v2_startup (struct usb_serial *serial);
159 static void cypress_shutdown (struct usb_serial *serial);
160 static int cypress_open (struct usb_serial_port *port, struct file *filp);
161 static void cypress_close (struct usb_serial_port *port, struct file *filp);
162 static int cypress_write (struct usb_serial_port *port, const unsigned char *buf, int count);
163 static void cypress_send (struct usb_serial_port *port);
164 static int cypress_write_room (struct usb_serial_port *port);
165 static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
166 static void cypress_set_termios (struct usb_serial_port *port, struct termios * old);
167 static int cypress_tiocmget (struct usb_serial_port *port, struct file *file);
168 static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
169 static int cypress_chars_in_buffer (struct usb_serial_port *port);
170 static void cypress_throttle (struct usb_serial_port *port);
171 static void cypress_unthrottle (struct usb_serial_port *port);
172 static void cypress_read_int_callback (struct urb *urb, struct pt_regs *regs);
173 static void cypress_write_int_callback (struct urb *urb, struct pt_regs *regs);
174 /* baud helper functions */
175 static int mask_to_rate (unsigned mask);
176 static unsigned rate_to_mask (int rate);
177 /* write buffer functions */
178 static struct cypress_buf *cypress_buf_alloc(unsigned int size);
179 static void cypress_buf_free(struct cypress_buf *cb);
180 static void cypress_buf_clear(struct cypress_buf *cb);
181 static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
182 static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
183 static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count);
184 static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
187 static struct usb_serial_driver cypress_earthmate_device = {
189 .owner = THIS_MODULE,
192 .description = "DeLorme Earthmate USB",
193 .id_table = id_table_earthmate,
194 .num_interrupt_in = 1,
195 .num_interrupt_out = 1,
196 .num_bulk_in = NUM_DONT_CARE,
197 .num_bulk_out = NUM_DONT_CARE,
199 .attach = cypress_earthmate_startup,
200 .shutdown = cypress_shutdown,
201 .open = cypress_open,
202 .close = cypress_close,
203 .write = cypress_write,
204 .write_room = cypress_write_room,
205 .ioctl = cypress_ioctl,
206 .set_termios = cypress_set_termios,
207 .tiocmget = cypress_tiocmget,
208 .tiocmset = cypress_tiocmset,
209 .chars_in_buffer = cypress_chars_in_buffer,
210 .throttle = cypress_throttle,
211 .unthrottle = cypress_unthrottle,
212 .read_int_callback = cypress_read_int_callback,
213 .write_int_callback = cypress_write_int_callback,
216 static struct usb_serial_driver cypress_hidcom_device = {
218 .owner = THIS_MODULE,
221 .description = "HID->COM RS232 Adapter",
222 .id_table = id_table_cyphidcomrs232,
223 .num_interrupt_in = 1,
224 .num_interrupt_out = 1,
225 .num_bulk_in = NUM_DONT_CARE,
226 .num_bulk_out = NUM_DONT_CARE,
228 .attach = cypress_hidcom_startup,
229 .shutdown = cypress_shutdown,
230 .open = cypress_open,
231 .close = cypress_close,
232 .write = cypress_write,
233 .write_room = cypress_write_room,
234 .ioctl = cypress_ioctl,
235 .set_termios = cypress_set_termios,
236 .tiocmget = cypress_tiocmget,
237 .tiocmset = cypress_tiocmset,
238 .chars_in_buffer = cypress_chars_in_buffer,
239 .throttle = cypress_throttle,
240 .unthrottle = cypress_unthrottle,
241 .read_int_callback = cypress_read_int_callback,
242 .write_int_callback = cypress_write_int_callback,
245 static struct usb_serial_driver cypress_ca42v2_device = {
247 .owner = THIS_MODULE,
248 .name = "nokiaca42v2",
250 .description = "Nokia CA-42 V2 Adapter",
251 .id_table = id_table_nokiaca42v2,
252 .num_interrupt_in = 1,
253 .num_interrupt_out = 1,
254 .num_bulk_in = NUM_DONT_CARE,
255 .num_bulk_out = NUM_DONT_CARE,
257 .attach = cypress_ca42v2_startup,
258 .shutdown = cypress_shutdown,
259 .open = cypress_open,
260 .close = cypress_close,
261 .write = cypress_write,
262 .write_room = cypress_write_room,
263 .ioctl = cypress_ioctl,
264 .set_termios = cypress_set_termios,
265 .tiocmget = cypress_tiocmget,
266 .tiocmset = cypress_tiocmset,
267 .chars_in_buffer = cypress_chars_in_buffer,
268 .throttle = cypress_throttle,
269 .unthrottle = cypress_unthrottle,
270 .read_int_callback = cypress_read_int_callback,
271 .write_int_callback = cypress_write_int_callback,
274 /*****************************************************************************
275 * Cypress serial helper functions
276 *****************************************************************************/
279 /* This function can either set or retrieve the current serial line settings */
280 static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,
281 int parity_enable, int parity_type, int reset, int cypress_request_type)
283 int new_baudrate = 0, retval = 0, tries = 0;
284 struct cypress_private *priv;
285 __u8 feature_buffer[8];
288 dbg("%s", __FUNCTION__);
290 priv = usb_get_serial_port_data(port);
292 switch(cypress_request_type) {
293 case CYPRESS_SET_CONFIG:
296 * The general purpose firmware for the Cypress M8 allows for a maximum speed
297 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose
298 * firmware or not), if you need to modify this speed setting for your own
299 * project please add your own chiptype and modify the code likewise. The
300 * Cypress HID->COM device will work successfully up to 115200bps (but the
301 * actual throughput is around 3kBps).
303 if (baud_mask != priv->cbr_mask) {
304 dbg("%s - baud rate is changing", __FUNCTION__);
305 if ( priv->chiptype == CT_EARTHMATE ) {
306 /* 300 and 600 baud rates are supported under the generic firmware,
307 * but are not used with NMEA and SiRF protocols */
309 if ( (baud_mask == B300) || (baud_mask == B600) ) {
310 err("%s - failed setting baud rate, unsupported speed",
312 new_baudrate = priv->baud_rate;
313 } else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
314 err("%s - failed setting baud rate, unsupported speed",
316 new_baudrate = priv->baud_rate;
318 } else if (priv->chiptype == CT_CYPHIDCOM) {
319 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
320 err("%s - failed setting baud rate, unsupported speed",
322 new_baudrate = priv->baud_rate;
324 } else if (priv->chiptype == CT_CA42V2) {
325 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
326 err("%s - failed setting baud rate, unsupported speed",
328 new_baudrate = priv->baud_rate;
330 } else if (priv->chiptype == CT_GENERIC) {
331 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
332 err("%s - failed setting baud rate, unsupported speed",
334 new_baudrate = priv->baud_rate;
337 info("%s - please define your chiptype", __FUNCTION__);
338 new_baudrate = priv->baud_rate;
340 } else { /* baud rate not changing, keep the old */
341 new_baudrate = priv->baud_rate;
343 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate);
345 memset(feature_buffer, 0, 8);
346 /* fill the feature_buffer with new configuration */
347 *((u_int32_t *)feature_buffer) = new_baudrate;
349 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
351 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
352 feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */
353 feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */
355 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
357 dbg("%s - device is being sent this feature report:", __FUNCTION__);
358 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1],
359 feature_buffer[2], feature_buffer[3], feature_buffer[4]);
362 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
363 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
364 0x0300, 0, feature_buffer, 8, 500);
370 usb_clear_halt(port->serial->dev, 0x00);
371 } while (retval != 8 && retval != ENODEV);
374 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
376 spin_lock_irqsave(&priv->lock, flags);
377 priv->baud_rate = new_baudrate;
378 priv->cbr_mask = baud_mask;
379 priv->current_config = feature_buffer[4];
380 spin_unlock_irqrestore(&priv->lock, flags);
383 case CYPRESS_GET_CONFIG:
384 dbg("%s - retreiving serial line settings", __FUNCTION__);
385 /* set initial values in feature buffer */
386 memset(feature_buffer, 0, 8);
389 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
390 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
391 0x0300, 0, feature_buffer, 8, 500);
397 usb_clear_halt(port->serial->dev, 0x00);
398 } while (retval != 5 && retval != ENODEV);
401 err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval);
404 spin_lock_irqsave(&priv->lock, flags);
406 /* store the config in one byte, and later use bit masks to check values */
407 priv->current_config = feature_buffer[4];
408 priv->baud_rate = *((u_int32_t *)feature_buffer);
410 if ( (priv->cbr_mask = rate_to_mask(priv->baud_rate)) == 0x40)
411 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__);
412 spin_unlock_irqrestore(&priv->lock, flags);
415 spin_lock_irqsave(&priv->lock, flags);
417 spin_unlock_irqrestore(&priv->lock, flags);
420 } /* cypress_serial_control */
423 /* given a baud mask, it will return integer baud on success */
424 static int mask_to_rate (unsigned mask)
429 case B0: rate = 0; break;
430 case B300: rate = 300; break;
431 case B600: rate = 600; break;
432 case B1200: rate = 1200; break;
433 case B2400: rate = 2400; break;
434 case B4800: rate = 4800; break;
435 case B9600: rate = 9600; break;
436 case B19200: rate = 19200; break;
437 case B38400: rate = 38400; break;
438 case B57600: rate = 57600; break;
439 case B115200: rate = 115200; break;
447 static unsigned rate_to_mask (int rate)
452 case 0: mask = B0; break;
453 case 300: mask = B300; break;
454 case 600: mask = B600; break;
455 case 1200: mask = B1200; break;
456 case 2400: mask = B2400; break;
457 case 4800: mask = B4800; break;
458 case 9600: mask = B9600; break;
459 case 19200: mask = B19200; break;
460 case 38400: mask = B38400; break;
461 case 57600: mask = B57600; break;
462 case 115200: mask = B115200; break;
463 default: mask = 0x40;
468 /*****************************************************************************
469 * Cypress serial driver functions
470 *****************************************************************************/
473 static int generic_startup (struct usb_serial *serial)
475 struct cypress_private *priv;
477 dbg("%s - port %d", __FUNCTION__, serial->port[0]->number);
479 priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
483 spin_lock_init(&priv->lock);
484 priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE);
485 if (priv->buf == NULL) {
489 init_waitqueue_head(&priv->delta_msr_wait);
491 usb_reset_configuration (serial->dev);
495 priv->line_control = 0;
496 priv->termios_initialized = 0;
498 priv->cbr_mask = B300;
499 usb_set_serial_port_data(serial->port[0], priv);
505 static int cypress_earthmate_startup (struct usb_serial *serial)
507 struct cypress_private *priv;
509 dbg("%s", __FUNCTION__);
511 if (generic_startup(serial)) {
512 dbg("%s - Failed setting up port %d", __FUNCTION__,
513 serial->port[0]->number);
517 priv = usb_get_serial_port_data(serial->port[0]);
518 priv->chiptype = CT_EARTHMATE;
521 } /* cypress_earthmate_startup */
524 static int cypress_hidcom_startup (struct usb_serial *serial)
526 struct cypress_private *priv;
528 dbg("%s", __FUNCTION__);
530 if (generic_startup(serial)) {
531 dbg("%s - Failed setting up port %d", __FUNCTION__,
532 serial->port[0]->number);
536 priv = usb_get_serial_port_data(serial->port[0]);
537 priv->chiptype = CT_CYPHIDCOM;
540 } /* cypress_hidcom_startup */
543 static int cypress_ca42v2_startup (struct usb_serial *serial)
545 struct cypress_private *priv;
547 dbg("%s", __FUNCTION__);
549 if (generic_startup(serial)) {
550 dbg("%s - Failed setting up port %d", __FUNCTION__,
551 serial->port[0]->number);
555 priv = usb_get_serial_port_data(serial->port[0]);
556 priv->chiptype = CT_CA42V2;
559 } /* cypress_ca42v2_startup */
562 static void cypress_shutdown (struct usb_serial *serial)
564 struct cypress_private *priv;
566 dbg ("%s - port %d", __FUNCTION__, serial->port[0]->number);
568 /* all open ports are closed at this point */
570 priv = usb_get_serial_port_data(serial->port[0]);
573 cypress_buf_free(priv->buf);
575 usb_set_serial_port_data(serial->port[0], NULL);
580 static int cypress_open (struct usb_serial_port *port, struct file *filp)
582 struct cypress_private *priv = usb_get_serial_port_data(port);
583 struct usb_serial *serial = port->serial;
587 dbg("%s - port %d", __FUNCTION__, port->number);
589 /* clear halts before open */
590 usb_clear_halt(serial->dev, 0x81);
591 usb_clear_halt(serial->dev, 0x02);
593 spin_lock_irqsave(&priv->lock, flags);
594 /* reset read/write statistics */
599 spin_unlock_irqrestore(&priv->lock, flags);
601 /* setting to zero could cause data loss */
602 port->tty->low_latency = 1;
604 /* raise both lines and set termios */
605 spin_lock_irqsave(&priv->lock, flags);
606 priv->line_control = CONTROL_DTR | CONTROL_RTS;
608 spin_unlock_irqrestore(&priv->lock, flags);
609 result = cypress_write(port, NULL, 0);
612 dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __FUNCTION__, result);
615 dbg("%s - success setting the control lines", __FUNCTION__);
617 cypress_set_termios(port, &priv->tmp_termios);
619 /* setup the port and start reading from the device */
620 if(!port->interrupt_in_urb){
621 err("%s - interrupt_in_urb is empty!", __FUNCTION__);
625 usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
626 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
627 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
628 cypress_read_int_callback, port, interval);
629 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
632 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
639 static void cypress_close(struct usb_serial_port *port, struct file * filp)
641 struct cypress_private *priv = usb_get_serial_port_data(port);
642 unsigned int c_cflag;
648 dbg("%s - port %d", __FUNCTION__, port->number);
650 /* wait for data to drain from buffer */
651 spin_lock_irqsave(&priv->lock, flags);
652 timeout = CYPRESS_CLOSING_WAIT;
653 init_waitqueue_entry(&wait, current);
654 add_wait_queue(&port->tty->write_wait, &wait);
656 set_current_state(TASK_INTERRUPTIBLE);
657 if (cypress_buf_data_avail(priv->buf) == 0
658 || timeout == 0 || signal_pending(current)
659 || !usb_get_intfdata(port->serial->interface))
661 spin_unlock_irqrestore(&priv->lock, flags);
662 timeout = schedule_timeout(timeout);
663 spin_lock_irqsave(&priv->lock, flags);
665 set_current_state(TASK_RUNNING);
666 remove_wait_queue(&port->tty->write_wait, &wait);
667 /* clear out any remaining data in the buffer */
668 cypress_buf_clear(priv->buf);
669 spin_unlock_irqrestore(&priv->lock, flags);
671 /* wait for characters to drain from device */
672 bps = tty_get_baud_rate(port->tty);
674 timeout = max((HZ*2560)/bps,HZ/10);
677 schedule_timeout_interruptible(timeout);
679 dbg("%s - stopping urbs", __FUNCTION__);
680 usb_kill_urb (port->interrupt_in_urb);
681 usb_kill_urb (port->interrupt_out_urb);
684 c_cflag = port->tty->termios->c_cflag;
685 if (c_cflag & HUPCL) {
686 /* drop dtr and rts */
687 priv = usb_get_serial_port_data(port);
688 spin_lock_irqsave(&priv->lock, flags);
689 priv->line_control = 0;
691 spin_unlock_irqrestore(&priv->lock, flags);
692 cypress_write(port, NULL, 0);
697 dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
698 priv->bytes_in, priv->bytes_out, priv->cmd_count);
699 } /* cypress_close */
702 static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, int count)
704 struct cypress_private *priv = usb_get_serial_port_data(port);
707 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
709 /* line control commands, which need to be executed immediately,
710 are not put into the buffer for obvious reasons.
712 if (priv->cmd_ctrl) {
720 spin_lock_irqsave(&priv->lock, flags);
721 count = cypress_buf_put(priv->buf, buf, count);
722 spin_unlock_irqrestore(&priv->lock, flags);
728 } /* cypress_write */
731 static void cypress_send(struct usb_serial_port *port)
733 int count = 0, result, offset, actual_size;
734 struct cypress_private *priv = usb_get_serial_port_data(port);
737 dbg("%s - port %d", __FUNCTION__, port->number);
738 dbg("%s - interrupt out size is %d", __FUNCTION__, port->interrupt_out_size);
740 spin_lock_irqsave(&priv->lock, flags);
741 if (priv->write_urb_in_use) {
742 dbg("%s - can't write, urb in use", __FUNCTION__);
743 spin_unlock_irqrestore(&priv->lock, flags);
746 spin_unlock_irqrestore(&priv->lock, flags);
749 memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size);
751 spin_lock_irqsave(&priv->lock, flags);
752 switch (port->interrupt_out_size) {
754 /* this is for the CY7C64013... */
756 port->interrupt_out_buffer[0] = priv->line_control;
759 /* this is for the CY7C63743... */
761 port->interrupt_out_buffer[0] = priv->line_control;
764 dbg("%s - wrong packet size", __FUNCTION__);
765 spin_unlock_irqrestore(&priv->lock, flags);
769 if (priv->line_control & CONTROL_RESET)
770 priv->line_control &= ~CONTROL_RESET;
772 if (priv->cmd_ctrl) {
774 dbg("%s - line control command being issued", __FUNCTION__);
775 spin_unlock_irqrestore(&priv->lock, flags);
778 spin_unlock_irqrestore(&priv->lock, flags);
780 count = cypress_buf_get(priv->buf, &port->interrupt_out_buffer[offset],
781 port->interrupt_out_size-offset);
787 switch (port->interrupt_out_size) {
789 port->interrupt_out_buffer[1] = count;
792 port->interrupt_out_buffer[0] |= count;
795 dbg("%s - count is %d", __FUNCTION__, count);
798 spin_lock_irqsave(&priv->lock, flags);
799 priv->write_urb_in_use = 1;
800 spin_unlock_irqrestore(&priv->lock, flags);
805 actual_size = count + (port->interrupt_out_size == 32 ? 2 : 1);
807 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, port->interrupt_out_size,
808 port->interrupt_out_urb->transfer_buffer);
810 port->interrupt_out_urb->transfer_buffer_length = actual_size;
811 port->interrupt_out_urb->dev = port->serial->dev;
812 port->interrupt_out_urb->interval = interval;
813 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
815 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__,
817 priv->write_urb_in_use = 0;
820 spin_lock_irqsave(&priv->lock, flags);
821 if (priv->cmd_ctrl) {
824 priv->bytes_out += count; /* do not count the line control and size bytes */
825 spin_unlock_irqrestore(&priv->lock, flags);
827 schedule_work(&port->work);
831 /* returns how much space is available in the soft buffer */
832 static int cypress_write_room(struct usb_serial_port *port)
834 struct cypress_private *priv = usb_get_serial_port_data(port);
838 dbg("%s - port %d", __FUNCTION__, port->number);
840 spin_lock_irqsave(&priv->lock, flags);
841 room = cypress_buf_space_avail(priv->buf);
842 spin_unlock_irqrestore(&priv->lock, flags);
844 dbg("%s - returns %d", __FUNCTION__, room);
849 static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
851 struct cypress_private *priv = usb_get_serial_port_data(port);
852 __u8 status, control;
853 unsigned int result = 0;
856 dbg("%s - port %d", __FUNCTION__, port->number);
858 spin_lock_irqsave(&priv->lock, flags);
859 control = priv->line_control;
860 status = priv->current_status;
861 spin_unlock_irqrestore(&priv->lock, flags);
863 result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0)
864 | ((control & CONTROL_RTS) ? TIOCM_RTS : 0)
865 | ((status & UART_CTS) ? TIOCM_CTS : 0)
866 | ((status & UART_DSR) ? TIOCM_DSR : 0)
867 | ((status & UART_RI) ? TIOCM_RI : 0)
868 | ((status & UART_CD) ? TIOCM_CD : 0);
870 dbg("%s - result = %x", __FUNCTION__, result);
876 static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
877 unsigned int set, unsigned int clear)
879 struct cypress_private *priv = usb_get_serial_port_data(port);
882 dbg("%s - port %d", __FUNCTION__, port->number);
884 spin_lock_irqsave(&priv->lock, flags);
886 priv->line_control |= CONTROL_RTS;
888 priv->line_control |= CONTROL_DTR;
889 if (clear & TIOCM_RTS)
890 priv->line_control &= ~CONTROL_RTS;
891 if (clear & TIOCM_DTR)
892 priv->line_control &= ~CONTROL_DTR;
893 spin_unlock_irqrestore(&priv->lock, flags);
896 return cypress_write(port, NULL, 0);
900 static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
902 struct cypress_private *priv = usb_get_serial_port_data(port);
904 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
908 if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct termios))) {
914 if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct termios))) {
917 /* here we need to call cypress_set_termios to invoke the new settings */
918 cypress_set_termios(port, &priv->tmp_termios);
921 /* these are called when setting baud rate from gpsd */
923 if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct termios))) {
929 if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct termios))) {
932 /* here we need to call cypress_set_termios to invoke the new settings */
933 cypress_set_termios(port, &priv->tmp_termios);
936 /* This code comes from drivers/char/serial.c and ftdi_sio.c */
938 while (priv != NULL) {
939 interruptible_sleep_on(&priv->delta_msr_wait);
940 /* see if a signal did it */
941 if (signal_pending(current))
944 char diff = priv->diff_status;
947 return -EIO; /* no change => error */
950 /* consume all events */
951 priv->diff_status = 0;
953 /* return 0 if caller wanted to know about these bits */
954 if ( ((arg & TIOCM_RNG) && (diff & UART_RI)) ||
955 ((arg & TIOCM_DSR) && (diff & UART_DSR)) ||
956 ((arg & TIOCM_CD) && (diff & UART_CD)) ||
957 ((arg & TIOCM_CTS) && (diff & UART_CTS)) ) {
960 /* otherwise caller can't care less about what happened,
961 * and so we continue to wait for more events.
971 dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __FUNCTION__, cmd);
974 } /* cypress_ioctl */
977 static void cypress_set_termios (struct usb_serial_port *port,
978 struct termios *old_termios)
980 struct cypress_private *priv = usb_get_serial_port_data(port);
981 struct tty_struct *tty;
982 int data_bits, stop_bits, parity_type, parity_enable;
983 unsigned cflag, iflag, baud_mask;
988 dbg("%s - port %d", __FUNCTION__, port->number);
991 if ((!tty) || (!tty->termios)) {
992 dbg("%s - no tty structures", __FUNCTION__);
996 spin_lock_irqsave(&priv->lock, flags);
997 if (!priv->termios_initialized) {
998 if (priv->chiptype == CT_EARTHMATE) {
999 *(tty->termios) = tty_std_termios;
1000 tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL |
1002 } else if (priv->chiptype == CT_CYPHIDCOM) {
1003 *(tty->termios) = tty_std_termios;
1004 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
1006 } else if (priv->chiptype == CT_CA42V2) {
1007 *(tty->termios) = tty_std_termios;
1008 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
1011 priv->termios_initialized = 1;
1013 spin_unlock_irqrestore(&priv->lock, flags);
1015 cflag = tty->termios->c_cflag;
1016 iflag = tty->termios->c_iflag;
1018 /* check if there are new settings */
1020 if ((cflag != old_termios->c_cflag) ||
1021 (RELEVANT_IFLAG(iflag) !=
1022 RELEVANT_IFLAG(old_termios->c_iflag))) {
1023 dbg("%s - attempting to set new termios settings",
1025 /* should make a copy of this in case something goes
1026 * wrong in the function, we can restore it */
1027 spin_lock_irqsave(&priv->lock, flags);
1028 priv->tmp_termios = *(tty->termios);
1029 spin_unlock_irqrestore(&priv->lock, flags);
1031 dbg("%s - nothing to do, exiting", __FUNCTION__);
1037 /* set number of data bits, parity, stop bits */
1038 /* when parity is disabled the parity type bit is ignored */
1040 /* 1 means 2 stop bits, 0 means 1 stop bit */
1041 stop_bits = cflag & CSTOPB ? 1 : 0;
1043 if (cflag & PARENB) {
1045 /* 1 means odd parity, 0 means even parity */
1046 parity_type = cflag & PARODD ? 1 : 0;
1048 parity_enable = parity_type = 0;
1050 if (cflag & CSIZE) {
1051 switch (cflag & CSIZE) {
1065 err("%s - CSIZE was set, but not CS5-CS8",
1072 spin_lock_irqsave(&priv->lock, flags);
1073 oldlines = priv->line_control;
1074 if ((cflag & CBAUD) == B0) {
1075 /* drop dtr and rts */
1076 dbg("%s - dropping the lines, baud rate 0bps", __FUNCTION__);
1078 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
1080 baud_mask = (cflag & CBAUD);
1083 dbg("%s - setting baud 300bps", __FUNCTION__);
1086 dbg("%s - setting baud 600bps", __FUNCTION__);
1089 dbg("%s - setting baud 1200bps", __FUNCTION__);
1092 dbg("%s - setting baud 2400bps", __FUNCTION__);
1095 dbg("%s - setting baud 4800bps", __FUNCTION__);
1098 dbg("%s - setting baud 9600bps", __FUNCTION__);
1101 dbg("%s - setting baud 19200bps", __FUNCTION__);
1104 dbg("%s - setting baud 38400bps", __FUNCTION__);
1107 dbg("%s - setting baud 57600bps", __FUNCTION__);
1110 dbg("%s - setting baud 115200bps", __FUNCTION__);
1113 dbg("%s - unknown masked baud rate", __FUNCTION__);
1115 priv->line_control = (CONTROL_DTR | CONTROL_RTS);
1117 spin_unlock_irqrestore(&priv->lock, flags);
1119 dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, "
1120 "%d data_bits (+5)", __FUNCTION__, stop_bits,
1121 parity_enable, parity_type, data_bits);
1123 cypress_serial_control(port, baud_mask, data_bits, stop_bits,
1124 parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
1126 /* we perform a CYPRESS_GET_CONFIG so that the current settings are
1127 * filled into the private structure this should confirm that all is
1128 * working if it returns what we just set */
1129 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
1131 /* Here we can define custom tty settings for devices; the main tty
1132 * termios flag base comes from empeg.c */
1134 spin_lock_irqsave(&priv->lock, flags);
1135 if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) {
1136 dbg("Using custom termios settings for a baud rate of "
1138 /* define custom termios settings for NMEA protocol */
1140 tty->termios->c_iflag /* input modes - */
1141 &= ~(IGNBRK /* disable ignore break */
1142 | BRKINT /* disable break causes interrupt */
1143 | PARMRK /* disable mark parity errors */
1144 | ISTRIP /* disable clear high bit of input char */
1145 | INLCR /* disable translate NL to CR */
1146 | IGNCR /* disable ignore CR */
1147 | ICRNL /* disable translate CR to NL */
1148 | IXON); /* disable enable XON/XOFF flow control */
1150 tty->termios->c_oflag /* output modes */
1151 &= ~OPOST; /* disable postprocess output char */
1153 tty->termios->c_lflag /* line discipline modes */
1154 &= ~(ECHO /* disable echo input characters */
1155 | ECHONL /* disable echo new line */
1156 | ICANON /* disable erase, kill, werase, and rprnt
1157 special characters */
1158 | ISIG /* disable interrupt, quit, and suspend
1159 special characters */
1160 | IEXTEN); /* disable non-POSIX special characters */
1161 } /* CT_CYPHIDCOM: Application should handle this for device */
1163 linechange = (priv->line_control != oldlines);
1164 spin_unlock_irqrestore(&priv->lock, flags);
1166 /* if necessary, set lines */
1169 cypress_write(port, NULL, 0);
1171 } /* cypress_set_termios */
1174 /* returns amount of data still left in soft buffer */
1175 static int cypress_chars_in_buffer(struct usb_serial_port *port)
1177 struct cypress_private *priv = usb_get_serial_port_data(port);
1179 unsigned long flags;
1181 dbg("%s - port %d", __FUNCTION__, port->number);
1183 spin_lock_irqsave(&priv->lock, flags);
1184 chars = cypress_buf_data_avail(priv->buf);
1185 spin_unlock_irqrestore(&priv->lock, flags);
1187 dbg("%s - returns %d", __FUNCTION__, chars);
1192 static void cypress_throttle (struct usb_serial_port *port)
1194 struct cypress_private *priv = usb_get_serial_port_data(port);
1195 unsigned long flags;
1197 dbg("%s - port %d", __FUNCTION__, port->number);
1199 spin_lock_irqsave(&priv->lock, flags);
1200 priv->rx_flags = THROTTLED;
1201 spin_unlock_irqrestore(&priv->lock, flags);
1205 static void cypress_unthrottle (struct usb_serial_port *port)
1207 struct cypress_private *priv = usb_get_serial_port_data(port);
1208 int actually_throttled, result;
1209 unsigned long flags;
1211 dbg("%s - port %d", __FUNCTION__, port->number);
1213 spin_lock_irqsave(&priv->lock, flags);
1214 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
1216 spin_unlock_irqrestore(&priv->lock, flags);
1218 if (actually_throttled) {
1219 port->interrupt_in_urb->dev = port->serial->dev;
1221 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1223 dev_err(&port->dev, "%s - failed submitting read urb, "
1224 "error %d\n", __FUNCTION__, result);
1229 static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1231 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1232 struct cypress_private *priv = usb_get_serial_port_data(port);
1233 struct tty_struct *tty;
1234 unsigned char *data = urb->transfer_buffer;
1235 unsigned long flags;
1236 char tty_flag = TTY_NORMAL;
1242 dbg("%s - port %d", __FUNCTION__, port->number);
1245 dbg("%s - nonzero read status received: %d", __FUNCTION__,
1250 spin_lock_irqsave(&priv->lock, flags);
1251 if (priv->rx_flags & THROTTLED) {
1252 dbg("%s - now throttling", __FUNCTION__);
1253 priv->rx_flags |= ACTUALLY_THROTTLED;
1254 spin_unlock_irqrestore(&priv->lock, flags);
1257 spin_unlock_irqrestore(&priv->lock, flags);
1261 dbg("%s - bad tty pointer - exiting", __FUNCTION__);
1265 spin_lock_irqsave(&priv->lock, flags);
1266 switch(urb->actual_length) {
1268 /* This is for the CY7C64013... */
1269 priv->current_status = data[0] & 0xF8;
1270 bytes = data[1] + 2;
1276 /* This is for the CY7C63743... */
1277 priv->current_status = data[0] & 0xF8;
1278 bytes = (data[0] & 0x07) + 1;
1284 dbg("%s - wrong packet size - received %d bytes",
1285 __FUNCTION__, urb->actual_length);
1286 spin_unlock_irqrestore(&priv->lock, flags);
1289 spin_unlock_irqrestore(&priv->lock, flags);
1291 usb_serial_debug_data (debug, &port->dev, __FUNCTION__,
1292 urb->actual_length, data);
1294 spin_lock_irqsave(&priv->lock, flags);
1295 /* check to see if status has changed */
1297 if (priv->current_status != priv->prev_status) {
1298 priv->diff_status |= priv->current_status ^
1300 wake_up_interruptible(&priv->delta_msr_wait);
1301 priv->prev_status = priv->current_status;
1304 spin_unlock_irqrestore(&priv->lock, flags);
1306 /* hangup, as defined in acm.c... this might be a bad place for it
1308 if (tty && !(tty->termios->c_cflag & CLOCAL) &&
1309 !(priv->current_status & UART_CD)) {
1310 dbg("%s - calling hangup", __FUNCTION__);
1315 /* There is one error bit... I'm assuming it is a parity error
1316 * indicator as the generic firmware will set this bit to 1 if a
1317 * parity error occurs.
1318 * I can not find reference to any other error events. */
1319 spin_lock_irqsave(&priv->lock, flags);
1320 if (priv->current_status & CYP_ERROR) {
1321 spin_unlock_irqrestore(&priv->lock, flags);
1322 tty_flag = TTY_PARITY;
1323 dbg("%s - Parity Error detected", __FUNCTION__);
1325 spin_unlock_irqrestore(&priv->lock, flags);
1327 /* process read if there is data other than line status */
1328 if (tty && (bytes > i)) {
1329 bytes = tty_buffer_request_room(tty, bytes);
1330 for (; i < bytes ; ++i) {
1331 dbg("pushing byte number %d - %d - %c", i, data[i],
1333 tty_insert_flip_char(tty, data[i], tty_flag);
1335 tty_flip_buffer_push(port->tty);
1338 spin_lock_irqsave(&priv->lock, flags);
1339 /* control and status byte(s) are also counted */
1340 priv->bytes_in += bytes;
1341 spin_unlock_irqrestore(&priv->lock, flags);
1345 /* Continue trying to always read... unless the port has closed. */
1347 if (port->open_count > 0) {
1348 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
1349 usb_rcvintpipe(port->serial->dev,
1350 port->interrupt_in_endpointAddress),
1351 port->interrupt_in_urb->transfer_buffer,
1352 port->interrupt_in_urb->transfer_buffer_length,
1353 cypress_read_int_callback, port, interval);
1354 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1356 dev_err(&urb->dev->dev, "%s - failed resubmitting "
1357 "read urb, error %d\n", __FUNCTION__,
1362 } /* cypress_read_int_callback */
1365 static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs)
1367 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1368 struct cypress_private *priv = usb_get_serial_port_data(port);
1371 dbg("%s - port %d", __FUNCTION__, port->number);
1373 switch (urb->status) {
1380 /* this urb is terminated, clean up */
1381 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
1382 priv->write_urb_in_use = 0;
1384 case -EPIPE: /* no break needed */
1385 usb_clear_halt(port->serial->dev, 0x02);
1387 /* error in the urb, so we have to resubmit it */
1388 dbg("%s - Overflow in write", __FUNCTION__);
1389 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
1390 port->interrupt_out_urb->transfer_buffer_length = 1;
1391 port->interrupt_out_urb->dev = port->serial->dev;
1392 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
1394 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n",
1395 __FUNCTION__, result);
1400 priv->write_urb_in_use = 0;
1402 /* send any buffered data */
1407 /*****************************************************************************
1408 * Write buffer functions - buffering code from pl2303 used
1409 *****************************************************************************/
1414 * Allocate a circular buffer and all associated memory.
1417 static struct cypress_buf *cypress_buf_alloc(unsigned int size)
1420 struct cypress_buf *cb;
1426 cb = (struct cypress_buf *)kmalloc(sizeof(struct cypress_buf), GFP_KERNEL);
1430 cb->buf_buf = kmalloc(size, GFP_KERNEL);
1431 if (cb->buf_buf == NULL) {
1436 cb->buf_size = size;
1437 cb->buf_get = cb->buf_put = cb->buf_buf;
1447 * Free the buffer and all associated memory.
1450 static void cypress_buf_free(struct cypress_buf *cb)
1462 * Clear out all data in the circular buffer.
1465 static void cypress_buf_clear(struct cypress_buf *cb)
1468 cb->buf_get = cb->buf_put;
1469 /* equivalent to a get of all data available */
1474 * cypress_buf_data_avail
1476 * Return the number of bytes of data available in the circular
1480 static unsigned int cypress_buf_data_avail(struct cypress_buf *cb)
1483 return ((cb->buf_size + cb->buf_put - cb->buf_get) % cb->buf_size);
1490 * cypress_buf_space_avail
1492 * Return the number of bytes of space available in the circular
1496 static unsigned int cypress_buf_space_avail(struct cypress_buf *cb)
1499 return ((cb->buf_size + cb->buf_get - cb->buf_put - 1) % cb->buf_size);
1508 * Copy data data from a user buffer and put it into the circular buffer.
1509 * Restrict to the amount of space available.
1511 * Return the number of bytes copied.
1514 static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf,
1524 len = cypress_buf_space_avail(cb);
1531 len = cb->buf_buf + cb->buf_size - cb->buf_put;
1533 memcpy(cb->buf_put, buf, len);
1534 memcpy(cb->buf_buf, buf+len, count - len);
1535 cb->buf_put = cb->buf_buf + count - len;
1537 memcpy(cb->buf_put, buf, count);
1539 cb->buf_put += count;
1540 else /* count == len */
1541 cb->buf_put = cb->buf_buf;
1552 * Get data from the circular buffer and copy to the given buffer.
1553 * Restrict to the amount of data available.
1555 * Return the number of bytes copied.
1558 static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,
1568 len = cypress_buf_data_avail(cb);
1575 len = cb->buf_buf + cb->buf_size - cb->buf_get;
1577 memcpy(buf, cb->buf_get, len);
1578 memcpy(buf+len, cb->buf_buf, count - len);
1579 cb->buf_get = cb->buf_buf + count - len;
1581 memcpy(buf, cb->buf_get, count);
1583 cb->buf_get += count;
1584 else /* count == len */
1585 cb->buf_get = cb->buf_buf;
1592 /*****************************************************************************
1594 *****************************************************************************/
1596 static int __init cypress_init(void)
1600 dbg("%s", __FUNCTION__);
1602 retval = usb_serial_register(&cypress_earthmate_device);
1604 goto failed_em_register;
1605 retval = usb_serial_register(&cypress_hidcom_device);
1607 goto failed_hidcom_register;
1608 retval = usb_serial_register(&cypress_ca42v2_device);
1610 goto failed_ca42v2_register;
1611 retval = usb_register(&cypress_driver);
1613 goto failed_usb_register;
1615 info(DRIVER_DESC " " DRIVER_VERSION);
1617 failed_usb_register:
1618 usb_deregister(&cypress_driver);
1619 failed_ca42v2_register:
1620 usb_serial_deregister(&cypress_ca42v2_device);
1621 failed_hidcom_register:
1622 usb_serial_deregister(&cypress_hidcom_device);
1624 usb_serial_deregister(&cypress_earthmate_device);
1630 static void __exit cypress_exit (void)
1632 dbg("%s", __FUNCTION__);
1634 usb_deregister (&cypress_driver);
1635 usb_serial_deregister (&cypress_earthmate_device);
1636 usb_serial_deregister (&cypress_hidcom_device);
1637 usb_serial_deregister (&cypress_ca42v2_device);
1641 module_init(cypress_init);
1642 module_exit(cypress_exit);
1644 MODULE_AUTHOR( DRIVER_AUTHOR );
1645 MODULE_DESCRIPTION( DRIVER_DESC );
1646 MODULE_VERSION( DRIVER_VERSION );
1647 MODULE_LICENSE("GPL");
1649 module_param(debug, bool, S_IRUGO | S_IWUSR);
1650 MODULE_PARM_DESC(debug, "Debug enabled or not");
1651 module_param(stats, bool, S_IRUGO | S_IWUSR);
1652 MODULE_PARM_DESC(stats, "Enable statistics or not");
1653 module_param(interval, int, S_IRUGO | S_IWUSR);
1654 MODULE_PARM_DESC(interval, "Overrides interrupt interval");