Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb PR/49233: Ben Gergely: Add huawei e353 to u3g



details:   https://anonhg.NetBSD.org/src/rev/fec93231c45c
branches:  trunk
changeset: 802626:fec93231c45c
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Sep 24 00:17:13 2014 +0000

description:
PR/49233: Ben Gergely: Add huawei e353 to u3g
(factor out some common code in the process)

diffstat:

 sys/dev/usb/u3g.c   |  90 ++++++++++++++++++++++++++++++++++++++--------------
 sys/dev/usb/usbdevs |   4 +-
 2 files changed, 68 insertions(+), 26 deletions(-)

diffs (191 lines):

diff -r 96f2fa8938a2 -r fec93231c45c sys/dev/usb/u3g.c
--- a/sys/dev/usb/u3g.c Wed Sep 24 00:11:43 2014 +0000
+++ b/sys/dev/usb/u3g.c Wed Sep 24 00:17:13 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: u3g.c,v 1.30 2013/09/02 07:39:03 christos Exp $        */
+/*     $NetBSD: u3g.c,v 1.31 2014/09/24 00:17:13 christos Exp $        */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.30 2013/09/02 07:39:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.31 2014/09/24 00:17:13 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -192,6 +192,7 @@
        { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_K3765 },
        { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },
        { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E171 },
+       { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E353 },
        /* OEM: Merlin */
        { USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 },
        /* OEM: Novatel */
@@ -334,6 +335,16 @@
        return (err == USBD_NORMAL_COMPLETION ? UMATCH_HIGHEST : UMATCH_NONE);
 }
 
+/* Byte 0..3: Command Block Wrapper (CBW) signature */
+static void
+set_cbw(unsigned char *cmd)
+{
+       cmd[0] = 0x55; 
+       cmd[1] = 0x53;
+       cmd[2] = 0x42;
+       cmd[3] = 0x43;
+}
+
 static int
 u3g_bulk_scsi_eject(usbd_device_handle dev)
 {
@@ -341,10 +352,7 @@
 
        memset(cmd, 0, sizeof(cmd));
        /* Byte 0..3: Command Block Wrapper (CBW) signature */
-       cmd[0] = 0x55; 
-       cmd[1] = 0x53;
-       cmd[2] = 0x42;
-       cmd[3] = 0x43;
+       set_cbw(cmd);
        /* 4..7: CBW Tag, has to unique, but only a single transfer used. */
        cmd[4] = 0x01;
        /* 8..11: CBW Transfer Length, no data here */
@@ -372,10 +380,7 @@
 
        memset(cmd, 0, sizeof(cmd));
        /* Byte 0..3: Command Block Wrapper (CBW) signature */
-       cmd[0] = 0x55; 
-       cmd[1] = 0x53;
-       cmd[2] = 0x42;
-       cmd[3] = 0x43;
+       set_cbw(cmd);
        /* 4..7: CBW Tag, has to unique, but only a single transfer used. */
        cmd[4] = 0x01;
        /* 8..11: CBW Transfer Length, no data here */
@@ -455,16 +460,14 @@
 
        /* magic string adapted from some webpage */
        memset(cmd, 0, sizeof(cmd));
-       cmd[0] = 0x55; 
-       cmd[1] = 0x53;
-       cmd[2] = 0x42;
-       cmd[3] = 0x43;
+       /* Byte 0..3: Command Block Wrapper (CBW) signature */
+       set_cbw(cmd);
+
        cmd[15]= 0x11;
        cmd[16]= 0x06;
 
        return send_bulkmsg(dev, cmd, sizeof(cmd));
 }
