qmi_wwan.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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, 512, &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. /* require a single interrupt status endpoint for subdriver */
  123. if (intf->cur_altsetting->desc.bNumEndpoints != 1)
  124. goto err;
  125. while (len > 3) {
  126. struct usb_descriptor_header *h = (void *)buf;
  127. /* ignore any misplaced descriptors */
  128. if (h->bDescriptorType != USB_DT_CS_INTERFACE)
  129. goto next_desc;
  130. /* buf[2] is CDC descriptor subtype */
  131. switch (buf[2]) {
  132. case USB_CDC_HEADER_TYPE:
  133. if (found & 1 << USB_CDC_HEADER_TYPE) {
  134. dev_dbg(&intf->dev, "extra CDC header\n");
  135. goto err;
  136. }
  137. if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
  138. dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
  139. goto err;
  140. }
  141. break;
  142. case USB_CDC_UNION_TYPE:
  143. if (found & 1 << USB_CDC_UNION_TYPE) {
  144. dev_dbg(&intf->dev, "extra CDC union\n");
  145. goto err;
  146. }
  147. if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
  148. dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
  149. goto err;
  150. }
  151. cdc_union = (struct usb_cdc_union_desc *)buf;
  152. break;
  153. case USB_CDC_ETHERNET_TYPE:
  154. if (found & 1 << USB_CDC_ETHERNET_TYPE) {
  155. dev_dbg(&intf->dev, "extra CDC ether\n");
  156. goto err;
  157. }
  158. if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
  159. dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength);
  160. goto err;
  161. }
  162. cdc_ether = (struct usb_cdc_ether_desc *)buf;
  163. break;
  164. }
  165. /*
  166. * Remember which CDC functional descriptors we've seen. Works
  167. * for all types we care about, of which USB_CDC_ETHERNET_TYPE
  168. * (0x0f) is the highest numbered
  169. */
  170. if (buf[2] < 32)
  171. found |= 1 << buf[2];
  172. next_desc:
  173. len -= h->bLength;
  174. buf += h->bLength;
  175. }
  176. /* did we find all the required ones? */
  177. if (!(found & (1 << USB_CDC_HEADER_TYPE)) ||
  178. !(found & (1 << USB_CDC_UNION_TYPE))) {
  179. dev_err(&intf->dev, "CDC functional descriptors missing\n");
  180. goto err;
  181. }
  182. /* verify CDC Union */
  183. if (desc->bInterfaceNumber != cdc_union->bMasterInterface0) {
  184. dev_err(&intf->dev, "bogus CDC Union: master=%u\n", cdc_union->bMasterInterface0);
  185. goto err;
  186. }
  187. /* need to save these for unbind */
  188. info->control = intf;
  189. info->data = usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0);
  190. if (!info->data) {
  191. dev_err(&intf->dev, "bogus CDC Union: slave=%u\n", cdc_union->bSlaveInterface0);
  192. goto err;
  193. }
  194. /* errors aren't fatal - we can live with the dynamic address */
  195. if (cdc_ether) {
  196. dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
  197. usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
  198. }
  199. /* claim data interface and set it up */
  200. status = usb_driver_claim_interface(driver, info->data, dev);
  201. if (status < 0)
  202. goto err;
  203. status = qmi_wwan_register_subdriver(dev);
  204. if (status < 0) {
  205. usb_set_intfdata(info->data, NULL);
  206. usb_driver_release_interface(driver, info->data);
  207. }
  208. err:
  209. return status;
  210. }
  211. /* Some devices combine the "control" and "data" functions into a
  212. * single interface with all three endpoints: interrupt + bulk in and
  213. * out
  214. */
  215. static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
  216. {
  217. int rv;
  218. struct qmi_wwan_state *info = (void *)&dev->data;
  219. /* ZTE makes devices where the interface descriptors and endpoint
  220. * configurations of two or more interfaces are identical, even
  221. * though the functions are completely different. If set, then
  222. * driver_info->data is a bitmap of acceptable interface numbers
  223. * allowing us to bind to one such interface without binding to
  224. * all of them
  225. */
  226. if (dev->driver_info->data &&
  227. !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) {
  228. dev_info(&intf->dev, "not on our whitelist - ignored");
  229. rv = -ENODEV;
  230. goto err;
  231. }
  232. /* control and data is shared */
  233. info->control = intf;
  234. info->data = intf;
  235. rv = qmi_wwan_register_subdriver(dev);
  236. err:
  237. return rv;
  238. }
  239. static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
  240. {
  241. struct qmi_wwan_state *info = (void *)&dev->data;
  242. struct usb_driver *driver = driver_of(intf);
  243. struct usb_interface *other;
  244. if (info->subdriver && info->subdriver->disconnect)
  245. info->subdriver->disconnect(info->control);
  246. /* allow user to unbind using either control or data */
  247. if (intf == info->control)
  248. other = info->data;
  249. else
  250. other = info->control;
  251. /* only if not shared */
  252. if (other && intf != other) {
  253. usb_set_intfdata(other, NULL);
  254. usb_driver_release_interface(driver, other);
  255. }
  256. info->subdriver = NULL;
  257. info->data = NULL;
  258. info->control = NULL;
  259. }
  260. /* suspend/resume wrappers calling both usbnet and the cdc-wdm
  261. * subdriver if present.
  262. *
  263. * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
  264. * wrappers for those without adding usbnet reset support first.
  265. */
  266. static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
  267. {
  268. struct usbnet *dev = usb_get_intfdata(intf);
  269. struct qmi_wwan_state *info = (void *)&dev->data;
  270. int ret;
  271. ret = usbnet_suspend(intf, message);
  272. if (ret < 0)
  273. goto err;
  274. if (info->subdriver && info->subdriver->suspend)
  275. ret = info->subdriver->suspend(intf, message);
  276. if (ret < 0)
  277. usbnet_resume(intf);
  278. err:
  279. return ret;
  280. }
  281. static int qmi_wwan_resume(struct usb_interface *intf)
  282. {
  283. struct usbnet *dev = usb_get_intfdata(intf);
  284. struct qmi_wwan_state *info = (void *)&dev->data;
  285. int ret = 0;
  286. if (info->subdriver && info->subdriver->resume)
  287. ret = info->subdriver->resume(intf);
  288. if (ret < 0)
  289. goto err;
  290. ret = usbnet_resume(intf);
  291. if (ret < 0 && info->subdriver && info->subdriver->resume && info->subdriver->suspend)
  292. info->subdriver->suspend(intf, PMSG_SUSPEND);
  293. err:
  294. return ret;
  295. }
  296. static const struct driver_info qmi_wwan_info = {
  297. .description = "WWAN/QMI device",
  298. .flags = FLAG_WWAN,
  299. .bind = qmi_wwan_bind,
  300. .unbind = qmi_wwan_unbind,
  301. .manage_power = qmi_wwan_manage_power,
  302. };
  303. static const struct driver_info qmi_wwan_shared = {
  304. .description = "WWAN/QMI device",
  305. .flags = FLAG_WWAN,
  306. .bind = qmi_wwan_bind_shared,
  307. .unbind = qmi_wwan_unbind,
  308. .manage_power = qmi_wwan_manage_power,
  309. };
  310. static const struct driver_info qmi_wwan_force_int0 = {
  311. .description = "Qualcomm WWAN/QMI device",
  312. .flags = FLAG_WWAN,
  313. .bind = qmi_wwan_bind_shared,
  314. .unbind = qmi_wwan_unbind,
  315. .manage_power = qmi_wwan_manage_power,
  316. .data = BIT(0), /* interface whitelist bitmap */
  317. };
  318. static const struct driver_info qmi_wwan_force_int1 = {
  319. .description = "Qualcomm WWAN/QMI device",
  320. .flags = FLAG_WWAN,
  321. .bind = qmi_wwan_bind_shared,
  322. .unbind = qmi_wwan_unbind,
  323. .manage_power = qmi_wwan_manage_power,
  324. .data = BIT(1), /* interface whitelist bitmap */
  325. };
  326. static const struct driver_info qmi_wwan_force_int2 = {
  327. .description = "Qualcomm WWAN/QMI device",
  328. .flags = FLAG_WWAN,
  329. .bind = qmi_wwan_bind_shared,
  330. .unbind = qmi_wwan_unbind,
  331. .manage_power = qmi_wwan_manage_power,
  332. .data = BIT(2), /* interface whitelist bitmap */
  333. };
  334. static const struct driver_info qmi_wwan_force_int3 = {
  335. .description = "Qualcomm WWAN/QMI device",
  336. .flags = FLAG_WWAN,
  337. .bind = qmi_wwan_bind_shared,
  338. .unbind = qmi_wwan_unbind,
  339. .manage_power = qmi_wwan_manage_power,
  340. .data = BIT(3), /* interface whitelist bitmap */
  341. };
  342. static const struct driver_info qmi_wwan_force_int4 = {
  343. .description = "Qualcomm WWAN/QMI device",
  344. .flags = FLAG_WWAN,
  345. .bind = qmi_wwan_bind_shared,
  346. .unbind = qmi_wwan_unbind,
  347. .manage_power = qmi_wwan_manage_power,
  348. .data = BIT(4), /* interface whitelist bitmap */
  349. };
  350. /* Sierra Wireless provide equally useless interface descriptors
  351. * Devices in QMI mode can be switched between two different
  352. * configurations:
  353. * a) USB interface #8 is QMI/wwan
  354. * b) USB interfaces #8, #19 and #20 are QMI/wwan
  355. *
  356. * Both configurations provide a number of other interfaces (serial++),
  357. * some of which have the same endpoint configuration as we expect, so
  358. * a whitelist or blacklist is necessary.
  359. *
  360. * FIXME: The below whitelist should include BIT(20). It does not
  361. * because I cannot get it to work...
  362. */
  363. static const struct driver_info qmi_wwan_sierra = {
  364. .description = "Sierra Wireless wwan/QMI device",
  365. .flags = FLAG_WWAN,
  366. .bind = qmi_wwan_bind_shared,
  367. .unbind = qmi_wwan_unbind,
  368. .manage_power = qmi_wwan_manage_power,
  369. .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
  370. };
  371. #define HUAWEI_VENDOR_ID 0x12D1
  372. /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
  373. #define QMI_GOBI1K_DEVICE(vend, prod) \
  374. USB_DEVICE(vend, prod), \
  375. .driver_info = (unsigned long)&qmi_wwan_force_int3
  376. /* Gobi 2000 and Gobi 3000 QMI/wwan interface number is 0 according to qcserial */
  377. #define QMI_GOBI_DEVICE(vend, prod) \
  378. USB_DEVICE(vend, prod), \
  379. .driver_info = (unsigned long)&qmi_wwan_force_int0
  380. static const struct usb_device_id products[] = {
  381. { /* Huawei E392, E398 and possibly others sharing both device id and more... */
  382. .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
  383. .idVendor = HUAWEI_VENDOR_ID,
  384. .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
  385. .bInterfaceSubClass = 1,
  386. .bInterfaceProtocol = 9, /* CDC Ethernet *control* interface */
  387. .driver_info = (unsigned long)&qmi_wwan_info,
  388. },
  389. { /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
  390. .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
  391. .idVendor = HUAWEI_VENDOR_ID,
  392. .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
  393. .bInterfaceSubClass = 1,
  394. .bInterfaceProtocol = 57, /* CDC Ethernet *control* interface */
  395. .driver_info = (unsigned long)&qmi_wwan_info,
  396. },
  397. { /* Huawei E392, E398 and possibly others in "Windows mode"
  398. * using a combined control and data interface without any CDC
  399. * functional descriptors
  400. */
  401. .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
  402. .idVendor = HUAWEI_VENDOR_ID,
  403. .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
  404. .bInterfaceSubClass = 1,
  405. .bInterfaceProtocol = 17,
  406. .driver_info = (unsigned long)&qmi_wwan_shared,
  407. },
  408. { /* Pantech UML290 */
  409. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  410. .idVendor = 0x106c,
  411. .idProduct = 0x3718,
  412. .bInterfaceClass = 0xff,
  413. .bInterfaceSubClass = 0xf0,
  414. .bInterfaceProtocol = 0xff,
  415. .driver_info = (unsigned long)&qmi_wwan_shared,
  416. },
  417. { /* ZTE MF820D */
  418. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  419. .idVendor = 0x19d2,
  420. .idProduct = 0x0167,
  421. .bInterfaceClass = 0xff,
  422. .bInterfaceSubClass = 0xff,
  423. .bInterfaceProtocol = 0xff,
  424. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  425. },
  426. { /* ZTE MF821D */
  427. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  428. .idVendor = 0x19d2,
  429. .idProduct = 0x0326,
  430. .bInterfaceClass = 0xff,
  431. .bInterfaceSubClass = 0xff,
  432. .bInterfaceProtocol = 0xff,
  433. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  434. },
  435. { /* ZTE (Vodafone) K3520-Z */
  436. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  437. .idVendor = 0x19d2,
  438. .idProduct = 0x0055,
  439. .bInterfaceClass = 0xff,
  440. .bInterfaceSubClass = 0xff,
  441. .bInterfaceProtocol = 0xff,
  442. .driver_info = (unsigned long)&qmi_wwan_force_int1,
  443. },
  444. { /* ZTE (Vodafone) K3565-Z */
  445. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  446. .idVendor = 0x19d2,
  447. .idProduct = 0x0063,
  448. .bInterfaceClass = 0xff,
  449. .bInterfaceSubClass = 0xff,
  450. .bInterfaceProtocol = 0xff,
  451. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  452. },
  453. { /* ZTE (Vodafone) K3570-Z */
  454. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  455. .idVendor = 0x19d2,
  456. .idProduct = 0x1008,
  457. .bInterfaceClass = 0xff,
  458. .bInterfaceSubClass = 0xff,
  459. .bInterfaceProtocol = 0xff,
  460. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  461. },
  462. { /* ZTE (Vodafone) K3571-Z */
  463. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  464. .idVendor = 0x19d2,
  465. .idProduct = 0x1010,
  466. .bInterfaceClass = 0xff,
  467. .bInterfaceSubClass = 0xff,
  468. .bInterfaceProtocol = 0xff,
  469. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  470. },
  471. { /* ZTE (Vodafone) K3765-Z */
  472. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  473. .idVendor = 0x19d2,
  474. .idProduct = 0x2002,
  475. .bInterfaceClass = 0xff,
  476. .bInterfaceSubClass = 0xff,
  477. .bInterfaceProtocol = 0xff,
  478. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  479. },
  480. { /* ZTE (Vodafone) K4505-Z */
  481. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  482. .idVendor = 0x19d2,
  483. .idProduct = 0x0104,
  484. .bInterfaceClass = 0xff,
  485. .bInterfaceSubClass = 0xff,
  486. .bInterfaceProtocol = 0xff,
  487. .driver_info = (unsigned long)&qmi_wwan_force_int4,
  488. },
  489. { /* ZTE MF60 */
  490. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  491. .idVendor = 0x19d2,
  492. .idProduct = 0x1402,
  493. .bInterfaceClass = 0xff,
  494. .bInterfaceSubClass = 0xff,
  495. .bInterfaceProtocol = 0xff,
  496. .driver_info = (unsigned long)&qmi_wwan_force_int2,
  497. },
  498. { /* Sierra Wireless MC77xx in QMI mode */
  499. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
  500. .idVendor = 0x1199,
  501. .idProduct = 0x68a2,
  502. .bInterfaceClass = 0xff,
  503. .bInterfaceSubClass = 0xff,
  504. .bInterfaceProtocol = 0xff,
  505. .driver_info = (unsigned long)&qmi_wwan_sierra,
  506. },
  507. /* Gobi 1000 devices */
  508. {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
  509. {QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
  510. {QMI_GOBI1K_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
  511. {QMI_GOBI1K_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
  512. {QMI_GOBI1K_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
  513. {QMI_GOBI1K_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
  514. {QMI_GOBI1K_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
  515. {QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
  516. {QMI_GOBI1K_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
  517. {QMI_GOBI1K_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
  518. {QMI_GOBI1K_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
  519. {QMI_GOBI1K_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
  520. {QMI_GOBI1K_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
  521. {QMI_GOBI1K_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
  522. /* Gobi 2000 and 3000 devices */
  523. {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
  524. {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
  525. {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
  526. {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
  527. {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
  528. {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
  529. {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
  530. {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
  531. {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
  532. {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  533. {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  534. {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  535. {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  536. {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  537. {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  538. {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  539. {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  540. {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  541. {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
  542. {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */
  543. {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
  544. {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
  545. {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
  546. {QMI_GOBI_DEVICE(0x1199, 0x9015)}, /* Sierra Wireless Gobi 3000 Modem device */
  547. {QMI_GOBI_DEVICE(0x1199, 0x9019)}, /* Sierra Wireless Gobi 3000 Modem device */
  548. { } /* END */
  549. };
  550. MODULE_DEVICE_TABLE(usb, products);
  551. static int qmi_wwan_probe(struct usb_interface *intf, const struct usb_device_id *prod)
  552. {
  553. struct usb_device_id *id = (struct usb_device_id *)prod;
  554. /* Workaround to enable dynamic IDs. This disables usbnet
  555. * blacklisting functionality. Which, if required, can be
  556. * reimplemented here by using a magic "blacklist" value
  557. * instead of 0 in the static device id table
  558. */
  559. if (!id->driver_info) {
  560. dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
  561. id->driver_info = (unsigned long)&qmi_wwan_shared;
  562. }
  563. return usbnet_probe(intf, id);
  564. }
  565. static struct usb_driver qmi_wwan_driver = {
  566. .name = "qmi_wwan",
  567. .id_table = products,
  568. .probe = qmi_wwan_probe,
  569. .disconnect = usbnet_disconnect,
  570. .suspend = qmi_wwan_suspend,
  571. .resume = qmi_wwan_resume,
  572. .reset_resume = qmi_wwan_resume,
  573. .supports_autosuspend = 1,
  574. .disable_hub_initiated_lpm = 1,
  575. };
  576. module_usb_driver(qmi_wwan_driver);
  577. MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
  578. MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
  579. MODULE_LICENSE("GPL");