kernel/generic: 3.18, 4.y: Add support for Quectel EC20 Mini PCIe module
[openwrt/openwrt.git] / target / linux / generic / patches-3.18 / 193-USB-qmi_wwan-Add-quirk-for-Quectel-EC20-Mini-PCIe-mo.patch
1 From fe29727caa7fe434fcb3166df2a62672bc516b54 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz@true.cz>
3 Date: Wed, 4 Nov 2015 16:23:37 +0100
4 Subject: [PATCH 2/2] USB: qmi_wwan: Add quirk for Quectel EC20 Mini PCIe
5 module
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This device has same vendor and product IDs as G2K devices, but it has
11 different number of interfaces(4 vs 5) and also different interface
12 layout where EC20 has QMI on interface 4 instead of 0.
13
14 lsusb output:
15
16 Bus 002 Device 003: ID 05c6:9215 Qualcomm, Inc. Acer Gobi 2000
17 Device Descriptor:
18 bLength 18
19 bDescriptorType 1
20 bcdUSB 2.00
21 bDeviceClass 0 (Defined at Interface level)
22 bDeviceSubClass 0
23 bDeviceProtocol 0
24 bMaxPacketSize0 64
25 idVendor 0x05c6 Qualcomm, Inc.
26 idProduct 0x9215 Acer Gobi 2000 Wireless Modem
27 bcdDevice 2.32
28 iManufacturer 1 Quectel
29 iProduct 2 Quectel LTE Module
30 iSerial 0
31 bNumConfigurations 1
32 Configuration Descriptor:
33 bLength 9
34 bDescriptorType 2
35 wTotalLength 209
36 bNumInterfaces 5
37 bConfigurationValue 1
38 iConfiguration 0
39 bmAttributes 0xa0
40 (Bus Powered)
41 Remote Wakeup
42 MaxPower 500mA
43
44 Signed-off-by: Petr Štetiar <ynezz@true.cz>
45 ---
46 drivers/net/usb/qmi_wwan.c | 21 +++++++++++++++++++++
47 1 file changed, 21 insertions(+)
48
49 diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
50 index 2a7c1be..b81a32c 100644
51 --- a/drivers/net/usb/qmi_wwan.c
52 +++ b/drivers/net/usb/qmi_wwan.c
53 @@ -822,6 +822,7 @@ static const struct usb_device_id products[] = {
54 {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
55 {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
56 {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
57 + {QMI_FIXED_INTF(0x05c6, 0x9215, 4)}, /* Quectel EC20 Mini PCIe */
58 {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
59 {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
60 {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
61 @@ -853,10 +854,24 @@ static const struct usb_device_id products[] = {
62 };
63 MODULE_DEVICE_TABLE(usb, products);
64
65 +static bool quectel_ec20_detected(struct usb_interface *intf)
66 +{
67 + struct usb_device *dev = interface_to_usbdev(intf);
68 +
69 + if (dev->actconfig &&
70 + le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
71 + le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
72 + dev->actconfig->desc.bNumInterfaces == 5)
73 + return true;
74 +
75 + return false;
76 +}
77 +
78 static int qmi_wwan_probe(struct usb_interface *intf,
79 const struct usb_device_id *prod)
80 {
81 struct usb_device_id *id = (struct usb_device_id *)prod;
82 + struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
83
84 /* Workaround to enable dynamic IDs. This disables usbnet
85 * blacklisting functionality. Which, if required, can be
86 @@ -868,6 +883,12 @@ static int qmi_wwan_probe(struct usb_interface *intf,
87 id->driver_info = (unsigned long)&qmi_wwan_info;
88 }
89
90 + /* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
91 + if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
92 + dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
93 + return -ENODEV;
94 + }
95 +
96 return usbnet_probe(intf, id);
97 }
98
99 --
100 1.7.9.5
101