blob: fe3be504d84b699bb0fde14956c61a2bf4f070ec [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 Mork8ed87e62013-04-18 12:57:09 +0000178/* Make up an ethernet header if the packet doesn't have one.
179 *
180 * A firmware bug common among several devices cause them to send raw
181 * IP packets under some circumstances. There is no way for the
182 * driver/host to know when this will happen. And even when the bug
183 * hits, some packets will still arrive with an intact header.
184 *
185 * The supported devices are only capably of sending IPv4, IPv6 and
186 * ARP packets on a point-to-point link. Any packet with an ethernet
187 * header will have either our address or a broadcast/multicast
188 * address as destination. ARP packets will always have a header.
189 *
190 * This means that this function will reliably add the appropriate
191 * header iff necessary, provided our hardware address does not start
192 * with 4 or 6.
Bjørn Morkd8abf422013-04-18 12:57:10 +0000193 *
194 * Another common firmware bug results in all packets being addressed
195 * to 00:a0:c6:00:00:00 despite the host address being different.
196 * This function will also fixup such packets.
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000197 */
198static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
199{
200 __be16 proto;
201
202 /* usbnet rx_complete guarantees that skb->len is at least
203 * hard_header_len, so we can inspect the dest address without
204 * checking skb->len
205 */
206 switch (skb->data[0] & 0xf0) {
207 case 0x40:
208 proto = htons(ETH_P_IP);
209 break;
210 case 0x60:
211 proto = htons(ETH_P_IPV6);
212 break;
Bjørn Morkd8abf422013-04-18 12:57:10 +0000213 case 0x00:
214 if (is_multicast_ether_addr(skb->data))
215 return 1;
216 /* possibly bogus destination - rewrite just in case */
217 skb_reset_mac_header(skb);
218 goto fix_dest;
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000219 default:
220 /* pass along other packets without modifications */
221 return 1;
222 }
223 if (skb_headroom(skb) < ETH_HLEN)
224 return 0;
225 skb_push(skb, ETH_HLEN);
226 skb_reset_mac_header(skb);
227 eth_hdr(skb)->h_proto = proto;
228 memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
Bjørn Morkd8abf422013-04-18 12:57:10 +0000229fix_dest:
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000230 memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
231 return 1;
232}
233
234/* very simplistic detection of IPv4 or IPv6 headers */
235static bool possibly_iphdr(const char *data)
236{
237 return (data[0] & 0xd0) == 0x40;
238}
239
240/* disallow addresses which may be confused with IP headers */
241static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
242{
243 struct sockaddr *addr = p;
244
245 if (!is_valid_ether_addr(addr->sa_data) ||
246 possibly_iphdr(addr->sa_data))
247 return -EADDRNOTAVAIL;
248 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
249 return 0;
250}
251
252static const struct net_device_ops qmi_wwan_netdev_ops = {
253 .ndo_open = usbnet_open,
254 .ndo_stop = usbnet_stop,
255 .ndo_start_xmit = usbnet_start_xmit,
256 .ndo_tx_timeout = usbnet_tx_timeout,
257 .ndo_change_mtu = usbnet_change_mtu,
258 .ndo_set_mac_address = qmi_wwan_mac_addr,
259 .ndo_validate_addr = eth_validate_addr,
260};
261
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100262/* using a counter to merge subdriver requests with our own into a combined state */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000263static int qmi_wwan_manage_power(struct usbnet *dev, int on)
264{
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100265 atomic_t *pmcount = (void *)&dev->data[1];
266 int rv = 0;
267
268 dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(pmcount), on);
269
270 if ((on && atomic_add_return(1, pmcount) == 1) || (!on && atomic_dec_and_test(pmcount))) {
271 /* need autopm_get/put here to ensure the usbcore sees the new value */
272 rv = usb_autopm_get_interface(dev->intf);
273 if (rv < 0)
274 goto err;
275 dev->intf->needs_remote_wakeup = on;
276 usb_autopm_put_interface(dev->intf);
277 }
278err:
279 return rv;
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000280}
281
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100282static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
283{
284 struct usbnet *dev = usb_get_intfdata(intf);
Bjørn Morka71e15c2012-06-21 23:11:18 +0000285
286 /* can be called while disconnecting */
287 if (!dev)
288 return 0;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100289 return qmi_wwan_manage_power(dev, on);
290}
291
292/* Some devices combine the "control" and "data" functions into a
293 * single interface with all three endpoints: interrupt + bulk in and
294 * out
295 *
296 * Setting up cdc-wdm as a subdriver owning the interrupt endpoint
297 * will let it provide userspace access to the encapsulated QMI
298 * protocol without interfering with the usbnet operations.
299 */
300static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
301{
302 int rv;
303 struct usb_driver *subdriver = NULL;
304 atomic_t *pmcount = (void *)&dev->data[1];
305
Bjørn Mork11207b62012-03-16 15:41:27 +0100306 /* ZTE makes devices where the interface descriptors and endpoint
307 * configurations of two or more interfaces are identical, even
308 * though the functions are completely different. If set, then
309 * driver_info->data is a bitmap of acceptable interface numbers
310 * allowing us to bind to one such interface without binding to
311 * all of them
312 */
313 if (dev->driver_info->data &&
314 !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) {
315 dev_info(&intf->dev, "not on our whitelist - ignored");
316 rv = -ENODEV;
317 goto err;
318 }
319
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100320 atomic_set(pmcount, 0);
321
322 /* collect all three endpoints */
323 rv = usbnet_get_endpoints(dev, intf);
324 if (rv < 0)
325 goto err;
326
327 /* require interrupt endpoint for subdriver */
328 if (!dev->status) {
329 rv = -EINVAL;
330 goto err;
331 }
332
333 subdriver = usb_cdc_wdm_register(intf, &dev->status->desc, 512, &qmi_wwan_cdc_wdm_manage_power);
334 if (IS_ERR(subdriver)) {
335 rv = PTR_ERR(subdriver);
336 goto err;
337 }
338
339 /* can't let usbnet use the interrupt endpoint */
340 dev->status = NULL;
341
342 /* save subdriver struct for suspend/resume wrappers */
343 dev->data[0] = (unsigned long)subdriver;
344
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000345 /* make MAC addr easily distinguishable from an IP header */
346 if (possibly_iphdr(dev->net->dev_addr)) {
347 dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */
348 dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */
349 }
350 dev->net->netdev_ops = &qmi_wwan_netdev_ops;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100351err:
352 return rv;
353}
354
355static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf)
356{
357 struct usb_driver *subdriver = (void *)dev->data[0];
358
359 if (subdriver && subdriver->disconnect)
360 subdriver->disconnect(intf);
361
362 dev->data[0] = (unsigned long)NULL;
363}
364
365/* suspend/resume wrappers calling both usbnet and the cdc-wdm
366 * subdriver if present.
367 *
368 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
369 * wrappers for those without adding usbnet reset support first.
370 */
371static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
372{
373 struct usbnet *dev = usb_get_intfdata(intf);
374 struct usb_driver *subdriver = (void *)dev->data[0];
375 int ret;
376
377 ret = usbnet_suspend(intf, message);
378 if (ret < 0)
379 goto err;
380
381 if (subdriver && subdriver->suspend)
382 ret = subdriver->suspend(intf, message);
383 if (ret < 0)
384 usbnet_resume(intf);
385err:
386 return ret;
387}
388
389static int qmi_wwan_resume(struct usb_interface *intf)
390{
391 struct usbnet *dev = usb_get_intfdata(intf);
392 struct usb_driver *subdriver = (void *)dev->data[0];
393 int ret = 0;
394
395 if (subdriver && subdriver->resume)
396 ret = subdriver->resume(intf);
397 if (ret < 0)
398 goto err;
399 ret = usbnet_resume(intf);
400 if (ret < 0 && subdriver && subdriver->resume && subdriver->suspend)
401 subdriver->suspend(intf, PMSG_SUSPEND);
402err:
403 return ret;
404}
405
406
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000407static const struct driver_info qmi_wwan_info = {
408 .description = "QMI speaking wwan device",
409 .flags = FLAG_WWAN,
410 .bind = qmi_wwan_bind,
411 .manage_power = qmi_wwan_manage_power,
412};
413
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100414static const struct driver_info qmi_wwan_shared = {
415 .description = "QMI speaking wwan device with combined interface",
416 .flags = FLAG_WWAN,
417 .bind = qmi_wwan_bind_shared,
418 .unbind = qmi_wwan_unbind_shared,
419 .manage_power = qmi_wwan_manage_power,
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000420 .rx_fixup = qmi_wwan_rx_fixup,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100421};
422
Bjørn Mork4dd20782012-06-21 02:45:58 +0000423static const struct driver_info qmi_wwan_force_int0 = {
424 .description = "Qualcomm WWAN/QMI device",
Bjørn Morkb086cf02012-03-09 12:35:06 +0100425 .flags = FLAG_WWAN,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000426 .bind = qmi_wwan_bind_shared,
Bjørn Morkb086cf02012-03-09 12:35:06 +0100427 .unbind = qmi_wwan_unbind_shared,
428 .manage_power = qmi_wwan_manage_power,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000429 .data = BIT(0), /* interface whitelist bitmap */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100430};
431
Andrew Bird (Sphere Systems)6052c2a2012-05-19 22:28:38 +0000432static const struct driver_info qmi_wwan_force_int1 = {
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(1), /* interface whitelist bitmap */
439};
440
Bjørn Morke7f558c2012-07-05 01:13:33 +0000441static const struct driver_info qmi_wwan_force_int2 = {
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(2), /* interface whitelist bitmap */
448};
449
Bjørn Mork4dd20782012-06-21 02:45:58 +0000450static const struct driver_info qmi_wwan_force_int3 = {
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(3), /* interface whitelist bitmap */
457};
458
Bjørn Mork11207b62012-03-16 15:41:27 +0100459static const struct driver_info qmi_wwan_force_int4 = {
Andrew Bird (Sphere Systems)eb2e99b2012-05-19 22:28:36 +0000460 .description = "Qualcomm WWAN/QMI device",
Bjørn Mork11207b62012-03-16 15:41:27 +0100461 .flags = FLAG_WWAN,
Andrew Bird (Sphere Systems)eb2e99b2012-05-19 22:28:36 +0000462 .bind = qmi_wwan_bind_shared,
Bjørn Mork11207b62012-03-16 15:41:27 +0100463 .unbind = qmi_wwan_unbind_shared,
464 .manage_power = qmi_wwan_manage_power,
465 .data = BIT(4), /* interface whitelist bitmap */
466};
467
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000468/* Sierra Wireless provide equally useless interface descriptors
469 * Devices in QMI mode can be switched between two different
470 * configurations:
471 * a) USB interface #8 is QMI/wwan
472 * b) USB interfaces #8, #19 and #20 are QMI/wwan
473 *
474 * Both configurations provide a number of other interfaces (serial++),
475 * some of which have the same endpoint configuration as we expect, so
476 * a whitelist or blacklist is necessary.
477 *
478 * FIXME: The below whitelist should include BIT(20). It does not
479 * because I cannot get it to work...
480 */
481static const struct driver_info qmi_wwan_sierra = {
482 .description = "Sierra Wireless wwan/QMI device",
483 .flags = FLAG_WWAN,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000484 .bind = qmi_wwan_bind_shared,
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000485 .unbind = qmi_wwan_unbind_shared,
486 .manage_power = qmi_wwan_manage_power,
487 .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
488};
Bjørn Mork11207b62012-03-16 15:41:27 +0100489
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000490#define HUAWEI_VENDOR_ID 0x12D1
Bjørn Mork4dd20782012-06-21 02:45:58 +0000491
492/* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
493#define QMI_GOBI1K_DEVICE(vend, prod) \
494 USB_DEVICE(vend, prod), \
495 .driver_info = (unsigned long)&qmi_wwan_force_int3
496
497/* Gobi 2000 and Gobi 3000 QMI/wwan interface number is 0 according to qcserial */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100498#define QMI_GOBI_DEVICE(vend, prod) \
499 USB_DEVICE(vend, prod), \
Bjørn Mork4dd20782012-06-21 02:45:58 +0000500 .driver_info = (unsigned long)&qmi_wwan_force_int0
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000501
502static const struct usb_device_id products[] = {
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100503 { /* Huawei E392, E398 and possibly others sharing both device id and more... */
504 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
505 .idVendor = HUAWEI_VENDOR_ID,
506 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
507 .bInterfaceSubClass = 1,
508 .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */
509 .driver_info = (unsigned long)&qmi_wwan_info,
510 },
Bjørn Mork11cbc502012-05-19 07:20:31 +0000511 { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
512 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
513 .idVendor = HUAWEI_VENDOR_ID,
514 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
515 .bInterfaceSubClass = 1,
516 .bInterfaceProtocol = 56, /* NOTE: This is the *slave* interface of the CDC Union! */
517 .driver_info = (unsigned long)&qmi_wwan_info,
518 },
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100519 { /* Huawei E392, E398 and possibly others in "Windows mode"
520 * using a combined control and data interface without any CDC
521 * functional descriptors
522 */
523 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
524 .idVendor = HUAWEI_VENDOR_ID,
525 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
526 .bInterfaceSubClass = 1,
527 .bInterfaceProtocol = 17,
528 .driver_info = (unsigned long)&qmi_wwan_shared,
529 },
Bjørn Morkb086cf02012-03-09 12:35:06 +0100530 { /* Pantech UML290 */
531 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
532 .idVendor = 0x106c,
533 .idProduct = 0x3718,
534 .bInterfaceClass = 0xff,
535 .bInterfaceSubClass = 0xf0,
536 .bInterfaceProtocol = 0xff,
537 .driver_info = (unsigned long)&qmi_wwan_shared,
538 },
Bjørn Mork64255042012-08-23 12:13:58 +0200539 { /* Pantech UML290 - newer firmware */
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 = 0xf1,
545 .bInterfaceProtocol = 0xff,
546 .driver_info = (unsigned long)&qmi_wwan_shared,
547 },
Bjørn Mork11207b62012-03-16 15:41:27 +0100548 { /* ZTE MF820D */
549 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
550 .idVendor = 0x19d2,
551 .idProduct = 0x0167,
552 .bInterfaceClass = 0xff,
553 .bInterfaceSubClass = 0xff,
554 .bInterfaceProtocol = 0xff,
555 .driver_info = (unsigned long)&qmi_wwan_force_int4,
556 },
Bjørn Morke7861ce2012-07-12 01:18:26 +0000557 { /* ZTE MF821D */
558 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
559 .idVendor = 0x19d2,
560 .idProduct = 0x0326,
561 .bInterfaceClass = 0xff,
562 .bInterfaceSubClass = 0xff,
563 .bInterfaceProtocol = 0xff,
564 .driver_info = (unsigned long)&qmi_wwan_force_int4,
565 },
Andrew Bird (Sphere Systems)6052c2a2012-05-19 22:28:38 +0000566 { /* ZTE (Vodafone) K3520-Z */
567 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
568 .idVendor = 0x19d2,
569 .idProduct = 0x0055,
570 .bInterfaceClass = 0xff,
571 .bInterfaceSubClass = 0xff,
572 .bInterfaceProtocol = 0xff,
573 .driver_info = (unsigned long)&qmi_wwan_force_int1,
574 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000575 { /* ZTE (Vodafone) K3565-Z */
576 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
577 .idVendor = 0x19d2,
578 .idProduct = 0x0063,
579 .bInterfaceClass = 0xff,
580 .bInterfaceSubClass = 0xff,
581 .bInterfaceProtocol = 0xff,
582 .driver_info = (unsigned long)&qmi_wwan_force_int4,
583 },
Andrew Bird (Sphere Systems)dbb6d092012-03-25 00:10:29 +0000584 { /* ZTE (Vodafone) K3570-Z */
585 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
586 .idVendor = 0x19d2,
587 .idProduct = 0x1008,
588 .bInterfaceClass = 0xff,
589 .bInterfaceSubClass = 0xff,
590 .bInterfaceProtocol = 0xff,
591 .driver_info = (unsigned long)&qmi_wwan_force_int4,
592 },
593 { /* ZTE (Vodafone) K3571-Z */
594 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
595 .idVendor = 0x19d2,
596 .idProduct = 0x1010,
597 .bInterfaceClass = 0xff,
598 .bInterfaceSubClass = 0xff,
599 .bInterfaceProtocol = 0xff,
600 .driver_info = (unsigned long)&qmi_wwan_force_int4,
601 },
Andrew Bird (Sphere Systems)4bf003852012-05-19 22:28:37 +0000602 { /* ZTE (Vodafone) K3765-Z */
603 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
604 .idVendor = 0x19d2,
605 .idProduct = 0x2002,
606 .bInterfaceClass = 0xff,
607 .bInterfaceSubClass = 0xff,
608 .bInterfaceProtocol = 0xff,
609 .driver_info = (unsigned long)&qmi_wwan_force_int4,
610 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000611 { /* ZTE (Vodafone) K4505-Z */
612 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
613 .idVendor = 0x19d2,
614 .idProduct = 0x0104,
615 .bInterfaceClass = 0xff,
616 .bInterfaceSubClass = 0xff,
617 .bInterfaceProtocol = 0xff,
618 .driver_info = (unsigned long)&qmi_wwan_force_int4,
619 },
Bjørn Mork64255042012-08-23 12:13:58 +0200620 { /* ZTE (Vodafone) K5006-Z */
621 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
622 .idVendor = 0x19d2,
623 .idProduct = 0x1018,
624 .bInterfaceClass = 0xff,
625 .bInterfaceSubClass = 0xff,
626 .bInterfaceProtocol = 0xff,
627 .driver_info = (unsigned long)&qmi_wwan_force_int3,
628 },
Bjørn Morke7f558c2012-07-05 01:13:33 +0000629 { /* ZTE MF60 */
630 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
631 .idVendor = 0x19d2,
632 .idProduct = 0x1402,
633 .bInterfaceClass = 0xff,
634 .bInterfaceSubClass = 0xff,
635 .bInterfaceProtocol = 0xff,
636 .driver_info = (unsigned long)&qmi_wwan_force_int2,
637 },
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000638 { /* Sierra Wireless MC77xx in QMI mode */
639 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
640 .idVendor = 0x1199,
641 .idProduct = 0x68a2,
642 .bInterfaceClass = 0xff,
643 .bInterfaceSubClass = 0xff,
644 .bInterfaceProtocol = 0xff,
645 .driver_info = (unsigned long)&qmi_wwan_sierra,
646 },
Bjørn Mork8d336272012-08-23 12:13:57 +0200647 { /* Sierra Wireless MC7700 */
648 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
649 .idVendor = 0x0f3d,
650 .idProduct = 0x68a2,
651 .bInterfaceClass = 0xff,
652 .bInterfaceSubClass = 0xff,
653 .bInterfaceProtocol = 0xff,
654 .driver_info = (unsigned long)&qmi_wwan_sierra,
655 },
656 { /* Sierra Wireless MC7750 */
657 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
658 .idVendor = 0x114f,
659 .idProduct = 0x68a2,
660 .bInterfaceClass = 0xff,
661 .bInterfaceSubClass = 0xff,
662 .bInterfaceProtocol = 0xff,
663 .driver_info = (unsigned long)&qmi_wwan_sierra,
664 },
665 { /* Sierra Wireless EM7700 */
666 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
667 .idVendor = 0x1199,
668 .idProduct = 0x901c,
669 .bInterfaceClass = 0xff,
670 .bInterfaceSubClass = 0xff,
671 .bInterfaceProtocol = 0xff,
672 .driver_info = (unsigned long)&qmi_wwan_sierra,
673 },
Bjørn Mork4dd20782012-06-21 02:45:58 +0000674
675 /* Gobi 1000 devices */
676 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
677 {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
678 {QMI_GOBI1K_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
679 {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
680 {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
681 {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
682 {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
683 {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
684 {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
685 {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
686 {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
687 {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
688 {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
689 {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
690
691 /* Gobi 2000 and 3000 devices */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100692 {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
693 {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
694 {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
695 {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
696 {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
697 {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
698 {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
699 {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
700 {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
Bjørn Mork8d336272012-08-23 12:13:57 +0200701 {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
702 {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100703 {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
704 {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
705 {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
706 {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
707 {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
708 {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
709 {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
710 {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
711 {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
712 {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
713 {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
714 {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
715 {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
716 {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
Bjørn Morkbf5ebae2012-05-23 23:19:32 +0000717 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
718 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
Bjørn Mork8d336272012-08-23 12:13:57 +0200719 {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
720
Bjørn Morkb086cf02012-03-09 12:35:06 +0100721 { } /* END */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000722};
723MODULE_DEVICE_TABLE(usb, products);
724
725static struct usb_driver qmi_wwan_driver = {
726 .name = "qmi_wwan",
727 .id_table = products,
728 .probe = usbnet_probe,
729 .disconnect = usbnet_disconnect,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100730 .suspend = qmi_wwan_suspend,
731 .resume = qmi_wwan_resume,
732 .reset_resume = qmi_wwan_resume,
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000733 .supports_autosuspend = 1,
734};
735
736static int __init qmi_wwan_init(void)
737{
738 return usb_register(&qmi_wwan_driver);
739}
740module_init(qmi_wwan_init);
741
742static void __exit qmi_wwan_exit(void)
743{
744 usb_deregister(&qmi_wwan_driver);
745}
746module_exit(qmi_wwan_exit);
747
748MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
749MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
750MODULE_LICENSE("GPL");