cypress_m8.c (80b6ca48321974a6566a1c9048ba34f60420bca6) cypress_m8.c (a5c44e29e5637b5e6fe59d225eb4f438688b3849)
1/*
2 * USB Cypress M8 driver
3 *
4 * Copyright (C) 2004
5 * Lonnie Mendez (dignome@gmail.com)
6 * Copyright (C) 2003,2004
7 * Neil Whelchel (koyama@firstlight.net)
8 *

--- 84 unchanged lines hidden (view full) ---

93 { } /* Terminating entry */
94};
95
96static struct usb_device_id id_table_cyphidcomrs232 [] = {
97 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
98 { } /* Terminating entry */
99};
100
1/*
2 * USB Cypress M8 driver
3 *
4 * Copyright (C) 2004
5 * Lonnie Mendez (dignome@gmail.com)
6 * Copyright (C) 2003,2004
7 * Neil Whelchel (koyama@firstlight.net)
8 *

--- 84 unchanged lines hidden (view full) ---

93 { } /* Terminating entry */
94};
95
96static struct usb_device_id id_table_cyphidcomrs232 [] = {
97 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
98 { } /* Terminating entry */
99};
100
101static struct usb_device_id id_table_nokiaca42v2 [] = {
102 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
103 { } /* Terminating entry */
104};
105
101static struct usb_device_id id_table_combined [] = {
102 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
103 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
104 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
106static 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) },
105 { } /* Terminating entry */
106};
107
108MODULE_DEVICE_TABLE (usb, id_table_combined);
109
110static struct usb_driver cypress_driver = {
111 .name = "cypress",
112 .probe = usb_serial_probe,

--- 31 unchanged lines hidden (view full) ---

144 char *buf_buf;
145 char *buf_get;
146 char *buf_put;
147};
148
149/* function prototypes for the Cypress USB to serial device */
150static int cypress_earthmate_startup (struct usb_serial *serial);
151static int cypress_hidcom_startup (struct usb_serial *serial);
111 { } /* Terminating entry */
112};
113
114MODULE_DEVICE_TABLE (usb, id_table_combined);
115
116static struct usb_driver cypress_driver = {
117 .name = "cypress",
118 .probe = usb_serial_probe,

--- 31 unchanged lines hidden (view full) ---

150 char *buf_buf;
151 char *buf_get;
152 char *buf_put;
153};
154
155/* function prototypes for the Cypress USB to serial device */
156static int cypress_earthmate_startup (struct usb_serial *serial);
157static int cypress_hidcom_startup (struct usb_serial *serial);
158static int cypress_ca42v2_startup (struct usb_serial *serial);
152static void cypress_shutdown (struct usb_serial *serial);
153static int cypress_open (struct usb_serial_port *port, struct file *filp);
154static void cypress_close (struct usb_serial_port *port, struct file *filp);
155static int cypress_write (struct usb_serial_port *port, const unsigned char *buf, int count);
156static void cypress_send (struct usb_serial_port *port);
157static int cypress_write_room (struct usb_serial_port *port);
158static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
159static void cypress_set_termios (struct usb_serial_port *port, struct termios * old);

--- 70 unchanged lines hidden (view full) ---

230 .tiocmset = cypress_tiocmset,
231 .chars_in_buffer = cypress_chars_in_buffer,
232 .throttle = cypress_throttle,
233 .unthrottle = cypress_unthrottle,
234 .read_int_callback = cypress_read_int_callback,
235 .write_int_callback = cypress_write_int_callback,
236};
237
159static void cypress_shutdown (struct usb_serial *serial);
160static int cypress_open (struct usb_serial_port *port, struct file *filp);
161static void cypress_close (struct usb_serial_port *port, struct file *filp);
162static int cypress_write (struct usb_serial_port *port, const unsigned char *buf, int count);
163static void cypress_send (struct usb_serial_port *port);
164static int cypress_write_room (struct usb_serial_port *port);
165static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
166static void cypress_set_termios (struct usb_serial_port *port, struct termios * old);