-
 static int
 u3g_huawei_e171_reinit(usbd_device_handle dev)
 {
@@ -472,10 +475,9 @@
 
        /* magic string adapted from some webpage */
        memset(cmd, 0, sizeof(cmd));
-       cmd[0] = 0x55; 
-       cmd[1] = 0x53;
-       cmd[2] = 0x42;
-       cmd[3] = 0x43;
+       /* Byte 0..3: Command Block Wrapper (CBW) signature */
+       set_cbw(cmd);
+
        cmd[15]= 0x11;
        cmd[16]= 0x06;
        cmd[17]= 0x20;
@@ -485,6 +487,28 @@
 }
 
 static int
+u3g_huawei_e353_reinit(usbd_device_handle dev)
+{
+       unsigned char cmd[31];
+
+       /* magic string adapted from some webpage */
+       memset(cmd, 0, sizeof(cmd));
+       /* Byte 0..3: Command Block Wrapper (CBW) signature */
+       set_cbw(cmd);
+
+       cmd[4] = 0x7f;
+       cmd[9] = 0x02;
+       cmd[12] = 0x80;
+       cmd[14] = 0x0a;
+       cmd[15] = 0x11;
+       cmd[16] = 0x06;
+       cmd[17] = 0x20;
+       cmd[23] = 0x01;
+
+       return send_bulkmsg(dev, cmd, sizeof(cmd));
+}
+
+static int
 u3g_sierra_reinit(usbd_device_handle dev)
 {
        /* Some Sierra devices presents themselves as a umass device with
@@ -508,12 +532,25 @@
 u3g_4gsystems_reinit(usbd_device_handle dev)
 {
        /* magic string adapted from usb_modeswitch database */
-       static unsigned char cmd[31] = {
-               0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 0x80, 0x00,
-               0x00, 0x00, 0x80, 0x00, 0x06, 0x06, 0xf5, 0x04, 0x02, 0x52,
-               0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00
-       };
+       unsigned char cmd[31];
+
+       memset(cmd, 0, sizeof(cmd));
+       /* Byte 0..3: Command Block Wrapper (CBW) signature */
+       set_cbw(cmd);
+
+       cmd[4] = 0x12;
+       cmd[5] = 0x34;
+       cmd[6] = 0x56;
+       cmd[7] = 0x78;
+       cmd[8] = 0x80;
+       cmd[12] = 0x80;
+       cmd[14] = 0x06;
+       cmd[15] = 0x06;
+       cmd[16] = 0xf5;
+       cmd[17] = 0x04;
+       cmd[18] = 0x02;
+       cmd[19] = 0x52;
+       cmd[20] = 0x70;
 
        return send_bulkmsg(dev, cmd, sizeof(cmd));
 }
@@ -545,6 +582,9 @@
                case USB_PRODUCT_HUAWEI_E171INIT:
                        return u3g_huawei_e171_reinit(uaa->device);
                        break;
+               case USB_PRODUCT_HUAWEI_E353INIT:
+                       return u3g_huawei_e353_reinit(uaa->device);
+                       break;
                default:
                        return u3g_huawei_reinit(uaa->device);
                        break;
diff -r 96f2fa8938a2 -r fec93231c45c sys/dev/usb/usbdevs
--- a/sys/dev/usb/usbdevs       Wed Sep 24 00:11:43 2014 +0000
+++ b/sys/dev/usb/usbdevs       Wed Sep 24 00:17:13 2014 +0000
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.681 2014/09/24 00:11:43 christos Exp $
+$NetBSD: usbdevs,v 1.682 2014/09/24 00:17:13 christos Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1733,7 +1733,9 @@
 product HUAWEI E1820           0x14ac  Huawei E1820
 product HUAWEI E171INIT                0x14fe  Huawei E171 USB CD
 product HUAWEI E171            0x1506  Huawei E171
+product HUAWEI E353            0x1507  Huawei E353
 product HUAWEI K3765INIT       0x1520  Huawei K3765 USB CD
+product HUAWEI E353INIT                0x1f01  Huawei E353 USB CD
 
 /* Huawei-3Com products */
 product HUAWEI3COM RT2573      0x0009  RT2573



Home | Main Index | Thread Index | Old Index