Linux 3.4.102
[linux/fpc-iii.git] / drivers / net / usb / qmi_wwan.c
blob387ececab6e84d3a4ed518b79d67f8fb046046b0
1 /*
2 * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 */
9 #include <linux/module.h>
10 #include <linux/netdevice.h>
11 #include <linux/ethtool.h>
12 #include <linux/etherdevice.h>
13 #include <linux/mii.h>
14 #include <linux/usb.h>
15 #include <linux/usb/cdc.h>
16 #include <linux/usb/usbnet.h>
17 #include <linux/usb/cdc-wdm.h>
19 /* The name of the CDC Device Management driver */
20 #define DM_DRIVER "cdc_wdm"
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
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
35 * Handling a protocol like QMI is out of the scope for any driver.
36 * It can be exported as a character device using the cdc-wdm driver,
37 * which will enable userspace applications ("modem managers") to
38 * handle it. This may be required to use the network interface
39 * provided by the driver.
41 * These devices may alternatively/additionally be configured using AT
42 * commands on any of the serial interfaces driven by the option driver
44 * This driver binds only to the data ("slave") interface to enable
45 * the cdc-wdm driver to bind to the control interface. It still
46 * parses the CDC functional descriptors on the control interface to
47 * a) verify that this is indeed a handled interface (CDC Union
48 * header lists it as slave)
49 * b) get MAC address and other ethernet config from the CDC Ethernet
50 * header
51 * c) enable user bind requests against the control interface, which
52 * is the common way to bind to CDC Ethernet Control Model type
53 * interfaces
54 * d) provide a hint to the user about which interface is the
55 * corresponding management interface
58 static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
60 int status = -1;
61 struct usb_interface *control = NULL;
62 u8 *buf = intf->cur_altsetting->extra;
63 int len = intf->cur_altsetting->extralen;
64 struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
65 struct usb_cdc_union_desc *cdc_union = NULL;
66 struct usb_cdc_ether_desc *cdc_ether = NULL;
67 u32 required = 1 << USB_CDC_HEADER_TYPE | 1 << USB_CDC_UNION_TYPE;
68 u32 found = 0;
69 atomic_t *pmcount = (void *)&dev->data[1];
71 atomic_set(pmcount, 0);
74 * assume a data interface has no additional descriptors and
75 * that the control and data interface are numbered
76 * consecutively - this holds for the Huawei device at least
78 if (len == 0 && desc->bInterfaceNumber > 0) {
79 control = usb_ifnum_to_if(dev->udev, desc->bInterfaceNumber - 1);
80 if (!control)
81 goto err;
83 buf = control->cur_altsetting->extra;
84 len = control->cur_altsetting->extralen;
85 dev_dbg(&intf->dev, "guessing \"control\" => %s, \"data\" => this\n",
86 dev_name(&control->dev));
89 while (len > 3) {
90 struct usb_descriptor_header *h = (void *)buf;
92 /* ignore any misplaced descriptors */
93 if (h->bDescriptorType != USB_DT_CS_INTERFACE)
94 goto next_desc;
96 /* buf[2] is CDC descriptor subtype */
97 switch (buf[2]) {
98 case USB_CDC_HEADER_TYPE:
99 if (found & 1 << USB_CDC_HEADER_TYPE) {
100 dev_dbg(&intf->dev, "extra CDC header\n");
101 goto err;
103 if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
104 dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
105 goto err;
107 break;
108 case USB_CDC_UNION_TYPE:
109 if (found & 1 << USB_CDC_UNION_TYPE) {
110 dev_dbg(&intf->dev, "extra CDC union\n");
111 goto err;
113 if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
114 dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
115 goto err;
117 cdc_union = (struct usb_cdc_union_desc *)buf;
118 break;
119 case USB_CDC_ETHERNET_TYPE:
120 if (found & 1 << USB_CDC_ETHERNET_TYPE) {
121 dev_dbg(&intf->dev, "extra CDC ether\n");
122 goto err;
124 if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
125 dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength);
126 goto err;
128 cdc_ether = (struct usb_cdc_ether_desc *)buf;
129 break;
133 * Remember which CDC functional descriptors we've seen. Works
134 * for all types we care about, of which USB_CDC_ETHERNET_TYPE
135 * (0x0f) is the highest numbered
137 if (buf[2] < 32)
138 found |= 1 << buf[2];
140 next_desc:
141 len -= h->bLength;
142 buf += h->bLength;
145 /* did we find all the required ones? */
146 if ((found & required) != required) {
147 dev_err(&intf->dev, "CDC functional descriptors missing\n");
148 goto err;
151 /* give the user a helpful hint if trying to bind to the wrong interface */
152 if (cdc_union && desc->bInterfaceNumber == cdc_union->bMasterInterface0) {
153 dev_err(&intf->dev, "leaving \"control\" interface for " DM_DRIVER " - try binding to %s instead!\n",
154 dev_name(&usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0)->dev));
155 goto err;
158 /* errors aren't fatal - we can live with the dynamic address */
159 if (cdc_ether) {
160 dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
161 usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
164 /* success! point the user to the management interface */
165 if (control)
166 dev_info(&intf->dev, "Use \"" DM_DRIVER "\" for QMI interface %s\n",
167 dev_name(&control->dev));
169 /* XXX: add a sysfs symlink somewhere to help management applications find it? */
171 /* collect bulk endpoints now that we know intf == "data" interface */
172 status = usbnet_get_endpoints(dev, intf);
174 err:
175 return status;
178 /* default ethernet address used by the modem */
179 static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
181 /* Make up an ethernet header if the packet doesn't have one.
183 * A firmware bug common among several devices cause them to send raw
184 * IP packets under some circumstances. There is no way for the
185 * driver/host to know when this will happen. And even when the bug
186 * hits, some packets will still arrive with an intact header.
188 * The supported devices are only capably of sending IPv4, IPv6 and
189 * ARP packets on a point-to-point link. Any packet with an ethernet
190 * header will have either our address or a broadcast/multicast
191 * address as destination. ARP packets will always have a header.
193 * This means that this function will reliably add the appropriate
194 * header iff necessary, provided our hardware address does not start
195 * with 4 or 6.
197 * Another common firmware bug results in all packets being addressed
198 * to 00:a0:c6:00:00:00 despite the host address being different.
199 * This function will also fixup such packets.
201 static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
203 __be16 proto;
205 /* This check is no longer done by usbnet */
206 if (skb->len < dev->net->hard_header_len)
207 return 0;
209 switch (skb->data[0] & 0xf0) {
210 case 0x40:
211 proto = htons(ETH_P_IP);
212 break;
213 case 0x60:
214 proto = htons(ETH_P_IPV6);
215 break;
216 case 0x00:
217 if (is_multicast_ether_addr(skb->data))
218 return 1;
219 /* possibly bogus destination - rewrite just in case */
220 skb_reset_mac_header(skb);
221 goto fix_dest;
222 default:
223 /* pass along other packets without modifications */
224 return 1;
226 if (skb_headroom(skb) < ETH_HLEN)
227 return 0;
228 skb_push(skb, ETH_HLEN);
229 skb_reset_mac_header(skb);
230 eth_hdr(skb)->h_proto = proto;
231 memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
232 fix_dest:
233 memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
234 return 1;
237 /* very simplistic detection of IPv4 or IPv6 headers */
238 static bool possibly_iphdr(const char *data)
240 return (data[0] & 0xd0) == 0x40;
243 /* disallow addresses which may be confused with IP headers */
244 static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
246 struct sockaddr *addr = p;
248 if (!is_valid_ether_addr(addr->sa_data) ||
249 possibly_iphdr(addr->sa_data))
250 return -EADDRNOTAVAIL;
251 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
252 return 0;
255 static const struct net_device_ops qmi_wwan_netdev_ops = {
256 .ndo_open = usbnet_open,
257 .ndo_stop = usbnet_stop,
258 .ndo_start_xmit = usbnet_start_xmit,
259 .ndo_tx_timeout = usbnet_tx_timeout,
260 .ndo_change_mtu = usbnet_change_mtu,
261 .ndo_set_mac_address = qmi_wwan_mac_addr,
262 .ndo_validate_addr = eth_validate_addr,
265 /* using a counter to merge subdriver requests with our own into a combined state */
266 static int qmi_wwan_manage_power(struct usbnet *dev, int on)
268 atomic_t *pmcount = (void *)&dev->data[1];
269 int rv = 0;
271 dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(pmcount), on);
273 if ((on && atomic_add_return(1, pmcount) == 1) || (!on && atomic_dec_and_test(pmcount))) {
274 /* need autopm_get/put here to ensure the usbcore sees the new value */
275 rv = usb_autopm_get_interface(dev->intf);
276 if (rv < 0)
277 goto err;
278 dev->intf->needs_remote_wakeup = on;
279 usb_autopm_put_interface(dev->intf);
281 err:
282 return rv;
285 static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
287 struct usbnet *dev = usb_get_intfdata(intf);
289 /* can be called while disconnecting */
290 if (!dev)
291 return 0;
292 return qmi_wwan_manage_power(dev, on);
295 /* Some devices combine the "control" and "data" functions into a
296 * single interface with all three endpoints: interrupt + bulk in and
297 * out
299 * Setting up cdc-wdm as a subdriver owning the interrupt endpoint
300 * will let it provide userspace access to the encapsulated QMI
301 * protocol without interfering with the usbnet operations.
303 static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
305 int rv;
306 struct usb_driver *subdriver = NULL;
307 atomic_t *pmcount = (void *)&dev->data[1];
309 /* ZTE makes devices where the interface descriptors and endpoint
310 * configurations of two or more interfaces are identical, even
311 * though the functions are completely different. If set, then
312 * driver_info->data is a bitmap of acceptable interface numbers
313 * allowing us to bind to one such interface without binding to
314 * all of them
316 if (dev->driver_info->data &&
317 !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) {
318 dev_info(&intf->dev, "not on our whitelist - ignored");
319 rv = -ENODEV;
320 goto err;
323 atomic_set(pmcount, 0);
325 /* collect all three endpoints */
326 rv = usbnet_get_endpoints(dev, intf);
327 if (rv < 0)
328 goto err;
330 /* require interrupt endpoint for subdriver */
331 if (!dev->status) {
332 rv = -EINVAL;
333 goto err;
336 subdriver = usb_cdc_wdm_register(intf, &dev->status->desc, 512, &qmi_wwan_cdc_wdm_manage_power);
337 if (IS_ERR(subdriver)) {
338 rv = PTR_ERR(subdriver);
339 goto err;
342 /* can't let usbnet use the interrupt endpoint */
343 dev->status = NULL;
345 /* save subdriver struct for suspend/resume wrappers */
346 dev->data[0] = (unsigned long)subdriver;
348 /* Never use the same address on both ends of the link, even
349 * if the buggy firmware told us to.
351 if (!compare_ether_addr(dev->net->dev_addr, default_modem_addr))
352 eth_hw_addr_random(dev->net);
354 /* make MAC addr easily distinguishable from an IP header */
355 if (possibly_iphdr(dev->net->dev_addr)) {
356 dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */
357 dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */
359 dev->net->netdev_ops = &qmi_wwan_netdev_ops;
360 err:
361 return rv;
364 static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf)
366 struct usb_driver *subdriver = (void *)dev->data[0];
368 if (subdriver && subdriver->disconnect)
369 subdriver->disconnect(intf);
371 dev->data[0] = (unsigned long)NULL;
374 /* suspend/resume wrappers calling both usbnet and the cdc-wdm
375 * subdriver if present.
377 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
378 * wrappers for those without adding usbnet reset support first.
380 static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
382 struct usbnet *dev = usb_get_intfdata(intf);
383 struct usb_driver *subdriver = (void *)dev->data[0];
384 int ret;
386 ret = usbnet_suspend(intf, message);
387 if (ret < 0)
388 goto err;
390 if (subdriver && subdriver->suspend)
391 ret = subdriver->suspend(intf, message);
392 if (ret < 0)
393 usbnet_resume(intf);
394 err:
395 return ret;
398 static int qmi_wwan_resume(struct usb_interface *intf)
400 struct usbnet *dev = usb_get_intfdata(intf);
401 struct usb_driver *subdriver = (void *)dev->data[0];
402 int ret = 0;
404 if (subdriver && subdriver->resume)
405 ret = subdriver->resume(intf);
406 if (ret < 0)
407 goto err;
408 ret = usbnet_resume(intf);
409 if (ret < 0 && subdriver && subdriver->resume && subdriver->suspend)
410 subdriver->suspend(intf, PMSG_SUSPEND);
411 err:
412 return ret;
416 static const struct driver_info qmi_wwan_info = {
417 .description = "QMI speaking wwan device",
418 .flags = FLAG_WWAN,
419 .bind = qmi_wwan_bind,
420 .manage_power = qmi_wwan_manage_power,
423 static const struct driver_info qmi_wwan_shared = {
424 .description = "QMI speaking wwan device with combined interface",
425 .flags = FLAG_WWAN,
426 .bind = qmi_wwan_bind_shared,
427 .unbind = qmi_wwan_unbind_shared,
428 .manage_power = qmi_wwan_manage_power,
429 .rx_fixup = qmi_wwan_rx_fixup,
432 static const struct driver_info qmi_wwan_force_int0 = {
433 .description = "Qualcomm WWAN/QMI device",
434 .flags = FLAG_WWAN,
435 .bind = qmi_wwan_bind_shared,
436 .unbind = qmi_wwan_unbind_shared,
437 .manage_power = qmi_wwan_manage_power,
438 .data = BIT(0), /* interface whitelist bitmap */
441 static const struct driver_info qmi_wwan_force_int1 = {
442 .description = "Qualcomm WWAN/QMI device",
443 .flags = FLAG_WWAN,
444 .bind = qmi_wwan_bind_shared,
445 .unbind = qmi_wwan_unbind_shared,
446 .manage_power = qmi_wwan_manage_power,
447 .data = BIT(1), /* interface whitelist bitmap */
450 static const struct driver_info qmi_wwan_force_int2 = {
451 .description = "Qualcomm WWAN/QMI device",
452 .flags = FLAG_WWAN,
453 .bind = qmi_wwan_bind_shared,
454 .unbind = qmi_wwan_unbind_shared,
455 .manage_power = qmi_wwan_manage_power,
456 .data = BIT(2), /* interface whitelist bitmap */
459 static const struct driver_info qmi_wwan_force_int3 = {
460 .description = "Qualcomm WWAN/QMI device",
461 .flags = FLAG_WWAN,
462 .bind = qmi_wwan_bind_shared,
463 .unbind = qmi_wwan_unbind_shared,
464 .manage_power = qmi_wwan_manage_power,
465 .data = BIT(3), /* interface whitelist bitmap */
468 static const struct driver_info qmi_wwan_force_int4 = {
469 .description = "Qualcomm WWAN/QMI device",
470 .flags = FLAG_WWAN,
471 .bind = qmi_wwan_bind_shared,
472 .unbind = qmi_wwan_unbind_shared,
473 .manage_power = qmi_wwan_manage_power,
474 .data = BIT(4), /* interface whitelist bitmap */
477 /* Sierra Wireless provide equally useless interface descriptors
478 * Devices in QMI mode can be switched between two different
479 * configurations:
480 * a) USB interface #8 is QMI/wwan
481 * b) USB interfaces #8, #19 and #20 are QMI/wwan
483 * Both configurations provide a number of other interfaces (serial++),
484 * some of which have the same endpoint configuration as we expect, so
485 * a whitelist or blacklist is necessary.
487 * FIXME: The below whitelist should include BIT(20). It does not
488 * because I cannot get it to work...
490 static const struct driver_info qmi_wwan_sierra = {
491 .description = "Sierra Wireless wwan/QMI device",
492 .flags = FLAG_WWAN,
493 .bind = qmi_wwan_bind_shared,
494 .unbind = qmi_wwan_unbind_shared,
495 .manage_power = qmi_wwan_manage_power,
496 .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
499 #define HUAWEI_VENDOR_ID 0x12D1
501 /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
502 #define QMI_GOBI1K_DEVICE(vend, prod) \
503 USB_DEVICE(vend, prod), \
504 .driver_info = (unsigned long)&qmi_wwan_force_int3
506 /* Gobi 2000 and Gobi 3000 QMI/wwan interface number is 0 according to qcserial */
507 #define QMI_GOBI_DEVICE(vend, prod) \
508 USB_DEVICE(vend, prod), \
509 .driver_info = (unsigned long)&qmi_wwan_force_int0
511 static const struct usb_device_id products[] = {
512 { /* Huawei E392, E398 and possibly others sharing both device id and more... */
513 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
514 .idVendor = HUAWEI_VENDOR_ID,
515 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
516 .bInterfaceSubClass = 1,
517 .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */
518 .driver_info = (unsigned long)&qmi_wwan_info,
520 { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
521 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
522 .idVendor = HUAWEI_VENDOR_ID,
523 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
524 .bInterfaceSubClass = 1,
525 .bInterfaceProtocol = 56, /* NOTE: This is the *slave* interface of the CDC Union! */
526 .driver_info = (unsigned long)&qmi_wwan_info,
528 { /* Huawei E392, E398 and possibly others in "Windows mode"
529 * using a combined control and data interface without any CDC
530 * functional descriptors
532 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
533 .idVendor = HUAWEI_VENDOR_ID,
534 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
535 .bInterfaceSubClass = 1,
536 .bInterfaceProtocol = 17,
537 .driver_info = (unsigned long)&qmi_wwan_shared,
539 { /* Pantech UML290 */
540 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
541 .idVendor = 0x106c,
542 .idProduct = 0x3718,
543 .bInterfaceClass = 0xff,
544 .bInterfaceSubClass = 0xf0,
545 .bInterfaceProtocol = 0xff,
546 .driver_info = (unsigned long)&qmi_wwan_shared,
548 { /* Pantech UML290 - newer firmware */
549 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
550 .idVendor = 0x106c,
551 .idProduct = 0x3718,
552 .bInterfaceClass = 0xff,
553 .bInterfaceSubClass = 0xf1,
554 .bInterfaceProtocol = 0xff,
555 .driver_info = (unsigned long)&qmi_wwan_shared,
557 { /* ZTE MF820D */
558 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
559 .idVendor = 0x19d2,
560 .idProduct = 0x0167,
561 .bInterfaceClass = 0xff,
562 .bInterfaceSubClass = 0xff,
563 .bInterfaceProtocol = 0xff,
564 .driver_info = (unsigned long)&qmi_wwan_force_int4,
566 { /* ZTE MF821D */
567 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
568 .idVendor = 0x19d2,
569 .idProduct = 0x0326,
570 .bInterfaceClass = 0xff,
571 .bInterfaceSubClass = 0xff,
572 .bInterfaceProtocol = 0xff,
573 .driver_info = (unsigned long)&qmi_wwan_force_int4,
575 { /* ZTE (Vodafone) K3520-Z */
576 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
577 .idVendor = 0x19d2,
578 .idProduct = 0x0055,
579 .bInterfaceClass = 0xff,
580 .bInterfaceSubClass = 0xff,
581 .bInterfaceProtocol = 0xff,
582 .driver_info = (unsigned long)&qmi_wwan_force_int1,
584 { /* ZTE (Vodafone) K3565-Z */
585 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
586 .idVendor = 0x19d2,
587 .idProduct = 0x0063,
588 .bInterfaceClass = 0xff,
589 .bInterfaceSubClass = 0xff,
590 .bInterfaceProtocol = 0xff,
591 .driver_info = (unsigned long)&qmi_wwan_force_int4,
593 { /* ZTE (Vodafone) K3570-Z */
594 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
595 .idVendor = 0x19d2,
596 .idProduct = 0x1008,
597 .bInterfaceClass = 0xff,
598 .bInterfaceSubClass = 0xff,
599 .bInterfaceProtocol = 0xff,
600 .driver_info = (unsigned long)&qmi_wwan_force_int4,
602 { /* ZTE (Vodafone) K3571-Z */
603 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
604 .idVendor = 0x19d2,
605 .idProduct = 0x1010,
606 .bInterfaceClass = 0xff,
607 .bInterfaceSubClass = 0xff,
608 .bInterfaceProtocol = 0xff,
609 .driver_info = (unsigned long)&qmi_wwan_force_int4,
611 { /* ZTE (Vodafone) K3765-Z */
612 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
613 .idVendor = 0x19d2,
614 .idProduct = 0x2002,
615 .bInterfaceClass = 0xff,
616 .bInterfaceSubClass = 0xff,
617 .bInterfaceProtocol = 0xff,
618 .driver_info = (unsigned long)&qmi_wwan_force_int4,
620 { /* ZTE (Vodafone) K4505-Z */
621 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
622 .idVendor = 0x19d2,
623 .idProduct = 0x0104,
624 .bInterfaceClass = 0xff,
625 .bInterfaceSubClass = 0xff,
626 .bInterfaceProtocol = 0xff,
627 .driver_info = (unsigned long)&qmi_wwan_force_int4,
629 { /* ZTE (Vodafone) K5006-Z */
630 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
631 .idVendor = 0x19d2,
632 .idProduct = 0x1018,
633 .bInterfaceClass = 0xff,
634 .bInterfaceSubClass = 0xff,
635 .bInterfaceProtocol = 0xff,
636 .driver_info = (unsigned long)&qmi_wwan_force_int3,
638 { /* ZTE MF60 */
639 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
640 .idVendor = 0x19d2,
641 .idProduct = 0x1402,
642 .bInterfaceClass = 0xff,
643 .bInterfaceSubClass = 0xff,
644 .bInterfaceProtocol = 0xff,
645 .driver_info = (unsigned long)&qmi_wwan_force_int2,
647 { /* Sierra Wireless MC77xx in QMI mode */
648 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
649 .idVendor = 0x1199,
650 .idProduct = 0x68a2,
651 .bInterfaceClass = 0xff,
652 .bInterfaceSubClass = 0xff,
653 .bInterfaceProtocol = 0xff,
654 .driver_info = (unsigned long)&qmi_wwan_sierra,
656 { /* Sierra Wireless MC7700 */
657 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
658 .idVendor = 0x0f3d,
659 .idProduct = 0x68a2,
660 .bInterfaceClass = 0xff,
661 .bInterfaceSubClass = 0xff,
662 .bInterfaceProtocol = 0xff,
663 .driver_info = (unsigned long)&qmi_wwan_sierra,
665 { /* Sierra Wireless MC7750 */
666 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
667 .idVendor = 0x114f,
668 .idProduct = 0x68a2,
669 .bInterfaceClass = 0xff,
670 .bInterfaceSubClass = 0xff,
671 .bInterfaceProtocol = 0xff,
672 .driver_info = (unsigned long)&qmi_wwan_sierra,
674 { /* Sierra Wireless EM7700 */
675 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
676 .idVendor = 0x1199,
677 .idProduct = 0x901c,
678 .bInterfaceClass = 0xff,
679 .bInterfaceSubClass = 0xff,
680 .bInterfaceProtocol = 0xff,
681 .driver_info = (unsigned long)&qmi_wwan_sierra,
684 /* Gobi 1000 devices */
685 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
686 {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
687 {QMI_GOBI1K_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
688 {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
689 {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
690 {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
691 {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
692 {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
693 {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
694 {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
695 {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
696 {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
697 {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
698 {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
700 /* Gobi 2000 and 3000 devices */
701 {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
702 {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
703 {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
704 {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
705 {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
706 {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
707 {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
708 {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
709 {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
710 {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
711 {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
712 {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
713 {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
714 {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
715 {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
716 {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
717 {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
718 {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
719 {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
720 {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
721 {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
722 {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
723 {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
724 {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
725 {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
726 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
727 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
728 {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
730 { } /* END */
732 MODULE_DEVICE_TABLE(usb, products);
734 static struct usb_driver qmi_wwan_driver = {
735 .name = "qmi_wwan",
736 .id_table = products,
737 .probe = usbnet_probe,
738 .disconnect = usbnet_disconnect,
739 .suspend = qmi_wwan_suspend,
740 .resume = qmi_wwan_resume,
741 .reset_resume = qmi_wwan_resume,
742 .supports_autosuspend = 1,
745 static int __init qmi_wwan_init(void)
747 return usb_register(&qmi_wwan_driver);
749 module_init(qmi_wwan_init);
751 static void __exit qmi_wwan_exit(void)
753 usb_deregister(&qmi_wwan_driver);
755 module_exit(qmi_wwan_exit);
757 MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
758 MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
759 MODULE_LICENSE("GPL");