Home | History | Annotate | Line # | Download | only in usb
umass_quirks.c revision 1.8.2.2
      1  1.8.2.2  nathanw /*	$NetBSD: umass_quirks.c,v 1.8.2.2 2002/01/08 00:32:14 nathanw Exp $	*/
      2  1.8.2.2  nathanw 
      3  1.8.2.2  nathanw /*
      4  1.8.2.2  nathanw  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  1.8.2.2  nathanw  * All rights reserved.
      6  1.8.2.2  nathanw  *
      7  1.8.2.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.8.2.2  nathanw  * by MAEKAWA Masahide (gehenna (at) NetBSD.org).
      9  1.8.2.2  nathanw  *
     10  1.8.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
     11  1.8.2.2  nathanw  * modification, are permitted provided that the following conditions
     12  1.8.2.2  nathanw  * are met:
     13  1.8.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     14  1.8.2.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     15  1.8.2.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.8.2.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     17  1.8.2.2  nathanw  *    documentation and/or other materials provided with the distribution.
     18  1.8.2.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     19  1.8.2.2  nathanw  *    must display the following acknowledgement:
     20  1.8.2.2  nathanw  *	  This product includes software developed by the NetBSD
     21  1.8.2.2  nathanw  *	  Foundation, Inc. and its contributors.
     22  1.8.2.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.8.2.2  nathanw  *    contributors may be used to endorse or promote products derived
     24  1.8.2.2  nathanw  *    from this software without specific prior written permission.
     25  1.8.2.2  nathanw  *
     26  1.8.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.8.2.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.8.2.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.8.2.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.8.2.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.8.2.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.8.2.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.8.2.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.8.2.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.8.2.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.8.2.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     37  1.8.2.2  nathanw  */
     38  1.8.2.2  nathanw 
     39  1.8.2.2  nathanw #include <sys/param.h>
     40  1.8.2.2  nathanw #include <sys/systm.h>
     41  1.8.2.2  nathanw #include <sys/device.h>
     42  1.8.2.2  nathanw #include <sys/buf.h>
     43  1.8.2.2  nathanw 
     44  1.8.2.2  nathanw #include <dev/scsipi/scsipi_all.h> /* for scsiconf.h below */
     45  1.8.2.2  nathanw #include <dev/scsipi/scsiconf.h> /* for quirks defines */
     46  1.8.2.2  nathanw 
     47  1.8.2.2  nathanw #include <dev/usb/usb.h>
     48  1.8.2.2  nathanw #include <dev/usb/usbdi.h>
     49  1.8.2.2  nathanw #include <dev/usb/usbdevs.h>
     50  1.8.2.2  nathanw 
     51  1.8.2.2  nathanw #include <dev/usb/umassvar.h>
     52  1.8.2.2  nathanw #include <dev/usb/umass_quirks.h>
     53  1.8.2.2  nathanw 
     54  1.8.2.2  nathanw Static usbd_status umass_init_insystem(struct umass_softc *);
     55  1.8.2.2  nathanw Static usbd_status umass_init_shuttle(struct umass_softc *);
     56  1.8.2.2  nathanw 
     57  1.8.2.2  nathanw Static void umass_fixup_sony(struct umass_softc *);
     58  1.8.2.2  nathanw Static void umass_fixup_yedata(struct umass_softc *);
     59  1.8.2.2  nathanw 
     60  1.8.2.2  nathanw Static const struct umass_quirk umass_quirks[] = {
     61  1.8.2.2  nathanw 	{ { USB_VENDOR_FUJIPHOTO, USB_PRODUCT_FUJIPHOTO_MASS0100 },
     62  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
     63  1.8.2.2  nathanw 	  UMASS_QUIRK_NO_START_STOP,
     64  1.8.2.2  nathanw 	  PQUIRK_NOTUR | PQUIRK_NOSENSE,
     65  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
     66  1.8.2.2  nathanw 	  NULL, NULL
     67  1.8.2.2  nathanw 	},
     68  1.8.2.2  nathanw 
     69  1.8.2.2  nathanw 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_USBCABLE },
     70  1.8.2.2  nathanw 	  UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
     71  1.8.2.2  nathanw 	  UMASS_QUIRK_NO_START_STOP,
     72  1.8.2.2  nathanw 	  PQUIRK_NOTUR,
     73  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
     74  1.8.2.2  nathanw 	  umass_init_insystem, NULL
     75  1.8.2.2  nathanw 	},
     76  1.8.2.2  nathanw 
     77  1.8.2.2  nathanw 	{ { USB_VENDOR_IOMEGA, USB_PRODUCT_IOMEGA_ZIP100 },
     78  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
     79  1.8.2.2  nathanw 	  0,
     80  1.8.2.2  nathanw 	  PQUIRK_NOTUR,
     81  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
     82  1.8.2.2  nathanw 	  NULL, NULL
     83  1.8.2.2  nathanw 	},
     84  1.8.2.2  nathanw 
     85  1.8.2.2  nathanw 	{ { USB_VENDOR_IOMEGA, USB_PRODUCT_IOMEGA_ZIP250 },
     86  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
     87  1.8.2.2  nathanw 	  0,
     88  1.8.2.2  nathanw 	  PQUIRK_NOTUR,
     89  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
     90  1.8.2.2  nathanw 	  NULL, NULL
     91  1.8.2.2  nathanw 	},
     92  1.8.2.2  nathanw 
     93  1.8.2.2  nathanw 	{ { USB_VENDOR_MICROTECH, USB_PRODUCT_MICROTECH_DPCM },
     94  1.8.2.2  nathanw 	  UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
     95  1.8.2.2  nathanw 	  0,
     96  1.8.2.2  nathanw 	  0,
     97  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
     98  1.8.2.2  nathanw 	  NULL, NULL
     99  1.8.2.2  nathanw 	},
    100  1.8.2.2  nathanw 
    101  1.8.2.2  nathanw 	{ { USB_VENDOR_MSYSTEMS, USB_PRODUCT_MSYSTEMS_DISKONKEY },
    102  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    103  1.8.2.2  nathanw 	  0,
    104  1.8.2.2  nathanw 	  PQUIRK_NOMODESENSE | PQUIRK_NODOORLOCK | PQUIRK_NOBIGMODESENSE,
    105  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    106  1.8.2.2  nathanw 	  NULL, NULL
    107  1.8.2.2  nathanw 	},
    108  1.8.2.2  nathanw 
    109  1.8.2.2  nathanw 	{ { USB_VENDOR_OLYMPUS, USB_PRODUCT_OLYMPUS_C1 },
    110  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    111  1.8.2.2  nathanw 	  UMASS_QUIRK_WRONG_CSWSIG,
    112  1.8.2.2  nathanw 	  0,
    113  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    114  1.8.2.2  nathanw 	  NULL, NULL
    115  1.8.2.2  nathanw 	},
    116  1.8.2.2  nathanw 
    117  1.8.2.2  nathanw 	{ { USB_VENDOR_SCANLOGIC, USB_PRODUCT_SCANLOGIC_SL11R },
    118  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UFI,
    119  1.8.2.2  nathanw 	  0,
    120  1.8.2.2  nathanw 	  0,
    121  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    122  1.8.2.2  nathanw 	  NULL, NULL
    123  1.8.2.2  nathanw 	},
    124  1.8.2.2  nathanw 
    125  1.8.2.2  nathanw 	{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_EUSB },
    126  1.8.2.2  nathanw 	  UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
    127  1.8.2.2  nathanw 	  UMASS_QUIRK_NO_START_STOP,
    128  1.8.2.2  nathanw 	  PQUIRK_NOTUR,
    129  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    130  1.8.2.2  nathanw 	  umass_init_shuttle, NULL
    131  1.8.2.2  nathanw 	},
    132  1.8.2.2  nathanw 
    133  1.8.2.2  nathanw 	{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_ZIOMMC },
    134  1.8.2.2  nathanw 	  UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
    135  1.8.2.2  nathanw 	  UMASS_QUIRK_NO_START_STOP,
    136  1.8.2.2  nathanw 	  PQUIRK_NOTUR,
    137  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    138  1.8.2.2  nathanw 	  NULL, NULL
    139  1.8.2.2  nathanw 	},
    140  1.8.2.2  nathanw 
    141  1.8.2.2  nathanw 	{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_MSC },
    142  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    143  1.8.2.2  nathanw 	  UMASS_QUIRK_FORCE_SHORT_INQUIRY,
    144  1.8.2.2  nathanw 	  0,
    145  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    146  1.8.2.2  nathanw 	  NULL, umass_fixup_sony
    147  1.8.2.2  nathanw 	},
    148  1.8.2.2  nathanw 
    149  1.8.2.2  nathanw 	{ { USB_VENDOR_SONY, USB_PRODUCT_ANY },
    150  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_RBC,
    151  1.8.2.2  nathanw 	  0,
    152  1.8.2.2  nathanw 	  0,
    153  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    154  1.8.2.2  nathanw 	  NULL, umass_fixup_sony
    155  1.8.2.2  nathanw 	},
    156  1.8.2.2  nathanw 
    157  1.8.2.2  nathanw 	{ { USB_VENDOR_TEAC, USB_PRODUCT_TEAC_FD05PUB },
    158  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    159  1.8.2.2  nathanw 	  0,
    160  1.8.2.2  nathanw 	  PQUIRK_NOMODESENSE,
    161  1.8.2.2  nathanw 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    162  1.8.2.2  nathanw 	  NULL, NULL
    163  1.8.2.2  nathanw 	},
    164  1.8.2.2  nathanw 
    165  1.8.2.2  nathanw 	{ { USB_VENDOR_YANO, USB_PRODUCT_YANO_U640MO },
    166  1.8.2.2  nathanw 	  UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
    167  1.8.2.2  nathanw 	  UMASS_QUIRK_FORCE_SHORT_INQUIRY,
    168  1.8.2.2  nathanw 	  0,
    169  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    170  1.8.2.2  nathanw 	  NULL, NULL
    171  1.8.2.2  nathanw 	},
    172  1.8.2.2  nathanw 
    173  1.8.2.2  nathanw 	{ { USB_VENDOR_YEDATA, USB_PRODUCT_YEDATA_FLASHBUSTERU },
    174  1.8.2.2  nathanw 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UFI,
    175  1.8.2.2  nathanw 	  UMASS_QUIRK_RS_NO_CLEAR_UA,
    176  1.8.2.2  nathanw 	  PQUIRK_NOMODESENSE,
    177  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT_REV,
    178  1.8.2.2  nathanw 	  NULL, umass_fixup_yedata
    179  1.8.2.2  nathanw 	},
    180  1.8.2.2  nathanw 
    181  1.8.2.2  nathanw 	/* InSystem Design ATA over USB devices */
    182  1.8.2.2  nathanw 	{ { USB_VENDOR_ATI, USB_PRODUCT_ATI2_205 },
    183  1.8.2.2  nathanw 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
    184  1.8.2.2  nathanw 	  0,
    185  1.8.2.2  nathanw 	  0,
    186  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    187  1.8.2.2  nathanw 	  NULL, NULL
    188  1.8.2.2  nathanw 	},
    189  1.8.2.2  nathanw 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_ATAPI },
    190  1.8.2.2  nathanw 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
    191  1.8.2.2  nathanw 	  0,
    192  1.8.2.2  nathanw 	  0,
    193  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    194  1.8.2.2  nathanw 	  NULL, NULL
    195  1.8.2.2  nathanw 	},
    196  1.8.2.2  nathanw 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_DRIVEV2_5 },
    197  1.8.2.2  nathanw 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
    198  1.8.2.2  nathanw 	  0,
    199  1.8.2.2  nathanw 	  0,
    200  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    201  1.8.2.2  nathanw 	  NULL, NULL
    202  1.8.2.2  nathanw 	},
    203  1.8.2.2  nathanw 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_ADAPTERV2 },
    204  1.8.2.2  nathanw 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
    205  1.8.2.2  nathanw 	  0,
    206  1.8.2.2  nathanw 	  0,
    207  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    208  1.8.2.2  nathanw 	  NULL, NULL
    209  1.8.2.2  nathanw 	},
    210  1.8.2.2  nathanw 	{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_DRIVEV2 },
    211  1.8.2.2  nathanw 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
    212  1.8.2.2  nathanw 	  0,
    213  1.8.2.2  nathanw 	  0,
    214  1.8.2.2  nathanw 	  UMATCH_VENDOR_PRODUCT,
    215  1.8.2.2  nathanw 	  NULL, NULL
    216  1.8.2.2  nathanw 	},
    217  1.8.2.2  nathanw };
    218  1.8.2.2  nathanw 
    219  1.8.2.2  nathanw const struct umass_quirk *
    220  1.8.2.2  nathanw umass_lookup(u_int16_t vendor, u_int16_t product)
    221  1.8.2.2  nathanw {
    222  1.8.2.2  nathanw 	return ((const struct umass_quirk *)
    223  1.8.2.2  nathanw 		usb_lookup(umass_quirks, vendor, product));
    224  1.8.2.2  nathanw }
    225  1.8.2.2  nathanw 
    226  1.8.2.2  nathanw Static usbd_status
    227  1.8.2.2  nathanw umass_init_insystem(struct umass_softc *sc)
    228  1.8.2.2  nathanw {
    229  1.8.2.2  nathanw 	usbd_status err;
    230  1.8.2.2  nathanw 
    231  1.8.2.2  nathanw 	err = usbd_set_interface(sc->sc_iface, 1);
    232  1.8.2.2  nathanw 	if (err) {
    233  1.8.2.2  nathanw 		DPRINTF(UDMASS_USB,
    234  1.8.2.2  nathanw 			("%s: could not switch to Alt Interface 1\n",
    235  1.8.2.2  nathanw 			USBDEVNAME(sc->sc_dev)));
    236  1.8.2.2  nathanw 		return (err);
    237  1.8.2.2  nathanw 	}
    238  1.8.2.2  nathanw 
    239  1.8.2.2  nathanw 	return (USBD_NORMAL_COMPLETION);
    240  1.8.2.2  nathanw }
    241  1.8.2.2  nathanw 
    242  1.8.2.2  nathanw Static usbd_status
    243  1.8.2.2  nathanw umass_init_shuttle(struct umass_softc *sc)
    244  1.8.2.2  nathanw {
    245  1.8.2.2  nathanw 	usb_device_request_t req;
    246  1.8.2.2  nathanw 	u_int8_t status[2];
    247  1.8.2.2  nathanw 
    248  1.8.2.2  nathanw 	/* The Linux driver does this */
    249  1.8.2.2  nathanw 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
    250  1.8.2.2  nathanw 	req.bRequest = 1;
    251  1.8.2.2  nathanw 	USETW(req.wValue, 0);
    252  1.8.2.2  nathanw 	USETW(req.wIndex, sc->sc_ifaceno);
    253  1.8.2.2  nathanw 	USETW(req.wLength, sizeof(status));
    254  1.8.2.2  nathanw 
    255  1.8.2.2  nathanw 	return (usbd_do_request(sc->sc_udev, &req, &status));
    256  1.8.2.2  nathanw }
    257  1.8.2.2  nathanw 
    258  1.8.2.2  nathanw Static void
    259  1.8.2.2  nathanw umass_fixup_sony(struct umass_softc *sc)
    260  1.8.2.2  nathanw {
    261  1.8.2.2  nathanw 	usb_interface_descriptor_t *id;
    262  1.8.2.2  nathanw 
    263  1.8.2.2  nathanw 	id = usbd_get_interface_descriptor(sc->sc_iface);
    264  1.8.2.2  nathanw 	if (id->bInterfaceSubClass == 0xff) {
    265  1.8.2.2  nathanw 		sc->sc_cmd = UMASS_CPROTO_RBC;
    266  1.8.2.2  nathanw 	}
    267  1.8.2.2  nathanw }
    268  1.8.2.2  nathanw 
    269  1.8.2.2  nathanw Static void
    270  1.8.2.2  nathanw umass_fixup_yedata(struct umass_softc *sc)
    271  1.8.2.2  nathanw {
    272  1.8.2.2  nathanw 	usb_device_descriptor_t *dd;
    273  1.8.2.2  nathanw 
    274  1.8.2.2  nathanw 	dd = usbd_get_device_descriptor(sc->sc_udev);
    275  1.8.2.2  nathanw 
    276  1.8.2.2  nathanw 	/*
    277  1.8.2.2  nathanw 	 * Revisions < 1.28 do not handle the interrupt endpoint very well.
    278  1.8.2.2  nathanw 	 */
    279  1.8.2.2  nathanw 	if (UGETW(dd->bcdDevice) < 0x128)
    280  1.8.2.2  nathanw 		sc->sc_wire = UMASS_WPROTO_CBI;
    281  1.8.2.2  nathanw 	else
    282  1.8.2.2  nathanw 		sc->sc_wire = UMASS_WPROTO_CBI_I;
    283  1.8.2.2  nathanw 
    284  1.8.2.2  nathanw 	/*
    285  1.8.2.2  nathanw 	 * Revisions < 1.28 do not have the TEST UNIT READY command
    286  1.8.2.2  nathanw 	 * Revisions == 1.28 have a broken TEST UNIT READY
    287  1.8.2.2  nathanw 	 */
    288  1.8.2.2  nathanw 	if (UGETW(dd->bcdDevice) <= 0x128)
    289  1.8.2.2  nathanw 		sc->sc_busquirks |= PQUIRK_NOTUR;
    290  1.8.2.2  nathanw }
    291