qmi_wwan.c 41 KB

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