Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1 | /* |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 2 | USB Driver for GSM modems |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 3 | |
| 4 | Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de> |
| 5 | |
| 6 | This driver is free software; you can redistribute it and/or modify |
| 7 | it under the terms of Version 2 of the GNU General Public License as |
| 8 | published by the Free Software Foundation. |
| 9 | |
| 10 | Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> |
| 11 | |
Matthias Urlichs | b3fdab5 | 2006-08-02 16:41:41 -0700 | [diff] [blame] | 12 | History: see the git log. |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 13 | |
| 14 | Work sponsored by: Sigos GmbH, Germany <info@sigos.de> |
| 15 | |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 16 | This driver exists because the "normal" serial driver doesn't work too well |
| 17 | with GSM modems. Issues: |
| 18 | - data loss -- one single Receive URB is not nearly enough |
Matthias Urlichs | 7c1c2f7 | 2006-07-20 04:56:00 +0200 | [diff] [blame] | 19 | - nonstandard flow (Option devices) control |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 20 | - controlling the baud rate doesn't make sense |
| 21 | |
| 22 | This driver is named "option" because the most common device it's |
| 23 | used for is a PC-Card (with an internal OHCI-USB interface, behind |
| 24 | which the GSM interface sits), made by Option Inc. |
| 25 | |
| 26 | Some of the "one port" devices actually exhibit multiple USB instances |
| 27 | on the USB bus. This is not a bug, these ports are used for different |
| 28 | device features. |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 29 | */ |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 30 | |
Chris Collins | 5f76004 | 2008-04-10 10:15:53 +0200 | [diff] [blame] | 31 | #define DRIVER_VERSION "v0.7.2" |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 32 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 33 | #define DRIVER_DESC "USB Driver for GSM modems" |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 34 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 35 | #include <linux/kernel.h> |
| 36 | #include <linux/jiffies.h> |
| 37 | #include <linux/errno.h> |
| 38 | #include <linux/tty.h> |
| 39 | #include <linux/tty_flip.h> |
| 40 | #include <linux/module.h> |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 41 | #include <linux/bitops.h> |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 42 | #include <linux/usb.h> |
Greg Kroah-Hartman | a969888 | 2006-07-11 21:22:58 -0700 | [diff] [blame] | 43 | #include <linux/usb/serial.h> |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 44 | |
| 45 | /* Function prototypes */ |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 46 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, |
| 47 | struct file *filp); |
| 48 | static void option_close(struct tty_struct *tty, struct usb_serial_port *port, |
| 49 | struct file *filp); |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 50 | static int option_startup(struct usb_serial *serial); |
| 51 | static void option_shutdown(struct usb_serial *serial); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 52 | static int option_write_room(struct tty_struct *tty); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 53 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 54 | static void option_instat_callback(struct urb *urb); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 55 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 56 | static int option_write(struct tty_struct *tty, struct usb_serial_port *port, |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 57 | const unsigned char *buf, int count); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 58 | static int option_chars_in_buffer(struct tty_struct *tty); |
| 59 | static void option_set_termios(struct tty_struct *tty, |
| 60 | struct usb_serial_port *port, struct ktermios *old); |
| 61 | static int option_tiocmget(struct tty_struct *tty, struct file *file); |
| 62 | static int option_tiocmset(struct tty_struct *tty, struct file *file, |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 63 | unsigned int set, unsigned int clear); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 64 | static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 65 | |
| 66 | /* Vendor and product IDs */ |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 67 | #define OPTION_VENDOR_ID 0x0AF0 |
| 68 | #define OPTION_PRODUCT_COLT 0x5000 |
| 69 | #define OPTION_PRODUCT_RICOLA 0x6000 |
| 70 | #define OPTION_PRODUCT_RICOLA_LIGHT 0x6100 |
| 71 | #define OPTION_PRODUCT_RICOLA_QUAD 0x6200 |
| 72 | #define OPTION_PRODUCT_RICOLA_QUAD_LIGHT 0x6300 |
| 73 | #define OPTION_PRODUCT_RICOLA_NDIS 0x6050 |
| 74 | #define OPTION_PRODUCT_RICOLA_NDIS_LIGHT 0x6150 |
| 75 | #define OPTION_PRODUCT_RICOLA_NDIS_QUAD 0x6250 |
| 76 | #define OPTION_PRODUCT_RICOLA_NDIS_QUAD_LIGHT 0x6350 |
| 77 | #define OPTION_PRODUCT_COBRA 0x6500 |
| 78 | #define OPTION_PRODUCT_COBRA_BUS 0x6501 |
| 79 | #define OPTION_PRODUCT_VIPER 0x6600 |
| 80 | #define OPTION_PRODUCT_VIPER_BUS 0x6601 |
| 81 | #define OPTION_PRODUCT_GT_MAX_READY 0x6701 |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 82 | #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 |
| 83 | #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 |
| 84 | #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761 |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 85 | #define OPTION_PRODUCT_KOI_MODEM 0x6800 |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 86 | #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 87 | #define OPTION_PRODUCT_ETNA_MODEM 0x7001 |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 88 | #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 |
| 89 | #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 |
| 90 | #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 91 | #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 92 | |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 93 | #define HUAWEI_VENDOR_ID 0x12D1 |
| 94 | #define HUAWEI_PRODUCT_E600 0x1001 |
| 95 | #define HUAWEI_PRODUCT_E220 0x1003 |
Jaime Velasco Juan | a3209a0 | 2007-09-07 19:06:39 +0100 | [diff] [blame] | 96 | #define HUAWEI_PRODUCT_E220BIS 0x1004 |
fangxiaozhi | aad8a27 | 2008-04-10 14:51:06 +0800 | [diff] [blame] | 97 | #define HUAWEI_PRODUCT_E1401 0x1401 |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 98 | #define HUAWEI_PRODUCT_E1402 0x1402 |
fangxiaozhi | aad8a27 | 2008-04-10 14:51:06 +0800 | [diff] [blame] | 99 | #define HUAWEI_PRODUCT_E1403 0x1403 |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 100 | #define HUAWEI_PRODUCT_E1404 0x1404 |
fangxiaozhi | aad8a27 | 2008-04-10 14:51:06 +0800 | [diff] [blame] | 101 | #define HUAWEI_PRODUCT_E1405 0x1405 |
| 102 | #define HUAWEI_PRODUCT_E1406 0x1406 |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 103 | #define HUAWEI_PRODUCT_E1407 0x1407 |
fangxiaozhi | aad8a27 | 2008-04-10 14:51:06 +0800 | [diff] [blame] | 104 | #define HUAWEI_PRODUCT_E1408 0x1408 |
| 105 | #define HUAWEI_PRODUCT_E1409 0x1409 |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 106 | #define HUAWEI_PRODUCT_E140A 0x140A |
| 107 | #define HUAWEI_PRODUCT_E140B 0x140B |
| 108 | #define HUAWEI_PRODUCT_E140C 0x140C |
| 109 | #define HUAWEI_PRODUCT_E140D 0x140D |
| 110 | #define HUAWEI_PRODUCT_E140E 0x140E |
| 111 | #define HUAWEI_PRODUCT_E140F 0x140F |
fangxiaozhi | aad8a27 | 2008-04-10 14:51:06 +0800 | [diff] [blame] | 112 | #define HUAWEI_PRODUCT_E1410 0x1410 |
| 113 | #define HUAWEI_PRODUCT_E1411 0x1411 |
| 114 | #define HUAWEI_PRODUCT_E1412 0x1412 |
| 115 | #define HUAWEI_PRODUCT_E1413 0x1413 |
| 116 | #define HUAWEI_PRODUCT_E1414 0x1414 |
| 117 | #define HUAWEI_PRODUCT_E1415 0x1415 |
| 118 | #define HUAWEI_PRODUCT_E1416 0x1416 |
| 119 | #define HUAWEI_PRODUCT_E1417 0x1417 |
| 120 | #define HUAWEI_PRODUCT_E1418 0x1418 |
| 121 | #define HUAWEI_PRODUCT_E1419 0x1419 |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 122 | #define HUAWEI_PRODUCT_E141A 0x141A |
| 123 | #define HUAWEI_PRODUCT_E141B 0x141B |
| 124 | #define HUAWEI_PRODUCT_E141C 0x141C |
| 125 | #define HUAWEI_PRODUCT_E141D 0x141D |
| 126 | #define HUAWEI_PRODUCT_E141E 0x141E |
| 127 | #define HUAWEI_PRODUCT_E141F 0x141F |
| 128 | #define HUAWEI_PRODUCT_E1420 0x1420 |
| 129 | #define HUAWEI_PRODUCT_E1421 0x1421 |
| 130 | #define HUAWEI_PRODUCT_E1422 0x1422 |
| 131 | #define HUAWEI_PRODUCT_E1423 0x1423 |
| 132 | #define HUAWEI_PRODUCT_E1424 0x1424 |
| 133 | #define HUAWEI_PRODUCT_E1425 0x1425 |
| 134 | #define HUAWEI_PRODUCT_E1426 0x1426 |
| 135 | #define HUAWEI_PRODUCT_E1427 0x1427 |
| 136 | #define HUAWEI_PRODUCT_E1428 0x1428 |
| 137 | #define HUAWEI_PRODUCT_E1429 0x1429 |
| 138 | #define HUAWEI_PRODUCT_E142A 0x142A |
| 139 | #define HUAWEI_PRODUCT_E142B 0x142B |
| 140 | #define HUAWEI_PRODUCT_E142C 0x142C |
| 141 | #define HUAWEI_PRODUCT_E142D 0x142D |
| 142 | #define HUAWEI_PRODUCT_E142E 0x142E |
| 143 | #define HUAWEI_PRODUCT_E142F 0x142F |
| 144 | #define HUAWEI_PRODUCT_E1430 0x1430 |
| 145 | #define HUAWEI_PRODUCT_E1431 0x1431 |
| 146 | #define HUAWEI_PRODUCT_E1432 0x1432 |
| 147 | #define HUAWEI_PRODUCT_E1433 0x1433 |
| 148 | #define HUAWEI_PRODUCT_E1434 0x1434 |
| 149 | #define HUAWEI_PRODUCT_E1435 0x1435 |
| 150 | #define HUAWEI_PRODUCT_E1436 0x1436 |
| 151 | #define HUAWEI_PRODUCT_E1437 0x1437 |
| 152 | #define HUAWEI_PRODUCT_E1438 0x1438 |
| 153 | #define HUAWEI_PRODUCT_E1439 0x1439 |
| 154 | #define HUAWEI_PRODUCT_E143A 0x143A |
| 155 | #define HUAWEI_PRODUCT_E143B 0x143B |
| 156 | #define HUAWEI_PRODUCT_E143C 0x143C |
| 157 | #define HUAWEI_PRODUCT_E143D 0x143D |
| 158 | #define HUAWEI_PRODUCT_E143E 0x143E |
| 159 | #define HUAWEI_PRODUCT_E143F 0x143F |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 160 | |
| 161 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 |
Dirk DeSchepper | 72ab641 | 2008-03-05 08:26:18 +0000 | [diff] [blame] | 162 | |
Leslie Watter | c6206fa | 2008-11-12 15:10:07 -0200 | [diff] [blame^] | 163 | /* YISO PRODUCTS */ |
| 164 | |
| 165 | #define YISO_VENDOR_ID 0x0EAB |
| 166 | #define YISO_PRODUCT_U893 0xC893 |
| 167 | |
Dirk DeSchepper | 72ab641 | 2008-03-05 08:26:18 +0000 | [diff] [blame] | 168 | /* MERLIN EVDO PRODUCTS */ |
| 169 | #define NOVATELWIRELESS_PRODUCT_V640 0x1100 |
| 170 | #define NOVATELWIRELESS_PRODUCT_V620 0x1110 |
| 171 | #define NOVATELWIRELESS_PRODUCT_V740 0x1120 |
| 172 | #define NOVATELWIRELESS_PRODUCT_V720 0x1130 |
| 173 | |
| 174 | /* MERLIN HSDPA/HSPA PRODUCTS */ |
| 175 | #define NOVATELWIRELESS_PRODUCT_U730 0x1400 |
| 176 | #define NOVATELWIRELESS_PRODUCT_U740 0x1410 |
| 177 | #define NOVATELWIRELESS_PRODUCT_U870 0x1420 |
| 178 | #define NOVATELWIRELESS_PRODUCT_XU870 0x1430 |
| 179 | #define NOVATELWIRELESS_PRODUCT_X950D 0x1450 |
| 180 | |
| 181 | /* EXPEDITE PRODUCTS */ |
| 182 | #define NOVATELWIRELESS_PRODUCT_EV620 0x2100 |
| 183 | #define NOVATELWIRELESS_PRODUCT_ES720 0x2110 |
| 184 | #define NOVATELWIRELESS_PRODUCT_E725 0x2120 |
Matthias Urlichs | a1d9bc1 | 2008-04-10 10:13:32 +0200 | [diff] [blame] | 185 | #define NOVATELWIRELESS_PRODUCT_ES620 0x2130 |
Dirk DeSchepper | 72ab641 | 2008-03-05 08:26:18 +0000 | [diff] [blame] | 186 | #define NOVATELWIRELESS_PRODUCT_EU730 0x2400 |
| 187 | #define NOVATELWIRELESS_PRODUCT_EU740 0x2410 |
| 188 | #define NOVATELWIRELESS_PRODUCT_EU870D 0x2420 |
| 189 | |
| 190 | /* OVATION PRODUCTS */ |
| 191 | #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 |
| 192 | #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 |
| 193 | |
| 194 | /* FUTURE NOVATEL PRODUCTS */ |
| 195 | #define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 |
| 196 | #define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 |
| 197 | #define NOVATELWIRELESS_PRODUCT_EMBEDDED_1 0x8000 |
| 198 | #define NOVATELWIRELESS_PRODUCT_GLOBAL_1 0x9000 |
| 199 | #define NOVATELWIRELESS_PRODUCT_EVDO_2 0x6001 |
| 200 | #define NOVATELWIRELESS_PRODUCT_HSPA_2 0x7001 |
| 201 | #define NOVATELWIRELESS_PRODUCT_EMBEDDED_2 0x8001 |
| 202 | #define NOVATELWIRELESS_PRODUCT_GLOBAL_2 0x9001 |
| 203 | |
tang kai | 32147be | 2008-04-14 10:06:35 +0800 | [diff] [blame] | 204 | /* AMOI PRODUCTS */ |
| 205 | #define AMOI_VENDOR_ID 0x1614 |
| 206 | #define AMOI_PRODUCT_H01 0x0800 |
| 207 | #define AMOI_PRODUCT_H01A 0x7002 |
| 208 | #define AMOI_PRODUCT_H02 0x0802 |
| 209 | |
Faidon Liambotis | 9644321 | 2007-08-07 05:46:05 +0300 | [diff] [blame] | 210 | #define DELL_VENDOR_ID 0x413C |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 211 | |
Dan Williams | 564d61d | 2008-02-19 13:15:30 -0500 | [diff] [blame] | 212 | #define KYOCERA_VENDOR_ID 0x0c88 |
Greg Kroah-Hartman | 640c1bc | 2008-06-19 11:21:16 -0700 | [diff] [blame] | 213 | #define KYOCERA_PRODUCT_KPC650 0x17da |
Dan Williams | 564d61d | 2008-02-19 13:15:30 -0500 | [diff] [blame] | 214 | #define KYOCERA_PRODUCT_KPC680 0x180a |
| 215 | |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 216 | #define ANYDATA_VENDOR_ID 0x16d5 |
Hiroshi Miura | f803382 | 2008-08-19 10:58:25 +0200 | [diff] [blame] | 217 | #define ANYDATA_PRODUCT_ADU_620UW 0x6202 |
Alexander Gattin | 46269db | 2007-06-20 00:48:10 +0300 | [diff] [blame] | 218 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 |
| 219 | #define ANYDATA_PRODUCT_ADU_500A 0x6502 |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 220 | |
Daniel Kozák | 85fb62a | 2008-03-04 18:54:53 +0100 | [diff] [blame] | 221 | #define AXESSTEL_VENDOR_ID 0x1726 |
| 222 | #define AXESSTEL_PRODUCT_MV110H 0x1000 |
| 223 | |
andreoli@samba.ing.unimo.it | 4c7d313 | 2008-05-01 19:26:16 +0200 | [diff] [blame] | 224 | #define ONDA_VENDOR_ID 0x19d2 |
Arnaldo Carvalho de Melo | 1b2d23d | 2008-05-16 15:41:40 -0300 | [diff] [blame] | 225 | #define ONDA_PRODUCT_MSA501HS 0x0001 |
andreoli@samba.ing.unimo.it | 4c7d313 | 2008-05-01 19:26:16 +0200 | [diff] [blame] | 226 | #define ONDA_PRODUCT_ET502HS 0x0002 |
| 227 | |
Leon Leong | 3f6e584 | 2007-04-26 00:38:02 -0700 | [diff] [blame] | 228 | #define BANDRICH_VENDOR_ID 0x1A8D |
| 229 | #define BANDRICH_PRODUCT_C100_1 0x1002 |
| 230 | #define BANDRICH_PRODUCT_C100_2 0x1003 |
Leon Leong | bf3fc82 | 2008-08-01 11:40:12 +0800 | [diff] [blame] | 231 | #define BANDRICH_PRODUCT_1004 0x1004 |
| 232 | #define BANDRICH_PRODUCT_1005 0x1005 |
| 233 | #define BANDRICH_PRODUCT_1006 0x1006 |
| 234 | #define BANDRICH_PRODUCT_1007 0x1007 |
| 235 | #define BANDRICH_PRODUCT_1008 0x1008 |
| 236 | #define BANDRICH_PRODUCT_1009 0x1009 |
| 237 | #define BANDRICH_PRODUCT_100A 0x100a |
| 238 | |
| 239 | #define BANDRICH_PRODUCT_100B 0x100b |
| 240 | #define BANDRICH_PRODUCT_100C 0x100c |
| 241 | #define BANDRICH_PRODUCT_100D 0x100d |
| 242 | #define BANDRICH_PRODUCT_100E 0x100e |
| 243 | |
| 244 | #define BANDRICH_PRODUCT_100F 0x100f |
| 245 | #define BANDRICH_PRODUCT_1010 0x1010 |
| 246 | #define BANDRICH_PRODUCT_1011 0x1011 |
| 247 | #define BANDRICH_PRODUCT_1012 0x1012 |
Leon Leong | 3f6e584 | 2007-04-26 00:38:02 -0700 | [diff] [blame] | 248 | |
Matthias Urlichs | a1d9bc1 | 2008-04-10 10:13:32 +0200 | [diff] [blame] | 249 | #define AMOI_VENDOR_ID 0x1614 |
| 250 | #define AMOI_PRODUCT_9508 0x0800 |
| 251 | |
Kevin Lloyd | d726fb7 | 2008-02-14 13:35:16 -0800 | [diff] [blame] | 252 | #define QUALCOMM_VENDOR_ID 0x05C6 |
| 253 | |
James Cameron | 80d9709 | 2008-04-09 18:59:13 +1000 | [diff] [blame] | 254 | #define MAXON_VENDOR_ID 0x16d8 |
| 255 | |
Greg Kroah-Hartman | ee53b0c | 2008-05-15 10:07:44 -0700 | [diff] [blame] | 256 | #define TELIT_VENDOR_ID 0x1bc7 |
| 257 | #define TELIT_PRODUCT_UC864E 0x1003 |
| 258 | |
Oliver Martin | 6188a83 | 2008-08-09 04:49:26 +0200 | [diff] [blame] | 259 | /* ZTE PRODUCTS */ |
| 260 | #define ZTE_VENDOR_ID 0x19d2 |
| 261 | #define ZTE_PRODUCT_MF628 0x0015 |
Mikhail Gusarov | bfd8408 | 2008-10-18 18:20:02 +0700 | [diff] [blame] | 262 | #define ZTE_PRODUCT_MF626 0x0031 |
Otavio Salvador | 884579d | 2008-09-17 14:40:46 -0300 | [diff] [blame] | 263 | #define ZTE_PRODUCT_CDMA_TECH 0xfffe |
Oliver Martin | 6188a83 | 2008-08-09 04:49:26 +0200 | [diff] [blame] | 264 | |
Dan Williams | b064eca9 | 2008-09-24 11:49:19 -0400 | [diff] [blame] | 265 | /* Ericsson products */ |
| 266 | #define ERICSSON_VENDOR_ID 0x0bdb |
| 267 | #define ERICSSON_PRODUCT_F3507G 0x1900 |
| 268 | |
Dan Williams | 8b6346e | 2008-10-10 06:41:16 -0400 | [diff] [blame] | 269 | /* Pantech products */ |
| 270 | #define PANTECH_VENDOR_ID 0x106c |
| 271 | #define PANTECH_PRODUCT_PC5740 0x3701 |
| 272 | #define PANTECH_PRODUCT_PC5750 0x3702 /* PX-500 */ |
| 273 | #define PANTECH_PRODUCT_UM150 0x3711 |
| 274 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 275 | static struct usb_device_id option_ids[] = { |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 276 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
| 277 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
| 278 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, |
| 279 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) }, |
| 280 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) }, |
| 281 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS) }, |
| 282 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_LIGHT) }, |
| 283 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_QUAD) }, |
| 284 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS_QUAD_LIGHT) }, |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 285 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 286 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA_BUS) }, |
| 287 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, |
| 288 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, |
| 289 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 290 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, |
| 291 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, |
| 292 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 293 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 294 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 295 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 296 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, |
| 297 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, |
| 298 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, |
Greg Kroah-Hartman | fd978bf | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 299 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, |
Michael Karcher | a7f3872 | 2008-05-28 23:58:18 +0200 | [diff] [blame] | 300 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, |
Jaime Velasco Juan | b5ce18a | 2007-11-30 16:30:11 +0000 | [diff] [blame] | 301 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, |
| 302 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, |
Michael Karcher | a7f3872 | 2008-05-28 23:58:18 +0200 | [diff] [blame] | 303 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1401, 0xff, 0xff, 0xff) }, |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 304 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1402, 0xff, 0xff, 0xff) }, |
Michael Karcher | a7f3872 | 2008-05-28 23:58:18 +0200 | [diff] [blame] | 305 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1403, 0xff, 0xff, 0xff) }, |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 306 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1404, 0xff, 0xff, 0xff) }, |
Michael Karcher | a7f3872 | 2008-05-28 23:58:18 +0200 | [diff] [blame] | 307 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1405, 0xff, 0xff, 0xff) }, |
| 308 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1406, 0xff, 0xff, 0xff) }, |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 309 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1407, 0xff, 0xff, 0xff) }, |
Michael Karcher | a7f3872 | 2008-05-28 23:58:18 +0200 | [diff] [blame] | 310 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1408, 0xff, 0xff, 0xff) }, |
| 311 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1409, 0xff, 0xff, 0xff) }, |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 312 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E140A, 0xff, 0xff, 0xff) }, |
| 313 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E140B, 0xff, 0xff, 0xff) }, |
| 314 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E140C, 0xff, 0xff, 0xff) }, |
| 315 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E140D, 0xff, 0xff, 0xff) }, |
| 316 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E140E, 0xff, 0xff, 0xff) }, |
| 317 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E140F, 0xff, 0xff, 0xff) }, |
Michael Karcher | a7f3872 | 2008-05-28 23:58:18 +0200 | [diff] [blame] | 318 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1410, 0xff, 0xff, 0xff) }, |
| 319 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1411, 0xff, 0xff, 0xff) }, |
| 320 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1412, 0xff, 0xff, 0xff) }, |
| 321 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1413, 0xff, 0xff, 0xff) }, |
| 322 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1414, 0xff, 0xff, 0xff) }, |
| 323 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1415, 0xff, 0xff, 0xff) }, |
| 324 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1416, 0xff, 0xff, 0xff) }, |
| 325 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1417, 0xff, 0xff, 0xff) }, |
| 326 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1418, 0xff, 0xff, 0xff) }, |
| 327 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1419, 0xff, 0xff, 0xff) }, |
fangxiaozhi | 1460e5e | 2008-10-15 14:15:36 +0800 | [diff] [blame] | 328 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E141A, 0xff, 0xff, 0xff) }, |
| 329 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E141B, 0xff, 0xff, 0xff) }, |
| 330 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E141C, 0xff, 0xff, 0xff) }, |
| 331 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E141D, 0xff, 0xff, 0xff) }, |
| 332 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E141E, 0xff, 0xff, 0xff) }, |
| 333 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E141F, 0xff, 0xff, 0xff) }, |
| 334 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1420, 0xff, 0xff, 0xff) }, |
| 335 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1421, 0xff, 0xff, 0xff) }, |
| 336 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1422, 0xff, 0xff, 0xff) }, |
| 337 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1423, 0xff, 0xff, 0xff) }, |
| 338 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1424, 0xff, 0xff, 0xff) }, |
| 339 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1425, 0xff, 0xff, 0xff) }, |
| 340 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1426, 0xff, 0xff, 0xff) }, |
| 341 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1427, 0xff, 0xff, 0xff) }, |
| 342 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1428, 0xff, 0xff, 0xff) }, |
| 343 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1429, 0xff, 0xff, 0xff) }, |
| 344 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E142A, 0xff, 0xff, 0xff) }, |
| 345 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E142B, 0xff, 0xff, 0xff) }, |
| 346 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E142C, 0xff, 0xff, 0xff) }, |
| 347 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E142D, 0xff, 0xff, 0xff) }, |
| 348 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E142E, 0xff, 0xff, 0xff) }, |
| 349 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E142F, 0xff, 0xff, 0xff) }, |
| 350 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1430, 0xff, 0xff, 0xff) }, |
| 351 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1431, 0xff, 0xff, 0xff) }, |
| 352 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1432, 0xff, 0xff, 0xff) }, |
| 353 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1433, 0xff, 0xff, 0xff) }, |
| 354 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1434, 0xff, 0xff, 0xff) }, |
| 355 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1435, 0xff, 0xff, 0xff) }, |
| 356 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1436, 0xff, 0xff, 0xff) }, |
| 357 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1437, 0xff, 0xff, 0xff) }, |
| 358 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1438, 0xff, 0xff, 0xff) }, |
| 359 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1439, 0xff, 0xff, 0xff) }, |
| 360 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143A, 0xff, 0xff, 0xff) }, |
| 361 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143B, 0xff, 0xff, 0xff) }, |
| 362 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143C, 0xff, 0xff, 0xff) }, |
| 363 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) }, |
| 364 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) }, |
| 365 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) }, |
Matthias Urlichs | a1d9bc1 | 2008-04-10 10:13:32 +0200 | [diff] [blame] | 366 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_9508) }, |
Dirk DeSchepper | 72ab641 | 2008-03-05 08:26:18 +0000 | [diff] [blame] | 367 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */ |
| 368 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */ |
| 369 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) }, /* Novatel Merlin EX720/V740/X720 */ |
| 370 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V720) }, /* Novatel Merlin V720/S720/PC720 */ |
| 371 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U730) }, /* Novatel U730/U740 (VF version) */ |
| 372 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U740) }, /* Novatel U740 */ |
| 373 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U870) }, /* Novatel U870 */ |
| 374 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_XU870) }, /* Novatel Merlin XU870 HSDPA/3G */ |
| 375 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_X950D) }, /* Novatel X950D */ |
| 376 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EV620) }, /* Novatel EV620/ES620 CDMA/EV-DO */ |
| 377 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_ES720) }, /* Novatel ES620/ES720/U720/USB720 */ |
| 378 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E725) }, /* Novatel E725/E726 */ |
Matthias Urlichs | a1d9bc1 | 2008-04-10 10:13:32 +0200 | [diff] [blame] | 379 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_ES620) }, /* Novatel Merlin ES620 SM Bus */ |
Dirk DeSchepper | 72ab641 | 2008-03-05 08:26:18 +0000 | [diff] [blame] | 380 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU730) }, /* Novatel EU730 and Vodafone EU740 */ |
| 381 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU740) }, /* Novatel non-Vodafone EU740 */ |
| 382 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ |
| 383 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ |
| 384 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ |
Dirk DeSchepper | 72ab641 | 2008-03-05 08:26:18 +0000 | [diff] [blame] | 385 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ |
| 386 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ |
| 387 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ |
| 388 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL_1) }, /* Novatel Global product */ |
| 389 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_2) }, /* Novatel EVDO product */ |
| 390 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_2) }, /* Novatel HSPA product */ |
| 391 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_2) }, /* Novatel Embedded product */ |
| 392 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL_2) }, /* Novatel Global product */ |
| 393 | |
tang kai | 32147be | 2008-04-14 10:06:35 +0800 | [diff] [blame] | 394 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, |
| 395 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, |
| 396 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) }, |
| 397 | |
Faidon Liambotis | 9644321 | 2007-08-07 05:46:05 +0300 | [diff] [blame] | 398 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ |
| 399 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
| 400 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ |
| 401 | { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ |
| 402 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ |
| 403 | { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ |
Andy Shevchenko | 59036e9 | 2008-02-04 23:57:49 -0800 | [diff] [blame] | 404 | { USB_DEVICE(DELL_VENDOR_ID, 0x8129) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */ |
Stefan Bader | aa59e05 | 2008-02-05 15:25:35 -0500 | [diff] [blame] | 405 | { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ |
| 406 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ |
Greg Kroah-Hartman | 2c4cd1f | 2007-08-30 19:02:10 +0200 | [diff] [blame] | 407 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ |
Dan Williams | 96cb15c | 2008-05-13 12:53:45 -0400 | [diff] [blame] | 408 | { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ |
Dan Williams | b064eca9 | 2008-09-24 11:49:19 -0400 | [diff] [blame] | 409 | { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */ |
Jon K Hellan | bb78a82 | 2008-10-03 10:36:16 +0200 | [diff] [blame] | 410 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ |
Alexander Gattin | 46269db | 2007-06-20 00:48:10 +0300 | [diff] [blame] | 411 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
Hiroshi Miura | f803382 | 2008-08-19 10:58:25 +0200 | [diff] [blame] | 412 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, |
Daniel Kozák | 85fb62a | 2008-03-04 18:54:53 +0100 | [diff] [blame] | 413 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
Arnaldo Carvalho de Melo | 1b2d23d | 2008-05-16 15:41:40 -0300 | [diff] [blame] | 414 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, |
andreoli@samba.ing.unimo.it | 4c7d313 | 2008-05-01 19:26:16 +0200 | [diff] [blame] | 415 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, |
Leslie Watter | c6206fa | 2008-11-12 15:10:07 -0200 | [diff] [blame^] | 416 | { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, |
Leon Leong | 3f6e584 | 2007-04-26 00:38:02 -0700 | [diff] [blame] | 417 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
| 418 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
Leon Leong | bf3fc82 | 2008-08-01 11:40:12 +0800 | [diff] [blame] | 419 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, |
| 420 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005) }, |
| 421 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006) }, |
| 422 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007) }, |
| 423 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008) }, |
| 424 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009) }, |
| 425 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A) }, |
| 426 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B) }, |
| 427 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C) }, |
| 428 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D) }, |
| 429 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E) }, |
| 430 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F) }, |
| 431 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010) }, |
| 432 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011) }, |
| 433 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012) }, |
Greg Kroah-Hartman | 640c1bc | 2008-06-19 11:21:16 -0700 | [diff] [blame] | 434 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, |
Dan Williams | 564d61d | 2008-02-19 13:15:30 -0500 | [diff] [blame] | 435 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
Greg Kroah-Hartman | d2e2aff | 2008-07-01 13:11:56 +0530 | [diff] [blame] | 436 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ |
Kevin Lloyd | d726fb7 | 2008-02-14 13:35:16 -0800 | [diff] [blame] | 437 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
James Cameron | 80d9709 | 2008-04-09 18:59:13 +1000 | [diff] [blame] | 438 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ |
Greg Kroah-Hartman | ee53b0c | 2008-05-15 10:07:44 -0700 | [diff] [blame] | 439 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
Mikhail Gusarov | bfd8408 | 2008-10-18 18:20:02 +0700 | [diff] [blame] | 440 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626) }, |
Oliver Martin | 6188a83 | 2008-08-09 04:49:26 +0200 | [diff] [blame] | 441 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, |
Otavio Salvador | 884579d | 2008-09-17 14:40:46 -0300 | [diff] [blame] | 442 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, |
Dan Williams | b064eca9 | 2008-09-24 11:49:19 -0400 | [diff] [blame] | 443 | { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) }, |
Dan Williams | 8b6346e | 2008-10-10 06:41:16 -0400 | [diff] [blame] | 444 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5740) }, |
| 445 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5750) }, |
| 446 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_UM150) }, |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 447 | { } /* Terminating entry */ |
| 448 | }; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 449 | MODULE_DEVICE_TABLE(usb, option_ids); |
| 450 | |
| 451 | static struct usb_driver option_driver = { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 452 | .name = "option", |
| 453 | .probe = usb_serial_probe, |
| 454 | .disconnect = usb_serial_disconnect, |
| 455 | .id_table = option_ids, |
Greg Kroah-Hartman | ba9dc65 | 2005-11-16 13:41:28 -0800 | [diff] [blame] | 456 | .no_dynamic_id = 1, |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 457 | }; |
| 458 | |
Uwe Zeisberger | c30fe7f | 2006-03-24 18:23:14 +0100 | [diff] [blame] | 459 | /* The card has three separate interfaces, which the serial driver |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 460 | * recognizes separately, thus num_port=1. |
| 461 | */ |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 462 | |
| 463 | static struct usb_serial_driver option_1port_device = { |
| 464 | .driver = { |
| 465 | .owner = THIS_MODULE, |
Matthias Urlichs | 02b2ac5 | 2006-08-02 16:41:41 -0700 | [diff] [blame] | 466 | .name = "option1", |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 467 | }, |
| 468 | .description = "GSM modem (1-port)", |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 469 | .usb_driver = &option_driver, |
Greg Kroah-Hartman | b656b2c | 2007-02-21 12:53:17 -0800 | [diff] [blame] | 470 | .id_table = option_ids, |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 471 | .num_ports = 1, |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 472 | .open = option_open, |
| 473 | .close = option_close, |
| 474 | .write = option_write, |
| 475 | .write_room = option_write_room, |
| 476 | .chars_in_buffer = option_chars_in_buffer, |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 477 | .set_termios = option_set_termios, |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 478 | .tiocmget = option_tiocmget, |
| 479 | .tiocmset = option_tiocmset, |
| 480 | .attach = option_startup, |
| 481 | .shutdown = option_shutdown, |
| 482 | .read_int_callback = option_instat_callback, |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 483 | }; |
| 484 | |
| 485 | static int debug; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 486 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 487 | /* per port private data */ |
| 488 | |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 489 | #define N_IN_URB 4 |
| 490 | #define N_OUT_URB 1 |
Matthias Urlichs | b27c73d | 2005-09-22 00:49:33 -0700 | [diff] [blame] | 491 | #define IN_BUFLEN 4096 |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 492 | #define OUT_BUFLEN 128 |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 493 | |
| 494 | struct option_port_private { |
| 495 | /* Input endpoints and buffer for this port */ |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 496 | struct urb *in_urbs[N_IN_URB]; |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 497 | u8 *in_buffer[N_IN_URB]; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 498 | /* Output endpoints and buffer for this port */ |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 499 | struct urb *out_urbs[N_OUT_URB]; |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 500 | u8 *out_buffer[N_OUT_URB]; |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 501 | unsigned long out_busy; /* Bit vector of URBs in use */ |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 502 | |
| 503 | /* Settings for the port */ |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 504 | int rts_state; /* Handshaking pins (outputs) */ |
| 505 | int dtr_state; |
| 506 | int cts_state; /* Handshaking pins (inputs) */ |
| 507 | int dsr_state; |
| 508 | int dcd_state; |
| 509 | int ri_state; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 510 | |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 511 | unsigned long tx_start_time[N_OUT_URB]; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 512 | }; |
| 513 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 514 | /* Functions used by new usb-serial code. */ |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 515 | static int __init option_init(void) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 516 | { |
| 517 | int retval; |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 518 | retval = usb_serial_register(&option_1port_device); |
| 519 | if (retval) |
| 520 | goto failed_1port_device_register; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 521 | retval = usb_register(&option_driver); |
| 522 | if (retval) |
| 523 | goto failed_driver_register; |
| 524 | |
Greg Kroah-Hartman | c197a8d | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 525 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 526 | DRIVER_DESC "\n"); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 527 | |
| 528 | return 0; |
| 529 | |
| 530 | failed_driver_register: |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 531 | usb_serial_deregister(&option_1port_device); |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 532 | failed_1port_device_register: |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 533 | return retval; |
| 534 | } |
| 535 | |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 536 | static void __exit option_exit(void) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 537 | { |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 538 | usb_deregister(&option_driver); |
| 539 | usb_serial_deregister(&option_1port_device); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | module_init(option_init); |
| 543 | module_exit(option_exit); |
| 544 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 545 | static void option_set_termios(struct tty_struct *tty, |
| 546 | struct usb_serial_port *port, struct ktermios *old_termios) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 547 | { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 548 | dbg("%s", __func__); |
Alan Cox | e650d8a | 2007-10-18 01:24:21 -0700 | [diff] [blame] | 549 | /* Doesn't support option setting */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 550 | tty_termios_copy_hw(tty->termios, old_termios); |
| 551 | option_send_setup(tty, port); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 552 | } |
| 553 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 554 | static int option_tiocmget(struct tty_struct *tty, struct file *file) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 555 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 556 | struct usb_serial_port *port = tty->driver_data; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 557 | unsigned int value; |
| 558 | struct option_port_private *portdata; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 559 | |
| 560 | portdata = usb_get_serial_port_data(port); |
| 561 | |
| 562 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | |
| 563 | ((portdata->dtr_state) ? TIOCM_DTR : 0) | |
| 564 | ((portdata->cts_state) ? TIOCM_CTS : 0) | |
| 565 | ((portdata->dsr_state) ? TIOCM_DSR : 0) | |
| 566 | ((portdata->dcd_state) ? TIOCM_CAR : 0) | |
| 567 | ((portdata->ri_state) ? TIOCM_RNG : 0); |
| 568 | |
| 569 | return value; |
| 570 | } |
| 571 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 572 | static int option_tiocmset(struct tty_struct *tty, struct file *file, |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 573 | unsigned int set, unsigned int clear) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 574 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 575 | struct usb_serial_port *port = tty->driver_data; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 576 | struct option_port_private *portdata; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 577 | |
| 578 | portdata = usb_get_serial_port_data(port); |
| 579 | |
Alan Cox | e298449 | 2008-02-20 20:51:45 +0000 | [diff] [blame] | 580 | /* FIXME: what locks portdata fields ? */ |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 581 | if (set & TIOCM_RTS) |
| 582 | portdata->rts_state = 1; |
| 583 | if (set & TIOCM_DTR) |
| 584 | portdata->dtr_state = 1; |
| 585 | |
| 586 | if (clear & TIOCM_RTS) |
| 587 | portdata->rts_state = 0; |
| 588 | if (clear & TIOCM_DTR) |
| 589 | portdata->dtr_state = 0; |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 590 | return option_send_setup(tty, port); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | /* Write */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 594 | static int option_write(struct tty_struct *tty, struct usb_serial_port *port, |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 595 | const unsigned char *buf, int count) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 596 | { |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 597 | struct option_port_private *portdata; |
| 598 | int i; |
| 599 | int left, todo; |
| 600 | struct urb *this_urb = NULL; /* spurious */ |
| 601 | int err; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 602 | |
| 603 | portdata = usb_get_serial_port_data(port); |
| 604 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 605 | dbg("%s: write (%d chars)", __func__, count); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 606 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 607 | i = 0; |
| 608 | left = count; |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 609 | for (i = 0; left > 0 && i < N_OUT_URB; i++) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 610 | todo = left; |
| 611 | if (todo > OUT_BUFLEN) |
| 612 | todo = OUT_BUFLEN; |
| 613 | |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 614 | this_urb = portdata->out_urbs[i]; |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 615 | if (test_and_set_bit(i, &portdata->out_busy)) { |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 616 | if (time_before(jiffies, |
| 617 | portdata->tx_start_time[i] + 10 * HZ)) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 618 | continue; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 619 | usb_unlink_urb(this_urb); |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 620 | continue; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 621 | } |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 622 | if (this_urb->status != 0) |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 623 | dbg("usb_write %p failed (err=%d)", |
| 624 | this_urb, this_urb->status); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 625 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 626 | dbg("%s: endpoint %d buf %d", __func__, |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 627 | usb_pipeendpoint(this_urb->pipe), i); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 628 | |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 629 | /* send the data */ |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 630 | memcpy(this_urb->transfer_buffer, buf, todo); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 631 | this_urb->transfer_buffer_length = todo; |
| 632 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 633 | this_urb->dev = port->serial->dev; |
| 634 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
| 635 | if (err) { |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 636 | dbg("usb_submit_urb %p (write bulk) failed " |
| 637 | "(%d, has %d)", this_urb, |
| 638 | err, this_urb->status); |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 639 | clear_bit(i, &portdata->out_busy); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 640 | continue; |
| 641 | } |
| 642 | portdata->tx_start_time[i] = jiffies; |
| 643 | buf += todo; |
| 644 | left -= todo; |
| 645 | } |
| 646 | |
| 647 | count -= left; |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 648 | dbg("%s: wrote (did %d)", __func__, count); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 649 | return count; |
| 650 | } |
| 651 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 652 | static void option_indat_callback(struct urb *urb) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 653 | { |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 654 | int err; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 655 | int endpoint; |
| 656 | struct usb_serial_port *port; |
| 657 | struct tty_struct *tty; |
| 658 | unsigned char *data = urb->transfer_buffer; |
Greg Kroah-Hartman | d6977b5 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 659 | int status = urb->status; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 660 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 661 | dbg("%s: %p", __func__, urb); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 662 | |
| 663 | endpoint = usb_pipeendpoint(urb->pipe); |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 664 | port = urb->context; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 665 | |
Greg Kroah-Hartman | d6977b5 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 666 | if (status) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 667 | dbg("%s: nonzero status: %d on endpoint %02x.", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 668 | __func__, status, endpoint); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 669 | } else { |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 670 | tty = tty_port_tty_get(&port->port); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 671 | if (urb->actual_length) { |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 672 | tty_buffer_request_room(tty, urb->actual_length); |
| 673 | tty_insert_flip_string(tty, data, urb->actual_length); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 674 | tty_flip_buffer_push(tty); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 675 | } else |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 676 | dbg("%s: empty read urb received", __func__); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 677 | tty_kref_put(tty); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 678 | |
| 679 | /* Resubmit urb so we continue receiving */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 680 | if (port->port.count && status != -ESHUTDOWN) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 681 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 682 | if (err) |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 683 | printk(KERN_ERR "%s: resubmit read urb failed. " |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 684 | "(%d)", __func__, err); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 685 | } |
| 686 | } |
| 687 | return; |
| 688 | } |
| 689 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 690 | static void option_outdat_callback(struct urb *urb) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 691 | { |
| 692 | struct usb_serial_port *port; |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 693 | struct option_port_private *portdata; |
| 694 | int i; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 695 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 696 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 697 | |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 698 | port = urb->context; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 699 | |
Pete Zaitcev | cf2c748 | 2006-05-22 21:58:49 -0700 | [diff] [blame] | 700 | usb_serial_port_softint(port); |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 701 | |
| 702 | portdata = usb_get_serial_port_data(port); |
| 703 | for (i = 0; i < N_OUT_URB; ++i) { |
| 704 | if (portdata->out_urbs[i] == urb) { |
| 705 | smp_mb__before_clear_bit(); |
| 706 | clear_bit(i, &portdata->out_busy); |
| 707 | break; |
| 708 | } |
| 709 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 710 | } |
| 711 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 712 | static void option_instat_callback(struct urb *urb) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 713 | { |
| 714 | int err; |
Greg Kroah-Hartman | d6977b5 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 715 | int status = urb->status; |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 716 | struct usb_serial_port *port = urb->context; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 717 | struct option_port_private *portdata = usb_get_serial_port_data(port); |
| 718 | struct usb_serial *serial = port->serial; |
| 719 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 720 | dbg("%s", __func__); |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 721 | dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 722 | |
Greg Kroah-Hartman | d6977b5 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 723 | if (status == 0) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 724 | struct usb_ctrlrequest *req_pkt = |
| 725 | (struct usb_ctrlrequest *)urb->transfer_buffer; |
| 726 | |
| 727 | if (!req_pkt) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 728 | dbg("%s: NULL req_pkt\n", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 729 | return; |
| 730 | } |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 731 | if ((req_pkt->bRequestType == 0xA1) && |
| 732 | (req_pkt->bRequest == 0x20)) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 733 | int old_dcd_state; |
| 734 | unsigned char signals = *((unsigned char *) |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 735 | urb->transfer_buffer + |
| 736 | sizeof(struct usb_ctrlrequest)); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 737 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 738 | dbg("%s: signal x%x", __func__, signals); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 739 | |
| 740 | old_dcd_state = portdata->dcd_state; |
| 741 | portdata->cts_state = 1; |
| 742 | portdata->dcd_state = ((signals & 0x01) ? 1 : 0); |
| 743 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
| 744 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
| 745 | |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 746 | if (old_dcd_state && !portdata->dcd_state) { |
| 747 | struct tty_struct *tty = |
| 748 | tty_port_tty_get(&port->port); |
| 749 | if (tty && !C_CLOCAL(tty)) |
| 750 | tty_hangup(tty); |
| 751 | tty_kref_put(tty); |
| 752 | } |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 753 | } else { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 754 | dbg("%s: type %x req %x", __func__, |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 755 | req_pkt->bRequestType, req_pkt->bRequest); |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 756 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 757 | } else |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 758 | dbg("%s: error %d", __func__, status); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 759 | |
| 760 | /* Resubmit urb so we continue receiving IRQ data */ |
Greg Kroah-Hartman | d6977b5 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 761 | if (status != -ESHUTDOWN) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 762 | urb->dev = serial->dev; |
| 763 | err = usb_submit_urb(urb, GFP_ATOMIC); |
| 764 | if (err) |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 765 | dbg("%s: resubmit intr urb failed. (%d)", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 766 | __func__, err); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 770 | static int option_write_room(struct tty_struct *tty) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 771 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 772 | struct usb_serial_port *port = tty->driver_data; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 773 | struct option_port_private *portdata; |
| 774 | int i; |
| 775 | int data_len = 0; |
| 776 | struct urb *this_urb; |
| 777 | |
| 778 | portdata = usb_get_serial_port_data(port); |
| 779 | |
Alan Cox | a5b6f60 | 2008-04-08 17:16:06 +0100 | [diff] [blame] | 780 | |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 781 | for (i = 0; i < N_OUT_URB; i++) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 782 | this_urb = portdata->out_urbs[i]; |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 783 | if (this_urb && !test_bit(i, &portdata->out_busy)) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 784 | data_len += OUT_BUFLEN; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 785 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 786 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 787 | dbg("%s: %d", __func__, data_len); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 788 | return data_len; |
| 789 | } |
| 790 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 791 | static int option_chars_in_buffer(struct tty_struct *tty) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 792 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 793 | struct usb_serial_port *port = tty->driver_data; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 794 | struct option_port_private *portdata; |
| 795 | int i; |
| 796 | int data_len = 0; |
| 797 | struct urb *this_urb; |
| 798 | |
| 799 | portdata = usb_get_serial_port_data(port); |
| 800 | |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 801 | for (i = 0; i < N_OUT_URB; i++) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 802 | this_urb = portdata->out_urbs[i]; |
Alan Cox | a5b6f60 | 2008-04-08 17:16:06 +0100 | [diff] [blame] | 803 | /* FIXME: This locking is insufficient as this_urb may |
| 804 | go unused during the test */ |
Alan Stern | 59c2afa | 2007-06-05 16:46:26 -0700 | [diff] [blame] | 805 | if (this_urb && test_bit(i, &portdata->out_busy)) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 806 | data_len += this_urb->transfer_buffer_length; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 807 | } |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 808 | dbg("%s: %d", __func__, data_len); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 809 | return data_len; |
| 810 | } |
| 811 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 812 | static int option_open(struct tty_struct *tty, |
| 813 | struct usb_serial_port *port, struct file *filp) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 814 | { |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 815 | struct option_port_private *portdata; |
| 816 | struct usb_serial *serial = port->serial; |
| 817 | int i, err; |
| 818 | struct urb *urb; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 819 | |
| 820 | portdata = usb_get_serial_port_data(port); |
| 821 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 822 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 823 | |
| 824 | /* Set some sane defaults */ |
| 825 | portdata->rts_state = 1; |
| 826 | portdata->dtr_state = 1; |
| 827 | |
| 828 | /* Reset low level data toggle and start reading from endpoints */ |
| 829 | for (i = 0; i < N_IN_URB; i++) { |
| 830 | urb = portdata->in_urbs[i]; |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 831 | if (!urb) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 832 | continue; |
| 833 | if (urb->dev != serial->dev) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 834 | dbg("%s: dev %p != %p", __func__, |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 835 | urb->dev, serial->dev); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 836 | continue; |
| 837 | } |
| 838 | |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 839 | /* |
| 840 | * make sure endpoint data toggle is synchronized with the |
| 841 | * device |
| 842 | */ |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 843 | usb_clear_halt(urb->dev, urb->pipe); |
| 844 | |
| 845 | err = usb_submit_urb(urb, GFP_KERNEL); |
| 846 | if (err) { |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 847 | dbg("%s: submit urb %d failed (%d) %d", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 848 | __func__, i, err, |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 849 | urb->transfer_buffer_length); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | /* Reset low level data toggle on out endpoints */ |
| 854 | for (i = 0; i < N_OUT_URB; i++) { |
| 855 | urb = portdata->out_urbs[i]; |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 856 | if (!urb) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 857 | continue; |
| 858 | urb->dev = serial->dev; |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 859 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), |
| 860 | usb_pipeout(urb->pipe), 0); */ |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 861 | } |
| 862 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 863 | if (tty) |
| 864 | tty->low_latency = 1; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 865 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 866 | option_send_setup(tty, port); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 867 | |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 868 | return 0; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 869 | } |
| 870 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 871 | static void option_close(struct tty_struct *tty, |
| 872 | struct usb_serial_port *port, struct file *filp) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 873 | { |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 874 | int i; |
| 875 | struct usb_serial *serial = port->serial; |
| 876 | struct option_port_private *portdata; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 877 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 878 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 879 | portdata = usb_get_serial_port_data(port); |
| 880 | |
| 881 | portdata->rts_state = 0; |
| 882 | portdata->dtr_state = 0; |
| 883 | |
| 884 | if (serial->dev) { |
Oliver Neukum | e33fe4d | 2008-01-21 17:44:10 +0100 | [diff] [blame] | 885 | mutex_lock(&serial->disc_mutex); |
| 886 | if (!serial->disconnected) |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 887 | option_send_setup(tty, port); |
Oliver Neukum | e33fe4d | 2008-01-21 17:44:10 +0100 | [diff] [blame] | 888 | mutex_unlock(&serial->disc_mutex); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 889 | |
| 890 | /* Stop reading/writing urbs */ |
| 891 | for (i = 0; i < N_IN_URB; i++) |
Oliver Neukum | 7d28e74 | 2007-03-20 13:41:21 +0100 | [diff] [blame] | 892 | usb_kill_urb(portdata->in_urbs[i]); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 893 | for (i = 0; i < N_OUT_URB; i++) |
Oliver Neukum | 7d28e74 | 2007-03-20 13:41:21 +0100 | [diff] [blame] | 894 | usb_kill_urb(portdata->out_urbs[i]); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 895 | } |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 896 | tty_port_tty_set(&port->port, NULL); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 897 | } |
| 898 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 899 | /* Helper functions used by option_setup_urbs */ |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 900 | static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint, |
| 901 | int dir, void *ctx, char *buf, int len, |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 902 | void (*callback)(struct urb *)) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 903 | { |
| 904 | struct urb *urb; |
| 905 | |
| 906 | if (endpoint == -1) |
| 907 | return NULL; /* endpoint not needed */ |
| 908 | |
| 909 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ |
| 910 | if (urb == NULL) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 911 | dbg("%s: alloc for endpoint %d failed.", __func__, endpoint); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 912 | return NULL; |
| 913 | } |
| 914 | |
| 915 | /* Fill URB using supplied data. */ |
| 916 | usb_fill_bulk_urb(urb, serial->dev, |
| 917 | usb_sndbulkpipe(serial->dev, endpoint) | dir, |
| 918 | buf, len, callback, ctx); |
| 919 | |
| 920 | return urb; |
| 921 | } |
| 922 | |
| 923 | /* Setup urbs */ |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 924 | static void option_setup_urbs(struct usb_serial *serial) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 925 | { |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 926 | int i, j; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 927 | struct usb_serial_port *port; |
| 928 | struct option_port_private *portdata; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 929 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 930 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 931 | |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 932 | for (i = 0; i < serial->num_ports; i++) { |
| 933 | port = serial->port[i]; |
| 934 | portdata = usb_get_serial_port_data(port); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 935 | |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 936 | /* Do indat endpoints first */ |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 937 | for (j = 0; j < N_IN_URB; ++j) { |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 938 | portdata->in_urbs[j] = option_setup_urb(serial, |
| 939 | port->bulk_in_endpointAddress, |
| 940 | USB_DIR_IN, port, |
| 941 | portdata->in_buffer[j], |
| 942 | IN_BUFLEN, option_indat_callback); |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 943 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 944 | |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 945 | /* outdat endpoints */ |
| 946 | for (j = 0; j < N_OUT_URB; ++j) { |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 947 | portdata->out_urbs[j] = option_setup_urb(serial, |
| 948 | port->bulk_out_endpointAddress, |
| 949 | USB_DIR_OUT, port, |
| 950 | portdata->out_buffer[j], |
| 951 | OUT_BUFLEN, option_outdat_callback); |
Matthias Urlichs | 14f76cc | 2006-06-02 11:48:56 +0200 | [diff] [blame] | 952 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 953 | } |
| 954 | } |
| 955 | |
Chris Collins | 5f76004 | 2008-04-10 10:15:53 +0200 | [diff] [blame] | 956 | |
| 957 | /** send RTS/DTR state to the port. |
| 958 | * |
| 959 | * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN |
| 960 | * CDC. |
| 961 | */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 962 | static int option_send_setup(struct tty_struct *tty, |
| 963 | struct usb_serial_port *port) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 964 | { |
| 965 | struct usb_serial *serial = port->serial; |
| 966 | struct option_port_private *portdata; |
Chris Collins | 5f76004 | 2008-04-10 10:15:53 +0200 | [diff] [blame] | 967 | int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 968 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 969 | |
| 970 | portdata = usb_get_serial_port_data(port); |
| 971 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 972 | if (tty) { |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 973 | int val = 0; |
| 974 | if (portdata->dtr_state) |
| 975 | val |= 0x01; |
| 976 | if (portdata->rts_state) |
| 977 | val |= 0x02; |
| 978 | |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 979 | return usb_control_msg(serial->dev, |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 980 | usb_rcvctrlpipe(serial->dev, 0), |
| 981 | 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 982 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 983 | return 0; |
| 984 | } |
| 985 | |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 986 | static int option_startup(struct usb_serial *serial) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 987 | { |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 988 | int i, j, err; |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 989 | struct usb_serial_port *port; |
| 990 | struct option_port_private *portdata; |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 991 | u8 *buffer; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 992 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 993 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 994 | |
| 995 | /* Now setup per port private data */ |
| 996 | for (i = 0; i < serial->num_ports; i++) { |
| 997 | port = serial->port[i]; |
Eric Sesterhenn | 80b6ca4 | 2006-02-27 21:29:43 +0100 | [diff] [blame] | 998 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 999 | if (!portdata) { |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 1000 | dbg("%s: kmalloc for option_port_private (%d) failed!.", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1001 | __func__, i); |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 1002 | return 1; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1003 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1004 | |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 1005 | for (j = 0; j < N_IN_URB; j++) { |
| 1006 | buffer = (u8 *)__get_free_page(GFP_KERNEL); |
| 1007 | if (!buffer) |
| 1008 | goto bail_out_error; |
| 1009 | portdata->in_buffer[j] = buffer; |
| 1010 | } |
| 1011 | |
| 1012 | for (j = 0; j < N_OUT_URB; j++) { |
| 1013 | buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); |
| 1014 | if (!buffer) |
| 1015 | goto bail_out_error2; |
| 1016 | portdata->out_buffer[j] = buffer; |
| 1017 | } |
| 1018 | |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1019 | usb_set_serial_port_data(port, portdata); |
| 1020 | |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 1021 | if (!port->interrupt_in_urb) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1022 | continue; |
| 1023 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
| 1024 | if (err) |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 1025 | dbg("%s: submit irq_in urb failed %d", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1026 | __func__, err); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1027 | } |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1028 | option_setup_urbs(serial); |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 1029 | return 0; |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 1030 | |
| 1031 | bail_out_error2: |
| 1032 | for (j = 0; j < N_OUT_URB; j++) |
| 1033 | kfree(portdata->out_buffer[j]); |
| 1034 | bail_out_error: |
| 1035 | for (j = 0; j < N_IN_URB; j++) |
| 1036 | if (portdata->in_buffer[j]) |
| 1037 | free_page((unsigned long)portdata->in_buffer[j]); |
| 1038 | kfree(portdata); |
| 1039 | return 1; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1040 | } |
| 1041 | |
Andrew Morton | 7bb75ae | 2005-07-27 01:08:30 -0700 | [diff] [blame] | 1042 | static void option_shutdown(struct usb_serial *serial) |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1043 | { |
Matthias Urlichs | ba460e4 | 2005-07-14 00:33:47 -0700 | [diff] [blame] | 1044 | int i, j; |
| 1045 | struct usb_serial_port *port; |
| 1046 | struct option_port_private *portdata; |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1047 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1048 | dbg("%s", __func__); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1049 | |
| 1050 | /* Stop reading/writing urbs */ |
| 1051 | for (i = 0; i < serial->num_ports; ++i) { |
| 1052 | port = serial->port[i]; |
| 1053 | portdata = usb_get_serial_port_data(port); |
| 1054 | for (j = 0; j < N_IN_URB; j++) |
Oliver Neukum | 7d28e74 | 2007-03-20 13:41:21 +0100 | [diff] [blame] | 1055 | usb_kill_urb(portdata->in_urbs[j]); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1056 | for (j = 0; j < N_OUT_URB; j++) |
Oliver Neukum | 7d28e74 | 2007-03-20 13:41:21 +0100 | [diff] [blame] | 1057 | usb_kill_urb(portdata->out_urbs[j]); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | /* Now free them */ |
| 1061 | for (i = 0; i < serial->num_ports; ++i) { |
| 1062 | port = serial->port[i]; |
| 1063 | portdata = usb_get_serial_port_data(port); |
| 1064 | |
| 1065 | for (j = 0; j < N_IN_URB; j++) { |
| 1066 | if (portdata->in_urbs[j]) { |
| 1067 | usb_free_urb(portdata->in_urbs[j]); |
Alan Cox | 19e58fa | 2008-07-22 11:15:45 +0100 | [diff] [blame] | 1068 | free_page((unsigned long) |
| 1069 | portdata->in_buffer[j]); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1070 | portdata->in_urbs[j] = NULL; |
| 1071 | } |
| 1072 | } |
| 1073 | for (j = 0; j < N_OUT_URB; j++) { |
| 1074 | if (portdata->out_urbs[j]) { |
| 1075 | usb_free_urb(portdata->out_urbs[j]); |
Oliver Neukum | 2129c4e | 2008-02-01 13:58:52 +0100 | [diff] [blame] | 1076 | kfree(portdata->out_buffer[j]); |
Matthias Urlichs | 58cfe91 | 2005-05-23 17:00:48 -0700 | [diff] [blame] | 1077 | portdata->out_urbs[j] = NULL; |
| 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | /* Now free per port private data */ |
| 1083 | for (i = 0; i < serial->num_ports; i++) { |
| 1084 | port = serial->port[i]; |
| 1085 | kfree(usb_get_serial_port_data(port)); |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 1090 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 1091 | MODULE_VERSION(DRIVER_VERSION); |
| 1092 | MODULE_LICENSE("GPL"); |
| 1093 | |
| 1094 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 1095 | MODULE_PARM_DESC(debug, "Debug messages"); |