|
Takashi Iwai |
6642a5 |
From 36cae568404a298a19a6e8a3f18641075d4cab04 Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
6642a5 |
From: Kristian Evensen <kristian.evensen@gmail.com>
|
|
Takashi Iwai |
6642a5 |
Date: Thu, 13 Sep 2018 11:21:49 +0200
|
|
Takashi Iwai |
6642a5 |
Subject: [PATCH] USB: serial: option: improve Quectel EP06 detection
|
|
Takashi Iwai |
6642a5 |
Git-commit: 36cae568404a298a19a6e8a3f18641075d4cab04
|
|
Takashi Iwai |
6642a5 |
Patch-mainline: v4.19-rc7
|
|
Takashi Iwai |
6642a5 |
References: bsc#1051510
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
The Quectel EP06 (and EM06/EG06) LTE modem supports updating the USB
|
|
Takashi Iwai |
6642a5 |
configuration, without the VID/PID or configuration number changing.
|
|
Takashi Iwai |
6642a5 |
When the configuration is updated and interfaces are added/removed, the
|
|
Takashi Iwai |
6642a5 |
interface numbers are updated. This causes our current code for matching
|
|
Takashi Iwai |
6642a5 |
EP06 not to work as intended, as the assumption about reserved
|
|
Takashi Iwai |
6642a5 |
interfaces no longer holds. If for example the diagnostic (first)
|
|
Takashi Iwai |
6642a5 |
interface is removed, option will (try to) bind to the QMI interface.
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
This patch improves EP06 detection by replacing the current match with
|
|
Takashi Iwai |
6642a5 |
two matches, and those matches check class, subclass and protocol as
|
|
Takashi Iwai |
6642a5 |
well as VID and PID. The diag interface exports class, subclass and
|
|
Takashi Iwai |
6642a5 |
protocol as 0xff. For the other serial interfaces, class is 0xff and
|
|
Takashi Iwai |
6642a5 |
subclass and protocol are both 0x0.
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
The modem can export the following devices and always in this order:
|
|
Takashi Iwai |
6642a5 |
diag, nmea, at, ppp. qmi and adb. This means that diag can only ever be
|
|
Takashi Iwai |
6642a5 |
interface 0, and interface numbers 1-5 should be marked as reserved. The
|
|
Takashi Iwai |
6642a5 |
three other serial devices can have interface numbers 0-3, but I have
|
|
Takashi Iwai |
6642a5 |
not marked any interfaces as reserved. The reason is that the serial
|
|
Takashi Iwai |
6642a5 |
devices are the only interfaces exported by the device where subclass
|
|
Takashi Iwai |
6642a5 |
and protocol is 0x0.
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
QMI exports the same class, subclass and protocol values as the diag
|
|
Takashi Iwai |
6642a5 |
interface. However, the two interfaces have different number of
|
|
Takashi Iwai |
6642a5 |
endpoints, QMI has three and diag two. I have added a check for number
|
|
Takashi Iwai |
6642a5 |
of interfaces if VID/PID matches the EP06, and we ignore the device if
|
|
Takashi Iwai |
6642a5 |
number of interfaces equals three (and subclass is set).
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
|
|
Takashi Iwai |
6642a5 |
Acked-by: Dan Williams <dcbw@redhat.com>
|
|
Takashi Iwai |
6642a5 |
[ johan: drop uneeded RSVD(5) for ADB ]
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
Cc: stable <stable@vger.kernel.org>
|
|
Takashi Iwai |
6642a5 |
Signed-off-by: Johan Hovold <johan@kernel.org>
|
|
Takashi Iwai |
6642a5 |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
---
|
|
Takashi Iwai |
6642a5 |
drivers/usb/serial/option.c | 18 ++++++++++++++++--
|
|
Takashi Iwai |
6642a5 |
1 file changed, 16 insertions(+), 2 deletions(-)
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
--- a/drivers/usb/serial/option.c
|
|
Takashi Iwai |
6642a5 |
+++ b/drivers/usb/serial/option.c
|
|
Takashi Iwai |
6642a5 |
@@ -1084,8 +1084,9 @@ static const struct usb_device_id option
|
|
Takashi Iwai |
6642a5 |
.driver_info = RSVD(4) },
|
|
Takashi Iwai |
6642a5 |
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
|
|
Takashi Iwai |
6642a5 |
.driver_info = RSVD(4) },
|
|
Takashi Iwai |
6642a5 |
- { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06),
|
|
Takashi Iwai |
6642a5 |
- .driver_info = RSVD(4) | RSVD(5) },
|
|
Takashi Iwai |
6642a5 |
+ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
|
|
Takashi Iwai |
6642a5 |
+ .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) },
|
|
Takashi Iwai |
6642a5 |
+ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
|
|
Takashi Iwai |
6642a5 |
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
|
|
Takashi Iwai |
6642a5 |
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
|
|
Takashi Iwai |
6642a5 |
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
|
|
Takashi Iwai |
6642a5 |
@@ -1990,6 +1991,7 @@ static int option_probe(struct usb_seria
|
|
Takashi Iwai |
6642a5 |
{
|
|
Takashi Iwai |
6642a5 |
struct usb_interface_descriptor *iface_desc =
|
|
Takashi Iwai |
6642a5 |
&serial->interface->cur_altsetting->desc;
|
|
Takashi Iwai |
6642a5 |
+ struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
|
|
Takashi Iwai |
6642a5 |
unsigned long device_flags = id->driver_info;
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
/* Never bind to the CD-Rom emulation interface */
|
|
Takashi Iwai |
6642a5 |
@@ -2004,6 +2006,18 @@ static int option_probe(struct usb_seria
|
|
Takashi Iwai |
6642a5 |
if (device_flags & RSVD(iface_desc->bInterfaceNumber))
|
|
Takashi Iwai |
6642a5 |
return -ENODEV;
|
|
Takashi Iwai |
6642a5 |
|
|
Takashi Iwai |
6642a5 |
+ /*
|
|
Takashi Iwai |
6642a5 |
+ * Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class,
|
|
Takashi Iwai |
6642a5 |
+ * subclass and protocol is 0xff for both the diagnostic port and the
|
|
Takashi Iwai |
6642a5 |
+ * QMI interface, but the diagnostic port only has two endpoints (QMI
|
|
Takashi Iwai |
6642a5 |
+ * has three).
|
|
Takashi Iwai |
6642a5 |
+ */
|
|
Takashi Iwai |
6642a5 |
+ if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) &&
|
|
Takashi Iwai |
6642a5 |
+ dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) &&
|
|
Takashi Iwai |
6642a5 |
+ iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) {
|
|
Takashi Iwai |
6642a5 |
+ return -ENODEV;
|
|
Takashi Iwai |
6642a5 |
+ }
|
|
Takashi Iwai |
6642a5 |
+
|
|
Takashi Iwai |
6642a5 |
/* Store the device flags so we can use them during attach. */
|
|
Takashi Iwai |
6642a5 |
usb_set_serial_data(serial, (void *)device_flags);
|
|
Takashi Iwai |
6642a5 |
|