Add HUAWEI ME906s LTE Module support
authoryan <yan-wyb@foxmail.com>
Mon, 20 Jul 2020 02:53:37 +0000 (10:53 +0800)
committeryan <yan-wyb@foxmail.com>
Mon, 20 Jul 2020 02:53:37 +0000 (10:53 +0800)
Signed-off-by: yan <yan-wyb@foxmail.com>
drivers/usb/serial/option.c
drivers/usb/serial/usb_wwan.c

index 07aab4b4ad4c615fccc91fa63dd2ce6f9153c3a3..27be746cb651d3570b31d21ef0f3b852bc6be056 100644 (file)
@@ -971,6 +971,7 @@ static const struct usb_device_id option_ids[] = {
        { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) },
        { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) },
        { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) },
+    { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) },
 
        /* Motorola devices */
        { USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x2a70, 0xff, 0xff, 0xff) },    /* mdm6600 */
@@ -2113,6 +2114,12 @@ static int option_attach(struct usb_serial *serial)
        struct usb_wwan_intf_private *data;
        unsigned long device_flags;
 
+    if (serial->dev->descriptor.idVendor == HUAWEI_VENDOR_ID) {
+        if ( 0 != (serial->dev->config->desc.bmAttributes & 0x20)){
+            usb_enable_autosuspend(serial->dev);
+        }
+    }
+
        data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
index 4569a8a66c412f8c3cb467d0eb0bcc6f78c7777d..10c5e5597790e438bc4001f4e770444bf1003b71 100644 (file)
@@ -36,6 +36,9 @@
 #include <linux/serial.h>
 #include "usb-wwan.h"
 
+#define HW_bcdUSB 0x0110
+#define HUAWEI_VENDOR_ID 0x12d1
+
 /*
  * Generate DTR/RTS signals on the port using the SET_CONTROL_LINE_STATE request
  * in CDC ACM.
@@ -217,6 +220,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
 {
        struct usb_wwan_port_private *portdata;
        struct usb_wwan_intf_private *intfdata;
+    struct usb_host_endpoint *ep;
        int i;
        int left, todo;
        struct urb *this_urb = NULL;    /* spurious */
@@ -256,6 +260,15 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
                memcpy(this_urb->transfer_buffer, buf, todo);
                this_urb->transfer_buffer_length = todo;
 
+        if((HUAWEI_VENDOR_ID == port->serial->dev->descriptor.idVendor)
+                && (HW_bcdUSB != port->serial->dev->descriptor.bcdUSB)){
+            ep = usb_pipe_endpoint(this_urb->dev, this_urb->pipe);
+            if(ep && (0 != this_urb->transfer_buffer_length)
+                    && (0 == this_urb->transfer_buffer_length % ep->desc.wMaxPacketSize)){
+                this_urb->transfer_flags |= URB_ZERO_PACKET;
+            }
+        }
+
                spin_lock_irqsave(&intfdata->susp_lock, flags);
                if (intfdata->suspended) {
                        usb_anchor_urb(this_urb, &portdata->delayed);