Steve Clark wrote:
Is there any detailed documentation on the FreeBSD usb device driver api?

This chapter helped me a lot to understand how this all works:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/usb.html

I sort of have it working by hacking ubsa.c to look for the sierra vendor id and product id of 0xfff in the usb_match function and return match. Then in the usb_attach code I look again for the vendor and product id of 0xfff and then send the control message to put it in modem mode.
    if ( uaa->vendor == USB_VENDOR_SIERRA && uaa->product == 0xfff )

It maybe a good idea to add 0xFFF to the usbdevs.
Does the "umass" driver attach to the 0xFFF device? I would recommend adding this as a quirk to umass.c then.

There are patches attached (ubsa.c_patch, umass_c.patch, usbdevs.patch) I am using to kill the "zeroconf" CD on the UMTS. They do not always work - i.e. umass_attach does not wait until the device is really detached. But setting USB_DEBUG helps :-)

    {
        ubsa_request_real( sc, 0x0b, 1, 0x40 );
        ucom->sc_dying = 1;
                goto error;
    }

This puts in modem mode with product id of 0x0023 which i have plugged into usbdevs and also put in ubsa.c so now I get a ucom device and can successfully run ppp. The problem I am running into now is sometime after it remove the device I will get a page fault panic in the kernel.

What kind of panic is this?

I think it is related to the sending the
control_message - something is not cleaned up when I "goto error" in the USB_ATTACH function.

http://www.freebsd.org/cgi/query-pr.cgi?pr=121755

There are two patches, one to ohci_pci.c, the other to usb_subr.c. One of them is not correct - after kldunloading the module you may run into problems. But it makes everyday life easier - at least you can remove the card and re-insert.

And finally, you will need something to increase your ubsa buffers, I am using the ubsa.c_buffers_patch attached. (Crude, but cleaner than
http://www.freebsd.org/cgi/query-pr.cgi?pr=119227)

--Marcin
--- /sys/dev/usb/ubsa.c 2007-06-22 07:56:05.000000000 +0200
+++ ubsa.c      2008-01-03 11:53:09.740739801 +0100
@@ -232,6 +232,8 @@
        { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD },
        /* Option GlobeTrotter 3G+ */
        { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS },
+       /* Option GlobeTrotter Max 3.6 */
+       { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 },
        /* Huawei Mobile */
        { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },
        { 0, 0 }
--- /sys/dev/usb/umass.c        2007-07-05 07:26:08.000000000 +0200
+++ umass.c     2008-01-03 11:53:13.592156965 +0100
@@ -323,6 +323,8 @@
         * sector number.
         */
 #      define READ_CAPACITY_OFFBY1     0x2000
+       /* Needs to be initialised the Qualcomm way */
+#      define TURNOFF_FLASH            0x4000
 };
 
 static struct umass_devdescr_t umass_devdescrs[] = {
@@ -636,6 +638,10 @@
          UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
          IGNORE_RESIDUE | NO_START_STOP
        },
+       { USB_VENDOR_QUALCOMM2, USB_PRODUCT_QUALCOMM2_MMC, RID_WILDCARD,
+         UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
+         TURNOFF_FLASH
+       },
        { USB_VENDOR_SAMSUNG,  USB_PRODUCT_SAMSUNG_YP_U2, RID_WILDCARD,
          UMASS_PROTO_SCSI | UMASS_PROTO_BBB,
          SHUTTLE_INIT | NO_GETMAXLUN
@@ -1027,6 +1033,8 @@
 
 /* quirk functions */
 static void umass_init_shuttle (struct umass_softc *sc);
+static void umass_turnoff_flash (struct umass_softc *sc);
+static void umass_turnoff_flash_cb(struct umass_softc *sc, void *priv, int 
residue, int status);
 
 /* generic transfer functions */
 static usbd_status umass_setup_transfer        (struct umass_softc *sc,
@@ -1472,6 +1480,13 @@
 
        if (sc->quirks & SHUTTLE_INIT)
                umass_init_shuttle(sc);
+       if (sc->quirks & TURNOFF_FLASH) {
+               DPRINTF(UDMASS_USB, ("%s: Detaching MMC\n",
+                       device_get_nameunit(sc->sc_dev)));
+               umass_turnoff_flash(sc);
+               umass_detach(self);
+               return ENXIO;
+       }
 
        /* Get the maximum LUN supported by the device.
         */
@@ -1576,6 +1591,21 @@
                device_get_nameunit(sc->sc_dev), status[0], status[1]));
 }
 
+static void
+umass_turnoff_flash(struct umass_softc *sc)
+{
+       static uint8_t cmd[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
+       umass_bbb_transfer(sc, 0, cmd, sizeof(cmd),
+                   NULL, 0, DIR_NONE, 0,
+                   umass_turnoff_flash_cb, NULL);
+}
+
+static void
+umass_turnoff_flash_cb(struct umass_softc *sc, void *priv, int residue, int 
status)
+{
+       /* Do nothing */
+}
+
  /*
  * Generic functions to handle transfers
  */
--- ubsa.c.orig 2008-03-08 04:22:00.333020955 +0100
+++ ubsa.c      2008-03-12 01:20:07.045184146 +0100
@@ -360,15 +360,15 @@
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
                        sc->sc_intr_number = ed->bEndpointAddress;
-                       sc->sc_isize = UGETW(ed->wMaxPacketSize);
+                       sc->sc_isize = 1024;
                } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
                        ucom->sc_bulkin_no = ed->bEndpointAddress;
-                       ucom->sc_ibufsize = UGETW(ed->wMaxPacketSize);
+                       ucom->sc_ibufsize = 2048;
                } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
                        ucom->sc_bulkout_no = ed->bEndpointAddress;
-                       ucom->sc_obufsize = UGETW(ed->wMaxPacketSize);
+                       ucom->sc_obufsize = 2048;
                }
        }
 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to