qmi_wwan.c 26 KB

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