80 lines
2.9 KiB
Diff
80 lines
2.9 KiB
Diff
From 32696e4eaee8f348f4810bbbee392df88a40a3e9 Mon Sep 17 00:00:00 2001
|
|
From: Harald Welte <laforge@gnumonks.org>
|
|
Date: Sat, 17 Dec 2016 16:39:01 +0100
|
|
Subject: [PATCH 1/3] qcserial: Add support for dynamic detection of
|
|
Qualcomm-Android
|
|
|
|
Some modem devices (Quectel EC20, EC21, EC25; Huawei ME906v, ...) a well
|
|
as many smartphones internally run a Qualcomm chipset with a Qualcomm
|
|
Android Linux kernel. That kernel implements also the USB gadget
|
|
functionality, and there are many different gadgets that can be bound to
|
|
various interfaces in arbitrary order. The old assumption to use fixed
|
|
interface numbers doesn't hold true and might change depending on the
|
|
firmware version / configuration used.
|
|
|
|
Those interfaces implemented by the f_serial gadget can be deteted by
|
|
matching on 3 endpoints, InterfaceClass=255, InterfaceSubClass=0 and
|
|
InterfaceProtocol=0. This is distinct from those other interfaces which
|
|
implement e.g. diag, adb or rmnet/qmi_wwan devices.
|
|
|
|
Signed-off-by: Harald Welte <laforge@gnumonks.org>
|
|
---
|
|
drivers/usb/serial/qcserial.c | 20 ++++++++++++++++++++
|
|
1 file changed, 20 insertions(+)
|
|
|
|
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
|
|
index 1bc6089b9008..ea8b1c1b6b21 100644
|
|
--- a/drivers/usb/serial/qcserial.c
|
|
+++ b/drivers/usb/serial/qcserial.c
|
|
@@ -30,6 +30,7 @@ enum qcserial_layouts {
|
|
QCSERIAL_G1K = 1, /* Gobi 1000 */
|
|
QCSERIAL_SWI = 2, /* Sierra Wireless */
|
|
QCSERIAL_HWI = 3, /* Huawei */
|
|
+ QCSERIAL_ANDROID = 4, /* Qualcomm Android */
|
|
};
|
|
|
|
#define DEVICE_G1K(v, p) \
|
|
@@ -38,6 +39,8 @@ enum qcserial_layouts {
|
|
USB_DEVICE(v, p), .driver_info = QCSERIAL_SWI
|
|
#define DEVICE_HWI(v, p) \
|
|
USB_DEVICE(v, p), .driver_info = QCSERIAL_HWI
|
|
+#define DEVICE_ANDROID(v, p) \
|
|
+ USB_DEVICE(v, p), .driver_info = QCSERIAL_ANDROID
|
|
|
|
static const struct usb_device_id id_table[] = {
|
|
/* Gobi 1000 devices */
|
|
@@ -172,6 +175,10 @@ static const struct usb_device_id id_table[] = {
|
|
/* Huawei devices */
|
|
{DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
|
|
|
|
+ /* Quectel devices */
|
|
+ {DEVICE_ANDROID(0x2c7c, 0x0125)}, /* Quectel EC25 */
|
|
+ {DEVICE_ANDROID(0x1d50, 0x4020)}, /* Quectel EC20 with Osmocom mod */
|
|
+
|
|
{ } /* Terminating entry */
|
|
};
|
|
MODULE_DEVICE_TABLE(usb, id_table);
|
|
@@ -383,6 +390,19 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
|
|
intf->desc.bInterfaceProtocol);
|
|
}
|
|
break;
|
|
+ case QCSERIAL_ANDROID:
|
|
+ /* the USB device is implemented using the Qualcomm
|
|
+ * Android Kernel, which uses 255/0/0 with 3 endpoints
|
|
+ * for serial devices. All other interfaces should be
|
|
+ * skipped (qmi_wwan, adb, etc.) */
|
|
+ if (intf->desc.bInterfaceClass == 0xff &&
|
|
+ intf->desc.bInterfaceSubClass == 0 &&
|
|
+ intf->desc.bInterfaceProtocol == 0 &&
|
|
+ intf->desc.bNumEndpoints == 3)
|
|
+ altsetting = 0;
|
|
+ else
|
|
+ altsetting = -1;
|
|
+ break;
|
|
default:
|
|
dev_err(dev, "unsupported device layout type: %lu\n",
|
|
id->driver_info);
|
|
--
|
|
2.11.0
|
|
|