099-0007-qmi_wwan-add-support-for-Quectel-EC21-and-EC25.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 9a765881bf3dcd32847d7108cf48cb04a4ed993f Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
  3. Date: Mon, 10 Oct 2016 21:12:49 +0200
  4. Subject: [PATCH] qmi_wwan: add support for Quectel EC21 and EC25
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The Quectel EC21 and EC25 need the same "set DTR" request as devices
  9. based on the MDM9230 chipset, but has no USB3 support. Our best guess
  10. is that the "set DTR" functionality depends on chipset and/or
  11. baseband firmware generation. But USB3 is still an optional feature.
  12. Since we cannot enable this unconditionally for all older devices, and
  13. there doesn't appear to be anything we can use in the USB descriptors
  14. to identify these chips, we are forced to use a device specific quirk
  15. flag.
  16. Reported-and-tested-by: Sebastian Sjoholm <sebastian.sjoholm@gmail.com>
  17. Signed-off-by: Bjørn Mork <bjorn@mork.no>
  18. Signed-off-by: David S. Miller <davem@davemloft.net>
  19. ---
  20. drivers/net/usb/qmi_wwan.c | 30 ++++++++++++++++++++++++++++--
  21. 1 file changed, 28 insertions(+), 2 deletions(-)
  22. --- a/drivers/net/usb/qmi_wwan.c
  23. +++ b/drivers/net/usb/qmi_wwan.c
  24. @@ -59,6 +59,10 @@ enum qmi_wwan_flags {
  25. QMI_WWAN_FLAG_RAWIP = 1 << 0,
  26. };
  27. +enum qmi_wwan_quirks {
  28. + QMI_WWAN_QUIRK_DTR = 1 << 0, /* needs "set DTR" request */
  29. +};
  30. +
  31. static void qmi_wwan_netdev_setup(struct net_device *net)
  32. {
  33. struct usbnet *dev = netdev_priv(net);
  34. @@ -411,9 +415,14 @@ static int qmi_wwan_bind(struct usbnet *
  35. * clearing out state the clients might need.
  36. *
  37. * MDM9x30 is the first QMI chipset with USB3 support. Abuse
  38. - * this fact to enable the quirk.
  39. + * this fact to enable the quirk for all USB3 devices.
  40. + *
  41. + * There are also chipsets with the same "set DTR" requirement
  42. + * but without USB3 support. Devices based on these chips
  43. + * need a quirk flag in the device ID table.
  44. */
  45. - if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
  46. + if (dev->driver_info->data & QMI_WWAN_QUIRK_DTR ||
  47. + le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
  48. qmi_wwan_manage_power(dev, 1);
  49. qmi_wwan_change_dtr(dev, true);
  50. }
  51. @@ -526,6 +535,16 @@ static const struct driver_info qmi_wwan
  52. .rx_fixup = qmi_wwan_rx_fixup,
  53. };
  54. +static const struct driver_info qmi_wwan_info_quirk_dtr = {
  55. + .description = "WWAN/QMI device",
  56. + .flags = FLAG_WWAN,
  57. + .bind = qmi_wwan_bind,
  58. + .unbind = qmi_wwan_unbind,
  59. + .manage_power = qmi_wwan_manage_power,
  60. + .rx_fixup = qmi_wwan_rx_fixup,
  61. + .data = QMI_WWAN_QUIRK_DTR,
  62. +};
  63. +
  64. #define HUAWEI_VENDOR_ID 0x12D1
  65. /* map QMI/wwan function by a fixed interface number */
  66. @@ -533,6 +552,11 @@ static const struct driver_info qmi_wwan
  67. USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
  68. .driver_info = (unsigned long)&qmi_wwan_info
  69. +/* devices requiring "set DTR" quirk */
  70. +#define QMI_QUIRK_SET_DTR(vend, prod, num) \
  71. + USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
  72. + .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr
  73. +
  74. /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
  75. #define QMI_GOBI1K_DEVICE(vend, prod) \
  76. QMI_FIXED_INTF(vend, prod, 3)
  77. @@ -917,6 +941,8 @@ static const struct usb_device_id produc
  78. {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */
  79. {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
  80. {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */
  81. + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
  82. + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */
  83. /* 4. Gobi 1000 devices */
  84. {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */