Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 1 | /* |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 2 | USB Driver for Sierra Wireless |
| 3 | |
Kevin Lloyd | f3564de | 2008-03-28 10:05:08 -0700 | [diff] [blame] | 4 | Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com> |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 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> |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 17 | #define DRIVER_VERSION "v.1.3.5" |
Kevin Lloyd | f3564de | 2008-03-28 10:05:08 -0700 | [diff] [blame] | 18 | #define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 20 | |
| 21 | #include <linux/kernel.h> |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 22 | #include <linux/jiffies.h> |
| 23 | #include <linux/errno.h> |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 24 | #include <linux/tty.h> |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 25 | #include <linux/tty_flip.h> |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 26 | #include <linux/module.h> |
| 27 | #include <linux/usb.h> |
Greg Kroah-Hartman | a969888 | 2006-07-11 21:22:58 -0700 | [diff] [blame] | 28 | #include <linux/usb/serial.h> |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 29 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 30 | #define SWIMS_USB_REQUEST_SetPower 0x00 |
| 31 | #define SWIMS_USB_REQUEST_SetNmea 0x07 |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 32 | |
Elina Pasheva | b748bb7 | 2009-04-24 18:41:49 -0700 | [diff] [blame] | 33 | #define N_IN_URB 8 |
| 34 | #define N_OUT_URB 64 |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 35 | #define IN_BUFLEN 4096 |
| 36 | |
| 37 | static int debug; |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 38 | static int nmea; |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 39 | |
Elina Pasheva | 4db2299 | 2009-06-11 14:32:01 +0100 | [diff] [blame] | 40 | /* Used in interface blacklisting */ |
| 41 | struct sierra_iface_info { |
| 42 | const u32 infolen; /* number of interface numbers on blacklist */ |
| 43 | const u8 *ifaceinfo; /* pointer to the array holding the numbers */ |
| 44 | }; |
| 45 | |
Adrian Bunk | 82a24e6 | 2007-07-29 16:59:02 +0200 | [diff] [blame] | 46 | static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 47 | { |
| 48 | int result; |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 49 | dev_dbg(&udev->dev, "%s\n", __func__); |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 50 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 51 | SWIMS_USB_REQUEST_SetPower, /* __u8 request */ |
Kevin Lloyd | f3564de | 2008-03-28 10:05:08 -0700 | [diff] [blame] | 52 | USB_TYPE_VENDOR, /* __u8 request type */ |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 53 | swiState, /* __u16 value */ |
| 54 | 0, /* __u16 index */ |
| 55 | NULL, /* void *data */ |
| 56 | 0, /* __u16 size */ |
| 57 | USB_CTRL_SET_TIMEOUT); /* int timeout */ |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 58 | return result; |
| 59 | } |
| 60 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 61 | static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 62 | { |
| 63 | int result; |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 64 | dev_dbg(&udev->dev, "%s\n", __func__); |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 65 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 66 | SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ |
Kevin Lloyd | f3564de | 2008-03-28 10:05:08 -0700 | [diff] [blame] | 67 | USB_TYPE_VENDOR, /* __u8 request type */ |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 68 | enable, /* __u16 value */ |
| 69 | 0x0000, /* __u16 index */ |
| 70 | NULL, /* void *data */ |
| 71 | 0, /* __u16 size */ |
| 72 | USB_CTRL_SET_TIMEOUT); /* int timeout */ |
| 73 | return result; |
| 74 | } |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 75 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 76 | static int sierra_calc_num_ports(struct usb_serial *serial) |
| 77 | { |
| 78 | int result; |
| 79 | int *num_ports = usb_get_serial_data(serial); |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 80 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 81 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 82 | result = *num_ports; |
| 83 | |
| 84 | if (result) { |
| 85 | kfree(num_ports); |
| 86 | usb_set_serial_data(serial, NULL); |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 89 | return result; |
| 90 | } |
| 91 | |
Elina Pasheva | 4db2299 | 2009-06-11 14:32:01 +0100 | [diff] [blame] | 92 | static int is_blacklisted(const u8 ifnum, |
| 93 | const struct sierra_iface_info *blacklist) |
| 94 | { |
| 95 | const u8 *info; |
| 96 | int i; |
| 97 | |
| 98 | if (blacklist) { |
| 99 | info = blacklist->ifaceinfo; |
| 100 | |
| 101 | for (i = 0; i < blacklist->infolen; i++) { |
| 102 | if (info[i] == ifnum) |
| 103 | return 1; |
| 104 | } |
| 105 | } |
| 106 | return 0; |
| 107 | } |
| 108 | |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 109 | static int sierra_calc_interface(struct usb_serial *serial) |
| 110 | { |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 111 | int interface; |
| 112 | struct usb_interface *p_interface; |
| 113 | struct usb_host_interface *p_host_interface; |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 114 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 115 | |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 116 | /* Get the interface structure pointer from the serial struct */ |
| 117 | p_interface = serial->interface; |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 118 | |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 119 | /* Get a pointer to the host interface structure */ |
| 120 | p_host_interface = p_interface->cur_altsetting; |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 121 | |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 122 | /* read the interface descriptor for this active altsetting |
| 123 | * to find out the interface number we are on |
| 124 | */ |
| 125 | interface = p_host_interface->desc.bInterfaceNumber; |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 126 | |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 127 | return interface; |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 130 | static int sierra_probe(struct usb_serial *serial, |
| 131 | const struct usb_device_id *id) |
| 132 | { |
| 133 | int result = 0; |
| 134 | struct usb_device *udev; |
| 135 | int *num_ports; |
| 136 | u8 ifnum; |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 137 | u8 numendpoints; |
| 138 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 139 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 140 | |
| 141 | num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL); |
| 142 | if (!num_ports) |
| 143 | return -ENOMEM; |
| 144 | |
| 145 | ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 146 | numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints; |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 147 | udev = serial->dev; |
| 148 | |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 149 | /* Figure out the interface number from the serial structure */ |
| 150 | ifnum = sierra_calc_interface(serial); |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 151 | |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 152 | /* |
| 153 | * If this interface supports more than 1 alternate |
| 154 | * select the 2nd one |
| 155 | */ |
| 156 | if (serial->interface->num_altsetting == 2) { |
| 157 | dev_dbg(&udev->dev, "Selecting alt setting for interface %d\n", |
| 158 | ifnum); |
| 159 | /* We know the alternate setting is 1 for the MC8785 */ |
| 160 | usb_set_interface(udev, ifnum, 1); |
| 161 | } |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 162 | |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 163 | /* Dummy interface present on some SKUs should be ignored */ |
Kevin Lloyd | 0585e4d | 2008-07-10 14:14:54 -0700 | [diff] [blame] | 164 | if (ifnum == 0x99) |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 165 | *num_ports = 0; |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 166 | else if (numendpoints <= 3) |
| 167 | *num_ports = 1; |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 168 | else |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 169 | *num_ports = (numendpoints-1)/2; |
| 170 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 171 | /* |
| 172 | * save off our num_ports info so that we can use it in the |
| 173 | * calc_num_ports callback |
| 174 | */ |
| 175 | usb_set_serial_data(serial, (void *)num_ports); |
| 176 | |
Elina Pasheva | 4db2299 | 2009-06-11 14:32:01 +0100 | [diff] [blame] | 177 | /* ifnum could have changed - by calling usb_set_interface */ |
| 178 | ifnum = sierra_calc_interface(serial); |
| 179 | |
| 180 | if (is_blacklisted(ifnum, |
| 181 | (struct sierra_iface_info *)id->driver_info)) { |
| 182 | dev_dbg(&serial->dev->dev, |
| 183 | "Ignoring blacklisted interface #%d\n", ifnum); |
| 184 | return -ENODEV; |
| 185 | } |
| 186 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 187 | return result; |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 188 | } |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 189 | |
Elina Pasheva | 4db2299 | 2009-06-11 14:32:01 +0100 | [diff] [blame] | 190 | static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11 }; |
| 191 | static const struct sierra_iface_info direct_ip_interface_blacklist = { |
| 192 | .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), |
| 193 | .ifaceinfo = direct_ip_non_serial_ifaces, |
| 194 | }; |
| 195 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 196 | static struct usb_device_id id_table [] = { |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 197 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 198 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ |
Greg Kroah-Hartman | 90ac3c8 | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 199 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ |
Tony Murray | f8834f1 | 2008-08-22 17:30:44 -0500 | [diff] [blame] | 200 | { USB_DEVICE(0x03f0, 0x1b1d) }, /* HP ev2200 a.k.a MC5720 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 201 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 202 | { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ |
agilmore@wirelessbeehive.com | b9e13ac | 2007-12-04 11:37:12 -0700 | [diff] [blame] | 203 | { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 204 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ |
| 205 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 206 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 207 | /* Sierra Wireless C597 */ |
| 208 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 209 | /* Sierra Wireless Device */ |
| 210 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, |
| 211 | { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ |
Kevin Lloyd | 73b2c20 | 2008-08-25 19:20:40 -0700 | [diff] [blame] | 212 | { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless Device */ |
| 213 | { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless Device */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 214 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 215 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 216 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 217 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 218 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 219 | { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Lenovo) */ |
Kevin Lloyd | 7f170a6 | 2008-03-14 00:53:24 -0700 | [diff] [blame] | 220 | { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */ |
Stefan Seyfried | 8f7f85e | 2008-04-17 07:47:34 +0200 | [diff] [blame] | 221 | { USB_DEVICE(0x03f0, 0x1e1d) }, /* HP hs2300 a.k.a MC8775 */ |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 222 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ |
Kevin Lloyd | 7106967 | 2008-04-02 11:24:56 -0700 | [diff] [blame] | 223 | { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 224 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ |
| 225 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ |
Kevin Lloyd | b77a5c7 | 2008-09-17 09:03:38 -0700 | [diff] [blame] | 226 | { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */ |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 227 | { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ |
Elina Pasheva | 4db2299 | 2009-06-11 14:32:01 +0100 | [diff] [blame] | 228 | /* Sierra Wireless MC8790, MC8791, MC8792 Composite */ |
| 229 | { USB_DEVICE(0x1199, 0x683C) }, |
| 230 | { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8791 Composite */ |
| 231 | /* Sierra Wireless MC8790, MC8791, MC8792 */ |
| 232 | { USB_DEVICE(0x1199, 0x683E) }, |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 233 | { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ |
| 234 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ |
| 235 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ |
| 236 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ |
Kevin Lloyd | 6835b32 | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 237 | { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */ |
Jessica L. Blank | 62aad3a | 2007-12-30 20:11:35 -0600 | [diff] [blame] | 238 | { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 239 | { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */ |
| 240 | { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */ |
| 241 | /* Sierra Wireless C885 */ |
| 242 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)}, |
| 243 | /* Sierra Wireless Device */ |
| 244 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, |
| 245 | /* Sierra Wireless Device */ |
Kevin Lloyd | 73b2c20 | 2008-08-25 19:20:40 -0700 | [diff] [blame] | 246 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)}, |
| 247 | /* Sierra Wireless Device */ |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 248 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 249 | |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 250 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ |
| 251 | { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 252 | |
Elina Pasheva | 4db2299 | 2009-06-11 14:32:01 +0100 | [diff] [blame] | 253 | { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */ |
| 254 | .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist |
| 255 | }, |
| 256 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 257 | { } |
| 258 | }; |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 259 | MODULE_DEVICE_TABLE(usb, id_table); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 260 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 261 | static struct usb_driver sierra_driver = { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 262 | .name = "sierra", |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 263 | .probe = usb_serial_probe, |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 264 | .disconnect = usb_serial_disconnect, |
| 265 | .id_table = id_table, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 266 | .no_dynamic_id = 1, |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 267 | }; |
| 268 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 269 | struct sierra_port_private { |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 270 | spinlock_t lock; /* lock the structure */ |
| 271 | int outstanding_urbs; /* number of out urbs in flight */ |
| 272 | |
Oliver Neukum | 4f4f9c5 | 2008-03-14 00:53:24 -0700 | [diff] [blame] | 273 | /* Input endpoints and buffers for this port */ |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 274 | struct urb *in_urbs[N_IN_URB]; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 275 | |
| 276 | /* Settings for the port */ |
| 277 | int rts_state; /* Handshaking pins (outputs) */ |
| 278 | int dtr_state; |
| 279 | int cts_state; /* Handshaking pins (inputs) */ |
| 280 | int dsr_state; |
| 281 | int dcd_state; |
| 282 | int ri_state; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 283 | }; |
| 284 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 285 | static int sierra_send_setup(struct usb_serial_port *port) |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 286 | { |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 287 | struct usb_serial *serial = port->serial; |
| 288 | struct sierra_port_private *portdata; |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 289 | __u16 interface = 0; |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 290 | int val = 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 291 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 292 | dev_dbg(&port->dev, "%s\n", __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 293 | |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 294 | portdata = usb_get_serial_port_data(port); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 295 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 296 | if (portdata->dtr_state) |
| 297 | val |= 0x01; |
| 298 | if (portdata->rts_state) |
| 299 | val |= 0x02; |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 300 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 301 | /* If composite device then properly report interface */ |
Alan Cox | 00b040d | 2009-06-11 14:29:29 +0100 | [diff] [blame] | 302 | if (serial->num_ports == 1) { |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 303 | interface = sierra_calc_interface(serial); |
Alan Cox | 00b040d | 2009-06-11 14:29:29 +0100 | [diff] [blame] | 304 | /* Control message is sent only to interfaces with |
| 305 | * interrupt_in endpoints |
| 306 | */ |
| 307 | if (port->interrupt_in_urb) { |
| 308 | /* send control message */ |
| 309 | return usb_control_msg(serial->dev, |
| 310 | usb_rcvctrlpipe(serial->dev, 0), |
| 311 | 0x22, 0x21, val, interface, |
| 312 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 313 | } |
| 314 | } |
Kevin Lloyd | e3173b2 | 2008-07-10 14:14:51 -0700 | [diff] [blame] | 315 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 316 | /* Otherwise the need to do non-composite mapping */ |
| 317 | else { |
| 318 | if (port->bulk_out_endpointAddress == 2) |
| 319 | interface = 0; |
| 320 | else if (port->bulk_out_endpointAddress == 4) |
| 321 | interface = 1; |
| 322 | else if (port->bulk_out_endpointAddress == 5) |
| 323 | interface = 2; |
Alan Cox | 00b040d | 2009-06-11 14:29:29 +0100 | [diff] [blame] | 324 | return usb_control_msg(serial->dev, |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 325 | usb_rcvctrlpipe(serial->dev, 0), |
| 326 | 0x22, 0x21, val, interface, |
| 327 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
Alan Cox | 00b040d | 2009-06-11 14:29:29 +0100 | [diff] [blame] | 328 | } |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 329 | return 0; |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 332 | static void sierra_set_termios(struct tty_struct *tty, |
| 333 | struct usb_serial_port *port, struct ktermios *old_termios) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 334 | { |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 335 | dev_dbg(&port->dev, "%s\n", __func__); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 336 | tty_termios_copy_hw(tty->termios, old_termios); |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 337 | sierra_send_setup(port); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 340 | static int sierra_tiocmget(struct tty_struct *tty, struct file *file) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 341 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 342 | struct usb_serial_port *port = tty->driver_data; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 343 | unsigned int value; |
| 344 | struct sierra_port_private *portdata; |
| 345 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 346 | dev_dbg(&port->dev, "%s\n", __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 347 | portdata = usb_get_serial_port_data(port); |
| 348 | |
| 349 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | |
| 350 | ((portdata->dtr_state) ? TIOCM_DTR : 0) | |
| 351 | ((portdata->cts_state) ? TIOCM_CTS : 0) | |
| 352 | ((portdata->dsr_state) ? TIOCM_DSR : 0) | |
| 353 | ((portdata->dcd_state) ? TIOCM_CAR : 0) | |
| 354 | ((portdata->ri_state) ? TIOCM_RNG : 0); |
| 355 | |
| 356 | return value; |
| 357 | } |
| 358 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 359 | static int sierra_tiocmset(struct tty_struct *tty, struct file *file, |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 360 | unsigned int set, unsigned int clear) |
| 361 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 362 | struct usb_serial_port *port = tty->driver_data; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 363 | struct sierra_port_private *portdata; |
| 364 | |
| 365 | portdata = usb_get_serial_port_data(port); |
| 366 | |
| 367 | if (set & TIOCM_RTS) |
| 368 | portdata->rts_state = 1; |
| 369 | if (set & TIOCM_DTR) |
| 370 | portdata->dtr_state = 1; |
| 371 | |
| 372 | if (clear & TIOCM_RTS) |
| 373 | portdata->rts_state = 0; |
| 374 | if (clear & TIOCM_DTR) |
| 375 | portdata->dtr_state = 0; |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 376 | return sierra_send_setup(port); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 377 | } |
| 378 | |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 379 | static void sierra_release_urb(struct urb *urb) |
| 380 | { |
| 381 | struct usb_serial_port *port; |
| 382 | if (urb) { |
| 383 | port = urb->context; |
| 384 | dev_dbg(&port->dev, "%s: %p\n", __func__, urb); |
| 385 | kfree(urb->transfer_buffer); |
| 386 | usb_free_urb(urb); |
| 387 | } |
| 388 | } |
| 389 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 390 | static void sierra_outdat_callback(struct urb *urb) |
| 391 | { |
| 392 | struct usb_serial_port *port = urb->context; |
| 393 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 394 | int status = urb->status; |
| 395 | unsigned long flags; |
| 396 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 397 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 398 | |
| 399 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
| 400 | kfree(urb->transfer_buffer); |
| 401 | |
| 402 | if (status) |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 403 | dev_dbg(&port->dev, "%s - nonzero write bulk status " |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 404 | "received: %d\n", __func__, status); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 405 | |
| 406 | spin_lock_irqsave(&portdata->lock, flags); |
| 407 | --portdata->outstanding_urbs; |
| 408 | spin_unlock_irqrestore(&portdata->lock, flags); |
| 409 | |
| 410 | usb_serial_port_softint(port); |
| 411 | } |
| 412 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 413 | /* Write */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 414 | static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, |
| 415 | const unsigned char *buf, int count) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 416 | { |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 417 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 418 | struct usb_serial *serial = port->serial; |
| 419 | unsigned long flags; |
| 420 | unsigned char *buffer; |
| 421 | struct urb *urb; |
| 422 | int status; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 423 | |
| 424 | portdata = usb_get_serial_port_data(port); |
| 425 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 426 | dev_dbg(&port->dev, "%s: write (%d chars)\n", __func__, count); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 427 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 428 | spin_lock_irqsave(&portdata->lock, flags); |
| 429 | if (portdata->outstanding_urbs > N_OUT_URB) { |
| 430 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 431 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 432 | return 0; |
| 433 | } |
| 434 | portdata->outstanding_urbs++; |
| 435 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 436 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 437 | buffer = kmalloc(count, GFP_ATOMIC); |
| 438 | if (!buffer) { |
| 439 | dev_err(&port->dev, "out of memory\n"); |
| 440 | count = -ENOMEM; |
| 441 | goto error_no_buffer; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 442 | } |
| 443 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 444 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
| 445 | if (!urb) { |
| 446 | dev_err(&port->dev, "no more free urbs\n"); |
| 447 | count = -ENOMEM; |
| 448 | goto error_no_urb; |
| 449 | } |
| 450 | |
| 451 | memcpy(buffer, buf, count); |
| 452 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 453 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 454 | |
| 455 | usb_fill_bulk_urb(urb, serial->dev, |
| 456 | usb_sndbulkpipe(serial->dev, |
| 457 | port->bulk_out_endpointAddress), |
| 458 | buffer, count, sierra_outdat_callback, port); |
| 459 | |
| 460 | /* send it down the pipe */ |
| 461 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 462 | if (status) { |
| 463 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 464 | "with status = %d\n", __func__, status); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 465 | count = status; |
| 466 | goto error; |
| 467 | } |
| 468 | |
| 469 | /* we are done with this urb, so let the host driver |
| 470 | * really free it when it is finished with it */ |
| 471 | usb_free_urb(urb); |
| 472 | |
| 473 | return count; |
| 474 | error: |
| 475 | usb_free_urb(urb); |
| 476 | error_no_urb: |
| 477 | kfree(buffer); |
| 478 | error_no_buffer: |
| 479 | spin_lock_irqsave(&portdata->lock, flags); |
| 480 | --portdata->outstanding_urbs; |
| 481 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 482 | return count; |
| 483 | } |
| 484 | |
| 485 | static void sierra_indat_callback(struct urb *urb) |
| 486 | { |
| 487 | int err; |
| 488 | int endpoint; |
| 489 | struct usb_serial_port *port; |
| 490 | struct tty_struct *tty; |
| 491 | unsigned char *data = urb->transfer_buffer; |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 492 | int status = urb->status; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 493 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 494 | dbg("%s: %p", __func__, urb); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 495 | |
| 496 | endpoint = usb_pipeendpoint(urb->pipe); |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 497 | port = urb->context; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 498 | |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 499 | if (status) { |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 500 | dev_dbg(&port->dev, "%s: nonzero status: %d on" |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 501 | " endpoint %02x\n", __func__, status, endpoint); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 502 | } else { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 503 | if (urb->actual_length) { |
Alan Cox | d95186d | 2009-01-02 13:42:56 +0000 | [diff] [blame] | 504 | tty = tty_port_tty_get(&port->port); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 505 | tty_buffer_request_room(tty, urb->actual_length); |
| 506 | tty_insert_flip_string(tty, data, urb->actual_length); |
| 507 | tty_flip_buffer_push(tty); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 508 | tty_kref_put(tty); |
| 509 | } else |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 510 | dev_dbg(&port->dev, "%s: empty read urb" |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 511 | " received\n", __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 512 | |
| 513 | /* Resubmit urb so we continue receiving */ |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 514 | if (port->port.count && status != -ESHUTDOWN && status != -EPERM) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 515 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 516 | if (err) |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 517 | dev_err(&port->dev, "resubmit read urb failed." |
Joe Perches | 898eb71 | 2007-10-18 03:06:30 -0700 | [diff] [blame] | 518 | "(%d)\n", err); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | return; |
| 522 | } |
| 523 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 524 | static void sierra_instat_callback(struct urb *urb) |
| 525 | { |
| 526 | int err; |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 527 | int status = urb->status; |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 528 | struct usb_serial_port *port = urb->context; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 529 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 530 | struct usb_serial *serial = port->serial; |
| 531 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 532 | dev_dbg(&port->dev, "%s\n", __func__); |
| 533 | dev_dbg(&port->dev, "%s: urb %p port %p has data %p\n", __func__, |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 534 | urb, port, portdata); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 535 | |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 536 | if (status == 0) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 537 | struct usb_ctrlrequest *req_pkt = |
| 538 | (struct usb_ctrlrequest *)urb->transfer_buffer; |
| 539 | |
| 540 | if (!req_pkt) { |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 541 | dev_dbg(&port->dev, "%s: NULL req_pkt\n", |
| 542 | __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 543 | return; |
| 544 | } |
| 545 | if ((req_pkt->bRequestType == 0xA1) && |
| 546 | (req_pkt->bRequest == 0x20)) { |
| 547 | int old_dcd_state; |
| 548 | unsigned char signals = *((unsigned char *) |
| 549 | urb->transfer_buffer + |
| 550 | sizeof(struct usb_ctrlrequest)); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 551 | struct tty_struct *tty; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 552 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 553 | dev_dbg(&port->dev, "%s: signal x%x\n", __func__, |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 554 | signals); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 555 | |
| 556 | old_dcd_state = portdata->dcd_state; |
| 557 | portdata->cts_state = 1; |
| 558 | portdata->dcd_state = ((signals & 0x01) ? 1 : 0); |
| 559 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
| 560 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
| 561 | |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 562 | tty = tty_port_tty_get(&port->port); |
| 563 | if (tty && !C_CLOCAL(tty) && |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 564 | old_dcd_state && !portdata->dcd_state) |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 565 | tty_hangup(tty); |
| 566 | tty_kref_put(tty); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 567 | } else { |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 568 | dev_dbg(&port->dev, "%s: type %x req %x\n", |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 569 | __func__, req_pkt->bRequestType, |
| 570 | req_pkt->bRequest); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 571 | } |
| 572 | } else |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 573 | dev_dbg(&port->dev, "%s: error %d\n", __func__, status); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 574 | |
| 575 | /* Resubmit urb so we continue receiving IRQ data */ |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 576 | if (status != -ESHUTDOWN) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 577 | urb->dev = serial->dev; |
| 578 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 579 | if (err) |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 580 | dev_dbg(&port->dev, "%s: resubmit intr urb " |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 581 | "failed. (%d)\n", __func__, err); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 582 | } |
| 583 | } |
| 584 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 585 | static int sierra_write_room(struct tty_struct *tty) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 586 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 587 | struct usb_serial_port *port = tty->driver_data; |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 588 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 589 | unsigned long flags; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 590 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 591 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 592 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 593 | /* try to give a good number back based on if we have any free urbs at |
| 594 | * this point in time */ |
| 595 | spin_lock_irqsave(&portdata->lock, flags); |
| 596 | if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { |
| 597 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 598 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 599 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 600 | } |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 601 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 602 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 603 | return 2048; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 606 | static void sierra_stop_rx_urbs(struct usb_serial_port *port) |
| 607 | { |
| 608 | int i; |
| 609 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 610 | |
| 611 | for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) |
| 612 | usb_kill_urb(portdata->in_urbs[i]); |
| 613 | |
| 614 | usb_kill_urb(port->interrupt_in_urb); |
| 615 | } |
| 616 | |
| 617 | static int sierra_submit_rx_urbs(struct usb_serial_port *port, gfp_t mem_flags) |
| 618 | { |
| 619 | int ok_cnt; |
| 620 | int err = -EINVAL; |
| 621 | int i; |
| 622 | struct urb *urb; |
| 623 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 624 | |
| 625 | ok_cnt = 0; |
| 626 | for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) { |
| 627 | urb = portdata->in_urbs[i]; |
| 628 | if (!urb) |
| 629 | continue; |
| 630 | err = usb_submit_urb(urb, mem_flags); |
| 631 | if (err) { |
| 632 | dev_err(&port->dev, "%s: submit urb failed: %d\n", |
| 633 | __func__, err); |
| 634 | } else { |
| 635 | ok_cnt++; |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | if (ok_cnt && port->interrupt_in_urb) { |
| 640 | err = usb_submit_urb(port->interrupt_in_urb, mem_flags); |
| 641 | if (err) { |
| 642 | dev_err(&port->dev, "%s: submit intr urb failed: %d\n", |
| 643 | __func__, err); |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | if (ok_cnt > 0) /* at least one rx urb submitted */ |
| 648 | return 0; |
| 649 | else |
| 650 | return err; |
| 651 | } |
| 652 | |
| 653 | static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint, |
| 654 | int dir, void *ctx, int len, |
| 655 | gfp_t mem_flags, |
| 656 | usb_complete_t callback) |
| 657 | { |
| 658 | struct urb *urb; |
| 659 | u8 *buf; |
| 660 | |
| 661 | if (endpoint == -1) |
| 662 | return NULL; |
| 663 | |
| 664 | urb = usb_alloc_urb(0, mem_flags); |
| 665 | if (urb == NULL) { |
| 666 | dev_dbg(&serial->dev->dev, "%s: alloc for endpoint %d failed\n", |
| 667 | __func__, endpoint); |
| 668 | return NULL; |
| 669 | } |
| 670 | |
| 671 | buf = kmalloc(len, mem_flags); |
| 672 | if (buf) { |
| 673 | /* Fill URB using supplied data */ |
| 674 | usb_fill_bulk_urb(urb, serial->dev, |
| 675 | usb_sndbulkpipe(serial->dev, endpoint) | dir, |
| 676 | buf, len, callback, ctx); |
| 677 | |
| 678 | /* debug */ |
| 679 | dev_dbg(&serial->dev->dev, "%s %c u : %p d:%p\n", __func__, |
| 680 | dir == USB_DIR_IN ? 'i' : 'o', urb, buf); |
| 681 | } else { |
| 682 | dev_dbg(&serial->dev->dev, "%s %c u:%p d:%p\n", __func__, |
| 683 | dir == USB_DIR_IN ? 'i' : 'o', urb, buf); |
| 684 | |
| 685 | sierra_release_urb(urb); |
| 686 | urb = NULL; |
| 687 | } |
| 688 | |
| 689 | return urb; |
| 690 | } |
| 691 | |
| 692 | static void sierra_close(struct usb_serial_port *port) |
| 693 | { |
| 694 | int i; |
| 695 | struct usb_serial *serial = port->serial; |
| 696 | struct sierra_port_private *portdata; |
| 697 | |
| 698 | dev_dbg(&port->dev, "%s\n", __func__); |
| 699 | portdata = usb_get_serial_port_data(port); |
| 700 | |
| 701 | portdata->rts_state = 0; |
| 702 | portdata->dtr_state = 0; |
| 703 | |
| 704 | if (serial->dev) { |
| 705 | mutex_lock(&serial->disc_mutex); |
| 706 | if (!serial->disconnected) |
| 707 | sierra_send_setup(port); |
| 708 | mutex_unlock(&serial->disc_mutex); |
| 709 | |
| 710 | /* Stop reading urbs */ |
| 711 | sierra_stop_rx_urbs(port); |
| 712 | /* .. and release them */ |
| 713 | for (i = 0; i < N_IN_URB; i++) { |
| 714 | sierra_release_urb(portdata->in_urbs[i]); |
| 715 | portdata->in_urbs[i] = NULL; |
| 716 | } |
| 717 | } |
| 718 | } |
| 719 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 720 | static int sierra_open(struct tty_struct *tty, |
| 721 | struct usb_serial_port *port, struct file *filp) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 722 | { |
| 723 | struct sierra_port_private *portdata; |
| 724 | struct usb_serial *serial = port->serial; |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 725 | int i; |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 726 | int err; |
| 727 | int endpoint; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 728 | struct urb *urb; |
| 729 | |
| 730 | portdata = usb_get_serial_port_data(port); |
| 731 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 732 | dev_dbg(&port->dev, "%s\n", __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 733 | |
| 734 | /* Set some sane defaults */ |
| 735 | portdata->rts_state = 1; |
| 736 | portdata->dtr_state = 1; |
| 737 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 738 | |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 739 | endpoint = port->bulk_in_endpointAddress; |
| 740 | for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) { |
| 741 | urb = sierra_setup_urb(serial, endpoint, USB_DIR_IN, port, |
| 742 | IN_BUFLEN, GFP_KERNEL, |
| 743 | sierra_indat_callback); |
| 744 | portdata->in_urbs[i] = urb; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 745 | } |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 746 | /* clear halt condition */ |
| 747 | usb_clear_halt(serial->dev, |
| 748 | usb_sndbulkpipe(serial->dev, endpoint) | USB_DIR_IN); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 749 | |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 750 | err = sierra_submit_rx_urbs(port, GFP_KERNEL); |
| 751 | if (err) { |
| 752 | /* get rid of everything as in close */ |
| 753 | sierra_close(port); |
| 754 | return err; |
| 755 | } |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 756 | sierra_send_setup(port); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 757 | |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 758 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 759 | } |
| 760 | |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 761 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 762 | static void sierra_dtr_rts(struct usb_serial_port *port, int on) |
| 763 | { |
| 764 | struct usb_serial *serial = port->serial; |
| 765 | struct sierra_port_private *portdata; |
| 766 | |
| 767 | portdata = usb_get_serial_port_data(port); |
| 768 | portdata->rts_state = on; |
| 769 | portdata->dtr_state = on; |
| 770 | |
| 771 | if (serial->dev) { |
| 772 | mutex_lock(&serial->disc_mutex); |
| 773 | if (!serial->disconnected) |
| 774 | sierra_send_setup(port); |
| 775 | mutex_unlock(&serial->disc_mutex); |
| 776 | } |
| 777 | } |
| 778 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 779 | static int sierra_startup(struct usb_serial *serial) |
| 780 | { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 781 | struct usb_serial_port *port; |
| 782 | struct sierra_port_private *portdata; |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 783 | int i; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 784 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 785 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 786 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 787 | /* Set Device mode to D0 */ |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 788 | sierra_set_power_state(serial->dev, 0x0000); |
| 789 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 790 | /* Check NMEA and set */ |
| 791 | if (nmea) |
| 792 | sierra_vsc_set_nmea(serial->dev, 1); |
| 793 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 794 | /* Now setup per port private data */ |
| 795 | for (i = 0; i < serial->num_ports; i++) { |
| 796 | port = serial->port[i]; |
| 797 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
| 798 | if (!portdata) { |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 799 | dev_dbg(&port->dev, "%s: kmalloc for " |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 800 | "sierra_port_private (%d) failed!.\n", |
Kevin Lloyd | 7384a92 | 2008-09-16 21:05:24 -0700 | [diff] [blame] | 801 | __func__, i); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 802 | return -ENOMEM; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 803 | } |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 804 | spin_lock_init(&portdata->lock); |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 805 | /* Set the port private data pointer */ |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 806 | usb_set_serial_port_data(port, portdata); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 807 | } |
| 808 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 809 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | static void sierra_shutdown(struct usb_serial *serial) |
| 813 | { |
Elina Pasheva | b9a44bc | 2009-06-11 14:30:21 +0100 | [diff] [blame] | 814 | int i; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 815 | struct usb_serial_port *port; |
| 816 | struct sierra_port_private *portdata; |
| 817 | |
Elina Pasheva | 5d44b36 | 2009-04-27 18:41:52 -0700 | [diff] [blame^] | 818 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 819 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 820 | for (i = 0; i < serial->num_ports; ++i) { |
| 821 | port = serial->port[i]; |
Greg Kroah-Hartman | f094e4f | 2007-04-26 00:12:01 -0700 | [diff] [blame] | 822 | if (!port) |
| 823 | continue; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 824 | portdata = usb_get_serial_port_data(port); |
Greg Kroah-Hartman | f094e4f | 2007-04-26 00:12:01 -0700 | [diff] [blame] | 825 | if (!portdata) |
| 826 | continue; |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 827 | kfree(portdata); |
| 828 | usb_set_serial_port_data(port, NULL); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 829 | } |
| 830 | } |
| 831 | |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 832 | static struct usb_serial_driver sierra_device = { |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 833 | .driver = { |
| 834 | .owner = THIS_MODULE, |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 835 | .name = "sierra", |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 836 | }, |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 837 | .description = "Sierra USB modem", |
| 838 | .id_table = id_table, |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 839 | .usb_driver = &sierra_driver, |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 840 | .calc_num_ports = sierra_calc_num_ports, |
| 841 | .probe = sierra_probe, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 842 | .open = sierra_open, |
| 843 | .close = sierra_close, |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 844 | .dtr_rts = sierra_dtr_rts, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 845 | .write = sierra_write, |
| 846 | .write_room = sierra_write_room, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 847 | .set_termios = sierra_set_termios, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 848 | .tiocmget = sierra_tiocmget, |
| 849 | .tiocmset = sierra_tiocmset, |
| 850 | .attach = sierra_startup, |
| 851 | .shutdown = sierra_shutdown, |
| 852 | .read_int_callback = sierra_instat_callback, |
| 853 | }; |
| 854 | |
| 855 | /* Functions used by new usb-serial code. */ |
| 856 | static int __init sierra_init(void) |
| 857 | { |
| 858 | int retval; |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 859 | retval = usb_serial_register(&sierra_device); |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 860 | if (retval) |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 861 | goto failed_device_register; |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 862 | |
| 863 | |
| 864 | retval = usb_register(&sierra_driver); |
| 865 | if (retval) |
| 866 | goto failed_driver_register; |
| 867 | |
Greg Kroah-Hartman | c197a8d | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 868 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 869 | DRIVER_DESC "\n"); |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 870 | |
| 871 | return 0; |
| 872 | |
| 873 | failed_driver_register: |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 874 | usb_serial_deregister(&sierra_device); |
| 875 | failed_device_register: |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 876 | return retval; |
| 877 | } |
| 878 | |
| 879 | static void __exit sierra_exit(void) |
| 880 | { |
Alan Cox | 9660ea3 | 2008-07-22 11:14:59 +0100 | [diff] [blame] | 881 | usb_deregister(&sierra_driver); |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 882 | usb_serial_deregister(&sierra_device); |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | module_init(sierra_init); |
| 886 | module_exit(sierra_exit); |
| 887 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 888 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 889 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 890 | MODULE_VERSION(DRIVER_VERSION); |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 891 | MODULE_LICENSE("GPL"); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 892 | |
Kevin Lloyd | 4e0fee8 | 2008-07-10 14:14:47 -0700 | [diff] [blame] | 893 | module_param(nmea, bool, S_IRUGO | S_IWUSR); |
Kevin Lloyd | 228426e | 2008-01-10 11:11:04 -0800 | [diff] [blame] | 894 | MODULE_PARM_DESC(nmea, "NMEA streaming"); |
| 895 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 896 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 897 | MODULE_PARM_DESC(debug, "Debug messages"); |