Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Introduce the new umass quirk table.



details:   https://anonhg.NetBSD.org/src/rev/3e5c4e9ea847
branches:  trunk
changeset: 519425:3e5c4e9ea847
user:      gehenna <gehenna%NetBSD.org@localhost>
date:      Mon Dec 17 12:16:14 2001 +0000

description:
Introduce the new umass quirk table.

Discussed with augustss.

diffstat:

 sys/dev/usb/files.usb      |    3 +-
 sys/dev/usb/umass.c        |  523 ++++++++++++++++----------------------------
 sys/dev/usb/umass_quirks.c |  252 +++++++++++++++++++++
 sys/dev/usb/umass_quirks.h |   61 +++++
 sys/dev/usb/umassbus.c     |   30 +-
 sys/dev/usb/umassvar.h     |   66 +----
 6 files changed, 536 insertions(+), 399 deletions(-)

diffs (truncated from 1310 to 300 lines):

diff -r a6653eee34e8 -r 3e5c4e9ea847 sys/dev/usb/files.usb
--- a/sys/dev/usb/files.usb     Mon Dec 17 06:01:23 2001 +0000
+++ b/sys/dev/usb/files.usb     Mon Dec 17 12:16:14 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.usb,v 1.32 2001/12/12 15:27:24 augustss Exp $
+#      $NetBSD: files.usb,v 1.33 2001/12/17 12:16:14 gehenna Exp $
 #
 # Config file and device description for machine-independent USB code.
 # Included by ports that need it.  Ports that use it must provide
@@ -83,6 +83,7 @@
 attach umass at uhub
 file   dev/usb/umass.c                 umass
 file   dev/usb/umassbus.c              umass
+file   dev/usb/umass_quirks.c          umass
 
 
 # IrDA bridges
diff -r a6653eee34e8 -r 3e5c4e9ea847 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Mon Dec 17 06:01:23 2001 +0000
+++ b/sys/dev/usb/umass.c       Mon Dec 17 12:16:14 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.77 2001/12/15 00:26:14 augustss Exp $      */
+/*     $NetBSD: umass.c,v 1.78 2001/12/17 12:16:14 gehenna Exp $       */
 /*-
  * Copyright (c) 1999 MAEKAWA Masahide <bishop%rr.iij4u.or.jp@localhost>,
  *                   Nick Hibma <n_hibma%freebsd.org@localhost>
@@ -94,7 +94,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.77 2001/12/15 00:26:14 augustss Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.78 2001/12/17 12:16:14 gehenna Exp $");
 
 #include "atapibus.h"
 
@@ -122,7 +122,7 @@
 
 #include <dev/usb/umassbus.h>
 #include <dev/usb/umassvar.h>
-
+#include <dev/usb/umass_quirks.h>
 
 
 
@@ -156,10 +156,6 @@
 /* USB device probe/attach/detach functions */
 USB_DECLARE_DRIVER(umass);
 Static void umass_disco(struct umass_softc *sc);
