net: qmi_wwan: support "raw IP" mode
[platform/kernel/linux-rpi.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/if_arp.h>
18 #include <linux/mii.h>
19 #include <linux/usb.h>
20 #include <linux/usb/cdc.h>
21 #include <linux/usb/usbnet.h>
22 #include <linux/usb/cdc-wdm.h>
23
24 /* This driver supports wwan (3G/LTE/?) devices using a vendor
25  * specific management protocol called Qualcomm MSM Interface (QMI) -
26  * in addition to the more common AT commands over serial interface
27  * management
28  *
29  * QMI is wrapped in CDC, using CDC encapsulated commands on the
30  * control ("master") interface of a two-interface CDC Union
31  * resembling standard CDC ECM.  The devices do not use the control
32  * interface for any other CDC messages.  Most likely because the
33  * management protocol is used in place of the standard CDC
34  * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
35  *
36  * Alternatively, control and data functions can be combined in a
37  * single USB interface.
38  *
39  * Handling a protocol like QMI is out of the scope for any driver.
40  * It is exported as a character device using the cdc-wdm driver as
41  * a subdriver, enabling userspace applications ("modem managers") to
42  * handle it.
43  *
44  * These devices may alternatively/additionally be configured using AT
45  * commands on a serial interface
46  */
47
48 /* driver specific data */
49 struct qmi_wwan_state {
50         struct usb_driver *subdriver;
51         atomic_t pmcount;
52         unsigned long flags;
53         struct usb_interface *control;
54         struct usb_interface *data;
55 };
56
57 enum qmi_wwan_flags {
58         QMI_WWAN_FLAG_RAWIP = 1 << 0,
59 };
60
61 static void qmi_wwan_netdev_setup(struct net_device *net)
62 {
63         struct usbnet *dev = netdev_priv(net);
64         struct qmi_wwan_state *info = (void *)&dev->data;
65
66         if (info->flags & QMI_WWAN_FLAG_RAWIP) {
67                 net->header_ops      = NULL;  /* No header */
68                 net->type            = ARPHRD_NONE;
69                 net->hard_header_len = 0;
70                 net->addr_len        = 0;
71                 net->flags           = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
72                 netdev_dbg(net, "mode: raw IP\n");
73         } else if (!net->header_ops) { /* don't bother if already set */
74                 ether_setup(net);
75                 netdev_dbg(net, "mode: Ethernet\n");
76         }
77
78         /* recalculate buffers after changing hard_header_len */
79         usbnet_change_mtu(net, net->mtu);
80 }
81
82 static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf)
83 {
84         struct usbnet *dev = netdev_priv(to_net_dev(d));
85         struct qmi_wwan_state *info = (void *)&dev->data;
86
87         return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N');
88 }
89
90 static ssize_t raw_ip_store(struct device *d,  struct device_attribute *attr, const char *buf, size_t len)
91 {
92         struct usbnet *dev = netdev_priv(to_net_dev(d));
93         struct qmi_wwan_state *info = (void *)&dev->data;
94         bool enable;
95         int err;
96
97         if (strtobool(buf, &enable))
98                 return -EINVAL;
99
100         /* no change? */
101         if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP))
102                 return len;
103
104         /* we don't want to modify a running netdev */
105         if (netif_running(dev->net)) {
106                 netdev_err(dev->net, "Cannot change a running device\n");
107                 return -EBUSY;
108         }
109
110         /* let other drivers deny the change */
111         err = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net);
112         err = notifier_to_errno(err);
113         if (err) {
114                 netdev_err(dev->net, "Type change was refused\n");
115                 return err;
116         }
117
118         if (enable)
119                 info->flags |= QMI_WWAN_FLAG_RAWIP;
120         else
121                 info->flags &= ~QMI_WWAN_FLAG_RAWIP;
122         qmi_wwan_netdev_setup(dev->net);
123         call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net);
124         return len;
125 }
126
127 static DEVICE_ATTR_RW(raw_ip);
128
129 static struct attribute *qmi_wwan_sysfs_attrs[] = {
130         &dev_attr_raw_ip.attr,
131         NULL,
132 };
133
134 static struct attribute_group qmi_wwan_sysfs_attr_group = {
135         .name = "qmi",
136         .attrs = qmi_wwan_sysfs_attrs,
137 };
138
139 /* default ethernet address used by the modem */
140 static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
141
142 static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
143
144 /* Make up an ethernet header if the packet doesn't have one.
145  *
146  * A firmware bug common among several devices cause them to send raw
147  * IP packets under some circumstances.  There is no way for the
148  * driver/host to know when this will happen.  And even when the bug
149  * hits, some packets will still arrive with an intact header.
150  *
151  * The supported devices are only capably of sending IPv4, IPv6 and
152  * ARP packets on a point-to-point link. Any packet with an ethernet
153  * header will have either our address or a broadcast/multicast
154  * address as destination.  ARP packets will always have a header.
155  *
156  * This means that this function will reliably add the appropriate
157  * header iff necessary, provided our hardware address does not start
158  * with 4 or 6.
159  *
160  * Another common firmware bug results in all packets being addressed
161  * to 00:a0:c6:00:00:00 despite the host address being different.
162  * This function will also fixup such packets.
163  */
164 static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
165 {
166         struct qmi_wwan_state *info = (void *)&dev->data;
167         bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP;
168         __be16 proto;
169
170         /* This check is no longer done by usbnet */
171         if (skb->len < dev->net->hard_header_len)
172                 return 0;
173
174         switch (skb->data[0] & 0xf0) {
175         case 0x40:
176                 proto = htons(ETH_P_IP);
177                 break;
178         case 0x60:
179                 proto = htons(ETH_P_IPV6);
180                 break;
181         case 0x00:
182                 if (rawip)
183                         return 0;
184                 if (is_multicast_ether_addr(skb->data))
185                         return 1;
186                 /* possibly bogus destination - rewrite just in case */
187                 skb_reset_mac_header(skb);
188                 goto fix_dest;
189         default:
190                 if (rawip)
191                         return 0;
192                 /* pass along other packets without modifications */
193                 return 1;
194         }
195         if (rawip) {
196                 skb->dev = dev->net; /* normally set by eth_type_trans */
197                 skb->protocol = proto;
198                 return 1;
199         }
200
201         if (skb_headroom(skb) < ETH_HLEN)
202                 return 0;
203         skb_push(skb, ETH_HLEN);
204         skb_reset_mac_header(skb);
205         eth_hdr(skb)->h_proto = proto;
206         eth_zero_addr(eth_hdr(skb)->h_source);
207 fix_dest:
208         memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
209         return 1;
210 }
211
212 /* very simplistic detection of IPv4 or IPv6 headers */
213 static bool possibly_iphdr(const char *data)
214 {
215         return (data[0] & 0xd0) == 0x40;
216 }
217
218 /* disallow addresses which may be confused with IP headers */
219 static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
220 {
221         int ret;
222         struct sockaddr *addr = p;
223
224         ret = eth_prepare_mac_addr_change(dev, p);
225         if (ret < 0)
226                 return ret;
227         if (possibly_iphdr(addr->sa_data))
228                 return -EADDRNOTAVAIL;
229         eth_commit_mac_addr_change(dev, p);
230         return 0;
231 }
232
233 static const struct net_device_ops qmi_wwan_netdev_ops = {
234         .ndo_open               = usbnet_open,
235         .ndo_stop               = usbnet_stop,
236         .ndo_start_xmit         = usbnet_start_xmit,
237         .ndo_tx_timeout         = usbnet_tx_timeout,
238         .ndo_change_mtu         = usbnet_change_mtu,
239         .ndo_set_mac_address    = qmi_wwan_mac_addr,
240         .ndo_validate_addr      = eth_validate_addr,
241 };
242
243 /* using a counter to merge subdriver requests with our own into a
244  * combined state
245  */
246 static int qmi_wwan_manage_power(struct usbnet *dev, int on)
247 {
248         struct qmi_wwan_state *info = (void *)&dev->data;
249         int rv;
250
251         dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
252                 atomic_read(&info->pmcount), on);
253
254         if ((on && atomic_add_return(1, &info->pmcount) == 1) ||
255             (!on && atomic_dec_and_test(&info->pmcount))) {
256                 /* need autopm_get/put here to ensure the usbcore sees
257                  * the new value
258                  */
259                 rv = usb_autopm_get_interface(dev->intf);
260                 dev->intf->needs_remote_wakeup = on;
261                 if (!rv)
262                         usb_autopm_put_interface(dev->intf);
263         }
264         return 0;
265 }
266
267 static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
268 {
269         struct usbnet *dev = usb_get_intfdata(intf);
270
271         /* can be called while disconnecting */
272         if (!dev)
273                 return 0;
274         return qmi_wwan_manage_power(dev, on);
275 }
276
277 /* collect all three endpoints and register subdriver */
278 static int qmi_wwan_register_subdriver(struct usbnet *dev)
279 {
280         int rv;
281         struct usb_driver *subdriver = NULL;
282         struct qmi_wwan_state *info = (void *)&dev->data;
283
284         /* collect bulk endpoints */
285         rv = usbnet_get_endpoints(dev, info->data);
286         if (rv < 0)
287                 goto err;
288
289         /* update status endpoint if separate control interface */
290         if (info->control != info->data)
291                 dev->status = &info->control->cur_altsetting->endpoint[0];
292
293         /* require interrupt endpoint for subdriver */
294         if (!dev->status) {
295                 rv = -EINVAL;
296                 goto err;
297         }
298
299         /* for subdriver power management */
300         atomic_set(&info->pmcount, 0);
301
302         /* register subdriver */
303         subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
304                                          4096, &qmi_wwan_cdc_wdm_manage_power);
305         if (IS_ERR(subdriver)) {
306                 dev_err(&info->control->dev, "subdriver registration failed\n");
307                 rv = PTR_ERR(subdriver);
308                 goto err;
309         }
310
311         /* prevent usbnet from using status endpoint */
312         dev->status = NULL;
313
314         /* save subdriver struct for suspend/resume wrappers */
315         info->subdriver = subdriver;
316
317 err:
318         return rv;
319 }
320
321 /* Send CDC SetControlLineState request, setting or clearing the DTR.
322  * "Required for Autoconnect and 9x30 to wake up" according to the
323  * GobiNet driver. The requirement has been verified on an MDM9230
324  * based Sierra Wireless MC7455
325  */
326 static int qmi_wwan_change_dtr(struct usbnet *dev, bool on)
327 {
328         u8 intf = dev->intf->cur_altsetting->desc.bInterfaceNumber;
329
330         return usbnet_write_cmd(dev, USB_CDC_REQ_SET_CONTROL_LINE_STATE,
331                                 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
332                                 on ? 0x01 : 0x00, intf, NULL, 0);
333 }
334
335 static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
336 {
337         int status = -1;
338         u8 *buf = intf->cur_altsetting->extra;
339         int len = intf->cur_altsetting->extralen;
340         struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
341         struct usb_cdc_union_desc *cdc_union;
342         struct usb_cdc_ether_desc *cdc_ether;
343         struct usb_driver *driver = driver_of(intf);
344         struct qmi_wwan_state *info = (void *)&dev->data;
345         struct usb_cdc_parsed_header hdr;
346
347         BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
348                       sizeof(struct qmi_wwan_state)));
349
350         /* set up initial state */
351         info->control = intf;
352         info->data = intf;
353
354         /* and a number of CDC descriptors */
355         cdc_parse_cdc_header(&hdr, intf, buf, len);
356         cdc_union = hdr.usb_cdc_union_desc;
357         cdc_ether = hdr.usb_cdc_ether_desc;
358
359         /* Use separate control and data interfaces if we found a CDC Union */
360         if (cdc_union) {
361                 info->data = usb_ifnum_to_if(dev->udev,
362                                              cdc_union->bSlaveInterface0);
363                 if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
364                     !info->data) {
365                         dev_err(&intf->dev,
366                                 "bogus CDC Union: master=%u, slave=%u\n",
367                                 cdc_union->bMasterInterface0,
368                                 cdc_union->bSlaveInterface0);
369                         goto err;
370                 }
371         }
372
373         /* errors aren't fatal - we can live with the dynamic address */
374         if (cdc_ether) {
375                 dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
376                 usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
377         }
378
379         /* claim data interface and set it up */
380         if (info->control != info->data) {
381                 status = usb_driver_claim_interface(driver, info->data, dev);
382                 if (status < 0)
383                         goto err;
384         }
385
386         status = qmi_wwan_register_subdriver(dev);
387         if (status < 0 && info->control != info->data) {
388                 usb_set_intfdata(info->data, NULL);
389                 usb_driver_release_interface(driver, info->data);
390         }
391
392         /* disabling remote wakeup on MDM9x30 devices has the same
393          * effect as clearing DTR. The device will not respond to QMI
394          * requests until we set DTR again.  This is similar to a
395          * QMI_CTL SYNC request, clearing a lot of firmware state
396          * including the client ID allocations.
397          *
398          * Our usage model allows a session to span multiple
399          * open/close events, so we must prevent the firmware from
400          * clearing out state the clients might need.
401          *
402          * MDM9x30 is the first QMI chipset with USB3 support. Abuse
403          * this fact to enable the quirk.
404          */
405         if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
406                 qmi_wwan_manage_power(dev, 1);
407                 qmi_wwan_change_dtr(dev, true);
408         }
409
410         /* Never use the same address on both ends of the link, even if the
411          * buggy firmware told us to. Or, if device is assigned the well-known
412          * buggy firmware MAC address, replace it with a random address,
413          */
414         if (ether_addr_equal(dev->net->dev_addr, default_modem_addr) ||
415             ether_addr_equal(dev->net->dev_addr, buggy_fw_addr))
416                 eth_hw_addr_random(dev->net);
417
418         /* make MAC addr easily distinguishable from an IP header */
419         if (possibly_iphdr(dev->net->dev_addr)) {
420                 dev->net->dev_addr[0] |= 0x02;  /* set local assignment bit */
421                 dev->net->dev_addr[0] &= 0xbf;  /* clear "IP" bit */
422         }
423         dev->net->netdev_ops = &qmi_wwan_netdev_ops;
424         dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group;
425 err:
426         return status;
427 }
428
429 static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
430 {
431         struct qmi_wwan_state *info = (void *)&dev->data;
432         struct usb_driver *driver = driver_of(intf);
433         struct usb_interface *other;
434
435         if (info->subdriver && info->subdriver->disconnect)
436                 info->subdriver->disconnect(info->control);
437
438         /* disable MDM9x30 quirk */
439         if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
440                 qmi_wwan_change_dtr(dev, false);
441                 qmi_wwan_manage_power(dev, 0);
442         }
443
444         /* allow user to unbind using either control or data */
445         if (intf == info->control)
446                 other = info->data;
447         else
448                 other = info->control;
449
450         /* only if not shared */
451         if (other && intf != other) {
452                 usb_set_intfdata(other, NULL);
453                 usb_driver_release_interface(driver, other);
454         }
455
456         info->subdriver = NULL;
457         info->data = NULL;
458         info->control = NULL;
459 }
460
461 /* suspend/resume wrappers calling both usbnet and the cdc-wdm
462  * subdriver if present.
463  *
464  * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
465  * wrappers for those without adding usbnet reset support first.
466  */
467 static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
468 {
469         struct usbnet *dev = usb_get_intfdata(intf);
470         struct qmi_wwan_state *info = (void *)&dev->data;
471         int ret;
472
473         /* Both usbnet_suspend() and subdriver->suspend() MUST return 0
474          * in system sleep context, otherwise, the resume callback has
475          * to recover device from previous suspend failure.
476          */
477         ret = usbnet_suspend(intf, message);
478         if (ret < 0)
479                 goto err;
480
481         if (intf == info->control && info->subdriver &&
482             info->subdriver->suspend)
483                 ret = info->subdriver->suspend(intf, message);
484         if (ret < 0)
485                 usbnet_resume(intf);
486 err:
487         return ret;
488 }
489
490 static int qmi_wwan_resume(struct usb_interface *intf)
491 {
492         struct usbnet *dev = usb_get_intfdata(intf);
493         struct qmi_wwan_state *info = (void *)&dev->data;
494         int ret = 0;
495         bool callsub = (intf == info->control && info->subdriver &&
496                         info->subdriver->resume);
497
498         if (callsub)
499                 ret = info->subdriver->resume(intf);
500         if (ret < 0)
501                 goto err;
502         ret = usbnet_resume(intf);
503         if (ret < 0 && callsub)
504                 info->subdriver->suspend(intf, PMSG_SUSPEND);
505 err:
506         return ret;
507 }
508
509 static const struct driver_info qmi_wwan_info = {
510         .description    = "WWAN/QMI device",
511         .flags          = FLAG_WWAN,
512         .bind           = qmi_wwan_bind,
513         .unbind         = qmi_wwan_unbind,
514         .manage_power   = qmi_wwan_manage_power,
515         .rx_fixup       = qmi_wwan_rx_fixup,
516 };
517
518 #define HUAWEI_VENDOR_ID        0x12D1
519
520 /* map QMI/wwan function by a fixed interface number */
521 #define QMI_FIXED_INTF(vend, prod, num) \
522         USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
523         .driver_info = (unsigned long)&qmi_wwan_info
524
525 /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
526 #define QMI_GOBI1K_DEVICE(vend, prod) \
527         QMI_FIXED_INTF(vend, prod, 3)
528
529 /* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
530 #define QMI_GOBI_DEVICE(vend, prod) \
531         QMI_FIXED_INTF(vend, prod, 0)
532
533 static const struct usb_device_id products[] = {
534         /* 1. CDC ECM like devices match on the control interface */
535         {       /* Huawei E392, E398 and possibly others sharing both device id and more... */
536                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
537                 .driver_info        = (unsigned long)&qmi_wwan_info,
538         },
539         {       /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
540                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
541                 .driver_info        = (unsigned long)&qmi_wwan_info,
542         },
543         {       /* HUAWEI_INTERFACE_NDIS_CONTROL_QUALCOMM */
544                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69),
545                 .driver_info        = (unsigned long)&qmi_wwan_info,
546         },
547
548         /* 2. Combined interface devices matching on class+protocol */
549         {       /* Huawei E367 and possibly others in "Windows mode" */
550                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
551                 .driver_info        = (unsigned long)&qmi_wwan_info,
552         },
553         {       /* Huawei E392, E398 and possibly others in "Windows mode" */
554                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
555                 .driver_info        = (unsigned long)&qmi_wwan_info,
556         },
557         {       /* HUAWEI_NDIS_SINGLE_INTERFACE_VDF */
558                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x37),
559                 .driver_info        = (unsigned long)&qmi_wwan_info,
560         },
561         {       /* HUAWEI_INTERFACE_NDIS_HW_QUALCOMM */
562                 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x67),
563                 .driver_info        = (unsigned long)&qmi_wwan_info,
564         },
565         {       /* Pantech UML290, P4200 and more */
566                 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
567                 .driver_info        = (unsigned long)&qmi_wwan_info,
568         },
569         {       /* Pantech UML290 - newer firmware */
570                 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
571                 .driver_info        = (unsigned long)&qmi_wwan_info,
572         },
573         {       /* Novatel USB551L and MC551 */
574                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
575                                               USB_CLASS_COMM,
576                                               USB_CDC_SUBCLASS_ETHERNET,
577                                               USB_CDC_PROTO_NONE),
578                 .driver_info        = (unsigned long)&qmi_wwan_info,
579         },
580         {       /* Novatel E362 */
581                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
582                                               USB_CLASS_COMM,
583                                               USB_CDC_SUBCLASS_ETHERNET,
584                                               USB_CDC_PROTO_NONE),
585                 .driver_info        = (unsigned long)&qmi_wwan_info,
586         },
587         {       /* Novatel Expedite E371 */
588                 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9011,
589                                               USB_CLASS_COMM,
590                                               USB_CDC_SUBCLASS_ETHERNET,
591                                               USB_CDC_PROTO_NONE),
592                 .driver_info        = (unsigned long)&qmi_wwan_info,
593         },
594         {       /* Dell Wireless 5800 (Novatel E362) */
595                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
596                                               USB_CLASS_COMM,
597                                               USB_CDC_SUBCLASS_ETHERNET,
598                                               USB_CDC_PROTO_NONE),
599                 .driver_info        = (unsigned long)&qmi_wwan_info,
600         },
601         {       /* Dell Wireless 5800 V2 (Novatel E362) */
602                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
603                                               USB_CLASS_COMM,
604                                               USB_CDC_SUBCLASS_ETHERNET,
605                                               USB_CDC_PROTO_NONE),
606                 .driver_info        = (unsigned long)&qmi_wwan_info,
607         },
608         {       /* Dell Wireless 5804 (Novatel E371) */
609                 USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x819b,
610                                               USB_CLASS_COMM,
611                                               USB_CDC_SUBCLASS_ETHERNET,
612                                               USB_CDC_PROTO_NONE),
613                 .driver_info        = (unsigned long)&qmi_wwan_info,
614         },
615         {       /* ADU960S */
616                 USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
617                                               USB_CLASS_COMM,
618                                               USB_CDC_SUBCLASS_ETHERNET,
619                                               USB_CDC_PROTO_NONE),
620                 .driver_info        = (unsigned long)&qmi_wwan_info,
621         },
622         {       /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
623                 USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7),
624                 .driver_info = (unsigned long)&qmi_wwan_info,
625         },
626
627         /* 3. Combined interface devices matching on interface number */
628         {QMI_FIXED_INTF(0x0408, 0xea42, 4)},    /* Yota / Megafon M100-1 */
629         {QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
630         {QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
631         {QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
632         {QMI_FIXED_INTF(0x05c6, 0x7101, 1)},
633         {QMI_FIXED_INTF(0x05c6, 0x7101, 2)},
634         {QMI_FIXED_INTF(0x05c6, 0x7101, 3)},
635         {QMI_FIXED_INTF(0x05c6, 0x7102, 1)},
636         {QMI_FIXED_INTF(0x05c6, 0x7102, 2)},
637         {QMI_FIXED_INTF(0x05c6, 0x7102, 3)},
638         {QMI_FIXED_INTF(0x05c6, 0x8000, 7)},
639         {QMI_FIXED_INTF(0x05c6, 0x8001, 6)},
640         {QMI_FIXED_INTF(0x05c6, 0x9000, 4)},
641         {QMI_FIXED_INTF(0x05c6, 0x9003, 4)},
642         {QMI_FIXED_INTF(0x05c6, 0x9005, 2)},
643         {QMI_FIXED_INTF(0x05c6, 0x900a, 4)},
644         {QMI_FIXED_INTF(0x05c6, 0x900b, 2)},
645         {QMI_FIXED_INTF(0x05c6, 0x900c, 4)},
646         {QMI_FIXED_INTF(0x05c6, 0x900c, 5)},
647         {QMI_FIXED_INTF(0x05c6, 0x900c, 6)},
648         {QMI_FIXED_INTF(0x05c6, 0x900d, 5)},
649         {QMI_FIXED_INTF(0x05c6, 0x900f, 3)},
650         {QMI_FIXED_INTF(0x05c6, 0x900f, 4)},
651         {QMI_FIXED_INTF(0x05c6, 0x900f, 5)},
652         {QMI_FIXED_INTF(0x05c6, 0x9010, 4)},
653         {QMI_FIXED_INTF(0x05c6, 0x9010, 5)},
654         {QMI_FIXED_INTF(0x05c6, 0x9011, 3)},
655         {QMI_FIXED_INTF(0x05c6, 0x9011, 4)},
656         {QMI_FIXED_INTF(0x05c6, 0x9021, 1)},
657         {QMI_FIXED_INTF(0x05c6, 0x9022, 2)},
658         {QMI_FIXED_INTF(0x05c6, 0x9025, 4)},    /* Alcatel-sbell ASB TL131 TDD LTE  (China Mobile) */
659         {QMI_FIXED_INTF(0x05c6, 0x9026, 3)},
660         {QMI_FIXED_INTF(0x05c6, 0x902e, 5)},
661         {QMI_FIXED_INTF(0x05c6, 0x9031, 5)},
662         {QMI_FIXED_INTF(0x05c6, 0x9032, 4)},
663         {QMI_FIXED_INTF(0x05c6, 0x9033, 3)},
664         {QMI_FIXED_INTF(0x05c6, 0x9033, 4)},
665         {QMI_FIXED_INTF(0x05c6, 0x9033, 5)},
666         {QMI_FIXED_INTF(0x05c6, 0x9033, 6)},
667         {QMI_FIXED_INTF(0x05c6, 0x9034, 3)},
668         {QMI_FIXED_INTF(0x05c6, 0x9034, 4)},
669         {QMI_FIXED_INTF(0x05c6, 0x9034, 5)},
670         {QMI_FIXED_INTF(0x05c6, 0x9034, 6)},
671         {QMI_FIXED_INTF(0x05c6, 0x9034, 7)},
672         {QMI_FIXED_INTF(0x05c6, 0x9035, 4)},
673         {QMI_FIXED_INTF(0x05c6, 0x9036, 3)},
674         {QMI_FIXED_INTF(0x05c6, 0x9037, 5)},
675         {QMI_FIXED_INTF(0x05c6, 0x9038, 4)},
676         {QMI_FIXED_INTF(0x05c6, 0x903b, 7)},
677         {QMI_FIXED_INTF(0x05c6, 0x903c, 6)},
678         {QMI_FIXED_INTF(0x05c6, 0x903d, 6)},
679         {QMI_FIXED_INTF(0x05c6, 0x903e, 5)},
680         {QMI_FIXED_INTF(0x05c6, 0x9043, 3)},
681         {QMI_FIXED_INTF(0x05c6, 0x9046, 3)},
682         {QMI_FIXED_INTF(0x05c6, 0x9046, 4)},
683         {QMI_FIXED_INTF(0x05c6, 0x9046, 5)},
684         {QMI_FIXED_INTF(0x05c6, 0x9047, 2)},
685         {QMI_FIXED_INTF(0x05c6, 0x9047, 3)},
686         {QMI_FIXED_INTF(0x05c6, 0x9047, 4)},
687         {QMI_FIXED_INTF(0x05c6, 0x9048, 4)},
688         {QMI_FIXED_INTF(0x05c6, 0x9048, 5)},
689         {QMI_FIXED_INTF(0x05c6, 0x9048, 6)},
690         {QMI_FIXED_INTF(0x05c6, 0x9048, 7)},
691         {QMI_FIXED_INTF(0x05c6, 0x9048, 8)},
692         {QMI_FIXED_INTF(0x05c6, 0x904c, 5)},
693         {QMI_FIXED_INTF(0x05c6, 0x904c, 6)},
694         {QMI_FIXED_INTF(0x05c6, 0x904c, 7)},
695         {QMI_FIXED_INTF(0x05c6, 0x904c, 8)},
696         {QMI_FIXED_INTF(0x05c6, 0x9050, 3)},
697         {QMI_FIXED_INTF(0x05c6, 0x9052, 4)},
698         {QMI_FIXED_INTF(0x05c6, 0x9053, 6)},
699         {QMI_FIXED_INTF(0x05c6, 0x9053, 7)},
700         {QMI_FIXED_INTF(0x05c6, 0x9054, 5)},
701         {QMI_FIXED_INTF(0x05c6, 0x9054, 6)},
702         {QMI_FIXED_INTF(0x05c6, 0x9055, 3)},
703         {QMI_FIXED_INTF(0x05c6, 0x9055, 4)},
704         {QMI_FIXED_INTF(0x05c6, 0x9055, 5)},
705         {QMI_FIXED_INTF(0x05c6, 0x9055, 6)},
706         {QMI_FIXED_INTF(0x05c6, 0x9055, 7)},
707         {QMI_FIXED_INTF(0x05c6, 0x9056, 3)},
708         {QMI_FIXED_INTF(0x05c6, 0x9062, 2)},
709         {QMI_FIXED_INTF(0x05c6, 0x9062, 3)},
710         {QMI_FIXED_INTF(0x05c6, 0x9062, 4)},
711         {QMI_FIXED_INTF(0x05c6, 0x9062, 5)},
712         {QMI_FIXED_INTF(0x05c6, 0x9062, 6)},
713         {QMI_FIXED_INTF(0x05c6, 0x9062, 7)},
714         {QMI_FIXED_INTF(0x05c6, 0x9062, 8)},
715         {QMI_FIXED_INTF(0x05c6, 0x9062, 9)},
716         {QMI_FIXED_INTF(0x05c6, 0x9064, 3)},
717         {QMI_FIXED_INTF(0x05c6, 0x9065, 6)},
718         {QMI_FIXED_INTF(0x05c6, 0x9065, 7)},
719         {QMI_FIXED_INTF(0x05c6, 0x9066, 5)},
720         {QMI_FIXED_INTF(0x05c6, 0x9066, 6)},
721         {QMI_FIXED_INTF(0x05c6, 0x9067, 1)},
722         {QMI_FIXED_INTF(0x05c6, 0x9068, 2)},
723         {QMI_FIXED_INTF(0x05c6, 0x9068, 3)},
724         {QMI_FIXED_INTF(0x05c6, 0x9068, 4)},
725         {QMI_FIXED_INTF(0x05c6, 0x9068, 5)},
726         {QMI_FIXED_INTF(0x05c6, 0x9068, 6)},
727         {QMI_FIXED_INTF(0x05c6, 0x9068, 7)},
728         {QMI_FIXED_INTF(0x05c6, 0x9069, 5)},
729         {QMI_FIXED_INTF(0x05c6, 0x9069, 6)},
730         {QMI_FIXED_INTF(0x05c6, 0x9069, 7)},
731         {QMI_FIXED_INTF(0x05c6, 0x9069, 8)},
732         {QMI_FIXED_INTF(0x05c6, 0x9070, 4)},
733         {QMI_FIXED_INTF(0x05c6, 0x9070, 5)},
734         {QMI_FIXED_INTF(0x05c6, 0x9075, 5)},
735         {QMI_FIXED_INTF(0x05c6, 0x9076, 4)},
736         {QMI_FIXED_INTF(0x05c6, 0x9076, 5)},
737         {QMI_FIXED_INTF(0x05c6, 0x9076, 6)},
738         {QMI_FIXED_INTF(0x05c6, 0x9076, 7)},
739         {QMI_FIXED_INTF(0x05c6, 0x9076, 8)},
740         {QMI_FIXED_INTF(0x05c6, 0x9077, 3)},
741         {QMI_FIXED_INTF(0x05c6, 0x9077, 4)},
742         {QMI_FIXED_INTF(0x05c6, 0x9077, 5)},
743         {QMI_FIXED_INTF(0x05c6, 0x9077, 6)},
744         {QMI_FIXED_INTF(0x05c6, 0x9078, 3)},
745         {QMI_FIXED_INTF(0x05c6, 0x9079, 4)},
746         {QMI_FIXED_INTF(0x05c6, 0x9079, 5)},
747         {QMI_FIXED_INTF(0x05c6, 0x9079, 6)},
748         {QMI_FIXED_INTF(0x05c6, 0x9079, 7)},
749         {QMI_FIXED_INTF(0x05c6, 0x9079, 8)},
750         {QMI_FIXED_INTF(0x05c6, 0x9080, 5)},
751         {QMI_FIXED_INTF(0x05c6, 0x9080, 6)},
752         {QMI_FIXED_INTF(0x05c6, 0x9080, 7)},
753         {QMI_FIXED_INTF(0x05c6, 0x9080, 8)},
754         {QMI_FIXED_INTF(0x05c6, 0x9083, 3)},
755         {QMI_FIXED_INTF(0x05c6, 0x9084, 4)},
756         {QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
757         {QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
758         {QMI_FIXED_INTF(0x0846, 0x68a2, 8)},
759         {QMI_FIXED_INTF(0x12d1, 0x140c, 1)},    /* Huawei E173 */
760         {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)},    /* Huawei E1820 */
761         {QMI_FIXED_INTF(0x16d8, 0x6003, 0)},    /* CMOTech 6003 */
762         {QMI_FIXED_INTF(0x16d8, 0x6007, 0)},    /* CMOTech CHE-628S */
763         {QMI_FIXED_INTF(0x16d8, 0x6008, 0)},    /* CMOTech CMU-301 */
764         {QMI_FIXED_INTF(0x16d8, 0x6280, 0)},    /* CMOTech CHU-628 */
765         {QMI_FIXED_INTF(0x16d8, 0x7001, 0)},    /* CMOTech CHU-720S */
766         {QMI_FIXED_INTF(0x16d8, 0x7002, 0)},    /* CMOTech 7002 */
767         {QMI_FIXED_INTF(0x16d8, 0x7003, 4)},    /* CMOTech CHU-629K */
768         {QMI_FIXED_INTF(0x16d8, 0x7004, 3)},    /* CMOTech 7004 */
769         {QMI_FIXED_INTF(0x16d8, 0x7006, 5)},    /* CMOTech CGU-629 */
770         {QMI_FIXED_INTF(0x16d8, 0x700a, 4)},    /* CMOTech CHU-629S */
771         {QMI_FIXED_INTF(0x16d8, 0x7211, 0)},    /* CMOTech CHU-720I */
772         {QMI_FIXED_INTF(0x16d8, 0x7212, 0)},    /* CMOTech 7212 */
773         {QMI_FIXED_INTF(0x16d8, 0x7213, 0)},    /* CMOTech 7213 */
774         {QMI_FIXED_INTF(0x16d8, 0x7251, 1)},    /* CMOTech 7251 */
775         {QMI_FIXED_INTF(0x16d8, 0x7252, 1)},    /* CMOTech 7252 */
776         {QMI_FIXED_INTF(0x16d8, 0x7253, 1)},    /* CMOTech 7253 */
777         {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
778         {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
779         {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
780         {QMI_FIXED_INTF(0x19d2, 0x0019, 3)},    /* ONDA MT689DC */
781         {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
782         {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
783         {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
784         {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
785         {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
786         {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
787         {QMI_FIXED_INTF(0x19d2, 0x0055, 1)},    /* ZTE (Vodafone) K3520-Z */
788         {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
789         {QMI_FIXED_INTF(0x19d2, 0x0063, 4)},    /* ZTE (Vodafone) K3565-Z */
790         {QMI_FIXED_INTF(0x19d2, 0x0104, 4)},    /* ZTE (Vodafone) K4505-Z */
791         {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
792         {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
793         {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
794         {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
795         {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
796         {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
797         {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
798         {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
799         {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
800         {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
801         {QMI_FIXED_INTF(0x19d2, 0x0157, 5)},    /* ZTE MF683 */
802         {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
803         {QMI_FIXED_INTF(0x19d2, 0x0167, 4)},    /* ZTE MF820D */
804         {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
805         {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
806         {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
807         {QMI_FIXED_INTF(0x19d2, 0x0191, 4)},    /* ZTE EuFi890 */
808         {QMI_FIXED_INTF(0x19d2, 0x0199, 1)},    /* ZTE MF820S */
809         {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
810         {QMI_FIXED_INTF(0x19d2, 0x0257, 3)},    /* ZTE MF821 */
811         {QMI_FIXED_INTF(0x19d2, 0x0265, 4)},    /* ONDA MT8205 4G LTE */
812         {QMI_FIXED_INTF(0x19d2, 0x0284, 4)},    /* ZTE MF880 */
813         {QMI_FIXED_INTF(0x19d2, 0x0326, 4)},    /* ZTE MF821D */
814         {QMI_FIXED_INTF(0x19d2, 0x0412, 4)},    /* Telewell TW-LTE 4G */
815         {QMI_FIXED_INTF(0x19d2, 0x1008, 4)},    /* ZTE (Vodafone) K3570-Z */
816         {QMI_FIXED_INTF(0x19d2, 0x1010, 4)},    /* ZTE (Vodafone) K3571-Z */
817         {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
818         {QMI_FIXED_INTF(0x19d2, 0x1018, 3)},    /* ZTE (Vodafone) K5006-Z */
819         {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
820         {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
821         {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
822         {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
823         {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
824         {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
825         {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
826         {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
827         {QMI_FIXED_INTF(0x19d2, 0x1270, 5)},    /* ZTE MF667 */
828         {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
829         {QMI_FIXED_INTF(0x19d2, 0x1402, 2)},    /* ZTE MF60 */
830         {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
831         {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
832         {QMI_FIXED_INTF(0x19d2, 0x1426, 2)},    /* ZTE MF91 */
833         {QMI_FIXED_INTF(0x19d2, 0x1428, 2)},    /* Telewell TW-LTE 4G v2 */
834         {QMI_FIXED_INTF(0x19d2, 0x2002, 4)},    /* ZTE (Vodafone) K3765-Z */
835         {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
836         {QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
837         {QMI_FIXED_INTF(0x1199, 0x68a2, 8)},    /* Sierra Wireless MC7710 in QMI mode */
838         {QMI_FIXED_INTF(0x1199, 0x68a2, 19)},   /* Sierra Wireless MC7710 in QMI mode */
839         {QMI_FIXED_INTF(0x1199, 0x68c0, 8)},    /* Sierra Wireless MC7304/MC7354 */
840         {QMI_FIXED_INTF(0x1199, 0x68c0, 10)},   /* Sierra Wireless MC7304/MC7354 */
841         {QMI_FIXED_INTF(0x1199, 0x901c, 8)},    /* Sierra Wireless EM7700 */
842         {QMI_FIXED_INTF(0x1199, 0x901f, 8)},    /* Sierra Wireless EM7355 */
843         {QMI_FIXED_INTF(0x1199, 0x9041, 8)},    /* Sierra Wireless MC7305/MC7355 */
844         {QMI_FIXED_INTF(0x1199, 0x9041, 10)},   /* Sierra Wireless MC7305/MC7355 */
845         {QMI_FIXED_INTF(0x1199, 0x9051, 8)},    /* Netgear AirCard 340U */
846         {QMI_FIXED_INTF(0x1199, 0x9053, 8)},    /* Sierra Wireless Modem */
847         {QMI_FIXED_INTF(0x1199, 0x9054, 8)},    /* Sierra Wireless Modem */
848         {QMI_FIXED_INTF(0x1199, 0x9055, 8)},    /* Netgear AirCard 341U */
849         {QMI_FIXED_INTF(0x1199, 0x9056, 8)},    /* Sierra Wireless Modem */
850         {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
851         {QMI_FIXED_INTF(0x1199, 0x9061, 8)},    /* Sierra Wireless Modem */
852         {QMI_FIXED_INTF(0x1199, 0x9071, 8)},    /* Sierra Wireless MC74xx/EM74xx */
853         {QMI_FIXED_INTF(0x1199, 0x9071, 10)},   /* Sierra Wireless MC74xx/EM74xx */
854         {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},    /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
855         {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)},    /* Alcatel L800MA */
856         {QMI_FIXED_INTF(0x2357, 0x0201, 4)},    /* TP-LINK HSUPA Modem MA180 */
857         {QMI_FIXED_INTF(0x2357, 0x9000, 4)},    /* TP-LINK MA260 */
858         {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},    /* Telit LE920 */
859         {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)},    /* Telit LE920 */
860         {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)},    /* XS Stick W100-2 from 4G Systems */
861         {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)},    /* Olivetti Olicard 100 */
862         {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)},    /* Olivetti Olicard 120 */
863         {QMI_FIXED_INTF(0x0b3c, 0xc002, 4)},    /* Olivetti Olicard 140 */
864         {QMI_FIXED_INTF(0x0b3c, 0xc004, 6)},    /* Olivetti Olicard 155 */
865         {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)},    /* Olivetti Olicard 200 */
866         {QMI_FIXED_INTF(0x0b3c, 0xc00a, 6)},    /* Olivetti Olicard 160 */
867         {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)},    /* Olivetti Olicard 500 */
868         {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)},    /* Cinterion PLxx */
869         {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)},    /* Cinterion PHxx,PXxx */
870         {QMI_FIXED_INTF(0x413c, 0x81a2, 8)},    /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
871         {QMI_FIXED_INTF(0x413c, 0x81a3, 8)},    /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
872         {QMI_FIXED_INTF(0x413c, 0x81a4, 8)},    /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
873         {QMI_FIXED_INTF(0x413c, 0x81a8, 8)},    /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
874         {QMI_FIXED_INTF(0x413c, 0x81a9, 8)},    /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
875         {QMI_FIXED_INTF(0x413c, 0x81b1, 8)},    /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
876         {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)},    /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
877
878         /* 4. Gobi 1000 devices */
879         {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},    /* Acer Gobi Modem Device */
880         {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)},    /* HP un2400 Gobi Modem Device */
881         {QMI_GOBI1K_DEVICE(0x04da, 0x250d)},    /* Panasonic Gobi Modem device */
882         {QMI_GOBI1K_DEVICE(0x413c, 0x8172)},    /* Dell Gobi Modem device */
883         {QMI_GOBI1K_DEVICE(0x1410, 0xa001)},    /* Novatel/Verizon USB-1000 */
884         {QMI_GOBI1K_DEVICE(0x1410, 0xa002)},    /* Novatel Gobi Modem device */
885         {QMI_GOBI1K_DEVICE(0x1410, 0xa003)},    /* Novatel Gobi Modem device */
886         {QMI_GOBI1K_DEVICE(0x1410, 0xa004)},    /* Novatel Gobi Modem device */
887         {QMI_GOBI1K_DEVICE(0x1410, 0xa005)},    /* Novatel Gobi Modem device */
888         {QMI_GOBI1K_DEVICE(0x1410, 0xa006)},    /* Novatel Gobi Modem device */
889         {QMI_GOBI1K_DEVICE(0x1410, 0xa007)},    /* Novatel Gobi Modem device */
890         {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)},    /* Asus Gobi Modem device */
891         {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)},    /* ONDA Gobi Modem device */
892         {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)},    /* Generic Gobi Modem device */
893         {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)},    /* Generic Gobi Modem device */
894         {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)},    /* Generic Gobi Modem device */
895         {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)},    /* Generic Gobi Modem device */
896         {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)},    /* Generic Gobi Modem device */
897         {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)},    /* Generic Gobi Modem device */
898
899         /* 5. Gobi 2000 and 3000 devices */
900         {QMI_GOBI_DEVICE(0x413c, 0x8186)},      /* Dell Gobi 2000 Modem device (N0218, VU936) */
901         {QMI_GOBI_DEVICE(0x413c, 0x8194)},      /* Dell Gobi 3000 Composite */
902         {QMI_GOBI_DEVICE(0x05c6, 0x920b)},      /* Generic Gobi 2000 Modem device */
903         {QMI_GOBI_DEVICE(0x05c6, 0x9225)},      /* Sony Gobi 2000 Modem device (N0279, VU730) */
904         {QMI_GOBI_DEVICE(0x05c6, 0x9245)},      /* Samsung Gobi 2000 Modem device (VL176) */
905         {QMI_GOBI_DEVICE(0x03f0, 0x251d)},      /* HP Gobi 2000 Modem device (VP412) */
906         {QMI_GOBI_DEVICE(0x05c6, 0x9215)},      /* Acer Gobi 2000 Modem device (VP413) */
907         {QMI_FIXED_INTF(0x05c6, 0x9215, 4)},    /* Quectel EC20 Mini PCIe */
908         {QMI_GOBI_DEVICE(0x05c6, 0x9265)},      /* Asus Gobi 2000 Modem device (VR305) */
909         {QMI_GOBI_DEVICE(0x05c6, 0x9235)},      /* Top Global Gobi 2000 Modem device (VR306) */
910         {QMI_GOBI_DEVICE(0x05c6, 0x9275)},      /* iRex Technologies Gobi 2000 Modem device (VR307) */
911         {QMI_GOBI_DEVICE(0x0af0, 0x8120)},      /* Option GTM681W */
912         {QMI_GOBI_DEVICE(0x1199, 0x68a5)},      /* Sierra Wireless Modem */
913         {QMI_GOBI_DEVICE(0x1199, 0x68a9)},      /* Sierra Wireless Modem */
914         {QMI_GOBI_DEVICE(0x1199, 0x9001)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
915         {QMI_GOBI_DEVICE(0x1199, 0x9002)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
916         {QMI_GOBI_DEVICE(0x1199, 0x9003)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
917         {QMI_GOBI_DEVICE(0x1199, 0x9004)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
918         {QMI_GOBI_DEVICE(0x1199, 0x9005)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
919         {QMI_GOBI_DEVICE(0x1199, 0x9006)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
920         {QMI_GOBI_DEVICE(0x1199, 0x9007)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
921         {QMI_GOBI_DEVICE(0x1199, 0x9008)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
922         {QMI_GOBI_DEVICE(0x1199, 0x9009)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
923         {QMI_GOBI_DEVICE(0x1199, 0x900a)},      /* Sierra Wireless Gobi 2000 Modem device (VT773) */
924         {QMI_GOBI_DEVICE(0x1199, 0x9011)},      /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
925         {QMI_GOBI_DEVICE(0x16d8, 0x8002)},      /* CMDTech Gobi 2000 Modem device (VU922) */
926         {QMI_GOBI_DEVICE(0x05c6, 0x9205)},      /* Gobi 2000 Modem device */
927         {QMI_GOBI_DEVICE(0x1199, 0x9013)},      /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
928         {QMI_GOBI_DEVICE(0x03f0, 0x371d)},      /* HP un2430 Mobile Broadband Module */
929         {QMI_GOBI_DEVICE(0x1199, 0x9015)},      /* Sierra Wireless Gobi 3000 Modem device */
930         {QMI_GOBI_DEVICE(0x1199, 0x9019)},      /* Sierra Wireless Gobi 3000 Modem device */
931         {QMI_GOBI_DEVICE(0x1199, 0x901b)},      /* Sierra Wireless MC7770 */
932         {QMI_GOBI_DEVICE(0x12d1, 0x14f1)},      /* Sony Gobi 3000 Composite */
933         {QMI_GOBI_DEVICE(0x1410, 0xa021)},      /* Foxconn Gobi 3000 Modem device (Novatel E396) */
934
935         { }                                     /* END */
936 };
937 MODULE_DEVICE_TABLE(usb, products);
938
939 static bool quectel_ec20_detected(struct usb_interface *intf)
940 {
941         struct usb_device *dev = interface_to_usbdev(intf);
942
943         if (dev->actconfig &&
944             le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
945             le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
946             dev->actconfig->desc.bNumInterfaces == 5)
947                 return true;
948
949         return false;
950 }
951
952 static int qmi_wwan_probe(struct usb_interface *intf,
953                           const struct usb_device_id *prod)
954 {
955         struct usb_device_id *id = (struct usb_device_id *)prod;
956         struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
957
958         /* Workaround to enable dynamic IDs.  This disables usbnet
959          * blacklisting functionality.  Which, if required, can be
960          * reimplemented here by using a magic "blacklist" value
961          * instead of 0 in the static device id table
962          */
963         if (!id->driver_info) {
964                 dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
965                 id->driver_info = (unsigned long)&qmi_wwan_info;
966         }
967
968         /* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
969         if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
970                 dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
971                 return -ENODEV;
972         }
973
974         return usbnet_probe(intf, id);
975 }
976
977 static struct usb_driver qmi_wwan_driver = {
978         .name                 = "qmi_wwan",
979         .id_table             = products,
980         .probe                = qmi_wwan_probe,
981         .disconnect           = usbnet_disconnect,
982         .suspend              = qmi_wwan_suspend,
983         .resume               = qmi_wwan_resume,
984         .reset_resume         = qmi_wwan_resume,
985         .supports_autosuspend = 1,
986         .disable_hub_initiated_lpm = 1,
987 };
988
989 module_usb_driver(qmi_wwan_driver);
990
991 MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
992 MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
993 MODULE_LICENSE("GPL");