qmi_wwan.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  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 lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
  580. USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7),
  581. .driver_info = (unsigned long)&qmi_wwan_info,
  582. },
  583. /* 3. Combined interface devices matching on interface number */
  584. {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
  585. {QMI_FIXED_INTF(0x05c6, 0x6001, 3)}, /* 4G LTE usb-modem U901 */
  586. {QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
  587. {QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
  588. {QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
  589. {QMI_FIXED_INTF(0x05c6, 0x7101, 1)},
  590. {QMI_FIXED_INTF(0x05c6, 0x7101, 2)},
  591. {QMI_FIXED_INTF(0x05c6, 0x7101, 3)},
  592. {QMI_FIXED_INTF(0x05c6, 0x7102, 1)},
  593. {QMI_FIXED_INTF(0x05c6, 0x7102, 2)},
  594. {QMI_FIXED_INTF(0x05c6, 0x7102, 3)},
  595. {QMI_FIXED_INTF(0x05c6, 0x8000, 7)},
  596. {QMI_FIXED_INTF(0x05c6, 0x8001, 6)},
  597. {QMI_FIXED_INTF(0x05c6, 0x9000, 4)},
  598. {QMI_FIXED_INTF(0x05c6, 0x9003, 4)},
  599. {QMI_FIXED_INTF(0x05c6, 0x9005, 2)},
  600. {QMI_FIXED_INTF(0x05c6, 0x900a, 4)},
  601. {QMI_FIXED_INTF(0x05c6, 0x900b, 2)},
  602. {QMI_FIXED_INTF(0x05c6, 0x900c, 4)},
  603. {QMI_FIXED_INTF(0x05c6, 0x900c, 5)},
  604. {QMI_FIXED_INTF(0x05c6, 0x900c, 6)},
  605. {QMI_FIXED_INTF(0x05c6, 0x900d, 5)},
  606. {QMI_FIXED_INTF(0x05c6, 0x900f, 3)},
  607. {QMI_FIXED_INTF(0x05c6, 0x900f, 4)},
  608. {QMI_FIXED_INTF(0x05c6, 0x900f, 5)},
  609. {QMI_FIXED_INTF(0x05c6, 0x9010, 4)},
  610. {QMI_FIXED_INTF(0x05c6, 0x9010, 5)},
  611. {QMI_FIXED_INTF(0x05c6, 0x9011, 3)},
  612. {QMI_FIXED_INTF(0x05c6, 0x9011, 4)},
  613. {QMI_FIXED_INTF(0x05c6, 0x9021, 1)},
  614. {QMI_FIXED_INTF(0x05c6, 0x9022, 2)},
  615. {QMI_FIXED_INTF(0x05c6, 0x9025, 4)}, /* Alcatel-sbell ASB TL131 TDD LTE (China Mobile) */
  616. {QMI_FIXED_INTF(0x05c6, 0x9026, 3)},
  617. {QMI_FIXED_INTF(0x05c6, 0x902e, 5)},
  618. {QMI_FIXED_INTF(0x05c6, 0x9031, 5)},
  619. {QMI_FIXED_INTF(0x05c6, 0x9032, 4)},
  620. {QMI_FIXED_INTF(0x05c6, 0x9033, 3)},
  621. {QMI_FIXED_INTF(0x05c6, 0x9033, 4)},
  622. {QMI_FIXED_INTF(0x05c6, 0x9033, 5)},
  623. {QMI_FIXED_INTF(0x05c6, 0x9033, 6)},
  624. {QMI_FIXED_INTF(0x05c6, 0x9034, 3)},
  625. {QMI_FIXED_INTF(0x05c6, 0x9034, 4)},
  626. {QMI_FIXED_INTF(0x05c6, 0x9034, 5)},
  627. {QMI_FIXED_INTF(0x05c6, 0x9034, 6)},
  628. {QMI_FIXED_INTF(0x05c6, 0x9034, 7)},
  629. {QMI_FIXED_INTF(0x05c6, 0x9035, 4)},
  630. {QMI_FIXED_INTF(0x05c6, 0x9036, 3)},
  631. {QMI_FIXED_INTF(0x05c6, 0x9037, 5)},
  632. {QMI_FIXED_INTF(0x05c6, 0x9038, 4)},
  633. {QMI_FIXED_INTF(0x05c6, 0x903b, 7)},
  634. {QMI_FIXED_INTF(0x05c6, 0x903c, 6)},
  635. {QMI_FIXED_INTF(0x05c6, 0x903d, 6)},
  636. {QMI_FIXED_INTF(0x05c6, 0x903e, 5)},
  637. {QMI_FIXED_INTF(0x05c6, 0x9043, 3)},
  638. {QMI_FIXED_INTF(0x05c6, 0x9046, 3)},
  639. {QMI_FIXED_INTF(0x05c6, 0x9046, 4)},
  640. {QMI_FIXED_INTF(0x05c6, 0x9046, 5)},
  641. {QMI_FIXED_INTF(0x05c6, 0x9047, 2)},
  642. {QMI_FIXED_INTF(0x05c6, 0x9047, 3)},
  643. {QMI_FIXED_INTF(0x05c6, 0x9047, 4)},
  644. {QMI_FIXED_INTF(0x05c6, 0x9048, 4)},
  645. {QMI_FIXED_INTF(0x05c6, 0x9048, 5)},
  646. {QMI_FIXED_INTF(0x05c6, 0x9048, 6)},
  647. {QMI_FIXED_INTF(0x05c6, 0x9048, 7)},
  648. {QMI_FIXED_INTF(0x05c6, 0x9048, 8)},
  649. {QMI_FIXED_INTF(0x05c6, 0x904c, 5)},
  650. {QMI_FIXED_INTF(0x05c6, 0x904c, 6)},
  651. {QMI_FIXED_INTF(0x05c6, 0x904c, 7)},
  652. {QMI_FIXED_INTF(0x05c6, 0x904c, 8)},
  653. {QMI_FIXED_INTF(0x05c6, 0x9050, 3)},
  654. {QMI_FIXED_INTF(0x05c6, 0x9052, 4)},
  655. {QMI_FIXED_INTF(0x05c6, 0x9053, 6)},
  656. {QMI_FIXED_INTF(0x05c6, 0x9053, 7)},
  657. {QMI_FIXED_INTF(0x05c6, 0x9054, 5)},
  658. {QMI_FIXED_INTF(0x05c6, 0x9054, 6)},
  659. {QMI_FIXED_INTF(0x05c6, 0x9055, 3)},
  660. {QMI_FIXED_INTF(0x05c6, 0x9055, 4)},
  661. {QMI_FIXED_INTF(0x05c6, 0x9055, 5)},
  662. {QMI_FIXED_INTF(0x05c6, 0x9055, 6)},
  663. {QMI_FIXED_INTF(0x05c6, 0x9055, 7)},
  664. {QMI_FIXED_INTF(0x05c6, 0x9056, 3)},
  665. {QMI_FIXED_INTF(0x05c6, 0x9062, 2)},
  666. {QMI_FIXED_INTF(0x05c6, 0x9062, 3)},
  667. {QMI_FIXED_INTF(0x05c6, 0x9062, 4)},
  668. {QMI_FIXED_INTF(0x05c6, 0x9062, 5)},
  669. {QMI_FIXED_INTF(0x05c6, 0x9062, 6)},
  670. {QMI_FIXED_INTF(0x05c6, 0x9062, 7)},
  671. {QMI_FIXED_INTF(0x05c6, 0x9062, 8)},
  672. {QMI_FIXED_INTF(0x05c6, 0x9062, 9)},
  673. {QMI_FIXED_INTF(0x05c6, 0x9064, 3)},
  674. {QMI_FIXED_INTF(0x05c6, 0x9065, 6)},
  675. {QMI_FIXED_INTF(0x05c6, 0x9065, 7)},
  676. {QMI_FIXED_INTF(0x05c6, 0x9066, 5)},
  677. {QMI_FIXED_INTF(0x05c6, 0x9066, 6)},
  678. {QMI_FIXED_INTF(0x05c6, 0x9067, 1)},
  679. {QMI_FIXED_INTF(0x05c6, 0x9068, 2)},
  680. {QMI_FIXED_INTF(0x05c6, 0x9068, 3)},
  681. {QMI_FIXED_INTF(0x05c6, 0x9068, 4)},
  682. {QMI_FIXED_INTF(0x05c6, 0x9068, 5)},
  683. {QMI_FIXED_INTF(0x05c6, 0x9068, 6)},
  684. {QMI_FIXED_INTF(0x05c6, 0x9068, 7)},
  685. {QMI_FIXED_INTF(0x05c6, 0x9069, 5)},
  686. {QMI_FIXED_INTF(0x05c6, 0x9069, 6)},
  687. {QMI_FIXED_INTF(0x05c6, 0x9069, 7)},
  688. {QMI_FIXED_INTF(0x05c6, 0x9069, 8)},
  689. {QMI_FIXED_INTF(0x05c6, 0x9070, 4)},
  690. {QMI_FIXED_INTF(0x05c6, 0x9070, 5)},
  691. {QMI_FIXED_INTF(0x05c6, 0x9075, 5)},
  692. {QMI_FIXED_INTF(0x05c6, 0x9076, 4)},
  693. {QMI_FIXED_INTF(0x05c6, 0x9076, 5)},
  694. {QMI_FIXED_INTF(0x05c6, 0x9076, 6)},
  695. {QMI_FIXED_INTF(0x05c6, 0x9076, 7)},
  696. {QMI_FIXED_INTF(0x05c6, 0x9076, 8)},
  697. {QMI_FIXED_INTF(0x05c6, 0x9077, 3)},
  698. {QMI_FIXED_INTF(0x05c6, 0x9077, 4)},
  699. {QMI_FIXED_INTF(0x05c6, 0x9077, 5)},
  700. {QMI_FIXED_INTF(0x05c6, 0x9077, 6)},
  701. {QMI_FIXED_INTF(0x05c6, 0x9078, 3)},
  702. {QMI_FIXED_INTF(0x05c6, 0x9079, 4)},
  703. {QMI_FIXED_INTF(0x05c6, 0x9079, 5)},
  704. {QMI_FIXED_INTF(0x05c6, 0x9079, 6)},
  705. {QMI_FIXED_INTF(0x05c6, 0x9079, 7)},
  706. {QMI_FIXED_INTF(0x05c6, 0x9079, 8)},
  707. {QMI_FIXED_INTF(0x05c6, 0x9080, 5)},
  708. {QMI_FIXED_INTF(0x05c6, 0x9080, 6)},
  709. {QMI_FIXED_INTF(0x05c6, 0x9080, 7)},
  710. {QMI_FIXED_INTF(0x05c6, 0x9080, 8)},
  711. {QMI_FIXED_INTF(0x05c6, 0x9083, 3)},
  712. {QMI_FIXED_INTF(0x05c6, 0x9084, 4)},
  713. {QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
  714. {QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
  715. {QMI_FIXED_INTF(0x0846, 0x68a2, 8)},
  716. {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
  717. {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
  718. {QMI_FIXED_INTF(0x16d8, 0x6003, 0)}, /* CMOTech 6003 */
  719. {QMI_FIXED_INTF(0x16d8, 0x6007, 0)}, /* CMOTech CHE-628S */
  720. {QMI_FIXED_INTF(0x16d8, 0x6008, 0)}, /* CMOTech CMU-301 */
  721. {QMI_FIXED_INTF(0x16d8, 0x6280, 0)}, /* CMOTech CHU-628 */
  722. {QMI_FIXED_INTF(0x16d8, 0x7001, 0)}, /* CMOTech CHU-720S */
  723. {QMI_FIXED_INTF(0x16d8, 0x7002, 0)}, /* CMOTech 7002 */
  724. {QMI_FIXED_INTF(0x16d8, 0x7003, 4)}, /* CMOTech CHU-629K */
  725. {QMI_FIXED_INTF(0x16d8, 0x7004, 3)}, /* CMOTech 7004 */
  726. {QMI_FIXED_INTF(0x16d8, 0x7006, 5)}, /* CMOTech CGU-629 */
  727. {QMI_FIXED_INTF(0x16d8, 0x700a, 4)}, /* CMOTech CHU-629S */
  728. {QMI_FIXED_INTF(0x16d8, 0x7211, 0)}, /* CMOTech CHU-720I */
  729. {QMI_FIXED_INTF(0x16d8, 0x7212, 0)}, /* CMOTech 7212 */
  730. {QMI_FIXED_INTF(0x16d8, 0x7213, 0)}, /* CMOTech 7213 */
  731. {QMI_FIXED_INTF(0x16d8, 0x7251, 1)}, /* CMOTech 7251 */
  732. {QMI_FIXED_INTF(0x16d8, 0x7252, 1)}, /* CMOTech 7252 */
  733. {QMI_FIXED_INTF(0x16d8, 0x7253, 1)}, /* CMOTech 7253 */
  734. {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
  735. {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
  736. {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
  737. {QMI_FIXED_INTF(0x19d2, 0x0019, 3)}, /* ONDA MT689DC */
  738. {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
  739. {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
  740. {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
  741. {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
  742. {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
  743. {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
  744. {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */
  745. {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
  746. {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */
  747. {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */
  748. {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
  749. {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
  750. {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
  751. {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
  752. {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
  753. {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
  754. {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
  755. {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
  756. {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
  757. {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
  758. {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */
  759. {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
  760. {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */
  761. {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
  762. {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
  763. {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
  764. {QMI_FIXED_INTF(0x19d2, 0x0191, 4)}, /* ZTE EuFi890 */
  765. {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */
  766. {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
  767. {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */
  768. {QMI_FIXED_INTF(0x19d2, 0x0265, 4)}, /* ONDA MT8205 4G LTE */
  769. {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */
  770. {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
  771. {QMI_FIXED_INTF(0x19d2, 0x0412, 4)}, /* Telewell TW-LTE 4G */
  772. {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
  773. {QMI_FIXED_INTF(0x19d2, 0x1010, 4)}, /* ZTE (Vodafone) K3571-Z */
  774. {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
  775. {QMI_FIXED_INTF(0x19d2, 0x1018, 3)}, /* ZTE (Vodafone) K5006-Z */
  776. {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
  777. {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
  778. {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
  779. {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
  780. {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
  781. {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
  782. {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
  783. {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
  784. {QMI_FIXED_INTF(0x19d2, 0x1270, 5)}, /* ZTE MF667 */
  785. {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
  786. {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */
  787. {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
  788. {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
  789. {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */
  790. {QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */
  791. {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
  792. {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */
  793. {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
  794. {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
  795. {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
  796. {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
  797. {QMI_FIXED_INTF(0x1199, 0x68c0, 8)}, /* Sierra Wireless MC7304/MC7354 */
  798. {QMI_FIXED_INTF(0x1199, 0x68c0, 10)}, /* Sierra Wireless MC7304/MC7354 */
  799. {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
  800. {QMI_FIXED_INTF(0x1199, 0x901f, 8)}, /* Sierra Wireless EM7355 */
  801. {QMI_FIXED_INTF(0x1199, 0x9041, 8)}, /* Sierra Wireless MC7305/MC7355 */
  802. {QMI_FIXED_INTF(0x1199, 0x9041, 10)}, /* Sierra Wireless MC7305/MC7355 */
  803. {QMI_FIXED_INTF(0x1199, 0x9051, 8)}, /* Netgear AirCard 340U */
  804. {QMI_FIXED_INTF(0x1199, 0x9053, 8)}, /* Sierra Wireless Modem */
  805. {QMI_FIXED_INTF(0x1199, 0x9054, 8)}, /* Sierra Wireless Modem */
  806. {QMI_FIXED_INTF(0x1199, 0x9055, 8)}, /* Netgear AirCard 341U */
  807. {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */
  808. {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
  809. {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */
  810. {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx */
  811. {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx */
  812. {QMI_FIXED_INTF(0x1199, 0x9079, 8)}, /* Sierra Wireless EM74xx */
  813. {QMI_FIXED_INTF(0x1199, 0x9079, 10)}, /* Sierra Wireless EM74xx */
  814. {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
  815. {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
  816. {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
  817. {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
  818. {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */
  819. {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
  820. {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
  821. {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */
  822. {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */
  823. {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */
  824. {QMI_FIXED_INTF(0x0b3c, 0xc002, 4)}, /* Olivetti Olicard 140 */
  825. {QMI_FIXED_INTF(0x0b3c, 0xc004, 6)}, /* Olivetti Olicard 155 */
  826. {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */
  827. {QMI_FIXED_INTF(0x0b3c, 0xc00a, 6)}, /* Olivetti Olicard 160 */
  828. {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)}, /* Olivetti Olicard 500 */
  829. {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */
  830. {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */
  831. {QMI_FIXED_INTF(0x1e2d, 0x0082, 4)}, /* Cinterion PHxx,PXxx (2 RmNet) */
  832. {QMI_FIXED_INTF(0x1e2d, 0x0082, 5)}, /* Cinterion PHxx,PXxx (2 RmNet) */
  833. {QMI_FIXED_INTF(0x1e2d, 0x0083, 4)}, /* Cinterion PHxx,PXxx (1 RmNet + USB Audio)*/
  834. {QMI_FIXED_INTF(0x413c, 0x81a2, 8)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
  835. {QMI_FIXED_INTF(0x413c, 0x81a3, 8)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
  836. {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
  837. {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
  838. {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
  839. {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
  840. {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
  841. {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
  842. {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
  843. {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */
  844. {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
  845. {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */
  846. /* 4. Gobi 1000 devices */
  847. {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
  848. {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
  849. {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
  850. {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
  851. {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel/Verizon USB-1000 */
  852. {QMI_GOBI1K_DEVICE(0x1410, 0xa002)}, /* Novatel Gobi Modem device */
  853. {QMI_GOBI1K_DEVICE(0x1410, 0xa003)}, /* Novatel Gobi Modem device */
  854. {QMI_GOBI1K_DEVICE(0x1410, 0xa004)}, /* Novatel Gobi Modem device */
  855. {QMI_GOBI1K_DEVICE(0x1410, 0xa005)}, /* Novatel Gobi Modem device */
  856. {QMI_GOBI1K_DEVICE(0x1410, 0xa006)}, /* Novatel Gobi Modem device */
  857. {QMI_GOBI1K_DEVICE(0x1410, 0xa007)}, /* Novatel Gobi Modem device */
  858. {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
  859. {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
  860. {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
  861. {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
  862. {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
  863. {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
  864. {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
  865. {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
  866. /* 5. Gobi 2000 and 3000 devices */
  867. {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
  868. {QMI_GOBI_DEVICE(0x413c, 0x8194)}, /* Dell Gobi 3000 Composite */
  869. {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
  870. {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
  871. {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
  872. {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
  873. {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
  874. {QMI_FIXED_INTF(0x05c6, 0x9215, 4)}, /* Quectel EC20 Mini PCIe */
  875. {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
  876. {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
  877. {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
  878. {QMI_GOBI_DEVICE(0x0af0, 0x8120)}, /* Option GTM681W */
  879. {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
  880. {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
  881. {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  882. {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  883. {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  884. {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  885. {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  886. {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  887. {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  888. {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  889. {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  890. {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  891. {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
  892. {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
  893. {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
  894. {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
  895. {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
  896. {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
  897. {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
  898. {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
  899. {QMI_GOBI_DEVICE(0x12d1, 0x14f1)}, /* Sony Gobi 3000 Composite */
  900. {QMI_GOBI_DEVICE(0x1410, 0xa021)}, /* Foxconn Gobi 3000 Modem device (Novatel E396) */
  901. { } /* END */
  902. };
  903. MODULE_DEVICE_TABLE(usb, products);
  904. static bool quectel_ec20_detected(struct usb_interface *intf)
  905. {
  906. struct usb_device *dev = interface_to_usbdev(intf);
  907. if (dev->actconfig &&
  908. le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
  909. le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
  910. dev->actconfig->desc.bNumInterfaces == 5)
  911. return true;
  912. return false;
  913. }
  914. static int qmi_wwan_probe(struct usb_interface *intf,
  915. const struct usb_device_id *prod)
  916. {
  917. struct usb_device_id *id = (struct usb_device_id *)prod;
  918. struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
  919. /* Workaround to enable dynamic IDs. This disables usbnet
  920. * blacklisting functionality. Which, if required, can be
  921. * reimplemented here by using a magic "blacklist" value
  922. * instead of 0 in the static device id table
  923. */
  924. if (!id->driver_info) {
  925. dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
  926. id->driver_info = (unsigned long)&qmi_wwan_info;
  927. }
  928. /* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
  929. if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
  930. dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
  931. return -ENODEV;
  932. }
  933. return usbnet_probe(intf, id);
  934. }
  935. static struct usb_driver qmi_wwan_driver = {
  936. .name = "qmi_wwan",
  937. .id_table = products,
  938. .probe = qmi_wwan_probe,
  939. .disconnect = usbnet_disconnect,
  940. .suspend = qmi_wwan_suspend,
  941. .resume = qmi_wwan_resume,
  942. .reset_resume = qmi_wwan_resume,
  943. .supports_autosuspend = 1,
  944. .disable_hub_initiated_lpm = 1,
  945. };
  946. module_usb_driver(qmi_wwan_driver);
  947. MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
  948. MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
  949. MODULE_LICENSE("GPL");