--- 70 unchanged lines hidden (view full) ---

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,
243};
244
245static struct usb_serial_driver cypress_ca42v2_device = {
246 .driver = {
247 .owner = THIS_MODULE,
248 .name = "nokiaca42v2",
249 },
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,
256 .num_ports = 1,
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,
272};
238
239/*****************************************************************************
240 * Cypress serial helper functions
241 *****************************************************************************/
242
243
244/* This function can either set or retrieve the current serial line settings */
245static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,

--- 35 unchanged lines hidden (view full) ---

281 new_baudrate = priv->baud_rate;
282 }
283 } else if (priv->chiptype == CT_CYPHIDCOM) {
284 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
285 err("%s - failed setting baud rate, unsupported speed",
286 __FUNCTION__);
287 new_baudrate = priv->baud_rate;
288 }
273
274/*****************************************************************************
275 * Cypress serial helper functions
276 *****************************************************************************/
277
278
279/* This function can either set or retrieve the current serial line settings */
280static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,

--- 35 unchanged lines hidden (view full) ---

316 new_baudrate = priv->baud_rate;
317 }
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",
321 __FUNCTION__);
322 new_baudrate = priv->baud_rate;
323 }
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",
327 __FUNCTION__);
328 new_baudrate = priv->baud_rate;
329 }
289 } else if (priv->chiptype == CT_GENERIC) {
290 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
291 err("%s - failed setting baud rate, unsupported speed",
292 __FUNCTION__);
293 new_baudrate = priv->baud_rate;
294 }
295 } else {
296 info("%s - please define your chiptype", __FUNCTION__);

--- 197 unchanged lines hidden (view full) ---

494
495 priv = usb_get_serial_port_data(serial->port[0]);
496 priv->chiptype = CT_CYPHIDCOM;
497
498 return 0;
499} /* cypress_hidcom_startup */
500
501
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",
333 __FUNCTION__);
334 new_baudrate = priv->baud_rate;
335 }
336 } else {
337 info("%s - please define your chiptype", __FUNCTION__);

--- 197 unchanged lines hidden (view full) ---

535
536 priv = usb_get_serial_port_data(serial->port[0]);
537 priv->chiptype = CT_CYPHIDCOM;
538
539 return 0;
540} /* cypress_hidcom_startup */
541
542
543static int cypress_ca42v2_startup (struct usb_serial *serial)
544{
545 struct cypress_private *priv;
546
547 dbg("%s", __FUNCTION__);
548
549 if (generic_startup(serial)) {
550 dbg("%s - Failed setting up port %d", __FUNCTION__,
551 serial->port[0]->number);
552 return 1;
553 }
554
555 priv = usb_get_serial_port_data(serial->port[0]);
556 priv->chiptype = CT_CA42V2;
557
558 return 0;
559} /* cypress_ca42v2_startup */
560
561
502static void cypress_shutdown (struct usb_serial *serial)
503{
504 struct cypress_private *priv;
505
506 dbg ("%s - port %d", __FUNCTION__, serial->port[0]->number);
507
508 /* all open ports are closed at this point */
509

--- 428 unchanged lines hidden (view full) ---

938 if (priv->chiptype == CT_EARTHMATE) {
939 *(tty->termios) = tty_std_termios;
940 tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL |
941 CLOCAL;
942 } else if (priv->chiptype == CT_CYPHIDCOM) {
943 *(tty->termios) = tty_std_termios;
944 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
945 CLOCAL;
562static void cypress_shutdown (struct usb_serial *serial)
563{
564 struct cypress_private *priv;
565
566 dbg ("%s - port %d", __FUNCTION__, serial->port[0]->number);
567
568 /* all open ports are closed at this point */
569

--- 428 unchanged lines hidden (view full) ---

998 if (priv->chiptype == CT_EARTHMATE) {
999 *(tty->termios) = tty_std_termios;
1000 tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL |
1001 CLOCAL;
1002 } else if (priv->chiptype == CT_CYPHIDCOM) {
1003 *(tty->termios) = tty_std_termios;
1004 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
1005 CLOCAL;
1006 } else if (priv->chiptype == CT_CA42V2) {
1007 *(tty->termios) = tty_std_termios;
1008 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
1009 CLOCAL;
946 }
947 priv->termios_initialized = 1;
948 }
949 spin_unlock_irqrestore(&priv->lock, flags);
950
951 cflag = tty->termios->c_cflag;
952 iflag = tty->termios->c_iflag;
953

--- 582 unchanged lines hidden (view full) ---

1536 dbg("%s", __FUNCTION__);
1537
1538 retval = usb_serial_register(&cypress_earthmate_device);
1539 if (retval)
1540 goto failed_em_register;
1541 retval = usb_serial_register(&cypress_hidcom_device);
1542 if (retval)
1543 goto failed_hidcom_register;
1010 }
1011 priv->termios_initialized = 1;
1012 }
1013 spin_unlock_irqrestore(&priv->lock, flags);
1014
1015 cflag = tty->termios->c_cflag;
1016 iflag = tty->termios->c_iflag;
1017

