cff0bbdd9f52558c579b2b0c5701b04b19ac173c
[projects/modsched/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/etherdevice.h>
17 #include <linux/mii.h>
18 #include <linux/usb.h>
19 #include <linux/usb/cdc.h>
20 #include <linux/usb/usbnet.h>
21 #include <linux/usb/cdc-wdm.h>
22
23 /* This driver supports wwan (3G/LTE/?) devices using a vendor
24  * specific management protocol called Qualcomm MSM Interface (QMI) -
25  * in addition to the more common AT commands over serial interface
26  * management
27  *
28  * QMI is wrapped in CDC, using CDC encapsulated commands on the
29  * control ("master") interface of a two-interface CDC Union
30  * resembling standard CDC ECM.  The devices do not use the control
31  * interface for any other CDC messages.  Most likely because the
32  * management protocol is used in place of the standard CDC
33  * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
34  *
35  * Alternatively, control and data functions can be combined in a
36  * single USB interface.
37  *
38  * Handling a protocol like QMI is out of the scope for any driver.
39  * It is exported as a character device using the cdc-wdm driver as
40  * a subdriver, enabling userspace applications ("modem managers") to
41  * handle it.
42  *
43  * These devices may alternatively/additionally be configured using AT
44  * commands on a serial interface
45  */
46
47 /* driver specific data */
48 struct qmi_wwan_state {
49         struct usb_driver *subdriver;
50         atomic_t pmcount;
51         unsigned long unused;
52         struct usb_interface *control;
53         struct usb_interface *data;
54 };
55
56 /* Make up an ethernet header if the packet doesn't have one.
57  *
58  * A firmware bug common among several devices cause them to send raw
59  * IP packets under some circumstances.  There is no way for the
60  * driver/host to know when this will happen.  And even when the bug
61  * hits, some packets will still arrive with an intact header.
62  *
63  * The supported devices are only capably of sending IPv4, IPv6 and
64  * ARP packets on a point-to-point link. Any packet with an ethernet
65  * header will have either our address or a broadcast/multicast
66  * address as destination.  ARP packets will always have a header.
67  *
68  * This means that this function will reliably add the appropriate
69  * header iff necessary, provided our hardware address does not start
70  * with 4 or 6.
71  *
72  * Another common firmware bug results in all packets being addressed
73  * to 00:a0:c6:00:00:00 despite the host address being different.
74  * This function will also fixup such packets.
75  */
76 static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
77 {
78         __be16 proto;
79
80         /* usbnet rx_complete guarantees that skb->len is at least
81          * hard_header_len, so we can inspect the dest address without
82          * checking skb->len
83          */
84         switch (skb->data[0] & 0xf0) {
85         case 0x40:
86                 proto = htons(ETH_P_IP);
87                 break;
88         case 0x60:
89                 proto = htons(ETH_P_IPV6);
90                 break;
91         case 0x00:
92                 if (is_multicast_ether_addr(skb->data))
93                         return 1;
94                 /* possibly bogus destination - rewrite just in case */
95                 skb_reset_mac_header(skb);
96                 goto fix_dest;
97         default:
98                 /* pass along other packets without modifications */
99                 return 1;
100         }
101         if (skb_headroom(skb) < ETH_HLEN)
102                 return 0;
103         skb_push(skb, ETH_HLEN);
104         skb_reset_mac_header(skb);
105         eth_hdr(skb)->h_proto = proto;
106         memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
107 fix_dest:
108         memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
109         return 1;
110 }
111
112 /* very simplistic detection of IPv4 or IPv6 headers */
113 static bool possibly_iphdr(const char *data)
114 {
115         return (data[0] & 0xd0) == 0x40;
116 }
117
118 /* disallow addresses which may be confused with IP headers */
119 static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
120 {
121         int ret;
122         struct sockaddr *addr = p;
123
124         ret = eth_prepare_mac_addr_change(dev, p);
125         if (ret < 0)
126                 return ret;
127         if (possibly_iphdr(addr->sa_data))
128                 return -EADDRNOTAVAIL;
129         eth_commit_mac_addr_change(dev, p);
130         return 0;
131 }
132
133 static const struct net_device_ops qmi_wwan_netdev_ops = {
134         .ndo_open               = usbnet_open,
135         .ndo_stop               = usbnet_stop,
136         .ndo_start_xmit         = usbnet_start_xmit,
137         .ndo_tx_timeout         = usbnet_tx_timeout,
138         .ndo_change_mtu         = usbnet_change_mtu,
139         .ndo_set_mac_address    = qmi_wwan_mac_addr,
140         .ndo_validate_addr      = eth_validate_addr,
141 };
142
143 /* using a counter to merge subdriver requests with our own into a combined state */
144 static int qmi_wwan_manage_power(struct usbnet *dev, int on)
145 {
146         struct qmi_wwan_state *info = (void *)&dev->data;
147         int rv = 0;
148
149         dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on);
150
151         if ((on && atomic_add_return(1, &info->pmcount) == 1) || (!on && atomic_dec_and_test(&info->pmcount))) {
152                 /* need autopm_get/put here to ensure the usbcore sees the new value */
153                 rv = usb_autopm_get_interface(dev->intf);
154                 if (rv < 0)
155                         goto err;
156                 dev->intf->needs_remote_wakeup = on;
157                 usb_autopm_put_interface(dev->intf);
158         }
159 err:
160         return rv;
161 }
162
163 static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
164 {
165         struct usbnet *dev = usb_get_intfdata(intf);
166
167         /* can be called while disconnecting */
168         if (!dev)
169                 return 0;
170         return qmi_wwan_manage_power(dev, on);
171 }
172
173 /* collect all three endpoints and register subdriver */
174 static int qmi_wwan_register_subdriver(struct usbnet *dev)
175 {
176         int rv;
177         struct usb_driver *subdriver = NULL;
178         struct qmi_wwan_state *info = (void *)&dev->data;
179
180         /* collect bulk endpoints */
181         rv = usbnet_get_endpoints(dev, info->data);
182         if (rv < 0)
183                 goto err;
184
185         /* update status endpoint if separate control interface */
186         if (info->control != info->data)
187                 dev->status = &info->control->cur_altsetting->endpoint[0];
188
189         /* require interrupt endpoint for subdriver */
190         if (!dev->status) {
191                 rv = -EINVAL;
192                 goto err;
193         }
194
195         /* for subdriver power management */
196         atomic_set(&info->pmcount, 0);
197
198         /* register subdriver */
199         subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 4096, &qmi_wwan_cdc_wdm_manage_power);
200         if (IS_ERR(subdriver)) {
201                 dev_err(&info->control->dev, "subdriver registration failed\n");
202                 rv = PTR_ERR(subdriver);
203                 goto err;
204         }
205
206         /* prevent usbnet from using status endpoint */
207         dev->status = NULL;
208
209         /* save subdriver struct for suspend/resume wrappers */
210         info->subdriver = subdriver;
211
212 err:
213         return rv;
214 }
215
216 static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
217 {
218         int status = -1;
219         u8 *buf = intf->cur_altsetting->extra;
220         int len = intf->cur_altsetting->extralen;
221         struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
222         struct usb_cdc_union_desc *cdc_union = NULL;
223         struct usb_cdc_ether_desc *cdc_ether = NULL;
224         u32 found = 0;
225         struct usb_driver *driver = driver_of(intf);
226         struct qmi_wwan_state *info = (void *)&dev->data;
227
228         BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state)));
229
230         /* set up initial state */
231         info->control = intf;
232         info->data = intf;
233
234         /* and a number of CDC descriptors */
235         while (len > 3) {
236                 struct usb_descriptor_header *h = (void *)buf;
237
238                 /* ignore any misplaced descriptors */
239                 if (h->bDescriptorType != USB_DT_CS_INTERFACE)
240                         goto next_desc;
241
242                 /* buf[2] is CDC descriptor subtype */
243                 switch (buf[2]) {
244                 case USB_CDC_HEADER_TYPE:
245                         if (found & 1 << USB_CDC_HEADER_TYPE) {
246                                 dev_dbg(&intf->dev, "extra CDC header\n");
247                                 goto err;
248                         }
249                         if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
250                                 dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
251                                 goto err;
252                         }
253                         break;
254                 case USB_CDC_UNION_TYPE:
255                         if (found & 1 << USB_CDC_UNION_TYPE) {
256                                 dev_dbg(&intf->dev, "extra CDC union\n");
257                                 goto err;
258                         }
259                         if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
260                                 dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
261                                 goto err;
262                         }
263                         cdc_union = (struct usb_cdc_union_desc *)buf;
264                         break;
265                 case USB_CDC_ETHERNET_TYPE:
266                         if (found & 1 << USB_CDC_ETHERNET_TYPE) {
267                                 dev_dbg(&intf->dev, "extra CDC ether\n");
268                                 goto err;
269                         }
270                         if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
271                                 dev_dbg(&intf->dev, "CDC ether len %u\n",  h->bLength);
272                                 goto err;
273                         }
274                         cdc_ether = (struct usb_cdc_ether_desc *)buf;
275                         break;
276                 }
277
278                 /*
279                  * Remember which CDC functional descriptors we've seen.  Works
280                  * for all types we care about, of which USB_CDC_ETHERNET_TYPE
281                  * (0x0f) is the highest numbered
282                  */
283                 if (buf[2] < 32)
284                         found |= 1 << buf[2];
285
286 next_desc:
287                 len -= h->bLength;
288                 buf += h->bLength;
289         }
290
291         /* Use separate control and data interfaces if we found a CDC Union */
292         if (cdc_union) {
293                 info->data = usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0);
294                 if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 || !info->data) {
295                         dev_err(&intf->dev, "bogus CDC Union: master=%u, slave=%u\n",
296                                 cdc_union->bMasterInterface0, cdc_union->bSlaveInterface0);
297                         goto err;
298                 }
299         }
300
301         /* errors aren't fatal - we can live with the dynamic address */
302         if (cdc_ether) {
303                 dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
304                 usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
305         }
306
307         /* claim data interface and set it up */
308         if (info->control != info->data) {
309                 status = usb_driver_claim_interface(driver, info->data, dev);
310                 if (status < 0)
311                         goto err;
312         }
313
314         status = qmi_wwan_register_subdriver(dev);
315         if (status < 0 && info->control != info->data) {
316                 usb_set_intfdata(info->data, NULL);
317                 usb_driver_release_interface(driver, info->data);
318         }
319
320         /* make MAC addr easily distinguishable from an IP header */
321         if (possibly_iphdr(dev->net->dev_addr)) {
322                 dev->net->dev_addr[0] |= 0x02;  /* set local assignment bit */
323                 dev->net->dev_addr[0] &= 0xbf;  /* clear "IP" bit */
324         }
325         dev->net->netdev_ops = &qmi_wwan_netdev_ops;
326 err:
327         return status;
328 }
329
330 static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
331 {
332         struct qmi_wwan_state *info = (void *)&dev->data;
333         struct usb_driver *driver = driver_of(intf);
334         struct usb_interface *other;
335
336         if (info->subdriver && info->subdriver->disconnect)
337                 info->subdriver->disconnect(info->control);
338
339         /* allow user to unbind using either control or data */
340         if (intf == info->control)
341                 other = info->data;
342         else
343                 other = info->control;
344
345         /* only if not shared */
346         if (other && intf != other) {
347                 usb_set_intfdata(other, NULL);
348                 usb_driver_release_interface(driver, other);
349         }
350
351         info->subdriver = NULL;
352         info->data = NULL;
353         info->control = NULL;
354 }
355
356 /* suspend/resume wrappers calling both usbnet and the cdc-wdm
357  * subdriver if present.
358  *
359  * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
360  * wrappers for those without adding usbnet reset support first.
361  */
362 static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
363 {
364         struct usbnet *dev = usb_get_intfdata(intf);
365         struct qmi_wwan_state *info = (void *)&dev->data;
366         int ret;
367
368         ret = usbnet_suspend(intf, message);
369         if (ret < 0)
370                 goto err;
371
372         if (intf == info->control && info->subdriver && info->subdriver->suspend)
373                 ret = info->subdriver->suspend(intf, message);
374         if (ret < 0)
375                 usbnet_resume(intf);
376 err:
377         return ret;
378 }
379
380 static int qmi_wwan_resume(struct usb_interface *intf)
381 {
382         struct usbnet *dev = usb_get_intfdata(intf);
383         struct qmi_wwan_state *info = (void *)&dev->data;
384         int ret = 0;
385         bool callsub = (intf == info->control && info->subdriver && info->subdriver->resume);
386
387         if (callsub)
388                 ret = info->subdriver->resume(intf);
389         if (ret < 0)
390                 goto err;
391         ret = usbnet_resume(intf);
392         if (ret < 0 && callsub && info->subdriver->suspend)
393                 info->subdriver->suspend(intf, PMSG_SUSPEND);
394 err:
395         return ret;
396 }
397
398 static const struct driver_info qmi_wwan_info = {
399         .description    = "WWAN/QMI device",
400         .flags          = FLAG_WWAN,
401         .bind           = qmi_wwan_bind,
402         .unbind         = qmi_wwan_unbind,
403         .manage_power   = qmi_wwan_manage_power,
404         .rx_fixup       = qmi_wwan_rx_fixup,
405 };
406
407 #define HUAWEI_VENDOR_ID        0x12D1
408
409 /* map QMI/wwan function by a fixed interface number */
410 #define QMI_FIXED_INTF(vend, prod, num) \
411         USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
412         .driver_info = (unsigned long)&qmi_wwan_info
413
414 /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
415 #define QMI_GOBI1K_DEVICE(vend, prod) \
416         QMI_FIXED_INTF(vend, prod, 3)
417
418 /* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
419 #define QMI_GOBI_DEVICE(vend, prod) \
420         QMI_FIXED_INTF(vend, prod, 0)
421
422 static const struct usb_device_id products[] = {
423         /* 1. CDC ECM like devices match on the control interface */
424         {       /* Huawei E392, E398 and possibly others sharing both device id and more... */
425                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
426                 .driver_info        = (unsigned long)&qmi_wwan_info,
427         },
428         {       /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
429                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
430                 .driver_info        = (unsigned long)&qmi_wwan_info,
431         },
432         {       /* HUAWEI_INTERFACE_NDIS_CONTROL_QUALCOMM */
433                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69),
434                 .driver_info        = (unsigned long)&qmi_wwan_info,
435         },
436
437         /* 2. Combined interface devices matching on class+protocol */
438         {       /* Huawei E367 and possibly others in "Windows mode" */
439                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
440                 .driver_info        = (unsigned long)&qmi_wwan_info,
441         },
442         {       /* Huawei E392, E398 and possibly others in "Windows mode" */
443                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
444                 .driver_info        = (unsigned long)&qmi_wwan_info,
445         },
446         {       /* HUAWEI_NDIS_SINGLE_INTERFACE_VDF */
447                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x37),
448                 .driver_info        = (unsigned long)&qmi_wwan_info,
449         },
450         {       /* HUAWEI_INTERFACE_NDIS_HW_QUALCOMM */
451                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x67),
452                 .driver_info        = (unsigned long)&qmi_wwan_info,
453         },
454         {       /* Pantech UML290, P4200 and more */
455                 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
456                 .driver_info        = (unsigned long)&qmi_wwan_info,
457         },
458         {       /* Pantech UML290 - newer firmware */
459                 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
460                 .driver_info        = (unsigned long)&qmi_wwan_info,
461         },
462         {       /* Novatel USB551L and MC551 */
463                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
464                                               USB_CLASS_COMM,
465                                               USB_CDC_SUBCLASS_ETHERNET,
466                                               USB_CDC_PROTO_NONE),
467                 .driver_info        = (unsigned long)&qmi_wwan_info,
468         },
469         {       /* Novatel E362 */
470                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
471                                               USB_CLASS_COMM,
472                                               USB_CDC_SUBCLASS_ETHERNET,
473                                               USB_CDC_PROTO_NONE),
474                 .driver_info        = (unsigned long)&qmi_wwan_info,
475         },
476         {       /* Dell Wireless 5800 (Novatel E362) */
477                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
478                                               USB_CLASS_COMM,
479                                               USB_CDC_SUBCLASS_ETHERNET,
480                                               USB_CDC_PROTO_NONE),
481                 .driver_info        = (unsigned long)&qmi_wwan_info,
482         },
483         {       /* Dell Wireless 5800 V2 (Novatel E362) */
484                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
485                                               USB_CLASS_COMM,
486                                               USB_CDC_SUBCLASS_ETHERNET,
487                                               USB_CDC_PROTO_NONE),
488                 .driver_info        = (unsigned long)&qmi_wwan_info,
489         },
490         {       /* ADU960S */
491                 USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
492                                               USB_CLASS_COMM,
493                                               USB_CDC_SUBCLASS_ETHERNET,
494                                               USB_CDC_PROTO_NONE),
495                 .driver_info        = (unsigned long)&qmi_wwan_info,
496         },
497
498         /* 3. Combined interface devices matching on interface number */
499         {QMI_FIXED_INTF(0x0408, 0xea42, 4)},    /* Yota / Megafon M100-1 */
500         {QMI_FIXED_INTF(0x12d1, 0x140c, 1)},    /* Huawei E173 */
501         {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
502         {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
503         {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
504         {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
505         {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
506         {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
507         {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
508         {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
509         {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
510         {QMI_FIXED_INTF(0x19d2, 0x0055, 1)},    /* ZTE (Vodafone) K3520-Z */
511         {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
512         {QMI_FIXED_INTF(0x19d2, 0x0063, 4)},    /* ZTE (Vodafone) K3565-Z */
513         {QMI_FIXED_INTF(0x19d2, 0x0104, 4)},    /* ZTE (Vodafone) K4505-Z */
514         {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
515         {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
516         {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
517         {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
518         {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
519         {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
520         {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
521         {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
522         {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
523         {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
524         {QMI_FIXED_INTF(0x19d2, 0x0157, 5)},    /* ZTE MF683 */
525         {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
526         {QMI_FIXED_INTF(0x19d2, 0x0167, 4)},    /* ZTE MF820D */
527         {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
528         {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
529         {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
530         {QMI_FIXED_INTF(0x19d2, 0x0191, 4)},    /* ZTE EuFi890 */
531         {QMI_FIXED_INTF(0x19d2, 0x0199, 1)},    /* ZTE MF820S */
532         {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
533         {QMI_FIXED_INTF(0x19d2, 0x0257, 3)},    /* ZTE MF821 */
534         {QMI_FIXED_INTF(0x19d2, 0x0265, 4)},    /* ONDA MT8205 4G LTE */
535         {QMI_FIXED_INTF(0x19d2, 0x0284, 4)},    /* ZTE MF880 */
536         {QMI_FIXED_INTF(0x19d2, 0x0326, 4)},    /* ZTE MF821D */
537         {QMI_FIXED_INTF(0x19d2, 0x1008, 4)},    /* ZTE (Vodafone) K3570-Z */
538         {QMI_FIXED_INTF(0x19d2, 0x1010, 4)},    /* ZTE (Vodafone) K3571-Z */
539         {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
540         {QMI_FIXED_INTF(0x19d2, 0x1018, 3)},    /* ZTE (Vodafone) K5006-Z */
541         {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
542         {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
543         {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
544         {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
545         {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
546         {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
547         {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
548         {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
549         {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
550         {QMI_FIXED_INTF(0x19d2, 0x1402, 2)},    /* ZTE MF60 */
551         {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
552         {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
553         {QMI_FIXED_INTF(0x19d2, 0x1426, 2)},    /* ZTE MF91 */
554         {QMI_FIXED_INTF(0x19d2, 0x2002, 4)},    /* ZTE (Vodafone) K3765-Z */
555         {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
556         {QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
557         {QMI_FIXED_INTF(0x1199, 0x68a2, 8)},    /* Sierra Wireless MC7710 in QMI mode */
558         {QMI_FIXED_INTF(0x1199, 0x68a2, 19)},   /* Sierra Wireless MC7710 in QMI mode */
559         {QMI_FIXED_INTF(0x1199, 0x901c, 8)},    /* Sierra Wireless EM7700 */
560         {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},    /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
561         {QMI_FIXED_INTF(0x2357, 0x0201, 4)},    /* TP-LINK HSUPA Modem MA180 */
562         {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},    /* Telit LE920 */
563
564         /* 4. Gobi 1000 devices */
565         {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},    /* Acer Gobi Modem Device */
566         {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)},    /* HP un2400 Gobi Modem Device */
567         {QMI_GOBI1K_DEVICE(0x04da, 0x250d)},    /* Panasonic Gobi Modem device */
568         {QMI_GOBI1K_DEVICE(0x413c, 0x8172)},    /* Dell Gobi Modem device */
569         {QMI_GOBI1K_DEVICE(0x1410, 0xa001)},    /* Novatel Gobi Modem device */
570         {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)},    /* Asus Gobi Modem device */
571         {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)},    /* ONDA Gobi Modem device */
572         {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)},    /* Generic Gobi Modem device */
573         {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)},    /* Generic Gobi Modem device */
574         {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)},    /* Generic Gobi Modem device */
575         {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)},    /* Generic Gobi Modem device */
576         {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)},    /* Generic Gobi Modem device */
577         {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)},    /* Generic Gobi Modem device */
578
579         /* 5. Gobi 2000 and 3000 devices */
580         {QMI_GOBI_DEVICE(0x413c, 0x8186)},      /* Dell Gobi 2000 Modem device (N0218, VU936) */
581         {QMI_GOBI_DEVICE(0x413c, 0x8194)},      /* Dell Gobi 3000 Composite */
582         {QMI_GOBI_DEVICE(0x05c6, 0x920b)},      /* Generic Gobi 2000 Modem device */
583         {QMI_GOBI_DEVICE(0x05c6, 0x920d)},      /* Gobi 3000 Composite */
584         {QMI_GOBI_DEVICE(0x05c6, 0x9225)},      /* Sony Gobi 2000 Modem device (N0279, VU730) */
585         {QMI_GOBI_DEVICE(0x05c6, 0x9245)},      /* Samsung Gobi 2000 Modem device (VL176) */
586         {QMI_GOBI_DEVICE(0x03f0, 0x251d)},      /* HP Gobi 2000 Modem device (VP412) */
587         {QMI_GOBI_DEVICE(0x05c6, 0x9215)},      /* Acer Gobi 2000 Modem device (VP413) */
588         {QMI_GOBI_DEVICE(0x05c6, 0x9265)},      /* Asus Gobi 2000 Modem device (VR305) */
589         {QMI_GOBI_DEVICE(0x05c6, 0x9235)},      /* Top Global Gobi 2000 Modem device (VR306) */
590         {QMI_GOBI_DEVICE(0x05c6, 0x9275)},      /* iRex Technologies Gobi 2000 Modem device (VR307) */
591         {QMI_GOBI_DEVICE(0x1199, 0x68a5)},      /* Sierra Wireless Modem */
592         {QMI_GOBI_DEVICE(0x1199, 0x68a9)},      /* Sierra Wireless Modem */
593         {QMI_GOBI_DEVICE(0x1199, 0x9001)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
594         {QMI_GOBI_DEVICE(0x1199, 0x9002)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
595         {QMI_GOBI_DEVICE(0x1199, 0x9003)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
596         {QMI_GOBI_DEVICE(0x1199, 0x9004)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
597         {QMI_GOBI_DEVICE(0x1199, 0x9005)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
598         {QMI_GOBI_DEVICE(0x1199, 0x9006)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
599         {QMI_GOBI_DEVICE(0x1199, 0x9007)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
600         {QMI_GOBI_DEVICE(0x1199, 0x9008)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
601         {QMI_GOBI_DEVICE(0x1199, 0x9009)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
602         {QMI_GOBI_DEVICE(0x1199, 0x900a)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
603         {QMI_GOBI_DEVICE(0x1199, 0x9011)},      /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
604         {QMI_FIXED_INTF(0x1199, 0x9011, 5)},    /* alternate interface number!? */
605         {QMI_GOBI_DEVICE(0x16d8, 0x8002)},      /* CMDTech Gobi 2000 Modem device (VU922) */
606         {QMI_GOBI_DEVICE(0x05c6, 0x9205)},      /* Gobi 2000 Modem device */
607         {QMI_GOBI_DEVICE(0x1199, 0x9013)},      /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
608         {QMI_GOBI_DEVICE(0x03f0, 0x371d)},      /* HP un2430 Mobile Broadband Module */
609         {QMI_GOBI_DEVICE(0x1199, 0x9015)},      /* Sierra Wireless Gobi 3000 Modem device */
610         {QMI_GOBI_DEVICE(0x1199, 0x9019)},      /* Sierra Wireless Gobi 3000 Modem device */
611         {QMI_GOBI_DEVICE(0x1199, 0x901b)},      /* Sierra Wireless MC7770 */
612         {QMI_GOBI_DEVICE(0x12d1, 0x14f1)},      /* Sony Gobi 3000 Composite */
613         {QMI_GOBI_DEVICE(0x1410, 0xa021)},      /* Foxconn Gobi 3000 Modem device (Novatel E396) */
614
615         { }                                     /* END */
616 };
617 MODULE_DEVICE_TABLE(usb, products);
618
619 static int qmi_wwan_probe(struct usb_interface *intf, const struct usb_device_id *prod)
620 {
621         struct usb_device_id *id = (struct usb_device_id *)prod;
622
623         /* Workaround to enable dynamic IDs.  This disables usbnet
624          * blacklisting functionality.  Which, if required, can be
625          * reimplemented here by using a magic "blacklist" value
626          * instead of 0 in the static device id table
627          */
628         if (!id->driver_info) {
629                 dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
630                 id->driver_info = (unsigned long)&qmi_wwan_info;
631         }
632
633         return usbnet_probe(intf, id);
634 }
635
636 static struct usb_driver qmi_wwan_driver = {
637         .name                 = "qmi_wwan",
638         .id_table             = products,
639         .probe                = qmi_wwan_probe,
640         .disconnect           = usbnet_disconnect,
641         .suspend              = qmi_wwan_suspend,
642         .resume               = qmi_wwan_resume,
643         .reset_resume         = qmi_wwan_resume,
644         .supports_autosuspend = 1,
645         .disable_hub_initiated_lpm = 1,
646 };
647
648 module_usb_driver(qmi_wwan_driver);
649
650 MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
651 MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
652 MODULE_LICENSE("GPL");