qmi_wwan.c 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. /*
  2. * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no>
  3. *
  4. * The probing code is heavily inspired by cdc_ether, which is:
  5. * Copyright (C) 2003-2005 by David Brownell
  6. * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/netdevice.h>
  14. #include <linux/ethtool.h>
  15. #include <linux/etherdevice.h>
  16. #include <linux/if_arp.h>
  17. #include <linux/mii.h>
  18. #include <linux/rtnetlink.h>
  19. #include <linux/usb.h>
  20. #include <linux/usb/cdc.h>
  21. #include <linux/usb/usbnet.h>
  22. #include <linux/usb/cdc-wdm.h>
  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. * Alternatively, control and data functions can be combined in a
  36. * single USB interface.
  37. *
  38. * Handling a protocol like QMI is out of the scope for any driver.
  39. * It is exported as a character device using the cdc-wdm driver as
  40. * a subdriver, enabling userspace applications ("modem managers") to
  41. * handle it.
  42. *
  43. * These devices may alternatively/additionally be configured using AT
  44. * commands on a serial interface
  45. */
  46. /* driver specific data */
  47. struct qmi_wwan_state {
  48. struct usb_driver *subdriver;
  49. atomic_t pmcount;
  50. unsigned long flags;
  51. struct usb_interface *control;
  52. struct usb_interface *data;
  53. };
  54. enum qmi_wwan_flags {
  55. QMI_WWAN_FLAG_RAWIP = 1 << 0,
  56. };
  57. enum qmi_wwan_quirks {
  58. QMI_WWAN_QUIRK_DTR = 1 << 0, /* needs "set DTR" request */
  59. };
  60. static void qmi_wwan_netdev_setup(struct net_device *net)
  61. {
  62. struct usbnet *dev = netdev_priv(net);
  63. struct qmi_wwan_state *info = (void *)&dev->data;
  64. if (info->flags & QMI_WWAN_FLAG_RAWIP) {
  65. net->header_ops = NULL; /* No header */
  66. net->type = ARPHRD_NONE;
  67. net->hard_header_len = 0;
  68. net->addr_len = 0;
  69. net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
  70. netdev_dbg(net, "mode: raw IP\n");
  71. } else if (!net->header_ops) { /* don't bother if already set */
  72. ether_setup(net);
  73. netdev_dbg(net, "mode: Ethernet\n");
  74. }
  75. /* recalculate buffers after changing hard_header_len */
  76. usbnet_change_mtu(net, net->mtu);
  77. }
  78. static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf)
  79. {
  80. struct usbnet *dev = netdev_priv(to_net_dev(d));
  81. struct qmi_wwan_state *info = (void *)&dev->data;
  82. return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N');
  83. }
  84. static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len)
  85. {
  86. struct usbnet *dev = netdev_priv(to_net_dev(d));
  87. struct qmi_wwan_state *info = (void *)&dev->data;
  88. bool enable;
  89. int ret;
  90. if (strtobool(buf, &enable))
  91. return -EINVAL;
  92. /* no change? */
  93. if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP))
  94. return len;
  95. if (!rtnl_trylock())
  96. return restart_syscall();
  97. /* we don't want to modify a running netdev */
  98. if (netif_running(dev->net)) {
  99. netdev_err(dev->net, "Cannot change a running device\n");
  100. ret = -EBUSY;
  101. goto err;
  102. }
  103. /* let other drivers deny the change */
  104. ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net);
  105. ret = notifier_to_errno(ret);
  106. if (ret) {
  107. netdev_err(dev->net, "Type change was refused\n");
  108. goto err;
  109. }
  110. if (enable)
  111. info->flags |= QMI_WWAN_FLAG_RAWIP;
  112. else
  113. info->flags &= ~QMI_WWAN_FLAG_RAWIP;
  114. qmi_wwan_netdev_setup(dev->net);
  115. call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net);
  116. ret = len;
  117. err:
  118. rtnl_unlock();
  119. return ret;
  120. }
  121. static DEVICE_ATTR_RW(raw_ip);
  122. static struct attribute *qmi_wwan_sysfs_attrs[] = {
  123. &dev_attr_raw_ip.attr,
  124. NULL,
  125. };
  126. static struct attribute_group qmi_wwan_sysfs_attr_group = {
  127. .name = "qmi",
  128. .attrs = qmi_wwan_sysfs_attrs,
  129. };
  130. /* default ethernet address used by the modem */
  131. static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
  132. static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
  133. /* Make up an ethernet header if the packet doesn't have one.
  134. *
  135. * A firmware bug common among several devices cause them to send raw
  136. * IP packets under some circumstances. There is no way for the
  137. * driver/host to know when this will happen. And even when the bug
  138. * hits, some packets will still arrive with an intact header.
  139. *
  140. * The supported devices are only capably of sending IPv4, IPv6 and
  141. * ARP packets on a point-to-point link. Any packet with an ethernet
  142. * header will have either our address or a broadcast/multicast
  143. * address as destination. ARP packets will always have a header.
  144. *
  145. * This means that this function will reliably add the appropriate
  146. * header iff necessary, provided our hardware address does not start
  147. * with 4 or 6.
  148. *
  149. * Another common firmware bug results in all packets being addressed
  150. * to 00:a0:c6:00:00:00 despite the host address being different.
  151. * This function will also fixup such packets.
  152. */
  153. static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
  154. {
  155. struct qmi_wwan_state *info = (void *)&dev->data;
  156. bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP;
  157. __be16 proto;
  158. /* This check is no longer done by usbnet */
  159. if (skb->len < dev->net->hard_header_len)
  160. return 0;
  161. switch (skb->data[0] & 0xf0) {
  162. case 0x40:
  163. proto = htons(ETH_P_IP);
  164. break;
  165. case 0x60:
  166. proto = htons(ETH_P_IPV6);
  167. break;
  168. case 0x00:
  169. if (rawip)
  170. return 0;
  171. if (is_multicast_ether_addr(skb->data))
  172. return 1;
  173. /* possibly bogus destination - rewrite just in case */
  174. skb_reset_mac_header(skb);
  175. goto fix_dest;
  176. default:
  177. if (rawip)
  178. return 0;
  179. /* pass along other packets without modifications */
  180. return 1;
  181. }
  182. if (rawip) {
  183. skb->dev = dev->net; /* normally set by eth_type_trans */
  184. skb->protocol = proto;
  185. return 1;
  186. }
  187. if (skb_headroom(skb) < ETH_HLEN)
  188. return 0;
  189. skb_push(skb, ETH_HLEN);
  190. skb_reset_mac_header(skb);
  191. eth_hdr(skb)->h_proto = proto;
  192. eth_zero_addr(eth_hdr(skb)->h_source);
  193. fix_dest:
  194. memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
  195. return 1;
  196. }
  197. /* very simplistic detection of IPv4 or IPv6 headers */
  198. static bool possibly_iphdr(const char *data)
  199. {
  200. return (data[0] & 0xd0) == 0x40;
  201. }
  202. /* disallow addresses which may be confused with IP headers */
  203. static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
  204. {
  205. int ret;
  206. struct sockaddr *addr = p;
  207. ret = eth_prepare_mac_addr_change(dev, p);
  208. if (ret < 0)
  209. return ret;
  210. if (possibly_iphdr(addr->sa_data))
  211. return -EADDRNOTAVAIL;
  212. eth_commit_mac_addr_change(dev, p);
  213. return 0;
  214. }
  215. static const struct net_device_ops qmi_wwan_netdev_ops = {
  216. .ndo_open = usbnet_open,
  217. .ndo_stop = usbnet_stop,
  218. .ndo_start_xmit = usbnet_start_xmit,
  219. .ndo_tx_timeout = usbnet_tx_timeout,
  220. .ndo_change_mtu = usbnet_change_mtu,
  221. .ndo_set_mac_address = qmi_wwan_mac_addr,
  222. .ndo_validate_addr = eth_validate_addr,
  223. };
  224. /* using a counter to merge subdriver requests with our own into a
  225. * combined state
  226. */
  227. static int qmi_wwan_manage_power(struct usbnet *dev, int on)
  228. {
  229. struct qmi_wwan_state *info = (void *)&dev->data;
  230. int rv;
  231. dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
  232. atomic_read(&info->pmcount), on);
  233. if ((on && atomic_add_return(1, &info->pmcount) == 1) ||
  234. (!on && atomic_dec_and_test(&info->pmcount))) {
  235. /* need autopm_get/put here to ensure the usbcore sees
  236. * the new value
  237. */
  238. rv = usb_autopm_get_interface(dev->intf);
  239. dev->intf->needs_remote_wakeup = on;
  240. if (!rv)
  241. usb_autopm_put_interface(dev->intf);
  242. }
  243. return 0;
  244. }
  245. static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
  246. {
  247. struct usbnet *dev = usb_get_intfdata(intf);
  248. /* can be called while disconnecting */
  249. if (!dev)
  250. return 0;
  251. return qmi_wwan_manage_power(dev, on);
  252. }
  253. /* collect all three endpoints and register subdriver */
  254. static int qmi_wwan_register_subdriver(struct usbnet *dev)
  255. {
  256. int rv;
  257. struct usb_driver *subdriver = NULL;
  258. struct qmi_wwan_state *info = (void *)&dev->data;
  259. /* collect bulk endpoints */
  260. rv = usbnet_get_endpoints(dev, info->data);
  261. if (rv < 0)
  262. goto err;
  263. /* update status endpoint if separate control interface */
  264. if (info->control != info->data)
  265. dev->status = &info->control->cur_altsetting->endpoint[0];
  266. /* require interrupt endpoint for subdriver */
  267. if (!dev->status) {
  268. rv = -EINVAL;
  269. goto err;
  270. }
  271. /* for subdriver power management */
  272. atomic_set(&info->pmcount, 0);
  273. /* register subdriver */
  274. subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
  275. 4096, &qmi_wwan_cdc_wdm_manage_power);
  276. if (IS_ERR(subdriver)) {
  277. dev_err(&info->control->dev, "subdriver registration failed\n");
  278. rv = PTR_ERR(subdriver);
  279. goto err;
  280. }
  281. /* prevent usbnet from using status endpoint */
  282. dev->status = NULL;
  283. /* save subdriver struct for suspend/resume wrappers */
  284. info->subdriver = subdriver;
  285. err:
  286. return rv;
  287. }
  288. /* Send CDC SetControlLineState request, setting or clearing the DTR.
  289. * "Required for Autoconnect and 9x30 to wake up" according to the
  290. * GobiNet driver. The requirement has been verified on an MDM9230
  291. * based Sierra Wireless MC7455
  292. */
  293. static int qmi_wwan_change_dtr(struct usbnet *dev, bool on)
  294. {
  295. u8 intf = dev->intf->cur_altsetting->desc.bInterfaceNumber;
  296. return usbnet_write_cmd(dev, USB_CDC_REQ_SET_CONTROL_LINE_STATE,
  297. USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  298. on ? 0x01 : 0x00, intf, NULL, 0);
  299. }
  300. static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
  301. {
  302. int status = -1;
  303. u8 *buf = intf->cur_altsetting->extra;
  304. int len = intf->cur_altsetting->extralen;
  305. struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
  306. struct usb_cdc_union_desc *cdc_union;
  307. struct usb_cdc_ether_desc *cdc_ether;
  308. struct usb_driver *driver = driver_of(intf);
  309. struct qmi_wwan_state *info = (void *)&dev->data;
  310. struct usb_cdc_parsed_header hdr;
  311. BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
  312. sizeof(struct qmi_wwan_state)));
  313. /* set up initial state */
  314. info->control = intf;
  315. info->data = intf;
  316. /* and a number of CDC descriptors */
  317. cdc_parse_cdc_header(&hdr, intf, buf, len);
  318. cdc_union = hdr.usb_cdc_union_desc;
  319. cdc_ether = hdr.usb_cdc_ether_desc;
  320. /* Use separate control and data interfaces if we found a CDC Union */
  321. if (cdc_union) {
  322. info->data = usb_ifnum_to_if(dev->udev,
  323. cdc_union->bSlaveInterface0);
  324. if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
  325. !info->data) {
  326. dev_err(&intf->dev,
  327. "bogus CDC Union: master=%u, slave=%u\n",
  328. cdc_union->bMasterInterface0,
  329. cdc_union->bSlaveInterface0);
  330. /* ignore and continue... */
  331. cdc_union = NULL;
  332. info->data = intf;
  333. }
  334. }
  335. /* errors aren't fatal - we can live with the dynamic address */
  336. if (cdc_ether) {
  337. dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
  338. usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
  339. }
  340. /* claim data interface and set it up */
  341. if (info->control != info->data) {
  342. status = usb_driver_claim_interface(driver, info->data, dev);
  343. if (status < 0)
  344. goto err;
  345. }
  346. status = qmi_wwan_register_subdriver(dev);
  347. if (status < 0 && info->control != info->data) {
  348. usb_set_intfdata(info->data, NULL);
  349. usb_driver_release_interface(driver, info->data);
  350. }
  351. /* disabling remote wakeup on MDM9x30 devices has the same
  352. * effect as clearing DTR. The device will not respond to QMI
  353. * requests until we set DTR again. This is similar to a
  354. * QMI_CTL SYNC request, clearing a lot of firmware state
  355. * including the client ID allocations.
  356. *
  357. * Our usage model allows a session to span multiple
  358. * open/close events, so we must prevent the firmware from
  359. * clearing out state the clients might need.
  360. *
  361. * MDM9x30 is the first QMI chipset with USB3 support. Abuse
  362. * this fact to enable the quirk for all USB3 devices.
  363. *
  364. * There are also chipsets with the same "set DTR" requirement
  365. * but without USB3 support. Devices based on these chips
  366. * need a quirk flag in the device ID table.
  367. */
  368. if (dev->driver_info->data & QMI_WWAN_QUIRK_DTR ||
  369. le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
  370. qmi_wwan_manage_power(dev, 1);
  371. qmi_wwan_change_dtr(dev, true);
  372. }
  373. /* Never use the same address on both ends of the link, even if the
  374. * buggy firmware told us to. Or, if device is assigned the well-known
  375. * buggy firmware MAC address, replace it with a random address,
  376. */
  377. if (ether_addr_equal(dev->net->dev_addr, default_modem_addr) ||
  378. ether_addr_equal(dev->net->dev_addr, buggy_fw_addr))
  379. eth_hw_addr_random(dev->net);
  380. /* make MAC addr easily distinguishable from an IP header */
  381. if (possibly_iphdr(dev->net->dev_addr)) {
  382. dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */
  383. dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */
  384. }
  385. dev->net->netdev_ops = &qmi_wwan_netdev_ops;
  386. dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group;
  387. err:
  388. return status;
  389. }
  390. static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
  391. {
  392. struct qmi_wwan_state *info = (void *)&dev->data;
  393. struct usb_driver *driver = driver_of(intf);
  394. struct usb_interface *other;
  395. if (info->subdriver && info->subdriver->disconnect)
  396. info->subdriver->disconnect(info->control);
  397. /* disable MDM9x30 quirk */
  398. if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
  399. qmi_wwan_change_dtr(dev, false);
  400. qmi_wwan_manage_power(dev, 0);
  401. }
  402. /* allow user to unbind using either control or data */
  403. if (intf == info->control)
  404. other = info->data;
  405. else
  406. other = info->control;
  407. /* only if not shared */
  408. if (other && intf != other) {
  409. usb_set_intfdata(other, NULL);
  410. usb_driver_release_interface(driver, other);
  411. }
  412. info->subdriver = NULL;
  413. info->data = NULL;
  414. info->control = NULL;
  415. }
  416. /* suspend/resume wrappers calling both usbnet and the cdc-wdm
  417. * subdriver if present.
  418. *
  419. * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
  420. * wrappers for those without adding usbnet reset support first.
  421. */
  422. static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
  423. {
  424. struct usbnet *dev = usb_get_intfdata(intf);
  425. struct qmi_wwan_state *info = (void *)&dev->data;
  426. int ret;
  427. /* Both usbnet_suspend() and subdriver->suspend() MUST return 0
  428. * in system sleep context, otherwise, the resume callback has
  429. * to recover device from previous suspend failure.
  430. */
  431. ret = usbnet_suspend(intf, message);
  432. if (ret < 0)
  433. goto err;
  434. if (intf == info->control && info->subdriver &&
  435. info->subdriver->suspend)
  436. ret = info->subdriver->suspend(intf, message);
  437. if (ret < 0)
  438. usbnet_resume(intf);
  439. err:
  440. return ret;
  441. }
  442. static int qmi_wwan_resume(struct usb_interface *intf)
  443. {
  444. struct usbnet *dev = usb_get_intfdata(intf);
  445. struct qmi_wwan_state *info = (void *)&dev->data;
  446. int ret = 0;
  447. bool callsub = (intf == info->control && info->subdriver &&
  448. info->subdriver->resume);
  449. if (callsub)
  450. ret = info->subdriver->resume(intf);
  451. if (ret < 0)
  452. goto err;
  453. ret = usbnet_resume(intf);
  454. if (ret < 0 && callsub)
  455. info->subdriver->suspend(intf, PMSG_SUSPEND);
  456. err:
  457. return ret;
  458. }
  459. static const struct driver_info qmi_wwan_info = {
  460. .description = "WWAN/QMI device",
  461. .flags = FLAG_WWAN,
  462. .bind = qmi_wwan_bind,
  463. .unbind = qmi_wwan_unbind,
  464. .manage_power = qmi_wwan_manage_power,
  465. .rx_fixup = qmi_wwan_rx_fixup,
  466. };
  467. static const struct driver_info qmi_wwan_info_quirk_dtr = {
  468. .description = "WWAN/QMI device",
  469. .flags = FLAG_WWAN,
  470. .bind = qmi_wwan_bind,
  471. .unbind = qmi_wwan_unbind,
  472. .manage_power = qmi_wwan_manage_power,
  473. .rx_fixup = qmi_wwan_rx_fixup,
  474. .data = QMI_WWAN_QUIRK_DTR,
  475. };
  476. #define HUAWEI_VENDOR_ID 0x12D1
  477. /* map QMI/wwan function by a fixed interface number */
  478. #define QMI_FIXED_INTF(vend, prod, num) \
  479. USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
  480. .driver_info = (unsigned long)&qmi_wwan_info
  481. /* devices requiring "set DTR" quirk */
  482. #define QMI_QUIRK_SET_DTR(vend, prod, num) \
  483. USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
  484. .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr
  485. /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
  486. #define QMI_GOBI1K_DEVICE(vend, prod) \
  487. QMI_FIXED_INTF(vend, prod, 3)
  488. /* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
  489. #define QMI_GOBI_DEVICE(vend, prod) \
  490. QMI_FIXED_INTF(vend, prod, 0)
  491. static const struct usb_device_id products[] = {
  492. /* 1. CDC ECM like devices match on the control interface */
  493. { /* Huawei E392, E398 and possibly others sharing both device id and more... */
  494. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
  495. .driver_info = (unsigned long)&qmi_wwan_info,
  496. },
  497. { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
  498. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
  499. .driver_info = (unsigned long)&qmi_wwan_info,
  500. },
  501. { /* HUAWEI_INTERFACE_NDIS_CONTROL_QUALCOMM */
  502. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69),
  503. .driver_info = (unsigned long)&qmi_wwan_info,
  504. },
  505. /* 2. Combined interface devices matching on class+protocol */
  506. { /* Huawei E367 and possibly others in "Windows mode" */
  507. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
  508. .driver_info = (unsigned long)&qmi_wwan_info,
  509. },
  510. { /* Huawei E392, E398 and possibly others in "Windows mode" */
  511. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
  512. .driver_info = (unsigned long)&qmi_wwan_info,
  513. },
  514. { /* HUAWEI_NDIS_SINGLE_INTERFACE_VDF */
  515. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x37),
  516. .driver_info = (unsigned long)&qmi_wwan_info,
  517. },
  518. { /* HUAWEI_INTERFACE_NDIS_HW_QUALCOMM */
  519. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x67),
  520. .driver_info = (unsigned long)&qmi_wwan_info,
  521. },
  522. { /* Pantech UML290, P4200 and more */
  523. USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
  524. .driver_info = (unsigned long)&qmi_wwan_info,
  525. },
  526. { /* Pantech UML290 - newer firmware */
  527. USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
  528. .driver_info = (unsigned long)&qmi_wwan_info,
  529. },
  530. { /* Novatel USB551L and MC551 */
  531. USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
  532. USB_CLASS_COMM,
  533. USB_CDC_SUBCLASS_ETHERNET,
  534. USB_CDC_PROTO_NONE),
  535. .driver_info = (unsigned long)&qmi_wwan_info,
  536. },
  537. { /* Novatel E362 */
  538. USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
  539. USB_CLASS_COMM,
  540. USB_CDC_SUBCLASS_ETHERNET,
  541. USB_CDC_PROTO_NONE),
  542. .driver_info = (unsigned long)&qmi_wwan_info,
  543. },
  544. { /* Novatel Expedite E371 */
  545. USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9011,
  546. USB_CLASS_COMM,
  547. USB_CDC_SUBCLASS_ETHERNET,
  548. USB_CDC_PROTO_NONE),
  549. .driver_info = (unsigned long)&qmi_wwan_info,
  550. },
  551. { /* Dell Wireless 5800 (Novatel E362) */
  552. USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
  553. USB_CLASS_COMM,
  554. USB_CDC_SUBCLASS_ETHERNET,
  555. USB_CDC_PROTO_NONE),
  556. .driver_info = (unsigned long)&qmi_wwan_info,
  557. },
  558. { /* Dell Wireless 5800 V2 (Novatel E362) */
  559. USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
  560. USB_CLASS_COMM,
  561. USB_CDC_SUBCLASS_ETHERNET,
  562. USB_CDC_PROTO_NONE),
  563. .driver_info = (unsigned long)&qmi_wwan_info,
  564. },
  565. { /* Dell Wireless 5804 (Novatel E371) */
  566. USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x819b,
  567. USB_CLASS_COMM,
  568. USB_CDC_SUBCLASS_ETHERNET,
  569. USB_CDC_PROTO_NONE),
  570. .driver_info = (unsigned long)&qmi_wwan_info,
  571. },
  572. { /* ADU960S */
  573. USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
  574. USB_CLASS_COMM,
  575. USB_CDC_SUBCLASS_ETHERNET,
  576. USB_CDC_PROTO_NONE),
  577. .driver_info = (unsigned long)&qmi_wwan_info,
  578. },
  579. { /* HP lt2523 (Novatel E371) */
  580. USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d,
  581. USB_CLASS_COMM,
  582. USB_CDC_SUBCLASS_ETHERNET,
  583. USB_CDC_PROTO_NONE),
  584. .driver_info = (unsigned long)&qmi_wwan_info,
  585. },
  586. { /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
  587. USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7),
  588. .driver_info = (unsigned long)&qmi_wwan_info,
  589. },
  590. /* 3. Combined interface devices matching on interface number */
  591. {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
  592. {QMI_FIXED_INTF(0x05c6, 0x6001, 3)}, /* 4G LTE usb-modem U901 */
  593. {QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
  594. {QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
  595. {QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
  596. {QMI_FIXED_INTF(0x05c6, 0x7101, 1)},
  597. {QMI_FIXED_INTF(0x05c6, 0x7101, 2)},
  598. {QMI_FIXED_INTF(0x05c6, 0x7101, 3)},
  599. {QMI_FIXED_INTF(0x05c6, 0x7102, 1)},
  600. {QMI_FIXED_INTF(0x05c6, 0x7102, 2)},
  601. {QMI_FIXED_INTF(0x05c6, 0x7102, 3)},
  602. {QMI_FIXED_INTF(0x05c6, 0x8000, 7)},
  603. {QMI_FIXED_INTF(0x05c6, 0x8001, 6)},
  604. {QMI_FIXED_INTF(0x05c6, 0x9000, 4)},
  605. {QMI_FIXED_INTF(0x05c6, 0x9003, 4)},
  606. {QMI_FIXED_INTF(0x05c6, 0x9005, 2)},
  607. {QMI_FIXED_INTF(0x05c6, 0x900a, 4)},
  608. {QMI_FIXED_INTF(0x05c6, 0x900b, 2)},
  609. {QMI_FIXED_INTF(0x05c6, 0x900c, 4)},
  610. {QMI_FIXED_INTF(0x05c6, 0x900c, 5)},
  611. {QMI_FIXED_INTF(0x05c6, 0x900c, 6)},
  612. {QMI_FIXED_INTF(0x05c6, 0x900d, 5)},
  613. {QMI_FIXED_INTF(0x05c6, 0x900f, 3)},
  614. {QMI_FIXED_INTF(0x05c6, 0x900f, 4)},
  615. {QMI_FIXED_INTF(0x05c6, 0x900f, 5)},
  616. {QMI_FIXED_INTF(0x05c6, 0x9010, 4)},
  617. {QMI_FIXED_INTF(0x05c6, 0x9010, 5)},
  618. {QMI_FIXED_INTF(0x05c6, 0x9011, 3)},
  619. {QMI_FIXED_INTF(0x05c6, 0x9011, 4)},
  620. {QMI_FIXED_INTF(0x05c6, 0x9021, 1)},
  621. {QMI_FIXED_INTF(0x05c6, 0x9022, 2)},
  622. {QMI_FIXED_INTF(0x05c6, 0x9025, 4)}, /* Alcatel-sbell ASB TL131 TDD LTE (China Mobile) */
  623. {QMI_FIXED_INTF(0x05c6, 0x9026, 3)},
  624. {QMI_FIXED_INTF(0x05c6, 0x902e, 5)},
  625. {QMI_FIXED_INTF(0x05c6, 0x9031, 5)},
  626. {QMI_FIXED_INTF(0x05c6, 0x9032, 4)},
  627. {QMI_FIXED_INTF(0x05c6, 0x9033, 3)},
  628. {QMI_FIXED_INTF(0x05c6, 0x9033, 4)},
  629. {QMI_FIXED_INTF(0x05c6, 0x9033, 5)},
  630. {QMI_FIXED_INTF(0x05c6, 0x9033, 6)},
  631. {QMI_FIXED_INTF(0x05c6, 0x9034, 3)},
  632. {QMI_FIXED_INTF(0x05c6, 0x9034, 4)},
  633. {QMI_FIXED_INTF(0x05c6, 0x9034, 5)},
  634. {QMI_FIXED_INTF(0x05c6, 0x9034, 6)},
  635. {QMI_FIXED_INTF(0x05c6, 0x9034, 7)},
  636. {QMI_FIXED_INTF(0x05c6, 0x9035, 4)},
  637. {QMI_FIXED_INTF(0x05c6, 0x9036, 3)},
  638. {QMI_FIXED_INTF(0x05c6, 0x9037, 5)},
  639. {QMI_FIXED_INTF(0x05c6, 0x9038, 4)},
  640. {QMI_FIXED_INTF(0x05c6, 0x903b, 7)},
  641. {QMI_FIXED_INTF(0x05c6, 0x903c, 6)},
  642. {QMI_FIXED_INTF(0x05c6, 0x903d, 6)},
  643. {QMI_FIXED_INTF(0x05c6, 0x903e, 5)},
  644. {QMI_FIXED_INTF(0x05c6, 0x9043, 3)},
  645. {QMI_FIXED_INTF(0x05c6, 0x9046, 3)},
  646. {QMI_FIXED_INTF(0x05c6, 0x9046, 4)},
  647. {QMI_FIXED_INTF(0x05c6, 0x9046, 5)},
  648. {QMI_FIXED_INTF(0x05c6, 0x9047, 2)},
  649. {QMI_FIXED_INTF(0x05c6, 0x9047, 3)},
  650. {QMI_FIXED_INTF(0x05c6, 0x9047, 4)},
  651. {QMI_FIXED_INTF(0x05c6, 0x9048, 4)},
  652. {QMI_FIXED_INTF(0x05c6, 0x9048, 5)},
  653. {QMI_FIXED_INTF(0x05c6, 0x9048, 6)},
  654. {QMI_FIXED_INTF(0x05c6, 0x9048, 7)},
  655. {QMI_FIXED_INTF(0x05c6, 0x9048, 8)},
  656. {QMI_FIXED_INTF(0x05c6, 0x904c, 5)},
  657. {QMI_FIXED_INTF(0x05c6, 0x904c, 6)},
  658. {QMI_FIXED_INTF(0x05c6, 0x904c, 7)},
  659. {QMI_FIXED_INTF(0x05c6, 0x904c, 8)},
  660. {QMI_FIXED_INTF(0x05c6, 0x9050, 3)},
  661. {QMI_FIXED_INTF(0x05c6, 0x9052, 4)},
  662. {QMI_FIXED_INTF(0x05c6, 0x9053, 6)},
  663. {QMI_FIXED_INTF(0x05c6, 0x9053, 7)},
  664. {QMI_FIXED_INTF(0x05c6, 0x9054, 5)},
  665. {QMI_FIXED_INTF(0x05c6, 0x9054, 6)},
  666. {QMI_FIXED_INTF(0x05c6, 0x9055, 3)},
  667. {QMI_FIXED_INTF(0x05c6, 0x9055, 4)},
  668. {QMI_FIXED_INTF(0x05c6, 0x9055, 5)},
  669. {QMI_FIXED_INTF(0x05c6, 0x9055, 6)},
  670. {QMI_FIXED_INTF(0x05c6, 0x9055, 7)},
  671. {QMI_FIXED_INTF(0x05c6, 0x9056, 3)},
  672. {QMI_FIXED_INTF(0x05c6, 0x9062, 2)},
  673. {QMI_FIXED_INTF(0x05c6, 0x9062, 3)},
  674. {QMI_FIXED_INTF(0x05c6, 0x9062, 4)},
  675. {QMI_FIXED_INTF(0x05c6, 0x9062, 5)},
  676. {QMI_FIXED_INTF(0x05c6, 0x9062, 6)},
  677. {QMI_FIXED_INTF(0x05c6, 0x9062, 7)},
  678. {QMI_FIXED_INTF(0x05c6, 0x9062, 8)},
  679. {QMI_FIXED_INTF(0x05c6, 0x9062, 9)},
  680. {QMI_FIXED_INTF(0x05c6, 0x9064, 3)},
  681. {QMI_FIXED_INTF(0x05c6, 0x9065, 6)},
  682. {QMI_FIXED_INTF(0x05c6, 0x9065, 7)},
  683. {QMI_FIXED_INTF(0x05c6, 0x9066, 5)},
  684. {QMI_FIXED_INTF(0x05c6, 0x9066, 6)},
  685. {QMI_FIXED_INTF(0x05c6, 0x9067, 1)},
  686. {QMI_FIXED_INTF(0x05c6, 0x9068, 2)},
  687. {QMI_FIXED_INTF(0x05c6, 0x9068, 3)},
  688. {QMI_FIXED_INTF(0x05c6, 0x9068, 4)},
  689. {QMI_FIXED_INTF(0x05c6, 0x9068, 5)},
  690. {QMI_FIXED_INTF(0x05c6, 0x9068, 6)},
  691. {QMI_FIXED_INTF(0x05c6, 0x9068, 7)},
  692. {QMI_FIXED_INTF(0x05c6, 0x9069, 5)},
  693. {QMI_FIXED_INTF(0x05c6, 0x9069, 6)},
  694. {QMI_FIXED_INTF(0x05c6, 0x9069, 7)},
  695. {QMI_FIXED_INTF(0x05c6, 0x9069, 8)},
  696. {QMI_FIXED_INTF(0x05c6, 0x9070, 4)},
  697. {QMI_FIXED_INTF(0x05c6, 0x9070, 5)},
  698. {QMI_FIXED_INTF(0x05c6, 0x9075, 5)},
  699. {QMI_FIXED_INTF(0x05c6, 0x9076, 4)},
  700. {QMI_FIXED_INTF(0x05c6, 0x9076, 5)},
  701. {QMI_FIXED_INTF(0x05c6, 0x9076, 6)},
  702. {QMI_FIXED_INTF(0x05c6, 0x9076, 7)},
  703. {QMI_FIXED_INTF(0x05c6, 0x9076, 8)},
  704. {QMI_FIXED_INTF(0x05c6, 0x9077, 3)},
  705. {QMI_FIXED_INTF(0x05c6, 0x9077, 4)},
  706. {QMI_FIXED_INTF(0x05c6, 0x9077, 5)},
  707. {QMI_FIXED_INTF(0x05c6, 0x9077, 6)},
  708. {QMI_FIXED_INTF(0x05c6, 0x9078, 3)},
  709. {QMI_FIXED_INTF(0x05c6, 0x9079, 4)},
  710. {QMI_FIXED_INTF(0x05c6, 0x9079, 5)},
  711. {QMI_FIXED_INTF(0x05c6, 0x9079, 6)},
  712. {QMI_FIXED_INTF(0x05c6, 0x9079, 7)},
  713. {QMI_FIXED_INTF(0x05c6, 0x9079, 8)},
  714. {QMI_FIXED_INTF(0x05c6, 0x9080, 5)},
  715. {QMI_FIXED_INTF(0x05c6, 0x9080, 6)},
  716. {QMI_FIXED_INTF(0x05c6, 0x9080, 7)},
  717. {QMI_FIXED_INTF(0x05c6, 0x9080, 8)},
  718. {QMI_FIXED_INTF(0x05c6, 0x9083, 3)},
  719. {QMI_FIXED_INTF(0x05c6, 0x9084, 4)},
  720. {QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
  721. {QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
  722. {QMI_FIXED_INTF(0x0846, 0x68a2, 8)},
  723. {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
  724. {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
  725. {QMI_FIXED_INTF(0x16d8, 0x6003, 0)}, /* CMOTech 6003 */
  726. {QMI_FIXED_INTF(0x16d8, 0x6007, 0)}, /* CMOTech CHE-628S */
  727. {QMI_FIXED_INTF(0x16d8, 0x6008, 0)}, /* CMOTech CMU-301 */
  728. {QMI_FIXED_INTF(0x16d8, 0x6280, 0)}, /* CMOTech CHU-628 */
  729. {QMI_FIXED_INTF(0x16d8, 0x7001, 0)}, /* CMOTech CHU-720S */
  730. {QMI_FIXED_INTF(0x16d8, 0x7002, 0)}, /* CMOTech 7002 */
  731. {QMI_FIXED_INTF(0x16d8, 0x7003, 4)}, /* CMOTech CHU-629K */
  732. {QMI_FIXED_INTF(0x16d8, 0x7004, 3)}, /* CMOTech 7004 */
  733. {QMI_FIXED_INTF(0x16d8, 0x7006, 5)}, /* CMOTech CGU-629 */
  734. {QMI_FIXED_INTF(0x16d8, 0x700a, 4)}, /* CMOTech CHU-629S */
  735. {QMI_FIXED_INTF(0x16d8, 0x7211, 0)}, /* CMOTech CHU-720I */
  736. {QMI_FIXED_INTF(0x16d8, 0x7212, 0)}, /* CMOTech 7212 */
  737. {QMI_FIXED_INTF(0x16d8, 0x7213, 0)}, /* CMOTech 7213 */
  738. {QMI_FIXED_INTF(0x16d8, 0x7251, 1)}, /* CMOTech 7251 */
  739. {QMI_FIXED_INTF(0x16d8, 0x7252, 1)}, /* CMOTech 7252 */
  740. {QMI_FIXED_INTF(0x16d8, 0x7253, 1)}, /* CMOTech 7253 */
  741. {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
  742. {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
  743. {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
  744. {QMI_FIXED_INTF(0x19d2, 0x0019, 3)}, /* ONDA MT689DC */
  745. {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
  746. {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
  747. {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
  748. {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
  749. {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
  750. {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
  751. {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */
  752. {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
  753. {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */
  754. {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */
  755. {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
  756. {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
  757. {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
  758. {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
  759. {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
  760. {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
  761. {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
  762. {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
  763. {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
  764. {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
  765. {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */
  766. {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
  767. {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */
  768. {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
  769. {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
  770. {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
  771. {QMI_FIXED_INTF(0x19d2, 0x0191, 4)}, /* ZTE EuFi890 */
  772. {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */
  773. {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
  774. {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */
  775. {QMI_FIXED_INTF(0x19d2, 0x0265, 4)}, /* ONDA MT8205 4G LTE */
  776. {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */
  777. {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
  778. {QMI_FIXED_INTF(0x19d2, 0x0412, 4)}, /* Telewell TW-LTE 4G */
  779. {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
  780. {QMI_FIXED_INTF(0x19d2, 0x1010, 4)}, /* ZTE (Vodafone) K3571-Z */
  781. {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
  782. {QMI_FIXED_INTF(0x19d2, 0x1018, 3)}, /* ZTE (Vodafone) K5006-Z */
  783. {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
  784. {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
  785. {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
  786. {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
  787. {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
  788. {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
  789. {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
  790. {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
  791. {QMI_FIXED_INTF(0x19d2, 0x1270, 5)}, /* ZTE MF667 */
  792. {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
  793. {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */
  794. {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
  795. {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
  796. {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */
  797. {QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */
  798. {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
  799. {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */
  800. {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */
  801. {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
  802. {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
  803. {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
  804. {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
  805. {QMI_FIXED_INTF(0x1199, 0x68c0, 8)}, /* Sierra Wireless MC7304/MC7354 */
  806. {QMI_FIXED_INTF(0x1199, 0x68c0, 10)}, /* Sierra Wireless MC7304/MC7354 */
  807. {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
  808. {QMI_FIXED_INTF(0x1199, 0x901f, 8)}, /* Sierra Wireless EM7355 */
  809. {QMI_FIXED_INTF(0x1199, 0x9041, 8)}, /* Sierra Wireless MC7305/MC7355 */
  810. {QMI_FIXED_INTF(0x1199, 0x9041, 10)}, /* Sierra Wireless MC7305/MC7355 */
  811. {QMI_FIXED_INTF(0x1199, 0x9051, 8)}, /* Netgear AirCard 340U */
  812. {QMI_FIXED_INTF(0x1199, 0x9053, 8)}, /* Sierra Wireless Modem */
  813. {QMI_FIXED_INTF(0x1199, 0x9054, 8)}, /* Sierra Wireless Modem */
  814. {QMI_FIXED_INTF(0x1199, 0x9055, 8)}, /* Netgear AirCard 341U */
  815. {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */
  816. {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
  817. {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */
  818. {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx */
  819. {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx */
  820. {QMI_FIXED_INTF(0x1199, 0x9079, 8)}, /* Sierra Wireless EM74xx */
  821. {QMI_FIXED_INTF(0x1199, 0x9079, 10)}, /* Sierra Wireless EM74xx */
  822. {QMI_FIXED_INTF(0x1199, 0x907b, 8)}, /* Sierra Wireless EM74xx */
  823. {QMI_FIXED_INTF(0x1199, 0x907b, 10)}, /* Sierra Wireless EM74xx */
  824. {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
  825. {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
  826. {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
  827. {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
  828. {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */
  829. {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */
  830. {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
  831. {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
  832. {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */
  833. {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */
  834. {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */
  835. {QMI_FIXED_INTF(0x0b3c, 0xc002, 4)}, /* Olivetti Olicard 140 */
  836. {QMI_FIXED_INTF(0x0b3c, 0xc004, 6)}, /* Olivetti Olicard 155 */
  837. {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */
  838. {QMI_FIXED_INTF(0x0b3c, 0xc00a, 6)}, /* Olivetti Olicard 160 */
  839. {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)}, /* Olivetti Olicard 500 */
  840. {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */
  841. {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */
  842. {QMI_FIXED_INTF(0x1e2d, 0x0082, 4)}, /* Cinterion PHxx,PXxx (2 RmNet) */
  843. {QMI_FIXED_INTF(0x1e2d, 0x0082, 5)}, /* Cinterion PHxx,PXxx (2 RmNet) */
  844. {QMI_FIXED_INTF(0x1e2d, 0x0083, 4)}, /* Cinterion PHxx,PXxx (1 RmNet + USB Audio)*/
  845. {QMI_FIXED_INTF(0x413c, 0x81a2, 8)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
  846. {QMI_FIXED_INTF(0x413c, 0x81a3, 8)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
  847. {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
  848. {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
  849. {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
  850. {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
  851. {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
  852. {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */
  853. {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */
  854. {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
  855. {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
  856. {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */
  857. {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
  858. {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */
  859. /* 4. Gobi 1000 devices */
  860. {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
  861. {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
  862. {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
  863. {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
  864. {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel/Verizon USB-1000 */
  865. {QMI_GOBI1K_DEVICE(0x1410, 0xa002)}, /* Novatel Gobi Modem device */
  866. {QMI_GOBI1K_DEVICE(0x1410, 0xa003)}, /* Novatel Gobi Modem device */
  867. {QMI_GOBI1K_DEVICE(0x1410, 0xa004)}, /* Novatel Gobi Modem device */
  868. {QMI_GOBI1K_DEVICE(0x1410, 0xa005)}, /* Novatel Gobi Modem device */
  869. {QMI_GOBI1K_DEVICE(0x1410, 0xa006)}, /* Novatel Gobi Modem device */
  870. {QMI_GOBI1K_DEVICE(0x1410, 0xa007)}, /* Novatel Gobi Modem device */
  871. {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
  872. {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
  873. {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
  874. {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
  875. {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
  876. {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
  877. {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
  878. {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
  879. /* 5. Gobi 2000 and 3000 devices */
  880. {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
  881. {QMI_GOBI_DEVICE(0x413c, 0x8194)}, /* Dell Gobi 3000 Composite */
  882. {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
  883. {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
  884. {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
  885. {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
  886. {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
  887. {QMI_FIXED_INTF(0x05c6, 0x9215, 4)}, /* Quectel EC20 Mini PCIe */
  888. {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
  889. {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
  890. {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
  891. {QMI_GOBI_DEVICE(0x0af0, 0x8120)}, /* Option GTM681W */
  892. {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
  893. {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
  894. {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  895. {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  896. {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  897. {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  898. {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  899. {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  900. {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  901. {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  902. {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  903. {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  904. {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
  905. {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
  906. {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
  907. {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
  908. {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
  909. {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
  910. {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
  911. {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
  912. {QMI_GOBI_DEVICE(0x12d1, 0x14f1)}, /* Sony Gobi 3000 Composite */
  913. {QMI_GOBI_DEVICE(0x1410, 0xa021)}, /* Foxconn Gobi 3000 Modem device (Novatel E396) */
  914. { } /* END */
  915. };
  916. MODULE_DEVICE_TABLE(usb, products);
  917. static bool quectel_ec20_detected(struct usb_interface *intf)
  918. {
  919. struct usb_device *dev = interface_to_usbdev(intf);
  920. if (dev->actconfig &&
  921. le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
  922. le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
  923. dev->actconfig->desc.bNumInterfaces == 5)
  924. return true;
  925. return false;
  926. }
  927. static int qmi_wwan_probe(struct usb_interface *intf,
  928. const struct usb_device_id *prod)
  929. {
  930. struct usb_device_id *id = (struct usb_device_id *)prod;
  931. struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
  932. /* Workaround to enable dynamic IDs. This disables usbnet
  933. * blacklisting functionality. Which, if required, can be
  934. * reimplemented here by using a magic "blacklist" value
  935. * instead of 0 in the static device id table
  936. */
  937. if (!id->driver_info) {
  938. dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
  939. id->driver_info = (unsigned long)&qmi_wwan_info;
  940. }
  941. /* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
  942. if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
  943. dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
  944. return -ENODEV;
  945. }
  946. return usbnet_probe(intf, id);
  947. }
  948. static struct usb_driver qmi_wwan_driver = {
  949. .name = "qmi_wwan",
  950. .id_table = products,
  951. .probe = qmi_wwan_probe,
  952. .disconnect = usbnet_disconnect,
  953. .suspend = qmi_wwan_suspend,
  954. .resume = qmi_wwan_resume,
  955. .reset_resume = qmi_wwan_resume,
  956. .supports_autosuspend = 1,
  957. .disable_hub_initiated_lpm = 1,
  958. };
  959. module_usb_driver(qmi_wwan_driver);
  960. MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
  961. MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
  962. MODULE_LICENSE("GPL");