]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/net/usb/qmi_wwan.c
Merge tag 'usb-for-v3.10-part2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / drivers / net / usb / qmi_wwan.c
1 /*
2  * Copyright (c) 2012  Bjørn Mork <bjorn@mork.no>
3  *
4  * The probing code is heavily inspired by cdc_ether, which is:
5  * Copyright (C) 2003-2005 by David Brownell
6  * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  */
12
13 #include <linux/module.h>
14 #include <linux/netdevice.h>
15 #include <linux/ethtool.h>
16 #include <linux/mii.h>
17 #include <linux/usb.h>
18 #include <linux/usb/cdc.h>
19 #include <linux/usb/usbnet.h>
20 #include <linux/usb/cdc-wdm.h>
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  * Alternatively, control and data functions can be combined in a
35  * single USB interface.
36  *
37  * Handling a protocol like QMI is out of the scope for any driver.
38  * It is exported as a character device using the cdc-wdm driver as
39  * a subdriver, enabling userspace applications ("modem managers") to
40  * handle it.
41  *
42  * These devices may alternatively/additionally be configured using AT
43  * commands on a serial interface
44  */
45
46 /* driver specific data */
47 struct qmi_wwan_state {
48         struct usb_driver *subdriver;
49         atomic_t pmcount;
50         unsigned long unused;
51         struct usb_interface *control;
52         struct usb_interface *data;
53 };
54
55 /* using a counter to merge subdriver requests with our own into a combined state */
56 static int qmi_wwan_manage_power(struct usbnet *dev, int on)
57 {
58         struct qmi_wwan_state *info = (void *)&dev->data;
59         int rv = 0;
60
61         dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on);
62
63         if ((on && atomic_add_return(1, &info->pmcount) == 1) || (!on && atomic_dec_and_test(&info->pmcount))) {
64                 /* need autopm_get/put here to ensure the usbcore sees the new value */
65                 rv = usb_autopm_get_interface(dev->intf);
66                 if (rv < 0)
67                         goto err;
68                 dev->intf->needs_remote_wakeup = on;
69                 usb_autopm_put_interface(dev->intf);
70         }
71 err:
72         return rv;
73 }
74
75 static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
76 {
77         struct usbnet *dev = usb_get_intfdata(intf);
78
79         /* can be called while disconnecting */
80         if (!dev)
81                 return 0;
82         return qmi_wwan_manage_power(dev, on);
83 }
84
85 /* collect all three endpoints and register subdriver */
86 static int qmi_wwan_register_subdriver(struct usbnet *dev)
87 {
88         int rv;
89         struct usb_driver *subdriver = NULL;
90         struct qmi_wwan_state *info = (void *)&dev->data;
91
92         /* collect bulk endpoints */
93         rv = usbnet_get_endpoints(dev, info->data);
94         if (rv < 0)
95                 goto err;
96
97         /* update status endpoint if separate control interface */
98         if (info->control != info->data)
99                 dev->status = &info->control->cur_altsetting->endpoint[0];
100
101         /* require interrupt endpoint for subdriver */
102         if (!dev->status) {
103                 rv = -EINVAL;
104                 goto err;
105         }
106
107         /* for subdriver power management */
108         atomic_set(&info->pmcount, 0);
109
110         /* register subdriver */
111         subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 4096, &qmi_wwan_cdc_wdm_manage_power);
112         if (IS_ERR(subdriver)) {
113                 dev_err(&info->control->dev, "subdriver registration failed\n");
114                 rv = PTR_ERR(subdriver);
115                 goto err;
116         }
117
118         /* prevent usbnet from using status endpoint */
119         dev->status = NULL;
120
121         /* save subdriver struct for suspend/resume wrappers */
122         info->subdriver = subdriver;
123
124 err:
125         return rv;
126 }
127
128 static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
129 {
130         int status = -1;
131         u8 *buf = intf->cur_altsetting->extra;
132         int len = intf->cur_altsetting->extralen;
133         struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
134         struct usb_cdc_union_desc *cdc_union = NULL;
135         struct usb_cdc_ether_desc *cdc_ether = NULL;
136         u32 found = 0;
137         struct usb_driver *driver = driver_of(intf);
138         struct qmi_wwan_state *info = (void *)&dev->data;
139
140         BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state)));
141
142         /* set up initial state */
143         info->control = intf;
144         info->data = intf;
145
146         /* and a number of CDC descriptors */
147         while (len > 3) {
148                 struct usb_descriptor_header *h = (void *)buf;
149
150                 /* ignore any misplaced descriptors */
151                 if (h->bDescriptorType != USB_DT_CS_INTERFACE)
152                         goto next_desc;
153
154                 /* buf[2] is CDC descriptor subtype */
155                 switch (buf[2]) {
156                 case USB_CDC_HEADER_TYPE:
157                         if (found & 1 << USB_CDC_HEADER_TYPE) {
158                                 dev_dbg(&intf->dev, "extra CDC header\n");
159                                 goto err;
160                         }
161                         if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
162                                 dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
163                                 goto err;
164                         }
165                         break;
166                 case USB_CDC_UNION_TYPE:
167                         if (found & 1 << USB_CDC_UNION_TYPE) {
168                                 dev_dbg(&intf->dev, "extra CDC union\n");
169                                 goto err;
170                         }
171                         if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
172                                 dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
173                                 goto err;
174                         }
175                         cdc_union = (struct usb_cdc_union_desc *)buf;
176                         break;
177                 case USB_CDC_ETHERNET_TYPE:
178                         if (found & 1 << USB_CDC_ETHERNET_TYPE) {
179                                 dev_dbg(&intf->dev, "extra CDC ether\n");
180                                 goto err;
181                         }
182                         if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
183                                 dev_dbg(&intf->dev, "CDC ether len %u\n",  h->bLength);
184                                 goto err;
185                         }
186                         cdc_ether = (struct usb_cdc_ether_desc *)buf;
187                         break;
188                 }
189
190                 /*
191                  * Remember which CDC functional descriptors we've seen.  Works
192                  * for all types we care about, of which USB_CDC_ETHERNET_TYPE
193                  * (0x0f) is the highest numbered
194                  */
195                 if (buf[2] < 32)
196                         found |= 1 << buf[2];
197
198 next_desc:
199                 len -= h->bLength;
200                 buf += h->bLength;
201         }
202
203         /* Use separate control and data interfaces if we found a CDC Union */
204         if (cdc_union) {
205                 info->data = usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0);
206                 if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 || !info->data) {
207                         dev_err(&intf->dev, "bogus CDC Union: master=%u, slave=%u\n",
208                                 cdc_union->bMasterInterface0, cdc_union->bSlaveInterface0);
209                         goto err;
210                 }
211         }
212
213         /* errors aren't fatal - we can live with the dynamic address */
214         if (cdc_ether) {
215                 dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
216                 usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
217         }
218
219         /* claim data interface and set it up */
220         if (info->control != info->data) {
221                 status = usb_driver_claim_interface(driver, info->data, dev);
222                 if (status < 0)
223                         goto err;
224         }
225
226         status = qmi_wwan_register_subdriver(dev);
227         if (status < 0 && info->control != info->data) {
228                 usb_set_intfdata(info->data, NULL);
229                 usb_driver_release_interface(driver, info->data);
230         }
231
232 err:
233         return status;
234 }
235
236 static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
237 {
238         struct qmi_wwan_state *info = (void *)&dev->data;
239         struct usb_driver *driver = driver_of(intf);
240         struct usb_interface *other;
241
242         if (info->subdriver && info->subdriver->disconnect)
243                 info->subdriver->disconnect(info->control);
244
245         /* allow user to unbind using either control or data */
246         if (intf == info->control)
247                 other = info->data;
248         else
249                 other = info->control;
250
251         /* only if not shared */
252         if (other && intf != other) {
253                 usb_set_intfdata(other, NULL);
254                 usb_driver_release_interface(driver, other);
255         }
256
257         info->subdriver = NULL;
258         info->data = NULL;
259         info->control = NULL;
260 }
261
262 /* suspend/resume wrappers calling both usbnet and the cdc-wdm
263  * subdriver if present.
264  *
265  * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
266  * wrappers for those without adding usbnet reset support first.
267  */
268 static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
269 {
270         struct usbnet *dev = usb_get_intfdata(intf);
271         struct qmi_wwan_state *info = (void *)&dev->data;
272         int ret;
273
274         /*
275          * Both usbnet_suspend() and subdriver->suspend() MUST return 0
276          * in system sleep context, otherwise, the resume callback has
277          * to recover device from previous suspend failure.
278          */
279         ret = usbnet_suspend(intf, message);
280         if (ret < 0)
281                 goto err;
282
283         if (intf == info->control && info->subdriver && info->subdriver->suspend)
284                 ret = info->subdriver->suspend(intf, message);
285         if (ret < 0)
286                 usbnet_resume(intf);
287 err:
288         return ret;
289 }
290
291 static int qmi_wwan_resume(struct usb_interface *intf)
292 {
293         struct usbnet *dev = usb_get_intfdata(intf);
294         struct qmi_wwan_state *info = (void *)&dev->data;
295         int ret = 0;
296         bool callsub = (intf == info->control && info->subdriver && info->subdriver->resume);
297
298         if (callsub)
299                 ret = info->subdriver->resume(intf);
300         if (ret < 0)
301                 goto err;
302         ret = usbnet_resume(intf);
303         if (ret < 0 && callsub && info->subdriver->suspend)
304                 info->subdriver->suspend(intf, PMSG_SUSPEND);
305 err:
306         return ret;
307 }
308
309 static const struct driver_info qmi_wwan_info = {
310         .description    = "WWAN/QMI device",
311         .flags          = FLAG_WWAN,
312         .bind           = qmi_wwan_bind,
313         .unbind         = qmi_wwan_unbind,
314         .manage_power   = qmi_wwan_manage_power,
315 };
316
317 #define HUAWEI_VENDOR_ID        0x12D1
318
319 /* map QMI/wwan function by a fixed interface number */
320 #define QMI_FIXED_INTF(vend, prod, num) \
321         USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
322         .driver_info = (unsigned long)&qmi_wwan_info
323
324 /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
325 #define QMI_GOBI1K_DEVICE(vend, prod) \
326         QMI_FIXED_INTF(vend, prod, 3)
327
328 /* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
329 #define QMI_GOBI_DEVICE(vend, prod) \
330         QMI_FIXED_INTF(vend, prod, 0)
331
332 static const struct usb_device_id products[] = {
333         /* 1. CDC ECM like devices match on the control interface */
334         {       /* Huawei E392, E398 and possibly others sharing both device id and more... */
335                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
336                 .driver_info        = (unsigned long)&qmi_wwan_info,
337         },
338         {       /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
339                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
340                 .driver_info        = (unsigned long)&qmi_wwan_info,
341         },
342         {       /* HUAWEI_INTERFACE_NDIS_CONTROL_QUALCOMM */
343                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69),
344                 .driver_info        = (unsigned long)&qmi_wwan_info,
345         },
346
347         /* 2. Combined interface devices matching on class+protocol */
348         {       /* Huawei E367 and possibly others in "Windows mode" */
349                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
350                 .driver_info        = (unsigned long)&qmi_wwan_info,
351         },
352         {       /* Huawei E392, E398 and possibly others in "Windows mode" */
353                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
354                 .driver_info        = (unsigned long)&qmi_wwan_info,
355         },
356         {       /* HUAWEI_NDIS_SINGLE_INTERFACE_VDF */
357                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x37),
358                 .driver_info        = (unsigned long)&qmi_wwan_info,
359         },
360         {       /* HUAWEI_INTERFACE_NDIS_HW_QUALCOMM */
361                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x67),
362                 .driver_info        = (unsigned long)&qmi_wwan_info,
363         },
364         {       /* Pantech UML290, P4200 and more */
365                 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
366                 .driver_info        = (unsigned long)&qmi_wwan_info,
367         },
368         {       /* Pantech UML290 - newer firmware */
369                 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
370                 .driver_info        = (unsigned long)&qmi_wwan_info,
371         },
372         {       /* Novatel USB551L and MC551 */
373                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
374                                               USB_CLASS_COMM,
375                                               USB_CDC_SUBCLASS_ETHERNET,
376                                               USB_CDC_PROTO_NONE),
377                 .driver_info        = (unsigned long)&qmi_wwan_info,
378         },
379         {       /* Novatel E362 */
380                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
381                                               USB_CLASS_COMM,
382                                               USB_CDC_SUBCLASS_ETHERNET,
383                                               USB_CDC_PROTO_NONE),
384                 .driver_info        = (unsigned long)&qmi_wwan_info,
385         },
386         {       /* Dell Wireless 5800 (Novatel E362) */
387                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
388                                               USB_CLASS_COMM,
389                                               USB_CDC_SUBCLASS_ETHERNET,
390                                               USB_CDC_PROTO_NONE),
391                 .driver_info        = (unsigned long)&qmi_wwan_info,
392         },
393         {       /* Dell Wireless 5800 V2 (Novatel E362) */
394                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
395                                               USB_CLASS_COMM,
396                                               USB_CDC_SUBCLASS_ETHERNET,
397                                               USB_CDC_PROTO_NONE),
398                 .driver_info        = (unsigned long)&qmi_wwan_info,
399         },
400         {       /* ADU960S */
401                 USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
402                                               USB_CLASS_COMM,
403                                               USB_CDC_SUBCLASS_ETHERNET,
404                                               USB_CDC_PROTO_NONE),
405                 .driver_info        = (unsigned long)&qmi_wwan_info,
406         },
407
408         /* 3. Combined interface devices matching on interface number */
409         {QMI_FIXED_INTF(0x0408, 0xea42, 4)},    /* Yota / Megafon M100-1 */
410         {QMI_FIXED_INTF(0x12d1, 0x140c, 1)},    /* Huawei E173 */
411         {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
412         {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
413         {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
414         {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
415         {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
416         {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
417         {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
418         {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
419         {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
420         {QMI_FIXED_INTF(0x19d2, 0x0055, 1)},    /* ZTE (Vodafone) K3520-Z */
421         {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
422         {QMI_FIXED_INTF(0x19d2, 0x0063, 4)},    /* ZTE (Vodafone) K3565-Z */
423         {QMI_FIXED_INTF(0x19d2, 0x0104, 4)},    /* ZTE (Vodafone) K4505-Z */
424         {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
425         {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
426         {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
427         {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
428         {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
429         {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
430         {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
431         {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
432         {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
433         {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
434         {QMI_FIXED_INTF(0x19d2, 0x0157, 5)},    /* ZTE MF683 */
435         {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
436         {QMI_FIXED_INTF(0x19d2, 0x0167, 4)},    /* ZTE MF820D */
437         {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
438         {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
439         {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
440         {QMI_FIXED_INTF(0x19d2, 0x0191, 4)},    /* ZTE EuFi890 */
441         {QMI_FIXED_INTF(0x19d2, 0x0199, 1)},    /* ZTE MF820S */
442         {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
443         {QMI_FIXED_INTF(0x19d2, 0x0257, 3)},    /* ZTE MF821 */
444         {QMI_FIXED_INTF(0x19d2, 0x0265, 4)},    /* ONDA MT8205 4G LTE */
445         {QMI_FIXED_INTF(0x19d2, 0x0284, 4)},    /* ZTE MF880 */
446         {QMI_FIXED_INTF(0x19d2, 0x0326, 4)},    /* ZTE MF821D */
447         {QMI_FIXED_INTF(0x19d2, 0x1008, 4)},    /* ZTE (Vodafone) K3570-Z */
448         {QMI_FIXED_INTF(0x19d2, 0x1010, 4)},    /* ZTE (Vodafone) K3571-Z */
449         {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
450         {QMI_FIXED_INTF(0x19d2, 0x1018, 3)},    /* ZTE (Vodafone) K5006-Z */
451         {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
452         {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
453         {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
454         {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
455         {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
456         {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
457         {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
458         {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
459         {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
460         {QMI_FIXED_INTF(0x19d2, 0x1402, 2)},    /* ZTE MF60 */
461         {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
462         {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
463         {QMI_FIXED_INTF(0x19d2, 0x1426, 2)},    /* ZTE MF91 */
464         {QMI_FIXED_INTF(0x19d2, 0x2002, 4)},    /* ZTE (Vodafone) K3765-Z */
465         {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
466         {QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
467         {QMI_FIXED_INTF(0x1199, 0x68a2, 8)},    /* Sierra Wireless MC7710 in QMI mode */
468         {QMI_FIXED_INTF(0x1199, 0x68a2, 19)},   /* Sierra Wireless MC7710 in QMI mode */
469         {QMI_FIXED_INTF(0x1199, 0x901c, 8)},    /* Sierra Wireless EM7700 */
470         {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},    /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
471         {QMI_FIXED_INTF(0x2357, 0x0201, 4)},    /* TP-LINK HSUPA Modem MA180 */
472         {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},    /* Telit LE920 */
473
474         /* 4. Gobi 1000 devices */
475         {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},    /* Acer Gobi Modem Device */
476         {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)},    /* HP un2400 Gobi Modem Device */
477         {QMI_GOBI1K_DEVICE(0x04da, 0x250d)},    /* Panasonic Gobi Modem device */
478         {QMI_GOBI1K_DEVICE(0x413c, 0x8172)},    /* Dell Gobi Modem device */
479         {QMI_GOBI1K_DEVICE(0x1410, 0xa001)},    /* Novatel Gobi Modem device */
480         {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)},    /* Asus Gobi Modem device */
481         {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)},    /* ONDA Gobi Modem device */
482         {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)},    /* Generic Gobi Modem device */
483         {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)},    /* Generic Gobi Modem device */
484         {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)},    /* Generic Gobi Modem device */
485         {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)},    /* Generic Gobi Modem device */
486         {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)},    /* Generic Gobi Modem device */
487         {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)},    /* Generic Gobi Modem device */
488
489         /* 5. Gobi 2000 and 3000 devices */
490         {QMI_GOBI_DEVICE(0x413c, 0x8186)},      /* Dell Gobi 2000 Modem device (N0218, VU936) */
491         {QMI_GOBI_DEVICE(0x413c, 0x8194)},      /* Dell Gobi 3000 Composite */
492         {QMI_GOBI_DEVICE(0x05c6, 0x920b)},      /* Generic Gobi 2000 Modem device */
493         {QMI_GOBI_DEVICE(0x05c6, 0x920d)},      /* Gobi 3000 Composite */
494         {QMI_GOBI_DEVICE(0x05c6, 0x9225)},      /* Sony Gobi 2000 Modem device (N0279, VU730) */
495         {QMI_GOBI_DEVICE(0x05c6, 0x9245)},      /* Samsung Gobi 2000 Modem device (VL176) */
496         {QMI_GOBI_DEVICE(0x03f0, 0x251d)},      /* HP Gobi 2000 Modem device (VP412) */
497         {QMI_GOBI_DEVICE(0x05c6, 0x9215)},      /* Acer Gobi 2000 Modem device (VP413) */
498         {QMI_GOBI_DEVICE(0x05c6, 0x9265)},      /* Asus Gobi 2000 Modem device (VR305) */
499         {QMI_GOBI_DEVICE(0x05c6, 0x9235)},      /* Top Global Gobi 2000 Modem device (VR306) */
500         {QMI_GOBI_DEVICE(0x05c6, 0x9275)},      /* iRex Technologies Gobi 2000 Modem device (VR307) */
501         {QMI_GOBI_DEVICE(0x1199, 0x68a5)},      /* Sierra Wireless Modem */
502         {QMI_GOBI_DEVICE(0x1199, 0x68a9)},      /* Sierra Wireless Modem */
503         {QMI_GOBI_DEVICE(0x1199, 0x9001)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
504         {QMI_GOBI_DEVICE(0x1199, 0x9002)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
505         {QMI_GOBI_DEVICE(0x1199, 0x9003)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
506         {QMI_GOBI_DEVICE(0x1199, 0x9004)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
507         {QMI_GOBI_DEVICE(0x1199, 0x9005)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
508         {QMI_GOBI_DEVICE(0x1199, 0x9006)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
509         {QMI_GOBI_DEVICE(0x1199, 0x9007)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
510         {QMI_GOBI_DEVICE(0x1199, 0x9008)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
511         {QMI_GOBI_DEVICE(0x1199, 0x9009)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
512         {QMI_GOBI_DEVICE(0x1199, 0x900a)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
513         {QMI_GOBI_DEVICE(0x1199, 0x9011)},      /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
514         {QMI_FIXED_INTF(0x1199, 0x9011, 5)},    /* alternate interface number!? */
515         {QMI_GOBI_DEVICE(0x16d8, 0x8002)},      /* CMDTech Gobi 2000 Modem device (VU922) */
516         {QMI_GOBI_DEVICE(0x05c6, 0x9205)},      /* Gobi 2000 Modem device */
517         {QMI_GOBI_DEVICE(0x1199, 0x9013)},      /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
518         {QMI_GOBI_DEVICE(0x03f0, 0x371d)},      /* HP un2430 Mobile Broadband Module */
519         {QMI_GOBI_DEVICE(0x1199, 0x9015)},      /* Sierra Wireless Gobi 3000 Modem device */
520         {QMI_GOBI_DEVICE(0x1199, 0x9019)},      /* Sierra Wireless Gobi 3000 Modem device */
521         {QMI_GOBI_DEVICE(0x1199, 0x901b)},      /* Sierra Wireless MC7770 */
522         {QMI_GOBI_DEVICE(0x12d1, 0x14f1)},      /* Sony Gobi 3000 Composite */
523         {QMI_GOBI_DEVICE(0x1410, 0xa021)},      /* Foxconn Gobi 3000 Modem device (Novatel E396) */
524
525         { }                                     /* END */
526 };
527 MODULE_DEVICE_TABLE(usb, products);
528
529 static int qmi_wwan_probe(struct usb_interface *intf, const struct usb_device_id *prod)
530 {
531         struct usb_device_id *id = (struct usb_device_id *)prod;
532
533         /* Workaround to enable dynamic IDs.  This disables usbnet
534          * blacklisting functionality.  Which, if required, can be
535          * reimplemented here by using a magic "blacklist" value
536          * instead of 0 in the static device id table
537          */
538         if (!id->driver_info) {
539                 dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
540                 id->driver_info = (unsigned long)&qmi_wwan_info;
541         }
542
543         return usbnet_probe(intf, id);
544 }
545
546 static struct usb_driver qmi_wwan_driver = {
547         .name                 = "qmi_wwan",
548         .id_table             = products,
549         .probe                = qmi_wwan_probe,
550         .disconnect           = usbnet_disconnect,
551         .suspend              = qmi_wwan_suspend,
552         .resume               = qmi_wwan_resume,
553         .reset_resume         = qmi_wwan_resume,
554         .supports_autosuspend = 1,
555         .disable_hub_initiated_lpm = 1,
556 };
557
558 module_usb_driver(qmi_wwan_driver);
559
560 MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
561 MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
562 MODULE_LICENSE("GPL");