[PATCH 7/7] usb: cdc-wdm: Add device-id for Huawei 3G/LTE modems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These modems use the Qualcomm MSM Interface (QMI) protocol for
management of their CDC ECM like wwan interface.  This driver
is perfect for exporting the protocol to userspace.

The created character device will be indistinguishable from a
common AT command based Device Management interface, so
userspace applications must do some intelligent matching
on the USB device.

Signed-off-by: Bjørn Mork <bjorn@xxxxxxx>
---
Finally, turning it on.  There are probably a number of other devices
which could take advantage of this as well, but this is a start

Using it to write QMI in one terminal:

bjorn@nemi:~$ perl -e 'print pack("C*", map { hex } @ARGV)' 1 f 0 0 0 0 0 1 22 0 4 0 1 1 0 1 >/dev/cdc-wdm2

While monitoring the transaction in another terminal:

bjorn@nemi:~$ /usr/local/src/git/modemmanager/decode/qmidevdebug.py /dev/cdc-wdm2
read 16 bytes

QMUX Header:
  len:    0x000f
  sender: 0x00 (client)
  svc:    0x00 (ctl)
  cid:    0x00 

QMI Header:
  Flags:  0x00 (request)
  TXN:    0x0001
  Cmd:    0x0022 (GET_CLIENT_ID)
  Size:   0x0004

  TLV:    0x01 (CTL/Get Client ID Request/Type)
  Size:   0x0001
  Data:   01


read 24 bytes

QMUX Header:
  len:    0x0017
  sender: 0x80 (service)
  svc:    0x00 (ctl)
  cid:    0x00 

QMI Header:
  Flags:  0x02 (response)
  TXN:    0x0001
  Cmd:    0x0022 (GET_CLIENT_ID)
  Size:   0x000c

  TLV:    0x02 (CTL/Get Client ID Response/Result Code)
  Size:   0x0004
  Status: 0 (SUCCESS)
  Error:  0

  TLV:    0x01 (CTL/Get Client ID Response/ID)
  Size:   0x0002
  Data:   01 03



Works like at charm!




 drivers/usb/class/cdc-wdm.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index e0c17ff..4ca3642 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -34,6 +34,8 @@
 /* attribute flags for device list */
 #define WDM_ATTR_ECHO	0x0001	/* device wants command echo */
 
+#define HUAWEI_VENDOR_ID	0x12D1
+
 static const struct usb_device_id wdm_ids[] = {
 	{
 		.match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
@@ -41,6 +43,20 @@ static const struct usb_device_id wdm_ids[] = {
 		.bInterfaceClass = USB_CLASS_COMM,
 		.bInterfaceSubClass = USB_CDC_SUBCLASS_DMM
 	},
+	{
+	/* 
+	 * Huawei E392, E398 and possibly other Qualcomm based modems
+	 * embeds the Qualcomm QMI protocol inside CDC on CDC ECM like
+	 * control interfaces.  Userspace access to this is required
+	 * to configure the accompanying data interface
+	 */
+	.match_flags        = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
+	.idVendor           = HUAWEI_VENDOR_ID,
+	.bInterfaceClass    = USB_CLASS_VENDOR_SPEC,
+	.bInterfaceSubClass = 1,
+	.bInterfaceProtocol = 9, /* NOTE: This is a CDC ECM control interface! */
+	.driver_info        = WDM_ATTR_ECHO,
+	},
 	{ }
 };
 
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux