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