diff options
Diffstat (limited to 'drivers/usb/serial/cypress_m8.c')
-rw-r--r-- | drivers/usb/serial/cypress_m8.c | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 68067fe117a4..7212fbe3b6f2 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -98,10 +98,16 @@ static struct usb_device_id id_table_cyphidcomrs232 [] = { | |||
98 | { } /* Terminating entry */ | 98 | { } /* Terminating entry */ |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static struct usb_device_id id_table_nokiaca42v2 [] = { | ||
102 | { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) }, | ||
103 | { } /* Terminating entry */ | ||
104 | }; | ||
105 | |||
101 | static struct usb_device_id id_table_combined [] = { | 106 | static struct usb_device_id id_table_combined [] = { |
102 | { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, | 107 | { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, |
103 | { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, | 108 | { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, |
104 | { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, | 109 | { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, |
110 | { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) }, | ||
105 | { } /* Terminating entry */ | 111 | { } /* Terminating entry */ |
106 | }; | 112 | }; |
107 | 113 | ||
@@ -149,6 +155,7 @@ struct cypress_buf { | |||
149 | /* function prototypes for the Cypress USB to serial device */ | 155 | /* function prototypes for the Cypress USB to serial device */ |
150 | static int cypress_earthmate_startup (struct usb_serial *serial); | 156 | static int cypress_earthmate_startup (struct usb_serial *serial); |
151 | static int cypress_hidcom_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); | ||
152 | static void cypress_shutdown (struct usb_serial *serial); | 159 | static void cypress_shutdown (struct usb_serial *serial); |
153 | static int cypress_open (struct usb_serial_port *port, struct file *filp); | 160 | static int cypress_open (struct usb_serial_port *port, struct file *filp); |
154 | static void cypress_close (struct usb_serial_port *port, struct file *filp); | 161 | static void cypress_close (struct usb_serial_port *port, struct file *filp); |
@@ -235,6 +242,34 @@ static struct usb_serial_driver cypress_hidcom_device = { | |||
235 | .write_int_callback = cypress_write_int_callback, | 242 | .write_int_callback = cypress_write_int_callback, |
236 | }; | 243 | }; |
237 | 244 | ||
245 | static 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 | 273 | ||
239 | /***************************************************************************** | 274 | /***************************************************************************** |
240 | * Cypress serial helper functions | 275 | * Cypress serial helper functions |
@@ -286,6 +321,12 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m | |||
286 | __FUNCTION__); | 321 | __FUNCTION__); |
287 | new_baudrate = priv->baud_rate; | 322 | new_baudrate = priv->baud_rate; |
288 | } | 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) { | 330 | } else if (priv->chiptype == CT_GENERIC) { |
290 | if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) { | 331 | if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) { |
291 | err("%s - failed setting baud rate, unsupported speed", | 332 | err("%s - failed setting baud rate, unsupported speed", |
@@ -435,11 +476,10 @@ static int generic_startup (struct usb_serial *serial) | |||
435 | 476 | ||
436 | dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); | 477 | dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); |
437 | 478 | ||
438 | priv = kmalloc(sizeof (struct cypress_private), GFP_KERNEL); | 479 | priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL); |
439 | if (!priv) | 480 | if (!priv) |
440 | return -ENOMEM; | 481 | return -ENOMEM; |
441 | 482 | ||
442 | memset(priv, 0x00, sizeof (struct cypress_private)); | ||
443 | spin_lock_init(&priv->lock); | 483 | spin_lock_init(&priv->lock); |
444 | priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE); | 484 | priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE); |
445 | if (priv->buf == NULL) { | 485 | if (priv->buf == NULL) { |
@@ -500,6 +540,25 @@ static int cypress_hidcom_startup (struct usb_serial *serial) | |||
500 | } /* cypress_hidcom_startup */ | 540 | } /* cypress_hidcom_startup */ |
501 | 541 | ||
502 | 542 | ||
543 | static 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 | |||
503 | static void cypress_shutdown (struct usb_serial *serial) | 562 | static void cypress_shutdown (struct usb_serial *serial) |
504 | { | 563 | { |
505 | struct cypress_private *priv; | 564 | struct cypress_private *priv; |
@@ -944,6 +1003,10 @@ static void cypress_set_termios (struct usb_serial_port *port, | |||
944 | *(tty->termios) = tty_std_termios; | 1003 | *(tty->termios) = tty_std_termios; |
945 | tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | | 1004 | tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | |
946 | CLOCAL; | 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; | ||
947 | } | 1010 | } |
948 | priv->termios_initialized = 1; | 1011 | priv->termios_initialized = 1; |
949 | } | 1012 | } |
@@ -1542,6 +1605,9 @@ static int __init cypress_init(void) | |||
1542 | retval = usb_serial_register(&cypress_hidcom_device); | 1605 | retval = usb_serial_register(&cypress_hidcom_device); |
1543 | if (retval) | 1606 | if (retval) |
1544 | goto failed_hidcom_register; | 1607 | goto failed_hidcom_register; |
1608 | retval = usb_serial_register(&cypress_ca42v2_device); | ||
1609 | if (retval) | ||
1610 | goto failed_ca42v2_register; | ||
1545 | retval = usb_register(&cypress_driver); | 1611 | retval = usb_register(&cypress_driver); |
1546 | if (retval) | 1612 | if (retval) |
1547 | goto failed_usb_register; | 1613 | goto failed_usb_register; |
@@ -1550,6 +1616,8 @@ static int __init cypress_init(void) | |||
1550 | return 0; | 1616 | return 0; |
1551 | failed_usb_register: | 1617 | failed_usb_register: |
1552 | usb_deregister(&cypress_driver); | 1618 | usb_deregister(&cypress_driver); |
1619 | failed_ca42v2_register: | ||
1620 | usb_serial_deregister(&cypress_ca42v2_device); | ||
1553 | failed_hidcom_register: | 1621 | failed_hidcom_register: |
1554 | usb_serial_deregister(&cypress_hidcom_device); | 1622 | usb_serial_deregister(&cypress_hidcom_device); |
1555 | failed_em_register: | 1623 | failed_em_register: |
@@ -1566,6 +1634,7 @@ static void __exit cypress_exit (void) | |||
1566 | usb_deregister (&cypress_driver); | 1634 | usb_deregister (&cypress_driver); |
1567 | usb_serial_deregister (&cypress_earthmate_device); | 1635 | usb_serial_deregister (&cypress_earthmate_device); |
1568 | usb_serial_deregister (&cypress_hidcom_device); | 1636 | usb_serial_deregister (&cypress_hidcom_device); |
1637 | usb_serial_deregister (&cypress_ca42v2_device); | ||
1569 | } | 1638 | } |
1570 | 1639 | ||
1571 | 1640 | ||