--- 582 unchanged lines hidden (view full) ---

1600 dbg("%s", __FUNCTION__);
1601
1602 retval = usb_serial_register(&cypress_earthmate_device);
1603 if (retval)
1604 goto failed_em_register;
1605 retval = usb_serial_register(&cypress_hidcom_device);
1606 if (retval)
1607 goto failed_hidcom_register;
1608 retval = usb_serial_register(&cypress_ca42v2_device);
1609 if (retval)
1610 goto failed_ca42v2_register;
1544 retval = usb_register(&cypress_driver);
1545 if (retval)
1546 goto failed_usb_register;
1547
1548 info(DRIVER_DESC " " DRIVER_VERSION);
1549 return 0;
1550failed_usb_register:
1551 usb_deregister(&cypress_driver);
1611 retval = usb_register(&cypress_driver);
1612 if (retval)
1613 goto failed_usb_register;
1614
1615 info(DRIVER_DESC " " DRIVER_VERSION);
1616 return 0;
1617failed_usb_register:
1618 usb_deregister(&cypress_driver);
1619failed_ca42v2_register:
1620 usb_serial_deregister(&cypress_ca42v2_device);
1552failed_hidcom_register:
1553 usb_serial_deregister(&cypress_hidcom_device);
1554failed_em_register:
1555 usb_serial_deregister(&cypress_earthmate_device);
1556
1557 return retval;
1558}
1559
1560
1561static void __exit cypress_exit (void)
1562{
1563 dbg("%s", __FUNCTION__);
1564
1565 usb_deregister (&cypress_driver);
1566 usb_serial_deregister (&cypress_earthmate_device);
1567 usb_serial_deregister (&cypress_hidcom_device);
1621failed_hidcom_register:
1622 usb_serial_deregister(&cypress_hidcom_device);
1623failed_em_register:
1624 usb_serial_deregister(&cypress_earthmate_device);
1625
1626 return retval;
1627}
1628
1629
1630static void __exit cypress_exit (void)
1631{
1632 dbg("%s", __FUNCTION__);
1633
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);
1568}
1569
1570
1571module_init(cypress_init);
1572module_exit(cypress_exit);
1573
1574MODULE_AUTHOR( DRIVER_AUTHOR );
1575MODULE_DESCRIPTION( DRIVER_DESC );
1576MODULE_VERSION( DRIVER_VERSION );
1577MODULE_LICENSE("GPL");
1578
1579module_param(debug, bool, S_IRUGO | S_IWUSR);
1580MODULE_PARM_DESC(debug, "Debug enabled or not");
1581module_param(stats, bool, S_IRUGO | S_IWUSR);
1582MODULE_PARM_DESC(stats, "Enable statistics or not");
1583module_param(interval, int, S_IRUGO | S_IWUSR);
1584MODULE_PARM_DESC(interval, "Overrides interrupt interval");
1638}
1639
1640
1641module_init(cypress_init);
1642module_exit(cypress_exit);
1643
1644MODULE_AUTHOR( DRIVER_AUTHOR );
1645MODULE_DESCRIPTION( DRIVER_DESC );
1646MODULE_VERSION( DRIVER_VERSION );
1647MODULE_LICENSE("GPL");
1648
1649module_param(debug, bool, S_IRUGO | S_IWUSR);
1650MODULE_PARM_DESC(debug, "Debug enabled or not");
1651module_param(stats, bool, S_IRUGO | S_IWUSR);
1652MODULE_PARM_DESC(stats, "Enable statistics or not");
1653module_param(interval, int, S_IRUGO | S_IWUSR);
1654MODULE_PARM_DESC(interval, "Overrides interrupt interval");