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 | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 4 | Copyright (C) 2006, 2007 Kevin Lloyd <linux@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 | |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 17 | #define DRIVER_VERSION "v.1.2.5b" |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 18 | #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" |
| 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 | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 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 |
| 34 | |
| 35 | /* per port private data */ |
| 36 | #define N_IN_URB 4 |
| 37 | #define N_OUT_URB 4 |
| 38 | #define IN_BUFLEN 4096 |
| 39 | |
| 40 | static int debug; |
| 41 | |
| 42 | enum devicetype { |
| 43 | DEVICE_3_PORT = 0, |
| 44 | DEVICE_1_PORT = 1, |
| 45 | DEVICE_INSTALLER = 2, |
| 46 | }; |
| 47 | |
| 48 | int 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 | |
| 63 | int 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 | |
| 78 | int 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 | } |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 95 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 96 | static struct usb_device_id id_table [] = { |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 97 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 98 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ |
Greg Kroah-Hartman | 90ac3c8 | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 99 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 100 | { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 101 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ |
| 102 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ |
| 103 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 104 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ |
| 105 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 106 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 107 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 108 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 109 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 110 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 111 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ |
| 112 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ |
| 113 | { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ |
| 114 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ |
| 115 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ |
| 116 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 117 | |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 118 | { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ |
| 119 | { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ |
| 120 | |
| 121 | { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 122 | { } |
| 123 | }; |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 124 | MODULE_DEVICE_TABLE(usb, id_table); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 125 | |
| 126 | static struct usb_device_id id_table_1port [] = { |
| 127 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ |
| 128 | { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */ |
| 129 | { } |
| 130 | }; |
| 131 | |
| 132 | static struct usb_device_id id_table_3port [] = { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 133 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 134 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 135 | { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ |
Greg Kroah-Hartman | 90ac3c8 | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 136 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 137 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ |
| 138 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ |
| 139 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 140 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 141 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 142 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 143 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 144 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 145 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 146 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ |
Kevin Lloyd | 9454c46 | 2007-07-16 13:49:29 -0700 | [diff] [blame] | 147 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ |
| 148 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ |
| 149 | { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ |
| 150 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ |
| 151 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880E */ |
| 152 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881E */ |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 153 | { } |
| 154 | }; |
| 155 | |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 156 | static struct usb_driver sierra_driver = { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 157 | .name = "sierra", |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 158 | .probe = sierra_probe, |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 159 | .disconnect = usb_serial_disconnect, |
| 160 | .id_table = id_table, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 161 | .no_dynamic_id = 1, |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 164 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 165 | struct sierra_port_private { |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 166 | spinlock_t lock; /* lock the structure */ |
| 167 | int outstanding_urbs; /* number of out urbs in flight */ |
| 168 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 169 | /* Input endpoints and buffer for this port */ |
| 170 | struct urb *in_urbs[N_IN_URB]; |
| 171 | char in_buffer[N_IN_URB][IN_BUFLEN]; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 172 | |
| 173 | /* Settings for the port */ |
| 174 | int rts_state; /* Handshaking pins (outputs) */ |
| 175 | int dtr_state; |
| 176 | int cts_state; /* Handshaking pins (inputs) */ |
| 177 | int dsr_state; |
| 178 | int dcd_state; |
| 179 | int ri_state; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 180 | }; |
| 181 | |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 182 | static int sierra_send_setup(struct usb_serial_port *port) |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 183 | { |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 184 | struct usb_serial *serial = port->serial; |
| 185 | struct sierra_port_private *portdata; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 186 | |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 187 | dbg("%s", __FUNCTION__); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 188 | |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 189 | portdata = usb_get_serial_port_data(port); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 190 | |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 191 | if (port->tty) { |
| 192 | int val = 0; |
| 193 | if (portdata->dtr_state) |
| 194 | val |= 0x01; |
| 195 | if (portdata->rts_state) |
| 196 | val |= 0x02; |
| 197 | |
| 198 | return usb_control_msg(serial->dev, |
| 199 | usb_rcvctrlpipe(serial->dev, 0), |
| 200 | 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); |
| 201 | } |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 202 | |
| 203 | return 0; |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 206 | static void sierra_rx_throttle(struct usb_serial_port *port) |
| 207 | { |
| 208 | dbg("%s", __FUNCTION__); |
| 209 | } |
| 210 | |
| 211 | static void sierra_rx_unthrottle(struct usb_serial_port *port) |
| 212 | { |
| 213 | dbg("%s", __FUNCTION__); |
| 214 | } |
| 215 | |
| 216 | static void sierra_break_ctl(struct usb_serial_port *port, int break_state) |
| 217 | { |
| 218 | /* Unfortunately, I don't know how to send a break */ |
| 219 | dbg("%s", __FUNCTION__); |
| 220 | } |
| 221 | |
| 222 | static void sierra_set_termios(struct usb_serial_port *port, |
Alan Cox | 606d099 | 2006-12-08 02:38:45 -0800 | [diff] [blame] | 223 | struct ktermios *old_termios) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 224 | { |
| 225 | dbg("%s", __FUNCTION__); |
| 226 | |
| 227 | sierra_send_setup(port); |
| 228 | } |
| 229 | |
| 230 | static int sierra_tiocmget(struct usb_serial_port *port, struct file *file) |
| 231 | { |
| 232 | unsigned int value; |
| 233 | struct sierra_port_private *portdata; |
| 234 | |
| 235 | portdata = usb_get_serial_port_data(port); |
| 236 | |
| 237 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | |
| 238 | ((portdata->dtr_state) ? TIOCM_DTR : 0) | |
| 239 | ((portdata->cts_state) ? TIOCM_CTS : 0) | |
| 240 | ((portdata->dsr_state) ? TIOCM_DSR : 0) | |
| 241 | ((portdata->dcd_state) ? TIOCM_CAR : 0) | |
| 242 | ((portdata->ri_state) ? TIOCM_RNG : 0); |
| 243 | |
| 244 | return value; |
| 245 | } |
| 246 | |
| 247 | static int sierra_tiocmset(struct usb_serial_port *port, struct file *file, |
| 248 | unsigned int set, unsigned int clear) |
| 249 | { |
| 250 | struct sierra_port_private *portdata; |
| 251 | |
| 252 | portdata = usb_get_serial_port_data(port); |
| 253 | |
| 254 | if (set & TIOCM_RTS) |
| 255 | portdata->rts_state = 1; |
| 256 | if (set & TIOCM_DTR) |
| 257 | portdata->dtr_state = 1; |
| 258 | |
| 259 | if (clear & TIOCM_RTS) |
| 260 | portdata->rts_state = 0; |
| 261 | if (clear & TIOCM_DTR) |
| 262 | portdata->dtr_state = 0; |
| 263 | return sierra_send_setup(port); |
| 264 | } |
| 265 | |
| 266 | static int sierra_ioctl(struct usb_serial_port *port, struct file *file, |
| 267 | unsigned int cmd, unsigned long arg) |
| 268 | { |
| 269 | return -ENOIOCTLCMD; |
| 270 | } |
| 271 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 272 | static void sierra_outdat_callback(struct urb *urb) |
| 273 | { |
| 274 | struct usb_serial_port *port = urb->context; |
| 275 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 276 | int status = urb->status; |
| 277 | unsigned long flags; |
| 278 | |
| 279 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 280 | |
| 281 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
| 282 | kfree(urb->transfer_buffer); |
| 283 | |
| 284 | if (status) |
| 285 | dbg("%s - nonzero write bulk status received: %d", |
| 286 | __FUNCTION__, status); |
| 287 | |
| 288 | spin_lock_irqsave(&portdata->lock, flags); |
| 289 | --portdata->outstanding_urbs; |
| 290 | spin_unlock_irqrestore(&portdata->lock, flags); |
| 291 | |
| 292 | usb_serial_port_softint(port); |
| 293 | } |
| 294 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 295 | /* Write */ |
| 296 | static int sierra_write(struct usb_serial_port *port, |
| 297 | const unsigned char *buf, int count) |
| 298 | { |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 299 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 300 | struct usb_serial *serial = port->serial; |
| 301 | unsigned long flags; |
| 302 | unsigned char *buffer; |
| 303 | struct urb *urb; |
| 304 | int status; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 305 | |
| 306 | portdata = usb_get_serial_port_data(port); |
| 307 | |
| 308 | dbg("%s: write (%d chars)", __FUNCTION__, count); |
| 309 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 310 | spin_lock_irqsave(&portdata->lock, flags); |
| 311 | if (portdata->outstanding_urbs > N_OUT_URB) { |
| 312 | spin_unlock_irqrestore(&portdata->lock, flags); |
| 313 | dbg("%s - write limit hit\n", __FUNCTION__); |
| 314 | return 0; |
| 315 | } |
| 316 | portdata->outstanding_urbs++; |
| 317 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 318 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 319 | buffer = kmalloc(count, GFP_ATOMIC); |
| 320 | if (!buffer) { |
| 321 | dev_err(&port->dev, "out of memory\n"); |
| 322 | count = -ENOMEM; |
| 323 | goto error_no_buffer; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 326 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
| 327 | if (!urb) { |
| 328 | dev_err(&port->dev, "no more free urbs\n"); |
| 329 | count = -ENOMEM; |
| 330 | goto error_no_urb; |
| 331 | } |
| 332 | |
| 333 | memcpy(buffer, buf, count); |
| 334 | |
| 335 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer); |
| 336 | |
| 337 | usb_fill_bulk_urb(urb, serial->dev, |
| 338 | usb_sndbulkpipe(serial->dev, |
| 339 | port->bulk_out_endpointAddress), |
| 340 | buffer, count, sierra_outdat_callback, port); |
| 341 | |
| 342 | /* send it down the pipe */ |
| 343 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 344 | if (status) { |
| 345 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
| 346 | "with status = %d\n", __FUNCTION__, status); |
| 347 | count = status; |
| 348 | goto error; |
| 349 | } |
| 350 | |
| 351 | /* we are done with this urb, so let the host driver |
| 352 | * really free it when it is finished with it */ |
| 353 | usb_free_urb(urb); |
| 354 | |
| 355 | return count; |
| 356 | error: |
| 357 | usb_free_urb(urb); |
| 358 | error_no_urb: |
| 359 | kfree(buffer); |
| 360 | error_no_buffer: |
| 361 | spin_lock_irqsave(&portdata->lock, flags); |
| 362 | --portdata->outstanding_urbs; |
| 363 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 364 | return count; |
| 365 | } |
| 366 | |
| 367 | static void sierra_indat_callback(struct urb *urb) |
| 368 | { |
| 369 | int err; |
| 370 | int endpoint; |
| 371 | struct usb_serial_port *port; |
| 372 | struct tty_struct *tty; |
| 373 | unsigned char *data = urb->transfer_buffer; |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 374 | int status = urb->status; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 375 | |
| 376 | dbg("%s: %p", __FUNCTION__, urb); |
| 377 | |
| 378 | endpoint = usb_pipeendpoint(urb->pipe); |
| 379 | port = (struct usb_serial_port *) urb->context; |
| 380 | |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 381 | if (status) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 382 | dbg("%s: nonzero status: %d on endpoint %02x.", |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 383 | __FUNCTION__, status, endpoint); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 384 | } else { |
| 385 | tty = port->tty; |
| 386 | if (urb->actual_length) { |
| 387 | tty_buffer_request_room(tty, urb->actual_length); |
| 388 | tty_insert_flip_string(tty, data, urb->actual_length); |
| 389 | tty_flip_buffer_push(tty); |
| 390 | } else { |
| 391 | dbg("%s: empty read urb received", __FUNCTION__); |
| 392 | } |
| 393 | |
| 394 | /* Resubmit urb so we continue receiving */ |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 395 | if (port->open_count && status != -ESHUTDOWN) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 396 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 397 | if (err) |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 398 | dev_err(&port->dev, "resubmit read urb failed." |
| 399 | "(%d)", err); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 400 | } |
| 401 | } |
| 402 | return; |
| 403 | } |
| 404 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 405 | static void sierra_instat_callback(struct urb *urb) |
| 406 | { |
| 407 | int err; |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 408 | int status = urb->status; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 409 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; |
| 410 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 411 | struct usb_serial *serial = port->serial; |
| 412 | |
| 413 | dbg("%s", __FUNCTION__); |
| 414 | dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); |
| 415 | |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 416 | if (status == 0) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 417 | struct usb_ctrlrequest *req_pkt = |
| 418 | (struct usb_ctrlrequest *)urb->transfer_buffer; |
| 419 | |
| 420 | if (!req_pkt) { |
| 421 | dbg("%s: NULL req_pkt\n", __FUNCTION__); |
| 422 | return; |
| 423 | } |
| 424 | if ((req_pkt->bRequestType == 0xA1) && |
| 425 | (req_pkt->bRequest == 0x20)) { |
| 426 | int old_dcd_state; |
| 427 | unsigned char signals = *((unsigned char *) |
| 428 | urb->transfer_buffer + |
| 429 | sizeof(struct usb_ctrlrequest)); |
| 430 | |
| 431 | dbg("%s: signal x%x", __FUNCTION__, signals); |
| 432 | |
| 433 | old_dcd_state = portdata->dcd_state; |
| 434 | portdata->cts_state = 1; |
| 435 | portdata->dcd_state = ((signals & 0x01) ? 1 : 0); |
| 436 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
| 437 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
| 438 | |
| 439 | if (port->tty && !C_CLOCAL(port->tty) && |
| 440 | old_dcd_state && !portdata->dcd_state) |
| 441 | tty_hangup(port->tty); |
| 442 | } else { |
| 443 | dbg("%s: type %x req %x", __FUNCTION__, |
| 444 | req_pkt->bRequestType,req_pkt->bRequest); |
| 445 | } |
| 446 | } else |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 447 | dbg("%s: error %d", __FUNCTION__, status); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 448 | |
| 449 | /* Resubmit urb so we continue receiving IRQ data */ |
Greg Kroah-Hartman | 17dd221 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 450 | if (status != -ESHUTDOWN) { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 451 | urb->dev = serial->dev; |
| 452 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 453 | if (err) |
| 454 | dbg("%s: resubmit intr urb failed. (%d)", |
| 455 | __FUNCTION__, err); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | static int sierra_write_room(struct usb_serial_port *port) |
| 460 | { |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 461 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
| 462 | unsigned long flags; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 463 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 464 | dbg("%s - port %d", __FUNCTION__, port->number); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 465 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 466 | /* try to give a good number back based on if we have any free urbs at |
| 467 | * this point in time */ |
| 468 | spin_lock_irqsave(&portdata->lock, flags); |
| 469 | if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { |
| 470 | spin_unlock_irqrestore(&portdata->lock, flags); |
| 471 | dbg("%s - write limit hit\n", __FUNCTION__); |
| 472 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 473 | } |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 474 | spin_unlock_irqrestore(&portdata->lock, flags); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 475 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 476 | return 2048; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | static int sierra_chars_in_buffer(struct usb_serial_port *port) |
| 480 | { |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 481 | dbg("%s - port %d", __FUNCTION__, port->number); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 482 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 483 | /* |
| 484 | * We can't really account for how much data we |
| 485 | * have sent out, but hasn't made it through to the |
| 486 | * device as we can't see the backend here, so just |
| 487 | * tell the tty layer that everything is flushed. |
| 488 | */ |
| 489 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | static int sierra_open(struct usb_serial_port *port, struct file *filp) |
| 493 | { |
| 494 | struct sierra_port_private *portdata; |
| 495 | struct usb_serial *serial = port->serial; |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 496 | int i; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 497 | struct urb *urb; |
Kevin Lloyd | e43062d | 2007-01-17 16:04:18 -0800 | [diff] [blame] | 498 | int result; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 499 | |
| 500 | portdata = usb_get_serial_port_data(port); |
| 501 | |
| 502 | dbg("%s", __FUNCTION__); |
| 503 | |
| 504 | /* Set some sane defaults */ |
| 505 | portdata->rts_state = 1; |
| 506 | portdata->dtr_state = 1; |
| 507 | |
| 508 | /* Reset low level data toggle and start reading from endpoints */ |
| 509 | for (i = 0; i < N_IN_URB; i++) { |
| 510 | urb = portdata->in_urbs[i]; |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 511 | if (!urb) |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 512 | continue; |
| 513 | if (urb->dev != serial->dev) { |
| 514 | dbg("%s: dev %p != %p", __FUNCTION__, |
| 515 | urb->dev, serial->dev); |
| 516 | continue; |
| 517 | } |
| 518 | |
| 519 | /* |
| 520 | * make sure endpoint data toggle is synchronized with the |
| 521 | * device |
| 522 | */ |
| 523 | usb_clear_halt(urb->dev, urb->pipe); |
| 524 | |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 525 | result = usb_submit_urb(urb, GFP_KERNEL); |
| 526 | if (result) { |
| 527 | dev_err(&port->dev, "submit urb %d failed (%d) %d", |
| 528 | i, result, urb->transfer_buffer_length); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 529 | } |
| 530 | } |
| 531 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 532 | port->tty->low_latency = 1; |
| 533 | |
| 534 | sierra_send_setup(port); |
| 535 | |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 536 | /* start up the interrupt endpoint if we have one */ |
| 537 | if (port->interrupt_in_urb) { |
| 538 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
| 539 | if (result) |
| 540 | dev_err(&port->dev, "submit irq_in urb failed %d", |
| 541 | result); |
| 542 | } |
| 543 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 544 | } |
| 545 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 546 | static void sierra_close(struct usb_serial_port *port, struct file *filp) |
| 547 | { |
| 548 | int i; |
| 549 | struct usb_serial *serial = port->serial; |
| 550 | struct sierra_port_private *portdata; |
| 551 | |
| 552 | dbg("%s", __FUNCTION__); |
| 553 | portdata = usb_get_serial_port_data(port); |
| 554 | |
| 555 | portdata->rts_state = 0; |
| 556 | portdata->dtr_state = 0; |
| 557 | |
| 558 | if (serial->dev) { |
| 559 | sierra_send_setup(port); |
| 560 | |
| 561 | /* Stop reading/writing urbs */ |
| 562 | for (i = 0; i < N_IN_URB; i++) |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 563 | usb_kill_urb(portdata->in_urbs[i]); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 564 | } |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 565 | |
| 566 | usb_kill_urb(port->interrupt_in_urb); |
| 567 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 568 | port->tty = NULL; |
| 569 | } |
| 570 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 571 | static int sierra_startup(struct usb_serial *serial) |
| 572 | { |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 573 | struct usb_serial_port *port; |
| 574 | struct sierra_port_private *portdata; |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 575 | struct urb *urb; |
| 576 | int i; |
| 577 | int j; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 578 | |
| 579 | dbg("%s", __FUNCTION__); |
| 580 | |
Kevin Lloyd | 112225b | 2007-07-16 13:49:27 -0700 | [diff] [blame] | 581 | /*Set Device mode to D0 */ |
| 582 | sierra_set_power_state(serial->dev, 0x0000); |
| 583 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 584 | /* Now setup per port private data */ |
| 585 | for (i = 0; i < serial->num_ports; i++) { |
| 586 | port = serial->port[i]; |
| 587 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
| 588 | if (!portdata) { |
| 589 | dbg("%s: kmalloc for sierra_port_private (%d) failed!.", |
| 590 | __FUNCTION__, i); |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 591 | return -ENOMEM; |
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 | spin_lock_init(&portdata->lock); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 594 | |
| 595 | usb_set_serial_port_data(port, portdata); |
| 596 | |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 597 | /* initialize the in urbs */ |
| 598 | for (j = 0; j < N_IN_URB; ++j) { |
| 599 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 600 | if (urb == NULL) { |
| 601 | dbg("%s: alloc for in port failed.", |
| 602 | __FUNCTION__); |
| 603 | continue; |
| 604 | } |
| 605 | /* Fill URB using supplied data. */ |
| 606 | usb_fill_bulk_urb(urb, serial->dev, |
| 607 | usb_rcvbulkpipe(serial->dev, |
| 608 | port->bulk_in_endpointAddress), |
| 609 | portdata->in_buffer[j], IN_BUFLEN, |
| 610 | sierra_indat_callback, port); |
| 611 | portdata->in_urbs[j] = urb; |
| 612 | } |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Greg Kroah-Hartman | 17c2327 | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 615 | return 0; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | static void sierra_shutdown(struct usb_serial *serial) |
| 619 | { |
| 620 | int i, j; |
| 621 | struct usb_serial_port *port; |
| 622 | struct sierra_port_private *portdata; |
| 623 | |
| 624 | dbg("%s", __FUNCTION__); |
| 625 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 626 | for (i = 0; i < serial->num_ports; ++i) { |
| 627 | port = serial->port[i]; |
Greg Kroah-Hartman | f094e4f | 2007-04-26 00:12:01 -0700 | [diff] [blame] | 628 | if (!port) |
| 629 | continue; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 630 | portdata = usb_get_serial_port_data(port); |
Greg Kroah-Hartman | f094e4f | 2007-04-26 00:12:01 -0700 | [diff] [blame] | 631 | if (!portdata) |
| 632 | continue; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 633 | |
| 634 | for (j = 0; j < N_IN_URB; j++) { |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 635 | usb_kill_urb(portdata->in_urbs[j]); |
| 636 | usb_free_urb(portdata->in_urbs[j]); |
| 637 | portdata->in_urbs[j] = NULL; |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 638 | } |
Greg Kroah-Hartman | 9e85c5f | 2007-06-20 14:22:23 +0900 | [diff] [blame] | 639 | kfree(portdata); |
| 640 | usb_set_serial_port_data(port, NULL); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 641 | } |
| 642 | } |
| 643 | |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 644 | static struct usb_serial_driver sierra_1port_device = { |
| 645 | .driver = { |
| 646 | .owner = THIS_MODULE, |
| 647 | .name = "sierra1", |
| 648 | }, |
| 649 | .description = "Sierra USB modem (1 port)", |
| 650 | .id_table = id_table_1port, |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 651 | .usb_driver = &sierra_driver, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 652 | .num_interrupt_in = NUM_DONT_CARE, |
| 653 | .num_bulk_in = 1, |
| 654 | .num_bulk_out = 1, |
| 655 | .num_ports = 1, |
| 656 | .open = sierra_open, |
| 657 | .close = sierra_close, |
| 658 | .write = sierra_write, |
| 659 | .write_room = sierra_write_room, |
| 660 | .chars_in_buffer = sierra_chars_in_buffer, |
| 661 | .throttle = sierra_rx_throttle, |
| 662 | .unthrottle = sierra_rx_unthrottle, |
| 663 | .ioctl = sierra_ioctl, |
| 664 | .set_termios = sierra_set_termios, |
| 665 | .break_ctl = sierra_break_ctl, |
| 666 | .tiocmget = sierra_tiocmget, |
| 667 | .tiocmset = sierra_tiocmset, |
| 668 | .attach = sierra_startup, |
| 669 | .shutdown = sierra_shutdown, |
| 670 | .read_int_callback = sierra_instat_callback, |
| 671 | }; |
| 672 | |
| 673 | static struct usb_serial_driver sierra_3port_device = { |
| 674 | .driver = { |
| 675 | .owner = THIS_MODULE, |
| 676 | .name = "sierra3", |
| 677 | }, |
| 678 | .description = "Sierra USB modem (3 port)", |
| 679 | .id_table = id_table_3port, |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 680 | .usb_driver = &sierra_driver, |
Greg Kroah-Hartman | 964ee1d | 2006-10-17 10:17:58 -0700 | [diff] [blame] | 681 | .num_interrupt_in = NUM_DONT_CARE, |
| 682 | .num_bulk_in = 3, |
| 683 | .num_bulk_out = 3, |
| 684 | .num_ports = 3, |
| 685 | .open = sierra_open, |
| 686 | .close = sierra_close, |
| 687 | .write = sierra_write, |
| 688 | .write_room = sierra_write_room, |
| 689 | .chars_in_buffer = sierra_chars_in_buffer, |
| 690 | .throttle = sierra_rx_throttle, |
| 691 | .unthrottle = sierra_rx_unthrottle, |
| 692 | .ioctl = sierra_ioctl, |
| 693 | .set_termios = sierra_set_termios, |
| 694 | .break_ctl = sierra_break_ctl, |
| 695 | .tiocmget = sierra_tiocmget, |
| 696 | .tiocmset = sierra_tiocmset, |
| 697 | .attach = sierra_startup, |
| 698 | .shutdown = sierra_shutdown, |
| 699 | .read_int_callback = sierra_instat_callback, |
| 700 | }; |
| 701 | |
| 702 | /* Functions used by new usb-serial code. */ |
| 703 | static int __init sierra_init(void) |
| 704 | { |
| 705 | int retval; |
| 706 | retval = usb_serial_register(&sierra_1port_device); |
| 707 | if (retval) |
| 708 | goto failed_1port_device_register; |
| 709 | retval = usb_serial_register(&sierra_3port_device); |
| 710 | if (retval) |
| 711 | goto failed_3port_device_register; |
| 712 | |
| 713 | |
| 714 | retval = usb_register(&sierra_driver); |
| 715 | if (retval) |
| 716 | goto failed_driver_register; |
| 717 | |
| 718 | info(DRIVER_DESC ": " DRIVER_VERSION); |
| 719 | |
| 720 | return 0; |
| 721 | |
| 722 | failed_driver_register: |
| 723 | usb_serial_deregister(&sierra_3port_device); |
| 724 | failed_3port_device_register: |
| 725 | usb_serial_deregister(&sierra_1port_device); |
| 726 | failed_1port_device_register: |
| 727 | return retval; |
| 728 | } |
| 729 | |
| 730 | static void __exit sierra_exit(void) |
| 731 | { |
| 732 | usb_deregister (&sierra_driver); |
| 733 | usb_serial_deregister(&sierra_1port_device); |
| 734 | usb_serial_deregister(&sierra_3port_device); |
| 735 | } |
| 736 | |
| 737 | module_init(sierra_init); |
| 738 | module_exit(sierra_exit); |
| 739 | |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 740 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 741 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 742 | MODULE_VERSION(DRIVER_VERSION); |
Kevin Lloyd | 69de51f | 2006-06-30 11:17:55 -0700 | [diff] [blame] | 743 | MODULE_LICENSE("GPL"); |
Kevin Lloyd | 033a3fb | 2006-10-13 23:53:21 -0700 | [diff] [blame] | 744 | |
| 745 | #ifdef CONFIG_USB_DEBUG |
| 746 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 747 | MODULE_PARM_DESC(debug, "Debug messages"); |
| 748 | #endif |
| 749 | |