net: qmi_wwan: remove 1199:9070 device id
[cascardo/linux.git] / drivers / net / usb / qmi_wwan.c
index c547199..e3727b6 100644 (file)
@@ -223,6 +223,20 @@ err:
        return rv;
 }
 
+/* Send CDC SetControlLineState request, setting or clearing the DTR.
+ * "Required for Autoconnect and 9x30 to wake up" according to the
+ * GobiNet driver. The requirement has been verified on an MDM9230
+ * based Sierra Wireless MC7455
+ */
+static int qmi_wwan_change_dtr(struct usbnet *dev, bool on)
+{
+       u8 intf = dev->intf->cur_altsetting->desc.bInterfaceNumber;
+
+       return usbnet_write_cmd(dev, USB_CDC_REQ_SET_CONTROL_LINE_STATE,
+                               USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+                               on ? 0x01 : 0x00, intf, NULL, 0);
+}
+
 static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 {
        int status = -1;
@@ -280,6 +294,24 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
                usb_driver_release_interface(driver, info->data);
        }
 
+       /* disabling remote wakeup on MDM9x30 devices has the same
+        * effect as clearing DTR. The device will not respond to QMI
+        * requests until we set DTR again.  This is similar to a
+        * QMI_CTL SYNC request, clearing a lot of firmware state
+        * including the client ID allocations.
+        *
+        * Our usage model allows a session to span multiple
+        * open/close events, so we must prevent the firmware from
+        * clearing out state the clients might need.
+        *
+        * MDM9x30 is the first QMI chipset with USB3 support. Abuse
+        * this fact to enable the quirk.
+        */
+       if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
+               qmi_wwan_manage_power(dev, 1);
+               qmi_wwan_change_dtr(dev, true);
+       }
+
        /* Never use the same address on both ends of the link, even if the
         * buggy firmware told us to. Or, if device is assigned the well-known
         * buggy firmware MAC address, replace it with a random address,
@@ -307,6 +339,12 @@ static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
        if (info->subdriver && info->subdriver->disconnect)
                info->subdriver->disconnect(info->control);
 
+       /* disable MDM9x30 quirk */
+       if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
+               qmi_wwan_change_dtr(dev, false);
+               qmi_wwan_manage_power(dev, 0);
+       }
+
        /* allow user to unbind using either control or data */
        if (intf == info->control)
                other = info->data;
@@ -715,8 +753,6 @@ static const struct usb_device_id products[] = {
        {QMI_FIXED_INTF(0x1199, 0x9056, 8)},    /* Sierra Wireless Modem */
        {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
        {QMI_FIXED_INTF(0x1199, 0x9061, 8)},    /* Sierra Wireless Modem */
-       {QMI_FIXED_INTF(0x1199, 0x9070, 8)},    /* Sierra Wireless MC74xx/EM74xx */
-       {QMI_FIXED_INTF(0x1199, 0x9070, 10)},   /* Sierra Wireless MC74xx/EM74xx */
        {QMI_FIXED_INTF(0x1199, 0x9071, 8)},    /* Sierra Wireless MC74xx/EM74xx */
        {QMI_FIXED_INTF(0x1199, 0x9071, 10)},   /* Sierra Wireless MC74xx/EM74xx */
        {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},    /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
@@ -725,6 +761,7 @@ static const struct usb_device_id products[] = {
        {QMI_FIXED_INTF(0x2357, 0x9000, 4)},    /* TP-LINK MA260 */
        {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},    /* Telit LE920 */
        {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)},    /* Telit LE920 */
+       {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)},    /* XS Stick W100-2 from 4G Systems */
        {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)},    /* Olivetti Olicard 100 */
        {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)},    /* Olivetti Olicard 120 */
        {QMI_FIXED_INTF(0x0b3c, 0xc002, 4)},    /* Olivetti Olicard 140 */
@@ -771,6 +808,7 @@ static const struct usb_device_id products[] = {
        {QMI_GOBI_DEVICE(0x05c6, 0x9245)},      /* Samsung Gobi 2000 Modem device (VL176) */
        {QMI_GOBI_DEVICE(0x03f0, 0x251d)},      /* HP Gobi 2000 Modem device (VP412) */
        {QMI_GOBI_DEVICE(0x05c6, 0x9215)},      /* Acer Gobi 2000 Modem device (VP413) */
+       {QMI_FIXED_INTF(0x05c6, 0x9215, 4)},    /* Quectel EC20 Mini PCIe */
        {QMI_GOBI_DEVICE(0x05c6, 0x9265)},      /* Asus Gobi 2000 Modem device (VR305) */
        {QMI_GOBI_DEVICE(0x05c6, 0x9235)},      /* Top Global Gobi 2000 Modem device (VR306) */
        {QMI_GOBI_DEVICE(0x05c6, 0x9275)},      /* iRex Technologies Gobi 2000 Modem device (VR307) */
@@ -802,10 +840,24 @@ static const struct usb_device_id products[] = {
 };
 MODULE_DEVICE_TABLE(usb, products);
 
+static bool quectel_ec20_detected(struct usb_interface *intf)
+{
+       struct usb_device *dev = interface_to_usbdev(intf);
+
+       if (dev->actconfig &&
+           le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
+           le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
+           dev->actconfig->desc.bNumInterfaces == 5)
+               return true;
+
+       return false;
+}
+
 static int qmi_wwan_probe(struct usb_interface *intf,
                          const struct usb_device_id *prod)
 {
        struct usb_device_id *id = (struct usb_device_id *)prod;
+       struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
 
        /* Workaround to enable dynamic IDs.  This disables usbnet
         * blacklisting functionality.  Which, if required, can be
@@ -817,6 +869,12 @@ static int qmi_wwan_probe(struct usb_interface *intf,
                id->driver_info = (unsigned long)&qmi_wwan_info;
        }
 
+       /* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
+       if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
+               dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
+               return -ENODEV;
+       }
+
        return usbnet_probe(intf, id);
 }