blob: e558d414ded19c8c7023f9a9dc655eca0a957b7c [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.
193 */
194static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
195{
196 __be16 proto;
197
198 /* usbnet rx_complete guarantees that skb->len is at least
199 * hard_header_len, so we can inspect the dest address without
200 * checking skb->len
201 */
202 switch (skb->data[0] & 0xf0) {
203 case 0x40:
204 proto = htons(ETH_P_IP);
205 break;
206 case 0x60:
207 proto = htons(ETH_P_IPV6);
208 break;
209 default:
210 /* pass along other packets without modifications */
211 return 1;
212 }
213 if (skb_headroom(skb) < ETH_HLEN)
214 return 0;
215 skb_push(skb, ETH_HLEN);
216 skb_reset_mac_header(skb);
217 eth_hdr(skb)->h_proto = proto;
218 memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
219 memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
220 return 1;
221}
222
223/* very simplistic detection of IPv4 or IPv6 headers */
224static bool possibly_iphdr(const char *data)
225{
226 return (data[0] & 0xd0) == 0x40;
227}
228
229/* disallow addresses which may be confused with IP headers */
230static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
231{
232 struct sockaddr *addr = p;
233
234 if (!is_valid_ether_addr(addr->sa_data) ||
235 possibly_iphdr(addr->sa_data))
236 return -EADDRNOTAVAIL;
237 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
238 return 0;
239}
240
241static const struct net_device_ops qmi_wwan_netdev_ops = {
242 .ndo_open = usbnet_open,
243 .ndo_stop = usbnet_stop,
244 .ndo_start_xmit = usbnet_start_xmit,
245 .ndo_tx_timeout = usbnet_tx_timeout,
246 .ndo_change_mtu = usbnet_change_mtu,
247 .ndo_set_mac_address = qmi_wwan_mac_addr,
248 .ndo_validate_addr = eth_validate_addr,
249};
250
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100251/* using a counter to merge subdriver requests with our own into a combined state */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000252static int qmi_wwan_manage_power(struct usbnet *dev, int on)
253{
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100254 atomic_t *pmcount = (void *)&dev->data[1];
255 int rv = 0;
256
257 dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(pmcount), on);
258
259 if ((on && atomic_add_return(1, pmcount) == 1) || (!on && atomic_dec_and_test(pmcount))) {
260 /* need autopm_get/put here to ensure the usbcore sees the new value */
261 rv = usb_autopm_get_interface(dev->intf);
262 if (rv < 0)
263 goto err;
264 dev->intf->needs_remote_wakeup = on;
265 usb_autopm_put_interface(dev->intf);
266 }
267err:
268 return rv;
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000269}
270
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100271static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
272{
273 struct usbnet *dev = usb_get_intfdata(intf);
Bjørn Morka71e15c2012-06-21 23:11:18 +0000274
275 /* can be called while disconnecting */
276 if (!dev)
277 return 0;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100278 return qmi_wwan_manage_power(dev, on);
279}
280
281/* Some devices combine the "control" and "data" functions into a
282 * single interface with all three endpoints: interrupt + bulk in and
283 * out
284 *
285 * Setting up cdc-wdm as a subdriver owning the interrupt endpoint
286 * will let it provide userspace access to the encapsulated QMI
287 * protocol without interfering with the usbnet operations.
288 */
289static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
290{
291 int rv;
292 struct usb_driver *subdriver = NULL;
293 atomic_t *pmcount = (void *)&dev->data[1];
294
Bjørn Mork11207b62012-03-16 15:41:27 +0100295 /* ZTE makes devices where the interface descriptors and endpoint
296 * configurations of two or more interfaces are identical, even
297 * though the functions are completely different. If set, then
298 * driver_info->data is a bitmap of acceptable interface numbers
299 * allowing us to bind to one such interface without binding to
300 * all of them
301 */
302 if (dev->driver_info->data &&
303 !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) {
304 dev_info(&intf->dev, "not on our whitelist - ignored");
305 rv = -ENODEV;
306 goto err;
307 }
308
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100309 atomic_set(pmcount, 0);
310
311 /* collect all three endpoints */
312 rv = usbnet_get_endpoints(dev, intf);
313 if (rv < 0)
314 goto err;
315
316 /* require interrupt endpoint for subdriver */
317 if (!dev->status) {
318 rv = -EINVAL;
319 goto err;
320 }
321
322 subdriver = usb_cdc_wdm_register(intf, &dev->status->desc, 512, &qmi_wwan_cdc_wdm_manage_power);
323 if (IS_ERR(subdriver)) {
324 rv = PTR_ERR(subdriver);
325 goto err;
326 }
327
328 /* can't let usbnet use the interrupt endpoint */
329 dev->status = NULL;
330
331 /* save subdriver struct for suspend/resume wrappers */
332 dev->data[0] = (unsigned long)subdriver;
333
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000334 /* make MAC addr easily distinguishable from an IP header */
335 if (possibly_iphdr(dev->net->dev_addr)) {
336 dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */
337 dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */
338 }
339 dev->net->netdev_ops = &qmi_wwan_netdev_ops;
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100340err:
341 return rv;
342}
343
344static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf)
345{
346 struct usb_driver *subdriver = (void *)dev->data[0];
347
348 if (subdriver && subdriver->disconnect)
349 subdriver->disconnect(intf);
350
351 dev->data[0] = (unsigned long)NULL;
352}
353
354/* suspend/resume wrappers calling both usbnet and the cdc-wdm
355 * subdriver if present.
356 *
357 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
358 * wrappers for those without adding usbnet reset support first.
359 */
360static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
361{
362 struct usbnet *dev = usb_get_intfdata(intf);
363 struct usb_driver *subdriver = (void *)dev->data[0];
364 int ret;
365
366 ret = usbnet_suspend(intf, message);
367 if (ret < 0)
368 goto err;
369
370 if (subdriver && subdriver->suspend)
371 ret = subdriver->suspend(intf, message);
372 if (ret < 0)
373 usbnet_resume(intf);
374err:
375 return ret;
376}
377
378static int qmi_wwan_resume(struct usb_interface *intf)
379{
380 struct usbnet *dev = usb_get_intfdata(intf);
381 struct usb_driver *subdriver = (void *)dev->data[0];
382 int ret = 0;
383
384 if (subdriver && subdriver->resume)
385 ret = subdriver->resume(intf);
386 if (ret < 0)
387 goto err;
388 ret = usbnet_resume(intf);
389 if (ret < 0 && subdriver && subdriver->resume && subdriver->suspend)
390 subdriver->suspend(intf, PMSG_SUSPEND);
391err:
392 return ret;
393}
394
395
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000396static const struct driver_info qmi_wwan_info = {
397 .description = "QMI speaking wwan device",
398 .flags = FLAG_WWAN,
399 .bind = qmi_wwan_bind,
400 .manage_power = qmi_wwan_manage_power,
401};
402
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100403static const struct driver_info qmi_wwan_shared = {
404 .description = "QMI speaking wwan device with combined interface",
405 .flags = FLAG_WWAN,
406 .bind = qmi_wwan_bind_shared,
407 .unbind = qmi_wwan_unbind_shared,
408 .manage_power = qmi_wwan_manage_power,
Bjørn Mork8ed87e62013-04-18 12:57:09 +0000409 .rx_fixup = qmi_wwan_rx_fixup,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100410};
411
Bjørn Mork4dd20782012-06-21 02:45:58 +0000412static const struct driver_info qmi_wwan_force_int0 = {
413 .description = "Qualcomm WWAN/QMI device",
Bjørn Morkb086cf02012-03-09 12:35:06 +0100414 .flags = FLAG_WWAN,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000415 .bind = qmi_wwan_bind_shared,
Bjørn Morkb086cf02012-03-09 12:35:06 +0100416 .unbind = qmi_wwan_unbind_shared,
417 .manage_power = qmi_wwan_manage_power,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000418 .data = BIT(0), /* interface whitelist bitmap */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100419};
420
Andrew Bird (Sphere Systems)6052c2a2012-05-19 22:28:38 +0000421static const struct driver_info qmi_wwan_force_int1 = {
422 .description = "Qualcomm WWAN/QMI device",
423 .flags = FLAG_WWAN,
424 .bind = qmi_wwan_bind_shared,
425 .unbind = qmi_wwan_unbind_shared,
426 .manage_power = qmi_wwan_manage_power,
427 .data = BIT(1), /* interface whitelist bitmap */
428};
429
Bjørn Morke7f558c2012-07-05 01:13:33 +0000430static const struct driver_info qmi_wwan_force_int2 = {
431 .description = "Qualcomm WWAN/QMI device",
432 .flags = FLAG_WWAN,
433 .bind = qmi_wwan_bind_shared,
434 .unbind = qmi_wwan_unbind_shared,
435 .manage_power = qmi_wwan_manage_power,
436 .data = BIT(2), /* interface whitelist bitmap */
437};
438
Bjørn Mork4dd20782012-06-21 02:45:58 +0000439static const struct driver_info qmi_wwan_force_int3 = {
440 .description = "Qualcomm WWAN/QMI device",
441 .flags = FLAG_WWAN,
442 .bind = qmi_wwan_bind_shared,
443 .unbind = qmi_wwan_unbind_shared,
444 .manage_power = qmi_wwan_manage_power,
445 .data = BIT(3), /* interface whitelist bitmap */
446};
447
Bjørn Mork11207b62012-03-16 15:41:27 +0100448static const struct driver_info qmi_wwan_force_int4 = {
Andrew Bird (Sphere Systems)eb2e99b2012-05-19 22:28:36 +0000449 .description = "Qualcomm WWAN/QMI device",
Bjørn Mork11207b62012-03-16 15:41:27 +0100450 .flags = FLAG_WWAN,
Andrew Bird (Sphere Systems)eb2e99b2012-05-19 22:28:36 +0000451 .bind = qmi_wwan_bind_shared,
Bjørn Mork11207b62012-03-16 15:41:27 +0100452 .unbind = qmi_wwan_unbind_shared,
453 .manage_power = qmi_wwan_manage_power,
454 .data = BIT(4), /* interface whitelist bitmap */
455};
456
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000457/* Sierra Wireless provide equally useless interface descriptors
458 * Devices in QMI mode can be switched between two different
459 * configurations:
460 * a) USB interface #8 is QMI/wwan
461 * b) USB interfaces #8, #19 and #20 are QMI/wwan
462 *
463 * Both configurations provide a number of other interfaces (serial++),
464 * some of which have the same endpoint configuration as we expect, so
465 * a whitelist or blacklist is necessary.
466 *
467 * FIXME: The below whitelist should include BIT(20). It does not
468 * because I cannot get it to work...
469 */
470static const struct driver_info qmi_wwan_sierra = {
471 .description = "Sierra Wireless wwan/QMI device",
472 .flags = FLAG_WWAN,
Bjørn Mork4dd20782012-06-21 02:45:58 +0000473 .bind = qmi_wwan_bind_shared,
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000474 .unbind = qmi_wwan_unbind_shared,
475 .manage_power = qmi_wwan_manage_power,
476 .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
477};
Bjørn Mork11207b62012-03-16 15:41:27 +0100478
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000479#define HUAWEI_VENDOR_ID 0x12D1
Bjørn Mork4dd20782012-06-21 02:45:58 +0000480
481/* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
482#define QMI_GOBI1K_DEVICE(vend, prod) \
483 USB_DEVICE(vend, prod), \
484 .driver_info = (unsigned long)&qmi_wwan_force_int3
485
486/* Gobi 2000 and Gobi 3000 QMI/wwan interface number is 0 according to qcserial */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100487#define QMI_GOBI_DEVICE(vend, prod) \
488 USB_DEVICE(vend, prod), \
Bjørn Mork4dd20782012-06-21 02:45:58 +0000489 .driver_info = (unsigned long)&qmi_wwan_force_int0
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000490
491static const struct usb_device_id products[] = {
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100492 { /* Huawei E392, E398 and possibly others sharing both device id and more... */
493 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
494 .idVendor = HUAWEI_VENDOR_ID,
495 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
496 .bInterfaceSubClass = 1,
497 .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */
498 .driver_info = (unsigned long)&qmi_wwan_info,
499 },
Bjørn Mork11cbc502012-05-19 07:20:31 +0000500 { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
501 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
502 .idVendor = HUAWEI_VENDOR_ID,
503 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
504 .bInterfaceSubClass = 1,
505 .bInterfaceProtocol = 56, /* NOTE: This is the *slave* interface of the CDC Union! */
506 .driver_info = (unsigned long)&qmi_wwan_info,
507 },
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100508 { /* Huawei E392, E398 and possibly others in "Windows mode"
509 * using a combined control and data interface without any CDC
510 * functional descriptors
511 */
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 = 17,
517 .driver_info = (unsigned long)&qmi_wwan_shared,
518 },
Bjørn Morkb086cf02012-03-09 12:35:06 +0100519 { /* Pantech UML290 */
520 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
521 .idVendor = 0x106c,
522 .idProduct = 0x3718,
523 .bInterfaceClass = 0xff,
524 .bInterfaceSubClass = 0xf0,
525 .bInterfaceProtocol = 0xff,
526 .driver_info = (unsigned long)&qmi_wwan_shared,
527 },
Bjørn Mork64255042012-08-23 12:13:58 +0200528 { /* Pantech UML290 - newer firmware */
529 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
530 .idVendor = 0x106c,
531 .idProduct = 0x3718,
532 .bInterfaceClass = 0xff,
533 .bInterfaceSubClass = 0xf1,
534 .bInterfaceProtocol = 0xff,
535 .driver_info = (unsigned long)&qmi_wwan_shared,
536 },
Bjørn Mork11207b62012-03-16 15:41:27 +0100537 { /* ZTE MF820D */
538 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
539 .idVendor = 0x19d2,
540 .idProduct = 0x0167,
541 .bInterfaceClass = 0xff,
542 .bInterfaceSubClass = 0xff,
543 .bInterfaceProtocol = 0xff,
544 .driver_info = (unsigned long)&qmi_wwan_force_int4,
545 },
Bjørn Morke7861ce2012-07-12 01:18:26 +0000546 { /* ZTE MF821D */
547 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
548 .idVendor = 0x19d2,
549 .idProduct = 0x0326,
550 .bInterfaceClass = 0xff,
551 .bInterfaceSubClass = 0xff,
552 .bInterfaceProtocol = 0xff,
553 .driver_info = (unsigned long)&qmi_wwan_force_int4,
554 },
Andrew Bird (Sphere Systems)6052c2a2012-05-19 22:28:38 +0000555 { /* ZTE (Vodafone) K3520-Z */
556 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
557 .idVendor = 0x19d2,
558 .idProduct = 0x0055,
559 .bInterfaceClass = 0xff,
560 .bInterfaceSubClass = 0xff,
561 .bInterfaceProtocol = 0xff,
562 .driver_info = (unsigned long)&qmi_wwan_force_int1,
563 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000564 { /* ZTE (Vodafone) K3565-Z */
565 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
566 .idVendor = 0x19d2,
567 .idProduct = 0x0063,
568 .bInterfaceClass = 0xff,
569 .bInterfaceSubClass = 0xff,
570 .bInterfaceProtocol = 0xff,
571 .driver_info = (unsigned long)&qmi_wwan_force_int4,
572 },
Andrew Bird (Sphere Systems)dbb6d092012-03-25 00:10:29 +0000573 { /* ZTE (Vodafone) K3570-Z */
574 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
575 .idVendor = 0x19d2,
576 .idProduct = 0x1008,
577 .bInterfaceClass = 0xff,
578 .bInterfaceSubClass = 0xff,
579 .bInterfaceProtocol = 0xff,
580 .driver_info = (unsigned long)&qmi_wwan_force_int4,
581 },
582 { /* ZTE (Vodafone) K3571-Z */
583 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
584 .idVendor = 0x19d2,
585 .idProduct = 0x1010,
586 .bInterfaceClass = 0xff,
587 .bInterfaceSubClass = 0xff,
588 .bInterfaceProtocol = 0xff,
589 .driver_info = (unsigned long)&qmi_wwan_force_int4,
590 },
Andrew Bird (Sphere Systems)4bf003852012-05-19 22:28:37 +0000591 { /* ZTE (Vodafone) K3765-Z */
592 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
593 .idVendor = 0x19d2,
594 .idProduct = 0x2002,
595 .bInterfaceClass = 0xff,
596 .bInterfaceSubClass = 0xff,
597 .bInterfaceProtocol = 0xff,
598 .driver_info = (unsigned long)&qmi_wwan_force_int4,
599 },
Andrew Bird (Sphere Systems)1aa35a22012-03-25 00:10:27 +0000600 { /* ZTE (Vodafone) K4505-Z */
601 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
602 .idVendor = 0x19d2,
603 .idProduct = 0x0104,
604 .bInterfaceClass = 0xff,
605 .bInterfaceSubClass = 0xff,
606 .bInterfaceProtocol = 0xff,
607 .driver_info = (unsigned long)&qmi_wwan_force_int4,
608 },
Bjørn Mork64255042012-08-23 12:13:58 +0200609 { /* ZTE (Vodafone) K5006-Z */
610 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
611 .idVendor = 0x19d2,
612 .idProduct = 0x1018,
613 .bInterfaceClass = 0xff,
614 .bInterfaceSubClass = 0xff,
615 .bInterfaceProtocol = 0xff,
616 .driver_info = (unsigned long)&qmi_wwan_force_int3,
617 },
Bjørn Morke7f558c2012-07-05 01:13:33 +0000618 { /* ZTE MF60 */
619 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
620 .idVendor = 0x19d2,
621 .idProduct = 0x1402,
622 .bInterfaceClass = 0xff,
623 .bInterfaceSubClass = 0xff,
624 .bInterfaceProtocol = 0xff,
625 .driver_info = (unsigned long)&qmi_wwan_force_int2,
626 },
Bjørn Mork3bc17d12012-04-17 09:38:23 +0000627 { /* Sierra Wireless MC77xx in QMI mode */
628 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
629 .idVendor = 0x1199,
630 .idProduct = 0x68a2,
631 .bInterfaceClass = 0xff,
632 .bInterfaceSubClass = 0xff,
633 .bInterfaceProtocol = 0xff,
634 .driver_info = (unsigned long)&qmi_wwan_sierra,
635 },
Bjørn Mork8d336272012-08-23 12:13:57 +0200636 { /* Sierra Wireless MC7700 */
637 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
638 .idVendor = 0x0f3d,
639 .idProduct = 0x68a2,
640 .bInterfaceClass = 0xff,
641 .bInterfaceSubClass = 0xff,
642 .bInterfaceProtocol = 0xff,
643 .driver_info = (unsigned long)&qmi_wwan_sierra,
644 },
645 { /* Sierra Wireless MC7750 */
646 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
647 .idVendor = 0x114f,
648 .idProduct = 0x68a2,
649 .bInterfaceClass = 0xff,
650 .bInterfaceSubClass = 0xff,
651 .bInterfaceProtocol = 0xff,
652 .driver_info = (unsigned long)&qmi_wwan_sierra,
653 },
654 { /* Sierra Wireless EM7700 */
655 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
656 .idVendor = 0x1199,
657 .idProduct = 0x901c,
658 .bInterfaceClass = 0xff,
659 .bInterfaceSubClass = 0xff,
660 .bInterfaceProtocol = 0xff,
661 .driver_info = (unsigned long)&qmi_wwan_sierra,
662 },
Bjørn Mork4dd20782012-06-21 02:45:58 +0000663
664 /* Gobi 1000 devices */
665 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
666 {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
667 {QMI_GOBI1K_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
668 {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
669 {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
670 {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
671 {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
672 {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
673 {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
674 {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
675 {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
676 {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
677 {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
678 {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
679
680 /* Gobi 2000 and 3000 devices */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100681 {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
682 {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
683 {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
684 {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
685 {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
686 {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
687 {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
688 {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
689 {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
Bjørn Mork8d336272012-08-23 12:13:57 +0200690 {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
691 {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
Bjørn Morkb086cf02012-03-09 12:35:06 +0100692 {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
693 {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
694 {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
695 {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
696 {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
697 {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
698 {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
699 {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
700 {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
701 {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
702 {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
703 {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
704 {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
705 {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
Bjørn Morkbf5ebae2012-05-23 23:19:32 +0000706 {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
707 {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
Bjørn Mork8d336272012-08-23 12:13:57 +0200708 {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
709
Bjørn Morkb086cf02012-03-09 12:35:06 +0100710 { } /* END */
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000711};
712MODULE_DEVICE_TABLE(usb, products);
713
714static struct usb_driver qmi_wwan_driver = {
715 .name = "qmi_wwan",
716 .id_table = products,
717 .probe = usbnet_probe,
718 .disconnect = usbnet_disconnect,
Bjørn Morkc3ecb082012-03-09 12:35:05 +0100719 .suspend = qmi_wwan_suspend,
720 .resume = qmi_wwan_resume,
721 .reset_resume = qmi_wwan_resume,
Bjørn Mork423ce8c2012-01-19 15:37:22 +0000722 .supports_autosuspend = 1,
723};
724
725static int __init qmi_wwan_init(void)
726{
727 return usb_register(&qmi_wwan_driver);
728}
729module_init(qmi_wwan_init);
730
731static void __exit qmi_wwan_exit(void)
732{
733 usb_deregister(&qmi_wwan_driver);
734}
735module_exit(qmi_wwan_exit);
736
737MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
738MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
739MODULE_LICENSE("GPL");