-Static int umass_match_proto(struct umass_softc *sc,
-                            usbd_interface_handle iface,
-                            usbd_device_handle dev);
-Static void umass_init_shuttle(struct umass_softc *sc);
 
 /* generic transfer functions */
 Static usbd_status umass_setup_transfer(struct umass_softc *sc,
@@ -219,271 +215,136 @@
  * USB device probe/attach/detach
  */
 
-/*
- * Match the device we are seeing with the devices supported. Fill in the
- * proto and drive fields in the softc accordingly.
- * This function is called from both probe and attach.
- */
-
-Static int
-umass_match_proto(struct umass_softc *sc, usbd_interface_handle iface,
-                 usbd_device_handle dev)
+USB_MATCH(umass)
 {
-       usb_device_descriptor_t *dd;
+       USB_MATCH_START(umass, uaa);
+       const struct umass_quirk *quirk;
        usb_interface_descriptor_t *id;
-       u_int vendor, product;
-
-       /*
-        * Fill in sc->drive and sc->proto and return a match
-        * value if both are determined and 0 otherwise.
-        */
-
-       sc->drive = DRIVE_GENERIC;
-       sc->transfer_speed = UMASS_DEFAULT_TRANSFER_SPEED;
-
-       sc->sc_udev = dev;
-       dd = usbd_get_device_descriptor(dev);
-       vendor = UGETW(dd->idVendor);
-       product = UGETW(dd->idProduct);
-
-       if (vendor == USB_VENDOR_SHUTTLE &&
-           (product == USB_PRODUCT_SHUTTLE_EUSB ||
-            product == USB_PRODUCT_SHUTTLE_ZIOMMC)
-           ) {
-               if (product == USB_PRODUCT_SHUTTLE_EUSB)
-                       sc->drive = SHUTTLE_EUSB;
-#if CBI_I
-               sc->wire_proto = WPROTO_CBI_I;
-               sc->cmd_proto = CPROTO_ATAPI;
-#else
-               sc->wire_proto = WPROTO_CBI;
-               sc->cmd_proto = CPROTO_ATAPI;
-#endif
-               sc->subclass = UISUBCLASS_SFF8020I;
-               sc->protocol = UIPROTO_MASS_CBI;
-               sc->quirks |= NO_TEST_UNIT_READY | NO_START_STOP;
-               return (UMATCH_VENDOR_PRODUCT);
-       }
-
-       if (vendor == USB_VENDOR_MICROTECH &&
-           product == USB_PRODUCT_MICROTECH_DPCM) {
-               sc->wire_proto = WPROTO_CBI;
-               sc->cmd_proto = CPROTO_ATAPI;
-               sc->subclass = UISUBCLASS_SFF8070I;
-               sc->protocol = UIPROTO_MASS_CBI;
-               sc->transfer_speed = UMASS_ZIP100_TRANSFER_SPEED * 2;
-
-               return (UMATCH_VENDOR_PRODUCT);
-       }
-
-       if (vendor == USB_VENDOR_YANO &&
-           product == USB_PRODUCT_YANO_U640MO) {
-#if CBI_I
-               sc->wire_proto = WPROTO_CBI_I;
-               sc->cmd_proto = CPROTO_ATAPI;
-#else
-               sc->wire_proto = WPROTO_CBI;
-               sc->cmd_proto = CPROTO_ATAPI;
-#endif
-               sc->quirks |= FORCE_SHORT_INQUIRY;
-               return (UMATCH_VENDOR_PRODUCT);
-       }
 
-       if (vendor == USB_VENDOR_SONY &&
-           product == USB_PRODUCT_SONY_MSC) {
-               sc->quirks |= FORCE_SHORT_INQUIRY;
-       }
-
-       if (vendor == USB_VENDOR_YEDATA &&
-           product == USB_PRODUCT_YEDATA_FLASHBUSTERU) {
-
-               /* Revisions < 1.28 do not handle the interrupt endpoint
-                * very well.
-                */
-               if (UGETW(dd->bcdDevice) < 0x128) {
-                       sc->wire_proto = WPROTO_CBI;
-                       sc->cmd_proto = CPROTO_UFI;
-               } else
-#if CBI_I
-                       sc->wire_proto = WPROTO_CBI_I;
-                       sc->cmd_proto = CPROTO_UFI;
-#else
-                       sc->wire_proto = WPROTO_CBI;
-                       sc->cmd_proto = CPROTO_UFI;
-#endif
-               /*
-                * Revisions < 1.28 do not have the TEST UNIT READY command
-                * Revisions == 1.28 have a broken TEST UNIT READY
-                */
-               if (UGETW(dd->bcdDevice) <= 0x128)
-                       sc->quirks |= NO_TEST_UNIT_READY;
-
-               sc->subclass = UISUBCLASS_UFI;
-               sc->protocol = UIPROTO_MASS_CBI;
-
-               sc->quirks |= RS_NO_CLEAR_UA;
-               sc->transfer_speed = UMASS_FLOPPY_TRANSFER_SPEED;
-               return (UMATCH_VENDOR_PRODUCT_REV);
-       }
+       if (uaa->iface == NULL)
+               return (UMATCH_NONE);
 
-       if (vendor == USB_VENDOR_INSYSTEM &&
-           product == USB_PRODUCT_INSYSTEM_USBCABLE) {
-               sc->drive = INSYSTEM_USBCABLE;
-               sc->wire_proto = WPROTO_CBI;
-               sc->cmd_proto = CPROTO_ATAPI;
-               sc->quirks |= NO_TEST_UNIT_READY | NO_START_STOP;
-               return (UMATCH_VENDOR_PRODUCT);
-       }
-
-       if (vendor == USB_VENDOR_IOMEGA &&
-           (product == USB_PRODUCT_IOMEGA_ZIP100 ||
-            product == USB_PRODUCT_IOMEGA_ZIP250)) {
-               sc->drive = ZIP_100;
-               sc->transfer_speed = UMASS_ZIP100_TRANSFER_SPEED;
-               sc->quirks |= NO_TEST_UNIT_READY;
-       }
+       quirk = umass_lookup(uaa->vendor, uaa->product);
+       if (quirk != NULL)
+               return (quirk->uq_match);
 
-       if (vendor == USB_VENDOR_OLYMPUS &&
-           product == USB_PRODUCT_OLYMPUS_C1) {
-               /*
-                * The Olympus C-1 camera uses a different command-status
-                * signature.
-                */
-               sc->quirks |= WRONG_CSWSIG;
-       }
-
-       if (UGETW(dd->idVendor) == USB_VENDOR_SCANLOGIC &&
-           UGETW(dd->idProduct) == USB_PRODUCT_SCANLOGIC_SL11R) {
-               /*
-                * ScanLogic SL11R IDE adapter claims to support
-                * SCSI, but really needs UFI.
-                * Note also that these devices need firmware > 0.71
-                */
-               sc->cmd_proto &= ~CPROTO_SCSI;
-               sc->cmd_proto |= CPROTO_UFI;
-       }
-
-       id = usbd_get_interface_descriptor(iface);
+       id = usbd_get_interface_descriptor(uaa->iface);
        if (id == NULL || id->bInterfaceClass != UICLASS_MASS)
                return (UMATCH_NONE);
 
-       if (vendor == USB_VENDOR_SONY && id->bInterfaceSubClass == 0xff) {
-               /* 
-                * Sony DSC devices set the sub class to 0xff
-                * instead of 1 (RBC). Fix that here.
-                */
-               id->bInterfaceSubClass = UISUBCLASS_RBC;
-               /* They also should be able to do higher speed. */
-               sc->transfer_speed = 500;
-       }
-
-       if (vendor == USB_VENDOR_FUJIPHOTO &&
-           product == USB_PRODUCT_FUJIPHOTO_MASS0100)
-               sc->quirks |= NO_TEST_UNIT_READY | NO_START_STOP;
-
-       sc->subclass = id->bInterfaceSubClass;
-       sc->protocol = id->bInterfaceProtocol;
-
-       switch (sc->subclass) {
+       switch (id->bInterfaceSubClass) {
+       case UISUBCLASS_RBC:
+       case UISUBCLASS_SFF8020I:
+       case UISUBCLASS_QIC157:
+       case UISUBCLASS_UFI:
+       case UISUBCLASS_SFF8070I:
        case UISUBCLASS_SCSI:
-               sc->cmd_proto = CPROTO_SCSI;
-               break;
-       case UISUBCLASS_UFI:
-               sc->transfer_speed = UMASS_FLOPPY_TRANSFER_SPEED;
-               sc->cmd_proto = CPROTO_UFI;
-               break;
-       case UISUBCLASS_SFF8020I:
-       case UISUBCLASS_SFF8070I:
-       case UISUBCLASS_QIC157:
-               sc->cmd_proto = CPROTO_ATAPI;
-               break;
-       case UISUBCLASS_RBC:
-               sc->cmd_proto = CPROTO_RBC;
                break;
        default:
-               DPRINTF(UDMASS_GEN, ("%s: Unsupported command protocol %d\n",
-                       USBDEVNAME(sc->sc_dev), id->bInterfaceSubClass));
-               return (UMATCH_NONE);
+               return (UMATCH_IFACECLASS);
        }
 
-       switch (sc->protocol) {
-       case UIPROTO_MASS_CBI:
-               sc->wire_proto = WPROTO_CBI;
-               break;
+       switch (id->bInterfaceProtocol) {
        case UIPROTO_MASS_CBI_I:
-#if CBI_I
-               sc->wire_proto = WPROTO_CBI_I;
-#else
-               sc->wire_proto = WPROTO_CBI;
-#endif
-               break;
+       case UIPROTO_MASS_CBI:
+       case UIPROTO_MASS_BBB_OLD:
        case UIPROTO_MASS_BBB:
-       case UIPROTO_MASS_BBB_OLD:
-               sc->wire_proto = WPROTO_BBB;
                break;
        default:
-               DPRINTF(UDMASS_GEN, ("%s: Unsupported wire protocol %d\n",
-                       USBDEVNAME(sc->sc_dev), id->bInterfaceProtocol));
-               return (UMATCH_NONE);
+               return (UMATCH_IFACECLASS_IFACESUBCLASS);
        }
 
-       return (UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO);
-}
-
-USB_MATCH(umass)
-{
-       USB_MATCH_START(umass, uaa);
-#if defined(__FreeBSD__)
-       struct umass_softc *sc = device_get_softc(self);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
-       struct umass_softc scs, *sc = &scs;
-       memset(sc, 0, sizeof *sc);
-       strcpy(sc->sc_dev.dv_xname, "umass");
-#endif



Home | Main Index | Thread Index | Old Index