qmi_wwan.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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/mii.h>
  16. #include <linux/usb.h>
  17. #include <linux/usb/cdc.h>
  18. #include <linux/usb/usbnet.h>
  19. #include <linux/usb/cdc-wdm.h>
  20. /* This driver supports wwan (3G/LTE/?) devices using a vendor
  21. * specific management protocol called Qualcomm MSM Interface (QMI) -
  22. * in addition to the more common AT commands over serial interface
  23. * management
  24. *
  25. * QMI is wrapped in CDC, using CDC encapsulated commands on the
  26. * control ("master") interface of a two-interface CDC Union
  27. * resembling standard CDC ECM. The devices do not use the control
  28. * interface for any other CDC messages. Most likely because the
  29. * management protocol is used in place of the standard CDC
  30. * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
  31. *
  32. * Alternatively, control and data functions can be combined in a
  33. * single USB interface.
  34. *
  35. * Handling a protocol like QMI is out of the scope for any driver.
  36. * It is exported as a character device using the cdc-wdm driver as
  37. * a subdriver, enabling userspace applications ("modem managers") to
  38. * handle it.
  39. *
  40. * These devices may alternatively/additionally be configured using AT
  41. * commands on a serial interface
  42. */
  43. /* driver specific data */
  44. struct qmi_wwan_state {
  45. struct usb_driver *subdriver;
  46. atomic_t pmcount;
  47. unsigned long unused;
  48. struct usb_interface *control;
  49. struct usb_interface *data;
  50. };
  51. /* using a counter to merge subdriver requests with our own into a combined state */
  52. static int qmi_wwan_manage_power(struct usbnet *dev, int on)
  53. {
  54. struct qmi_wwan_state *info = (void *)&dev->data;
  55. int rv = 0;
  56. dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on);
  57. if ((on && atomic_add_return(1, &info->pmcount) == 1) || (!on && atomic_dec_and_test(&info->pmcount))) {
  58. /* need autopm_get/put here to ensure the usbcore sees the new value */
  59. rv = usb_autopm_get_interface(dev->intf);
  60. if (rv < 0)
  61. goto err;
  62. dev->intf->needs_remote_wakeup = on;
  63. usb_autopm_put_interface(dev->intf);
  64. }
  65. err:
  66. return rv;
  67. }
  68. static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
  69. {
  70. struct usbnet *dev = usb_get_intfdata(intf);
  71. /* can be called while disconnecting */
  72. if (!dev)
  73. return 0;
  74. return qmi_wwan_manage_power(dev, on);
  75. }
  76. /* collect all three endpoints and register subdriver */
  77. static int qmi_wwan_register_subdriver(struct usbnet *dev)
  78. {
  79. int rv;
  80. struct usb_driver *subdriver = NULL;
  81. struct qmi_wwan_state *info = (void *)&dev->data;
  82. /* collect bulk endpoints */
  83. rv = usbnet_get_endpoints(dev, info->data);
  84. if (rv < 0)
  85. goto err;
  86. /* update status endpoint if separate control interface */
  87. if (info->control != info->data)
  88. dev->status = &info->control->cur_altsetting->endpoint[0];
  89. /* require interrupt endpoint for subdriver */
  90. if (!dev->status) {
  91. rv = -EINVAL;
  92. goto err;
  93. }
  94. /* for subdriver power management */
  95. atomic_set(&info->pmcount, 0);
  96. /* register subdriver */
  97. subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 4096, &qmi_wwan_cdc_wdm_manage_power);
  98. if (IS_ERR(subdriver)) {
  99. dev_err(&info->control->dev, "subdriver registration failed\n");
  100. rv = PTR_ERR(subdriver);
  101. goto err;
  102. }
  103. /* prevent usbnet from using status endpoint */
  104. dev->status = NULL;
  105. /* save subdriver struct for suspend/resume wrappers */
  106. info->subdriver = subdriver;
  107. err:
  108. return rv;
  109. }
  110. static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
  111. {
  112. int status = -1;
  113. u8 *buf = intf->cur_altsetting->extra;
  114. int len = intf->cur_altsetting->extralen;
  115. struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
  116. struct usb_cdc_union_desc *cdc_union = NULL;
  117. struct usb_cdc_ether_desc *cdc_ether = NULL;
  118. u32 found = 0;
  119. struct usb_driver *driver = driver_of(intf);
  120. struct qmi_wwan_state *info = (void *)&dev->data;
  121. BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state)));
  122. /* control and data is shared? */
  123. if (intf->cur_altsetting->desc.bNumEndpoints == 3) {
  124. info->control = intf;
  125. info->data = intf;
  126. goto shared;
  127. }
  128. /* else require a single interrupt status endpoint on control intf */
  129. if (intf->cur_altsetting->desc.bNumEndpoints != 1)
  130. goto err;
  131. /* and a number of CDC descriptors */
  132. while (len > 3) {
  133. struct usb_descriptor_header *h = (void *)buf;
  134. /* ignore any misplaced descriptors */
  135. if (h->bDescriptorType != USB_DT_CS_INTERFACE)
  136. goto next_desc;
  137. /* buf[2] is CDC descriptor subtype */
  138. switch (buf[2]) {
  139. case USB_CDC_HEADER_TYPE:
  140. if (found & 1 << USB_CDC_HEADER_TYPE) {
  141. dev_dbg(&intf->dev, "extra CDC header\n");
  142. goto err;
  143. }
  144. if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
  145. dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
  146. goto err;
  147. }
  148. break;
  149. case USB_CDC_UNION_TYPE:
  150. if (found & 1 << USB_CDC_UNION_TYPE) {
  151. dev_dbg(&intf->dev, "extra CDC union\n");
  152. goto err;
  153. }
  154. if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
  155. dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
  156. goto err;
  157. }
  158. cdc_union = (struct usb_cdc_union_desc *)buf;
  159. break;
  160. case USB_CDC_ETHERNET_TYPE:
  161. if (found & 1 << USB_CDC_ETHERNET_TYPE) {
  162. dev_dbg(&intf->dev, "extra CDC ether\n");
  163. goto err;
  164. }
  165. if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
  166. dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength);
  167. goto err;
  168. }
  169. cdc_ether = (struct usb_cdc_ether_desc *)buf;
  170. break;
  171. }
  172. /*
  173. * Remember which CDC functional descriptors we've seen. Works
  174. * for all types we care about, of which USB_CDC_ETHERNET_TYPE
  175. * (0x0f) is the highest numbered
  176. */
  177. if (buf[2] < 32)
  178. found |= 1 << buf[2];
  179. next_desc:
  180. len -= h->bLength;
  181. buf += h->bLength;
  182. }
  183. /* did we find all the required ones? */
  184. if (!(found & (1 << USB_CDC_HEADER_TYPE)) ||
  185. !(found & (1 << USB_CDC_UNION_TYPE))) {
  186. dev_err(&intf->dev, "CDC functional descriptors missing\n");
  187. goto err;
  188. }
  189. /* verify CDC Union */
  190. if (desc->bInterfaceNumber != cdc_union->bMasterInterface0) {
  191. dev_err(&intf->dev, "bogus CDC Union: master=%u\n", cdc_union->bMasterInterface0);
  192. goto err;
  193. }
  194. /* need to save these for unbind */
  195. info->control = intf;
  196. info->data = usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0);
  197. if (!info->data) {
  198. dev_err(&intf->dev, "bogus CDC Union: slave=%u\n", cdc_union->bSlaveInterface0);
  199. goto err;
  200. }
  201. /* errors aren't fatal - we can live with the dynamic address */
  202. if (cdc_ether) {
  203. dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
  204. usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
  205. }
  206. /* claim data interface and set it up */
  207. status = usb_driver_claim_interface(driver, info->data, dev);
  208. if (status < 0)
  209. goto err;
  210. shared:
  211. status = qmi_wwan_register_subdriver(dev);
  212. if (status < 0 && info->control != info->data) {
  213. usb_set_intfdata(info->data, NULL);
  214. usb_driver_release_interface(driver, info->data);
  215. }
  216. err:
  217. return status;
  218. }
  219. static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
  220. {
  221. struct qmi_wwan_state *info = (void *)&dev->data;
  222. struct usb_driver *driver = driver_of(intf);
  223. struct usb_interface *other;
  224. if (info->subdriver && info->subdriver->disconnect)
  225. info->subdriver->disconnect(info->control);
  226. /* allow user to unbind using either control or data */
  227. if (intf == info->control)
  228. other = info->data;
  229. else
  230. other = info->control;
  231. /* only if not shared */
  232. if (other && intf != other) {
  233. usb_set_intfdata(other, NULL);
  234. usb_driver_release_interface(driver, other);
  235. }
  236. info->subdriver = NULL;
  237. info->data = NULL;
  238. info->control = NULL;
  239. }
  240. /* suspend/resume wrappers calling both usbnet and the cdc-wdm
  241. * subdriver if present.
  242. *
  243. * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
  244. * wrappers for those without adding usbnet reset support first.
  245. */
  246. static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
  247. {
  248. struct usbnet *dev = usb_get_intfdata(intf);
  249. struct qmi_wwan_state *info = (void *)&dev->data;
  250. int ret;
  251. ret = usbnet_suspend(intf, message);
  252. if (ret < 0)
  253. goto err;
  254. if (intf == info->control && info->subdriver && info->subdriver->suspend)
  255. ret = info->subdriver->suspend(intf, message);
  256. if (ret < 0)
  257. usbnet_resume(intf);
  258. err:
  259. return ret;
  260. }
  261. static int qmi_wwan_resume(struct usb_interface *intf)
  262. {
  263. struct usbnet *dev = usb_get_intfdata(intf);
  264. struct qmi_wwan_state *info = (void *)&dev->data;
  265. int ret = 0;
  266. bool callsub = (intf == info->control && info->subdriver && info->subdriver->resume);
  267. if (callsub)
  268. ret = info->subdriver->resume(intf);
  269. if (ret < 0)
  270. goto err;
  271. ret = usbnet_resume(intf);
  272. if (ret < 0 && callsub && info->subdriver->suspend)
  273. info->subdriver->suspend(intf, PMSG_SUSPEND);
  274. err:
  275. return ret;
  276. }
  277. static const struct driver_info qmi_wwan_info = {
  278. .description = "WWAN/QMI device",
  279. .flags = FLAG_WWAN,
  280. .bind = qmi_wwan_bind,
  281. .unbind = qmi_wwan_unbind,
  282. .manage_power = qmi_wwan_manage_power,
  283. };
  284. #define HUAWEI_VENDOR_ID 0x12D1
  285. /* map QMI/wwan function by a fixed interface number */
  286. #define QMI_FIXED_INTF(vend, prod, num) \
  287. USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
  288. .driver_info = (unsigned long)&qmi_wwan_info
  289. /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
  290. #define QMI_GOBI1K_DEVICE(vend, prod) \
  291. QMI_FIXED_INTF(vend, prod, 3)
  292. /* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
  293. #define QMI_GOBI_DEVICE(vend, prod) \
  294. QMI_FIXED_INTF(vend, prod, 0)
  295. static const struct usb_device_id products[] = {
  296. /* 1. CDC ECM like devices match on the control interface */
  297. { /* Huawei E392, E398 and possibly others sharing both device id and more... */
  298. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
  299. .driver_info = (unsigned long)&qmi_wwan_info,
  300. },
  301. { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
  302. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
  303. .driver_info = (unsigned long)&qmi_wwan_info,
  304. },
  305. /* 2. Combined interface devices matching on class+protocol */
  306. { /* Huawei E367 and possibly others in "Windows mode" */
  307. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
  308. .driver_info = (unsigned long)&qmi_wwan_info,
  309. },
  310. { /* Huawei E392, E398 and possibly others in "Windows mode" */
  311. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
  312. .driver_info = (unsigned long)&qmi_wwan_info,
  313. },
  314. { /* Pantech UML290, P4200 and more */
  315. USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
  316. .driver_info = (unsigned long)&qmi_wwan_info,
  317. },
  318. { /* Pantech UML290 - newer firmware */
  319. USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
  320. .driver_info = (unsigned long)&qmi_wwan_info,
  321. },
  322. { /* Novatel USB551L and MC551 */
  323. USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
  324. USB_CLASS_COMM,
  325. USB_CDC_SUBCLASS_ETHERNET,
  326. USB_CDC_PROTO_NONE),
  327. .driver_info = (unsigned long)&qmi_wwan_info,
  328. },
  329. { /* Novatel E362 */
  330. USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
  331. USB_CLASS_COMM,
  332. USB_CDC_SUBCLASS_ETHERNET,
  333. USB_CDC_PROTO_NONE),
  334. .driver_info = (unsigned long)&qmi_wwan_info,
  335. },
  336. { /* Dell Wireless 5800 (Novatel E362) */
  337. USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
  338. USB_CLASS_COMM,
  339. USB_CDC_SUBCLASS_ETHERNET,
  340. USB_CDC_PROTO_NONE),
  341. .driver_info = (unsigned long)&qmi_wwan_info,
  342. },
  343. { /* Dell Wireless 5800 V2 (Novatel E362) */
  344. USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
  345. USB_CLASS_COMM,
  346. USB_CDC_SUBCLASS_ETHERNET,
  347. USB_CDC_PROTO_NONE),
  348. .driver_info = (unsigned long)&qmi_wwan_info,
  349. },
  350. /* 3. Combined interface devices matching on interface number */
  351. {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
  352. {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
  353. {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
  354. {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
  355. {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
  356. {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
  357. {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
  358. {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
  359. {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
  360. {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
  361. {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */
  362. {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
  363. {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */
  364. {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */
  365. {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
  366. {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
  367. {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
  368. {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
  369. {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
  370. {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
  371. {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
  372. {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
  373. {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
  374. {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
  375. {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */
  376. {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
  377. {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */
  378. {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
  379. {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
  380. {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
  381. {QMI_FIXED_INTF(0x19d2, 0x0191, 4)}, /* ZTE EuFi890 */
  382. {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */
  383. {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
  384. {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */
  385. {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */
  386. {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
  387. {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
  388. {QMI_FIXED_INTF(0x19d2, 0x1010, 4)}, /* ZTE (Vodafone) K3571-Z */
  389. {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
  390. {QMI_FIXED_INTF(0x19d2, 0x1018, 3)}, /* ZTE (Vodafone) K5006-Z */
  391. {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
  392. {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
  393. {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
  394. {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
  395. {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
  396. {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
  397. {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
  398. {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
  399. {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
  400. {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */
  401. {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
  402. {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
  403. {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */
  404. {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
  405. {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
  406. {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
  407. {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
  408. {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
  409. {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
  410. {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
  411. /* 4. Gobi 1000 devices */
  412. {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
  413. {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
  414. {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
  415. {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
  416. {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
  417. {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
  418. {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
  419. {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
  420. {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
  421. {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
  422. {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
  423. {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
  424. {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
  425. /* 5. Gobi 2000 and 3000 devices */
  426. {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
  427. {QMI_GOBI_DEVICE(0x413c, 0x8194)}, /* Dell Gobi 3000 Composite */
  428. {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
  429. {QMI_GOBI_DEVICE(0x05c6, 0x920d)}, /* Gobi 3000 Composite */
  430. {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
  431. {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
  432. {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
  433. {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
  434. {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
  435. {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
  436. {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
  437. {QMI_GOBI_DEVICE(0x1199, 0x68a5)}, /* Sierra Wireless Modem */
  438. {QMI_GOBI_DEVICE(0x1199, 0x68a9)}, /* Sierra Wireless Modem */
  439. {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  440. {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  441. {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  442. {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  443. {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  444. {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  445. {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  446. {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  447. {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  448. {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  449. {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
  450. {QMI_FIXED_INTF(0x1199, 0x9011, 5)}, /* alternate interface number!? */
  451. {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
  452. {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
  453. {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
  454. {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
  455. {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
  456. {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
  457. {QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
  458. {QMI_GOBI_DEVICE(0x12d1, 0x14f1)}, /* Sony Gobi 3000 Composite */
  459. {QMI_GOBI_DEVICE(0x1410, 0xa021)}, /* Foxconn Gobi 3000 Modem device (Novatel E396) */
  460. { } /* END */
  461. };
  462. MODULE_DEVICE_TABLE(usb, products);
  463. static int qmi_wwan_probe(struct usb_interface *intf, const struct usb_device_id *prod)
  464. {
  465. struct usb_device_id *id = (struct usb_device_id *)prod;
  466. /* Workaround to enable dynamic IDs. This disables usbnet
  467. * blacklisting functionality. Which, if required, can be
  468. * reimplemented here by using a magic "blacklist" value
  469. * instead of 0 in the static device id table
  470. */
  471. if (!id->driver_info) {
  472. dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
  473. id->driver_info = (unsigned long)&qmi_wwan_info;
  474. }
  475. return usbnet_probe(intf, id);
  476. }
  477. static struct usb_driver qmi_wwan_driver = {
  478. .name = "qmi_wwan",
  479. .id_table = products,
  480. .probe = qmi_wwan_probe,
  481. .disconnect = usbnet_disconnect,
  482. .suspend = qmi_wwan_suspend,
  483. .resume = qmi_wwan_resume,
  484. .reset_resume = qmi_wwan_resume,
  485. .supports_autosuspend = 1,
  486. .disable_hub_initiated_lpm = 1,
  487. };
  488. module_usb_driver(qmi_wwan_driver);
  489. MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
  490. MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
  491. MODULE_LICENSE("GPL");