sierra.c (1ff8392c32a2645d2665ca779ecb91bb29361c13) sierra.c (112225b13cedd53dfd6455038b8843cf004ddec9)
1/*
2 USB Driver for Sierra Wireless
3
1/*
2 USB Driver for Sierra Wireless
3
4 Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com>
4 Copyright (C) 2006, 2007 Kevin Lloyd <linux@sierrawireless.com>
5
6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 Sierra Wireless. Use at your own risk.
8
9 This driver is free software; you can redistribute it and/or modify
10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
12
13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
5
6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 Sierra Wireless. Use at your own risk.
8
9 This driver is free software; you can redistribute it and/or modify
10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
12
13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15
16*/
17
15*/
16
18#define DRIVER_VERSION "v.1.0.6"
17#define DRIVER_VERSION "v.1.2.4b"
19#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
20#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
21
22#include <linux/kernel.h>
23#include <linux/jiffies.h>
24#include <linux/errno.h>
25#include <linux/tty.h>
26#include <linux/tty_flip.h>
27#include <linux/module.h>
28#include <linux/usb.h>
29#include <linux/usb/serial.h>
30
18#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
20
21#include <linux/kernel.h>
22#include <linux/jiffies.h>
23#include <linux/errno.h>
24#include <linux/tty.h>
25#include <linux/tty_flip.h>
26#include <linux/module.h>
27#include <linux/usb.h>
28#include <linux/usb/serial.h>
29
30#define SWIMS_USB_REQUEST_SetMode 0x0B
31#define SWIMS_USB_REQUEST_TYPE_SetMode 0x40
32#define SWIMS_USB_INDEX_SetMode 0x0000
33#define SWIMS_SET_MODE_Modem 0x0001
31
34
35/* per port private data */
36#define N_IN_URB 4
37#define N_OUT_URB 4
38#define IN_BUFLEN 4096
39
40static int debug;
41
42enum devicetype {
43 DEVICE_3_PORT = 0,
44 DEVICE_1_PORT = 1,
45 DEVICE_INSTALLER = 2,
46};
47
48int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
49{
50 int result;
51 dev_dbg(&udev->dev, "%s", "SET POWER STATE");
52 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
53 0x00, /* __u8 request */
54 0x40, /* __u8 request type */
55 swiState, /* __u16 value */
56 0, /* __u16 index */
57 NULL, /* void *data */
58 0, /* __u16 size */
59 USB_CTRL_SET_TIMEOUT); /* int timeout */
60 return result;
61}
62
63int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode)
64{
65 int result;
66 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH");
67 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
68 SWIMS_USB_REQUEST_SetMode, /* __u8 request */
69 SWIMS_USB_REQUEST_TYPE_SetMode, /* __u8 request type */
70 eSocMode, /* __u16 value */
71 SWIMS_USB_INDEX_SetMode, /* __u16 index */
72 NULL, /* void *data */
73 0, /* __u16 size */
74 USB_CTRL_SET_TIMEOUT); /* int timeout */
75 return result;
76}
77
78int sierra_probe(struct usb_interface *iface, const struct usb_device_id *id)
79{
80 int result;
81 struct usb_device *udev;
82
83 udev = usb_get_dev(interface_to_usbdev(iface));
84
85 /* Check if in installer mode */
86 if (id->driver_info == DEVICE_INSTALLER) {
87 dev_dbg(&udev->dev, "%s", "FOUND DEVICE(SW)\n");
88 result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem);
89 /*We do not want to bind to the device when in installer mode*/
90 return -EIO;
91 }
92
93 return usb_serial_probe(iface, id);
94}
95
32static struct usb_device_id id_table [] = {
33 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
34 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
35 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
36 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
38 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */
39 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
40 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
41 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
42 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
43 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
44 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
45
96static struct usb_device_id id_table [] = {
97 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
98 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
99 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
100 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
101 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
102 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */
103 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
104 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
105 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
106 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
107 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
108 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
109
46 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
47 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
110 { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */
111 { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */
112
113 { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER},
48 { }
49};
50MODULE_DEVICE_TABLE(usb, id_table);
51
52static struct usb_device_id id_table_1port [] = {
53 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
54 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
55 { }
56};
57
58static struct usb_device_id id_table_3port [] = {
114 { }
115};
116MODULE_DEVICE_TABLE(usb, id_table);
117
118static struct usb_device_id id_table_1port [] = {
119 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
120 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
121 { }
122};
123
124static struct usb_device_id id_table_3port [] = {
125 /* CDMA Devices */
59 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
60 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
61 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
62 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
63 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
64 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */
65 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
126 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
127 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
128 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
129 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
130 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
131 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */
132 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
133
134 /* GSM/UMTS Devices */
66 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
67 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
68 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
69 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
70 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
71 { }
72};
73
74static struct usb_driver sierra_driver = {
75 .name = "sierra",
135 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
136 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
137 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
138 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
139 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
140 { }
141};
142
143static struct usb_driver sierra_driver = {
144 .name = "sierra",
76 .probe = usb_serial_probe,
145 .probe = sierra_probe,
77 .disconnect = usb_serial_disconnect,
78 .id_table = id_table,
79 .no_dynamic_id = 1,
80};
81
82
146 .disconnect = usb_serial_disconnect,
147 .id_table = id_table,
148 .no_dynamic_id = 1,
149};
150
151
83static int debug;
84
85/* per port private data */
86#define N_IN_URB 4
87#define N_OUT_URB 4
88#define IN_BUFLEN 4096
89
90struct sierra_port_private {
91 spinlock_t lock; /* lock the structure */
92 int outstanding_urbs; /* number of out urbs in flight */
93
94 /* Input endpoints and buffer for this port */
95 struct urb *in_urbs[N_IN_URB];
96 char in_buffer[N_IN_URB][IN_BUFLEN];
97

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

416
417static int sierra_open(struct usb_serial_port *port, struct file *filp)
418{
419 struct sierra_port_private *portdata;
420 struct usb_serial *serial = port->serial;
421 int i;
422 struct urb *urb;
423 int result;
152struct sierra_port_private {
153 spinlock_t lock; /* lock the structure */
154 int outstanding_urbs; /* number of out urbs in flight */
155
156 /* Input endpoints and buffer for this port */
157 struct urb *in_urbs[N_IN_URB];
158 char in_buffer[N_IN_URB][IN_BUFLEN];
159

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

478
479static int sierra_open(struct usb_serial_port *port, struct file *filp)
480{
481 struct sierra_port_private *portdata;
482 struct usb_serial *serial = port->serial;
483 int i;
484 struct urb *urb;
485 int result;
424 __u16 set_mode_dzero = 0x0000;
425
426 portdata = usb_get_serial_port_data(port);
427
428 dbg("%s", __FUNCTION__);
429
430 /* Set some sane defaults */
431 portdata->rts_state = 1;
432 portdata->dtr_state = 1;

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

452 if (result) {
453 dev_err(&port->dev, "submit urb %d failed (%d) %d",
454 i, result, urb->transfer_buffer_length);
455 }
456 }
457
458 port->tty->low_latency = 1;
459
486
487 portdata = usb_get_serial_port_data(port);
488
489 dbg("%s", __FUNCTION__);
490
491 /* Set some sane defaults */
492 portdata->rts_state = 1;
493 portdata->dtr_state = 1;

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

513 if (result) {
514 dev_err(&port->dev, "submit urb %d failed (%d) %d",
515 i, result, urb->transfer_buffer_length);
516 }
517 }
518
519 port->tty->low_latency = 1;
520
460 /* set mode to D0 */
461 result = usb_control_msg(serial->dev,
462 usb_rcvctrlpipe(serial->dev, 0),
463 0x00, 0x40, set_mode_dzero, 0, NULL,
464 0, USB_CTRL_SET_TIMEOUT);
465
466 sierra_send_setup(port);
467
468 /* start up the interrupt endpoint if we have one */
469 if (port->interrupt_in_urb) {
470 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
471 if (result)
472 dev_err(&port->dev, "submit irq_in urb failed %d",
473 result);

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

505 struct usb_serial_port *port;
506 struct sierra_port_private *portdata;
507 struct urb *urb;
508 int i;
509 int j;
510
511 dbg("%s", __FUNCTION__);
512
521 sierra_send_setup(port);
522
523 /* start up the interrupt endpoint if we have one */
524 if (port->interrupt_in_urb) {
525 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
526 if (result)
527 dev_err(&port->dev, "submit irq_in urb failed %d",
528 result);

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

560 struct usb_serial_port *port;
561 struct sierra_port_private *portdata;
562 struct urb *urb;
563 int i;
564 int j;
565
566 dbg("%s", __FUNCTION__);
567
568 /*Set Device mode to D0 */
569 sierra_set_power_state(serial->dev, 0x0000);
570
513 /* Now setup per port private data */
514 for (i = 0; i < serial->num_ports; i++) {
515 port = serial->port[i];
516 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
517 if (!portdata) {
518 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
519 __FUNCTION__, i);
520 return -ENOMEM;

--- 158 unchanged lines hidden ---
571 /* Now setup per port private data */
572 for (i = 0; i < serial->num_ports; i++) {
573 port = serial->port[i];
574 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
575 if (!portdata) {
576 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
577 __FUNCTION__, i);
578 return -ENOMEM;

--- 158 unchanged lines hidden ---