blob: 387ececab6e84d3a4ed518b79d67f8fb046046b0 [file] [log] [blame]
Bjørn Mork423ce8c2012-01-19 15:37:22 +00001/*
2 * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 */
8
9#include <linux/module.h>
10#include <linux/netdevice.h>
11#include <linux/ethtool.h>
Bjørn Mork8ed87e62013-04-18 12:57:09 +000012#include <linux/etherdevice.h>
Bjørn Mork423ce8c2012-01-19 15:37:22 +000013#include <linux/mii.h>
14#include <linux/usb.h>
15#include <linux/usb/cdc.h>
16#include <linux/usb/usbnet.h>
Bjørn Morkc3ecb082012-03-09 12:35:05 +010017#include <linux/usb/cdc-wdm.h>
Bjørn Mork423ce8c2012-01-19 15:37:22 +000018
19/* The name of the CDC Device Management driver */
20#define DM_DRIVER "cdc_wdm"
21
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 * 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.
40 *
41 * These devices may alternatively/additionally be configured using AT
42 * commands on any of the serial interfaces driven by the option driver
43 *
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
56 */
57
58static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
59{
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;
Bjørn Morkc3ecb082012-03-09 12:35:05 +010069 atomic_t *pmcount = (void *)&dev->data[1];
70
71 atomic_set(pmcount, 0);
Bjørn Mork423ce8c2012-01-19 15:37:22 +000072
73 /*
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
77 */
78 if (len == 0 && desc->bInterfaceNumber > 0) {
79 control = usb_ifnum_to_if(dev->udev, desc->bInterfaceNumber - 1);
80 if (!control)
81 goto err;
82
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));
87 }
88
89 while (len > 3) {
90 struct usb_descriptor_header *h = (void *)buf;
91
92 /* ignore any misplaced descriptors */
93 if (h->bDescriptorType != USB_DT_CS_INTERFACE)
94 goto next_desc;
95
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;
102 }
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;
106 }
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;
112 }
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;
116 }
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;
123 }
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;
127 }
128 cdc_ether = (struct usb_cdc_ether_desc *)buf;
129 break;
130 }
131
132 /*
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
136 */
137 if (buf[2] < 32)
138 found |= 1 << buf[2];
139
140next_desc:
141 len -= h->bLength;
142 buf += h->bLength;
143 }
144
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;
149 }
150
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;
156 }
157
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);
162 }
163
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));
168
169 /* XXX: add a sysfs symlink somewhere to help management applications find it? */
170
171 /* collect bulk endpoints now that we know intf == "data" interface */
172 status = usbnet_get_endpoints(dev, intf);
173
174err:
175 return status;
176}
177
Bjørn Mork1203d9c2013-04-18 12:57:11 +0000178/* default ethernet address used by the modem */
179static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
180
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000181/* Make up an ethernet header if the packet doesn't have one.
182 *
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.
187 *
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.
192 *
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.
Bjørn Morkd8abf422013-04-18 12:57:10 +0000196 *
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.
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000200 */
201static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
202{
203 __be16 proto;
204
Emil Goode4d4d28c2014-02-13 17:50:19 +0100205 /* This check is no longer done by usbnet */
206 if (skb->len < dev->net->hard_header_len)
207 return 0;
208
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000209 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;
Bjørn Morkd8abf422013-04-18 12:57:10 +0000216 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;
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000222 default:
223 /* pass along other packets without modifications */
224 return 1;
225 }
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);
Bjørn Morkd8abf422013-04-18 12:57:10 +0000232fix_dest:
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000233 memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
234 return 1;
235}
236
237/* very simplistic detection of IPv4 or IPv6 headers */
238static bool possibly_iphdr(const char *data)
239{
240 return (data[0] & 0xd0) == 0x40;
241}
242
243/* disallow addresses which may be confused with IP headers */
244static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
245{
246 struct sockaddr *addr = p;
247
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;
253}
254
255static 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,
263};
264
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100265/* using a counter to merge subdriver requests with our own into a combined state */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000266static int qmi_wwan_manage_power(struct usbnet *dev, int on)
267{
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100268 atomic_t *pmcount = (void *)&dev->data[1];
269 int rv = 0;
270
271 dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(pmcount), on);
272
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);
280 }
281err:
282 return rv;
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000283}
284
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100285static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
286{
287 struct usbnet *dev = usb_get_intfdata(intf);
Bjørn Morka71e15c2012-06-21 23:11:18 +0000288
289 /* can be called while disconnecting */
290 if (!dev)
291 return 0;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100292 return qmi_wwan_manage_power(dev, on);
293}
294
295/* Some devices combine the "control" and "data" functions into a
296 * single interface with all three endpoints: interrupt + bulk in and
297 * out
298 *
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.
302 */
303static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
304{
305 int rv;
306 struct usb_driver *subdriver = NULL;
307 atomic_t *pmcount = (void *)&dev->data[1];
308
Bjørn Mork11207b62012-03-16 15:41:27 +0100309 /* 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
315 */
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;
321 }
322
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100323 atomic_set(pmcount, 0);
324
325 /* collect all three endpoints */
326 rv = usbnet_get_endpoints(dev, intf);
327 if (rv < 0)
328 goto err;
329
330 /* require interrupt endpoint for subdriver */
331 if (!dev->status) {
332 rv = -EINVAL;
333 goto err;
334 }
335
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;
340 }
341
342 /* can't let usbnet use the interrupt endpoint */
343 dev->status = NULL;
344
345 /* save subdriver struct for suspend/resume wrappers */
346 dev->data[0] = (unsigned long)subdriver;
347
Bjørn Mork1203d9c2013-04-18 12:57:11 +0000348 /* Never use the same address on both ends of the link, even
349 * if the buggy firmware told us to.
350 */
351 if (!compare_ether_addr(dev->net->dev_addr, default_modem_addr))
352 eth_hw_addr_random(dev->net);
353
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000354 /* 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 */
358 }
359 dev->net->netdev_ops = &qmi_wwan_netdev_ops;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100360err:
361 return rv;
362}
363
364static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf)
365{
366 struct usb_driver *subdriver = (void *)dev->data[0];
367
368 if (subdriver && subdriver->disconnect)
369 subdriver->disconnect(intf);
370
371 dev->data[0] = (unsigned long)NULL;
372}
373
374/* suspend/resume wrappers calling both usbnet and the cdc-wdm
375 * subdriver if present.
376 *
377 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
378 * wrappers for those without adding usbnet reset support first.
379 */
380static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
381{
382 struct usbnet *dev = usb_get_intfdata(intf);
383 struct usb_driver *subdriver = (void *)dev->data[0];
384 int ret;
385
386 ret = usbnet_suspend(intf, message);
387 if (ret < 0)
388 goto err;
389
390 if (subdriver && subdriver->suspend)
391 ret = subdriver->suspend(intf, message);
392 if (ret < 0)
393 usbnet_resume(intf);
394err:
395 return ret;
396}
397
398static int qmi_wwan_resume(struct usb_interface *intf)
399{
400 struct usbnet *dev = usb_get_intfdata(intf);
401 struct usb_driver *subdriver = (void *)dev->data[0];
402 int ret = 0;
403
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);
411err:
412 return ret;
413}
414
415
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000416static 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,
421};
422
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100423static 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,
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000429 .rx_fixup = qmi_wwan_rx_fixup,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100430};
431
Bjørn Mork4dd20782012-06-21 02:45:58 +0000432static const struct driver_info qmi_wwan_force_int0 = {
433 .description = "Qualcomm WWAN/QMI device",
Bjørn Morkb086cf02012-03-09 12:35:06 +0100434 .flags = FLAG_WWAN,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000435 .bind = qmi_wwan_bind_shared,
Bjørn Morkb086cf02012-03-09 12:35:06 +0100436 .unbind = qmi_wwan_unbind_shared,
437 .manage_power = qmi_wwan_manage_power,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000438 .data = BIT(0), /* interface whitelist bitmap */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100439};
440
Andrew Bird (Sphere Systems)6052c2a2012-05-19 22:28:38 +0000441static 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 */
448};
449
Bjørn Morke7f558c2012-07-05 01:13:33 +0000450static 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 */
457};
458
Bjørn Mork4dd20782012-06-21 02:45:58 +0000459static 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 */
466};
467
Bjørn Mork11207b62012-03-16 15:41:27 +0100468static const struct driver_info qmi_wwan_force_int4 = {
Andrew Bird (Sphere Systems)eb2e99b2012-05-19 22:28:36 +0000469 .description = "Qualcomm WWAN/QMI device",
Bjørn Mork11207b62012-03-16 15:41:27 +0100470 .flags = FLAG_WWAN,
Andrew Bird (Sphere Systems)eb2e99b2012-05-19 22:28:36 +0000471 .bind = qmi_wwan_bind_shared,
Bjørn Mork11207b62012-03-16 15:41:27 +0100472 .unbind = qmi_wwan_unbind_shared,
473 .manage_power = qmi_wwan_manage_power,
474 .data = BIT(4), /* interface whitelist bitmap */
475};
476
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000477/* 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
482 *
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.
486 *
487 * FIXME: The below whitelist should include BIT(20). It does not
488 * because I cannot get it to work...
489 */
490static const struct driver_info qmi_wwan_sierra = {
491 .description = "Sierra Wireless wwan/QMI device",
492 .flags = FLAG_WWAN,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000493 .bind = qmi_wwan_bind_shared,
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000494 .unbind = qmi_wwan_unbind_shared,
495 .manage_power = qmi_wwan_manage_power,
496 .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
497};
Bjørn Mork11207b62012-03-16 15:41:27 +0100498
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000499#define HUAWEI_VENDOR_ID 0x12D1
Bjørn Mork4dd20782012-06-21 02:45:58 +0000500
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
505
506/* Gobi 2000 and Gobi 3000 QMI/wwan interface number is 0 according to qcserial */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100507#define QMI_GOBI_DEVICE(vend, prod) \
508 USB_DEVICE(vend, prod), \
Bjørn Mork4dd20782012-06-21 02:45:58 +0000509 .driver_info = (unsigned long)&qmi_wwan_force_int0
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000510
511static const struct usb_device_id products[] = {
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100512 { /* 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,
519 },
Bjørn Mork11cbc502012-05-19 07:20:31 +0000520 { /* 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,
527 },
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100528 { /* Huawei E392, E398 and possibly others in "Windows mode"
529 * using a combined control and data interface without any CDC
530 * functional descriptors
531 */
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,
538 },
Bjørn Morkb086cf02012-03-09 12:35:06 +0100539 { /* 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,
547 },
Bjørn Mork64255042012-08-23 12:13:58 +0200548 { /* 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,
556 },
Bjørn Mork11207b62012-03-16 15:41:27 +0100557 { /* 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,
565 },
Bjørn Morke7861ce2012-07-12 01:18:26 +0000566 { /* 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,
574 },
Andrew Bird (Sphere Systems)6052c2a2012-05-19 22:28:38 +0000575 { /* 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,
583 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000584 { /* 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,
592 },
Andrew Bird (Sphere Systems)dbb6d092012-03-25 00:10:29 +0000593 { /* 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,
601 },
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,
610 },
Andrew Bird (Sphere Systems)4bf003852012-05-19 22:28:37 +0000611 { /* 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,
619 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000620 { /* 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,
628 },
Bjørn Mork64255042012-08-23 12:13:58 +0200629 { /* 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,
637 },
Bjørn Morke7f558c2012-07-05 01:13:33 +0000638 { /* 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,
646 },
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000647 { /* 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,
655 },
Bjørn Mork8d336272012-08-23 12:13:57 +0200656 { /* 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,
664 },
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,
673 },
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,
682 },
Bjørn Mork4dd20782012-06-21 02:45:58 +0000683
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 */
699
700 /* Gobi 2000 and 3000 devices */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100701 {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) */
Bjørn Mork8d336272012-08-23 12:13:57 +0200710 {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
711 {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100712 {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) */
Bjørn Morkbf5ebae2012-05-23 23:19:32 +0000726 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
727 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
Bjørn Mork8d336272012-08-23 12:13:57 +0200728 {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
729
Bjørn Morkb086cf02012-03-09 12:35:06 +0100730 { } /* END */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000731};
732MODULE_DEVICE_TABLE(usb, products);
733
734static struct usb_driver qmi_wwan_driver = {
735 .name = "qmi_wwan",
736 .id_table = products,
737 .probe = usbnet_probe,
738 .disconnect = usbnet_disconnect,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100739 .suspend = qmi_wwan_suspend,
740 .resume = qmi_wwan_resume,
741 .reset_resume = qmi_wwan_resume,
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000742 .supports_autosuspend = 1,
743};
744
745static int __init qmi_wwan_init(void)
746{
747 return usb_register(&qmi_wwan_driver);
748}
749module_init(qmi_wwan_init);
750
751static void __exit qmi_wwan_exit(void)
752{
753 usb_deregister(&qmi_wwan_driver);
754}
755module_exit(qmi_wwan_exit);
756
757MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
758MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
759MODULE_LICENSE("GPL");