blob: 6fcf54d43eab427541cbc43b00ae01c829c12a11 [file] [log] [blame]
Bjørn Mork423ce8c2012-01-19 15:37:22 +00001/*
2 * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 */
8
9#include <linux/module.h>
10#include <linux/netdevice.h>
11#include <linux/ethtool.h>
12#include <linux/mii.h>
13#include <linux/usb.h>
14#include <linux/usb/cdc.h>
15#include <linux/usb/usbnet.h>
Bjørn Morkc3ecb082012-03-09 12:35:05 +010016#include <linux/usb/cdc-wdm.h>
Bjørn Mork423ce8c2012-01-19 15:37:22 +000017
18/* The name of the CDC Device Management driver */
19#define DM_DRIVER "cdc_wdm"
20
21/*
22 * This driver supports wwan (3G/LTE/?) devices using a vendor
23 * specific management protocol called Qualcomm MSM Interface (QMI) -
24 * in addition to the more common AT commands over serial interface
25 * management
26 *
27 * QMI is wrapped in CDC, using CDC encapsulated commands on the
28 * control ("master") interface of a two-interface CDC Union
29 * resembling standard CDC ECM. The devices do not use the control
30 * interface for any other CDC messages. Most likely because the
31 * management protocol is used in place of the standard CDC
32 * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
33 *
34 * Handling a protocol like QMI is out of the scope for any driver.
35 * It can be exported as a character device using the cdc-wdm driver,
36 * which will enable userspace applications ("modem managers") to
37 * handle it. This may be required to use the network interface
38 * provided by the driver.
39 *
40 * These devices may alternatively/additionally be configured using AT
41 * commands on any of the serial interfaces driven by the option driver
42 *
43 * This driver binds only to the data ("slave") interface to enable
44 * the cdc-wdm driver to bind to the control interface. It still
45 * parses the CDC functional descriptors on the control interface to
46 * a) verify that this is indeed a handled interface (CDC Union
47 * header lists it as slave)
48 * b) get MAC address and other ethernet config from the CDC Ethernet
49 * header
50 * c) enable user bind requests against the control interface, which
51 * is the common way to bind to CDC Ethernet Control Model type
52 * interfaces
53 * d) provide a hint to the user about which interface is the
54 * corresponding management interface
55 */
56
Bjørn Mork853c24f2012-06-19 00:41:59 +000057/* driver specific data */
58struct qmi_wwan_state {
59 struct usb_driver *subdriver;
60 atomic_t pmcount;
Bjørn Morkf47cd132012-06-19 00:42:00 +000061 unsigned long unused;
62 struct usb_interface *control;
63 struct usb_interface *data;
Bjørn Mork853c24f2012-06-19 00:41:59 +000064};
65
Bjørn Morkf47cd132012-06-19 00:42:00 +000066/* using a counter to merge subdriver requests with our own into a combined state */
67static int qmi_wwan_manage_power(struct usbnet *dev, int on)
68{
69 struct qmi_wwan_state *info = (void *)&dev->data;
70 int rv = 0;
71
72 dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on);
73
74 if ((on && atomic_add_return(1, &info->pmcount) == 1) || (!on && atomic_dec_and_test(&info->pmcount))) {
75 /* need autopm_get/put here to ensure the usbcore sees the new value */
76 rv = usb_autopm_get_interface(dev->intf);
77 if (rv < 0)
78 goto err;
79 dev->intf->needs_remote_wakeup = on;
80 usb_autopm_put_interface(dev->intf);
81 }
82err:
83 return rv;
84}
85
86static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
87{
88 struct usbnet *dev = usb_get_intfdata(intf);
89 return qmi_wwan_manage_power(dev, on);
90}
91
92/* collect all three endpoints and register subdriver */
93static int qmi_wwan_register_subdriver(struct usbnet *dev)
94{
95 int rv;
96 struct usb_driver *subdriver = NULL;
97 struct qmi_wwan_state *info = (void *)&dev->data;
98
99 /* collect bulk endpoints */
100 rv = usbnet_get_endpoints(dev, info->data);
101 if (rv < 0)
102 goto err;
103
104 /* update status endpoint if separate control interface */
105 if (info->control != info->data)
106 dev->status = &info->control->cur_altsetting->endpoint[0];
107
108 /* require interrupt endpoint for subdriver */
109 if (!dev->status) {
110 rv = -EINVAL;
111 goto err;
112 }
113
114 /* for subdriver power management */
115 atomic_set(&info->pmcount, 0);
116
117 /* register subdriver */
118 subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 512, &qmi_wwan_cdc_wdm_manage_power);
119 if (IS_ERR(subdriver)) {
120 dev_err(&info->control->dev, "subdriver registration failed\n");
121 rv = PTR_ERR(subdriver);
122 goto err;
123 }
124
125 /* prevent usbnet from using status endpoint */
126 dev->status = NULL;
127
128 /* save subdriver struct for suspend/resume wrappers */
129 info->subdriver = subdriver;
130
131err:
132 return rv;
133}
134
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000135static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
136{
137 int status = -1;
138 struct usb_interface *control = NULL;
139 u8 *buf = intf->cur_altsetting->extra;
140 int len = intf->cur_altsetting->extralen;
141 struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
142 struct usb_cdc_union_desc *cdc_union = NULL;
143 struct usb_cdc_ether_desc *cdc_ether = NULL;
144 u32 required = 1 << USB_CDC_HEADER_TYPE | 1 << USB_CDC_UNION_TYPE;
145 u32 found = 0;
Bjørn Mork853c24f2012-06-19 00:41:59 +0000146 struct qmi_wwan_state *info = (void *)&dev->data;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100147
Bjørn Mork853c24f2012-06-19 00:41:59 +0000148 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state)));
149
150 atomic_set(&info->pmcount, 0);
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000151
152 /*
153 * assume a data interface has no additional descriptors and
154 * that the control and data interface are numbered
155 * consecutively - this holds for the Huawei device at least
156 */
157 if (len == 0 && desc->bInterfaceNumber > 0) {
158 control = usb_ifnum_to_if(dev->udev, desc->bInterfaceNumber - 1);
159 if (!control)
160 goto err;
161
162 buf = control->cur_altsetting->extra;
163 len = control->cur_altsetting->extralen;
164 dev_dbg(&intf->dev, "guessing \"control\" => %s, \"data\" => this\n",
165 dev_name(&control->dev));
166 }
167
168 while (len > 3) {
169 struct usb_descriptor_header *h = (void *)buf;
170
171 /* ignore any misplaced descriptors */
172 if (h->bDescriptorType != USB_DT_CS_INTERFACE)
173 goto next_desc;
174
175 /* buf[2] is CDC descriptor subtype */
176 switch (buf[2]) {
177 case USB_CDC_HEADER_TYPE:
178 if (found & 1 << USB_CDC_HEADER_TYPE) {
179 dev_dbg(&intf->dev, "extra CDC header\n");
180 goto err;
181 }
182 if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
183 dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
184 goto err;
185 }
186 break;
187 case USB_CDC_UNION_TYPE:
188 if (found & 1 << USB_CDC_UNION_TYPE) {
189 dev_dbg(&intf->dev, "extra CDC union\n");
190 goto err;
191 }
192 if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
193 dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
194 goto err;
195 }
196 cdc_union = (struct usb_cdc_union_desc *)buf;
197 break;
198 case USB_CDC_ETHERNET_TYPE:
199 if (found & 1 << USB_CDC_ETHERNET_TYPE) {
200 dev_dbg(&intf->dev, "extra CDC ether\n");
201 goto err;
202 }
203 if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
204 dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength);
205 goto err;
206 }
207 cdc_ether = (struct usb_cdc_ether_desc *)buf;
208 break;
209 }
210
211 /*
212 * Remember which CDC functional descriptors we've seen. Works
213 * for all types we care about, of which USB_CDC_ETHERNET_TYPE
214 * (0x0f) is the highest numbered
215 */
216 if (buf[2] < 32)
217 found |= 1 << buf[2];
218
219next_desc:
220 len -= h->bLength;
221 buf += h->bLength;
222 }
223
224 /* did we find all the required ones? */
225 if ((found & required) != required) {
226 dev_err(&intf->dev, "CDC functional descriptors missing\n");
227 goto err;
228 }
229
230 /* give the user a helpful hint if trying to bind to the wrong interface */
231 if (cdc_union && desc->bInterfaceNumber == cdc_union->bMasterInterface0) {
232 dev_err(&intf->dev, "leaving \"control\" interface for " DM_DRIVER " - try binding to %s instead!\n",
233 dev_name(&usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0)->dev));
234 goto err;
235 }
236
237 /* errors aren't fatal - we can live with the dynamic address */
238 if (cdc_ether) {
239 dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
240 usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
241 }
242
243 /* success! point the user to the management interface */
244 if (control)
245 dev_info(&intf->dev, "Use \"" DM_DRIVER "\" for QMI interface %s\n",
246 dev_name(&control->dev));
247
248 /* XXX: add a sysfs symlink somewhere to help management applications find it? */
249
250 /* collect bulk endpoints now that we know intf == "data" interface */
251 status = usbnet_get_endpoints(dev, intf);
252
253err:
254 return status;
255}
256
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100257/* Some devices combine the "control" and "data" functions into a
258 * single interface with all three endpoints: interrupt + bulk in and
259 * out
260 *
261 * Setting up cdc-wdm as a subdriver owning the interrupt endpoint
262 * will let it provide userspace access to the encapsulated QMI
263 * protocol without interfering with the usbnet operations.
264 */
265static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
266{
267 int rv;
Bjørn Mork853c24f2012-06-19 00:41:59 +0000268 struct qmi_wwan_state *info = (void *)&dev->data;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100269
Bjørn Mork11207b62012-03-16 15:41:27 +0100270 /* ZTE makes devices where the interface descriptors and endpoint
271 * configurations of two or more interfaces are identical, even
272 * though the functions are completely different. If set, then
273 * driver_info->data is a bitmap of acceptable interface numbers
274 * allowing us to bind to one such interface without binding to
275 * all of them
276 */
277 if (dev->driver_info->data &&
278 !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) {
279 dev_info(&intf->dev, "not on our whitelist - ignored");
280 rv = -ENODEV;
281 goto err;
282 }
283
Bjørn Morkf47cd132012-06-19 00:42:00 +0000284 /* control and data is shared */
285 info->control = intf;
286 info->data = intf;
287 rv = qmi_wwan_register_subdriver(dev);
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100288
289err:
290 return rv;
291}
292
Bjørn Morkb086cf02012-03-09 12:35:06 +0100293/* Gobi devices uses identical class/protocol codes for all interfaces regardless
294 * of function. Some of these are CDC ACM like and have the exact same endpoints
295 * we are looking for. This leaves two possible strategies for identifying the
296 * correct interface:
297 * a) hardcoding interface number, or
298 * b) use the fact that the wwan interface is the only one lacking additional
299 * (CDC functional) descriptors
300 *
301 * Let's see if we can get away with the generic b) solution.
302 */
303static int qmi_wwan_bind_gobi(struct usbnet *dev, struct usb_interface *intf)
304{
305 int rv = -EINVAL;
306
307 /* ignore any interface with additional descriptors */
308 if (intf->cur_altsetting->extralen)
309 goto err;
310
311 rv = qmi_wwan_bind_shared(dev, intf);
312err:
313 return rv;
314}
315
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100316static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf)
317{
Bjørn Mork853c24f2012-06-19 00:41:59 +0000318 struct qmi_wwan_state *info = (void *)&dev->data;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100319
Bjørn Mork853c24f2012-06-19 00:41:59 +0000320 if (info->subdriver && info->subdriver->disconnect)
321 info->subdriver->disconnect(intf);
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100322
Bjørn Mork853c24f2012-06-19 00:41:59 +0000323 info->subdriver = NULL;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100324}
325
326/* suspend/resume wrappers calling both usbnet and the cdc-wdm
327 * subdriver if present.
328 *
329 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
330 * wrappers for those without adding usbnet reset support first.
331 */
332static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
333{
334 struct usbnet *dev = usb_get_intfdata(intf);
Bjørn Mork853c24f2012-06-19 00:41:59 +0000335 struct qmi_wwan_state *info = (void *)&dev->data;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100336 int ret;
337
338 ret = usbnet_suspend(intf, message);
339 if (ret < 0)
340 goto err;
341
Bjørn Mork853c24f2012-06-19 00:41:59 +0000342 if (info->subdriver && info->subdriver->suspend)
343 ret = info->subdriver->suspend(intf, message);
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100344 if (ret < 0)
345 usbnet_resume(intf);
346err:
347 return ret;
348}
349
350static int qmi_wwan_resume(struct usb_interface *intf)
351{
352 struct usbnet *dev = usb_get_intfdata(intf);
Bjørn Mork853c24f2012-06-19 00:41:59 +0000353 struct qmi_wwan_state *info = (void *)&dev->data;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100354 int ret = 0;
355
Bjørn Mork853c24f2012-06-19 00:41:59 +0000356 if (info->subdriver && info->subdriver->resume)
357 ret = info->subdriver->resume(intf);
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100358 if (ret < 0)
359 goto err;
360 ret = usbnet_resume(intf);
Bjørn Mork853c24f2012-06-19 00:41:59 +0000361 if (ret < 0 && info->subdriver && info->subdriver->resume && info->subdriver->suspend)
362 info->subdriver->suspend(intf, PMSG_SUSPEND);
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100363err:
364 return ret;
365}
366
367
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000368static const struct driver_info qmi_wwan_info = {
369 .description = "QMI speaking wwan device",
370 .flags = FLAG_WWAN,
371 .bind = qmi_wwan_bind,
372 .manage_power = qmi_wwan_manage_power,
373};
374
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100375static const struct driver_info qmi_wwan_shared = {
376 .description = "QMI speaking wwan device with combined interface",
377 .flags = FLAG_WWAN,
378 .bind = qmi_wwan_bind_shared,
379 .unbind = qmi_wwan_unbind_shared,
380 .manage_power = qmi_wwan_manage_power,
381};
382
Bjørn Morkb086cf02012-03-09 12:35:06 +0100383static const struct driver_info qmi_wwan_gobi = {
384 .description = "Qualcomm Gobi wwan/QMI device",
385 .flags = FLAG_WWAN,
386 .bind = qmi_wwan_bind_gobi,
387 .unbind = qmi_wwan_unbind_shared,
388 .manage_power = qmi_wwan_manage_power,
389};
390
Bjørn Mork11207b62012-03-16 15:41:27 +0100391/* ZTE suck at making USB descriptors */
Andrew Bird (Sphere Systems)f7142e62012-05-19 22:28:38 +0000392static const struct driver_info qmi_wwan_force_int1 = {
393 .description = "Qualcomm WWAN/QMI device",
394 .flags = FLAG_WWAN,
395 .bind = qmi_wwan_bind_shared,
396 .unbind = qmi_wwan_unbind_shared,
397 .manage_power = qmi_wwan_manage_power,
398 .data = BIT(1), /* interface whitelist bitmap */
399};
400
Bjørn Mork11207b62012-03-16 15:41:27 +0100401static const struct driver_info qmi_wwan_force_int4 = {
Andrew Bird (Sphere Systems)00001882012-05-19 22:28:36 +0000402 .description = "Qualcomm WWAN/QMI device",
Bjørn Mork11207b62012-03-16 15:41:27 +0100403 .flags = FLAG_WWAN,
Andrew Bird (Sphere Systems)00001882012-05-19 22:28:36 +0000404 .bind = qmi_wwan_bind_shared,
Bjørn Mork11207b62012-03-16 15:41:27 +0100405 .unbind = qmi_wwan_unbind_shared,
406 .manage_power = qmi_wwan_manage_power,
407 .data = BIT(4), /* interface whitelist bitmap */
408};
409
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000410/* Sierra Wireless provide equally useless interface descriptors
411 * Devices in QMI mode can be switched between two different
412 * configurations:
413 * a) USB interface #8 is QMI/wwan
414 * b) USB interfaces #8, #19 and #20 are QMI/wwan
415 *
416 * Both configurations provide a number of other interfaces (serial++),
417 * some of which have the same endpoint configuration as we expect, so
418 * a whitelist or blacklist is necessary.
419 *
420 * FIXME: The below whitelist should include BIT(20). It does not
421 * because I cannot get it to work...
422 */
423static const struct driver_info qmi_wwan_sierra = {
424 .description = "Sierra Wireless wwan/QMI device",
425 .flags = FLAG_WWAN,
426 .bind = qmi_wwan_bind_gobi,
427 .unbind = qmi_wwan_unbind_shared,
428 .manage_power = qmi_wwan_manage_power,
429 .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
430};
Bjørn Mork11207b62012-03-16 15:41:27 +0100431
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000432#define HUAWEI_VENDOR_ID 0x12D1
Bjørn Morkb086cf02012-03-09 12:35:06 +0100433#define QMI_GOBI_DEVICE(vend, prod) \
434 USB_DEVICE(vend, prod), \
435 .driver_info = (unsigned long)&qmi_wwan_gobi
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000436
437static const struct usb_device_id products[] = {
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100438 { /* Huawei E392, E398 and possibly others sharing both device id and more... */
439 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
440 .idVendor = HUAWEI_VENDOR_ID,
441 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
442 .bInterfaceSubClass = 1,
443 .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */
444 .driver_info = (unsigned long)&qmi_wwan_info,
445 },
Bjørn Mork88c16dc2012-05-19 07:20:31 +0000446 { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
447 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
448 .idVendor = HUAWEI_VENDOR_ID,
449 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
450 .bInterfaceSubClass = 1,
451 .bInterfaceProtocol = 56, /* NOTE: This is the *slave* interface of the CDC Union! */
452 .driver_info = (unsigned long)&qmi_wwan_info,
453 },
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100454 { /* Huawei E392, E398 and possibly others in "Windows mode"
455 * using a combined control and data interface without any CDC
456 * functional descriptors
457 */
458 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
459 .idVendor = HUAWEI_VENDOR_ID,
460 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
461 .bInterfaceSubClass = 1,
462 .bInterfaceProtocol = 17,
463 .driver_info = (unsigned long)&qmi_wwan_shared,
464 },
Bjørn Morkb086cf02012-03-09 12:35:06 +0100465 { /* Pantech UML290 */
466 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
467 .idVendor = 0x106c,
468 .idProduct = 0x3718,
469 .bInterfaceClass = 0xff,
470 .bInterfaceSubClass = 0xf0,
471 .bInterfaceProtocol = 0xff,
472 .driver_info = (unsigned long)&qmi_wwan_shared,
473 },
Bjørn Mork11207b62012-03-16 15:41:27 +0100474 { /* ZTE MF820D */
475 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
476 .idVendor = 0x19d2,
477 .idProduct = 0x0167,
478 .bInterfaceClass = 0xff,
479 .bInterfaceSubClass = 0xff,
480 .bInterfaceProtocol = 0xff,
481 .driver_info = (unsigned long)&qmi_wwan_force_int4,
482 },
Andrew Bird (Sphere Systems)f7142e62012-05-19 22:28:38 +0000483 { /* ZTE (Vodafone) K3520-Z */
484 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
485 .idVendor = 0x19d2,
486 .idProduct = 0x0055,
487 .bInterfaceClass = 0xff,
488 .bInterfaceSubClass = 0xff,
489 .bInterfaceProtocol = 0xff,
490 .driver_info = (unsigned long)&qmi_wwan_force_int1,
491 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000492 { /* ZTE (Vodafone) K3565-Z */
493 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
494 .idVendor = 0x19d2,
495 .idProduct = 0x0063,
496 .bInterfaceClass = 0xff,
497 .bInterfaceSubClass = 0xff,
498 .bInterfaceProtocol = 0xff,
499 .driver_info = (unsigned long)&qmi_wwan_force_int4,
500 },
Andrew Bird (Sphere Systems)dbb6d092012-03-25 00:10:29 +0000501 { /* ZTE (Vodafone) K3570-Z */
502 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
503 .idVendor = 0x19d2,
504 .idProduct = 0x1008,
505 .bInterfaceClass = 0xff,
506 .bInterfaceSubClass = 0xff,
507 .bInterfaceProtocol = 0xff,
508 .driver_info = (unsigned long)&qmi_wwan_force_int4,
509 },
510 { /* ZTE (Vodafone) K3571-Z */
511 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
512 .idVendor = 0x19d2,
513 .idProduct = 0x1010,
514 .bInterfaceClass = 0xff,
515 .bInterfaceSubClass = 0xff,
516 .bInterfaceProtocol = 0xff,
517 .driver_info = (unsigned long)&qmi_wwan_force_int4,
518 },
Andrew Bird (Sphere Systems)8965c982012-05-19 22:28:37 +0000519 { /* ZTE (Vodafone) K3765-Z */
520 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
521 .idVendor = 0x19d2,
522 .idProduct = 0x2002,
523 .bInterfaceClass = 0xff,
524 .bInterfaceSubClass = 0xff,
525 .bInterfaceProtocol = 0xff,
526 .driver_info = (unsigned long)&qmi_wwan_force_int4,
527 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000528 { /* ZTE (Vodafone) K4505-Z */
529 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
530 .idVendor = 0x19d2,
531 .idProduct = 0x0104,
532 .bInterfaceClass = 0xff,
533 .bInterfaceSubClass = 0xff,
534 .bInterfaceProtocol = 0xff,
535 .driver_info = (unsigned long)&qmi_wwan_force_int4,
536 },
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000537 { /* Sierra Wireless MC77xx in QMI mode */
538 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
539 .idVendor = 0x1199,
540 .idProduct = 0x68a2,
541 .bInterfaceClass = 0xff,
542 .bInterfaceSubClass = 0xff,
543 .bInterfaceProtocol = 0xff,
544 .driver_info = (unsigned long)&qmi_wwan_sierra,
545 },
Bjørn Morkb086cf02012-03-09 12:35:06 +0100546 {QMI_GOBI_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
547 {QMI_GOBI_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
548 {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
549 {QMI_GOBI_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
550 {QMI_GOBI_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
551 {QMI_GOBI_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
552 {QMI_GOBI_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
553 {QMI_GOBI_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
554 {QMI_GOBI_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
555 {QMI_GOBI_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
556 {QMI_GOBI_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
557 {QMI_GOBI_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
558 {QMI_GOBI_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
559 {QMI_GOBI_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
560 {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
561 {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
562 {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
563 {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
564 {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
565 {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
566 {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
567 {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
568 {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
569 {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
570 {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
571 {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
572 {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
573 {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
574 {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
575 {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
576 {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
577 {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
578 {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
579 {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
580 {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
581 {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
582 {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
Bjørn Mork5e071b52012-05-23 23:19:32 +0000583 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
584 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100585 { } /* END */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000586};
587MODULE_DEVICE_TABLE(usb, products);
588
589static struct usb_driver qmi_wwan_driver = {
590 .name = "qmi_wwan",
591 .id_table = products,
592 .probe = usbnet_probe,
593 .disconnect = usbnet_disconnect,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100594 .suspend = qmi_wwan_suspend,
595 .resume = qmi_wwan_resume,
596 .reset_resume = qmi_wwan_resume,
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000597 .supports_autosuspend = 1,
Sarah Sharpe1f12eb2012-04-23 10:08:51 -0700598 .disable_hub_initiated_lpm = 1,
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000599};
600
601static int __init qmi_wwan_init(void)
602{
603 return usb_register(&qmi_wwan_driver);
604}
605module_init(qmi_wwan_init);
606
607static void __exit qmi_wwan_exit(void)
608{
609 usb_deregister(&qmi_wwan_driver);
610}
611module_exit(qmi_wwan_exit);
612
613MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
614MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
615MODULE_LICENSE("GPL");