Home | History | Annotate | Line # | Download | only in usb
umass_quirks.c revision 1.79.2.1
      1  1.79.2.1     rmind /*	$NetBSD: umass_quirks.c,v 1.79.2.1 2010/07/03 01:19:41 rmind Exp $	*/
      2       1.1   gehenna 
      3       1.1   gehenna /*
      4      1.68   mycroft  * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
      5       1.1   gehenna  * All rights reserved.
      6       1.1   gehenna  *
      7       1.1   gehenna  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1   gehenna  * by MAEKAWA Masahide (gehenna (at) NetBSD.org).
      9      1.68   mycroft  * This code is derived from software contributed to The NetBSD Foundation
     10      1.68   mycroft  * by Charles M. Hannum.
     11       1.1   gehenna  *
     12       1.1   gehenna  * Redistribution and use in source and binary forms, with or without
     13       1.1   gehenna  * modification, are permitted provided that the following conditions
     14       1.1   gehenna  * are met:
     15       1.1   gehenna  * 1. Redistributions of source code must retain the above copyright
     16       1.1   gehenna  *    notice, this list of conditions and the following disclaimer.
     17       1.1   gehenna  * 2. Redistributions in binary form must reproduce the above copyright
     18       1.1   gehenna  *    notice, this list of conditions and the following disclaimer in the
     19       1.1   gehenna  *    documentation and/or other materials provided with the distribution.
     20       1.1   gehenna  *
     21       1.1   gehenna  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     22       1.1   gehenna  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23       1.1   gehenna  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24       1.1   gehenna  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     25       1.1   gehenna  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26       1.1   gehenna  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27       1.1   gehenna  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28       1.1   gehenna  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29       1.1   gehenna  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30       1.1   gehenna  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31       1.1   gehenna  * POSSIBILITY OF SUCH DAMAGE.
     32       1.1   gehenna  */
     33      1.44     lukem 
     34      1.44     lukem #include <sys/cdefs.h>
     35  1.79.2.1     rmind __KERNEL_RCSID(0, "$NetBSD: umass_quirks.c,v 1.79.2.1 2010/07/03 01:19:41 rmind Exp $");
     36       1.1   gehenna 
     37       1.1   gehenna #include <sys/param.h>
     38       1.1   gehenna #include <sys/systm.h>
     39       1.1   gehenna #include <sys/device.h>
     40       1.1   gehenna #include <sys/buf.h>
     41       1.1   gehenna 
     42       1.7  augustss #include <dev/scsipi/scsipi_all.h> /* for scsiconf.h below */
     43       1.7  augustss #include <dev/scsipi/scsiconf.h> /* for quirks defines */
     44       1.7  augustss 
     45       1.1   gehenna #include <dev/usb/usb.h>
     46       1.1   gehenna #include <dev/usb/usbdi.h>
     47       1.1   gehenna #include <dev/usb/usbdevs.h>
     48       1.1   gehenna 
     49       1.1   gehenna #include <dev/usb/umassvar.h>
     50       1.1   gehenna #include <dev/usb/umass_quirks.h>
     51       1.1   gehenna 
     52       1.1   gehenna Static usbd_status umass_init_insystem(struct umass_softc *);
     53       1.1   gehenna Static usbd_status umass_init_shuttle(struct umass_softc *);
     54       1.1   gehenna 
     55      1.25       cjs Static void umass_fixup_sony(struct umass_softc *);
     56       1.1   gehenna 
     57      1.65   mycroft /*
     58      1.65   mycroft  * XXX
     59      1.65   mycroft  * PLEASE NOTE that if you want quirk entries added to this table, you MUST
     60      1.65   mycroft  * compile a kernel with USB_DEBUG, and submit a full log of the output from
     61      1.65   mycroft  * whatever operation is "failing" with ?hcidebug=20 or higher and
     62      1.65   mycroft  * umassdebug=0xffffff.  (It's usually helpful to also set MSGBUFSIZE to
     63      1.65   mycroft  * something "large" unless you're using a serial console.)  Without this
     64      1.65   mycroft  * information, the source of the problem cannot be properly analyzed, and
     65      1.65   mycroft  * the quirk entry WILL NOT be accepted.
     66      1.65   mycroft  * Also, when an entry is committed to this table, a concise but clear
     67      1.65   mycroft  * description of the problem MUST accompany it.
     68      1.65   mycroft  * - mycroft
     69      1.65   mycroft  */
     70       1.1   gehenna Static const struct umass_quirk umass_quirks[] = {
     71      1.63  augustss 	/*
     72      1.63  augustss 	 * The following 3 In-System Design adapters use a non-standard ATA
     73      1.63  augustss 	 * over BBB protocol.  Force this protocol by quirk entries.
     74      1.63  augustss 	 */
     75      1.63  augustss 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_ADAPTERV2 },
     76      1.63  augustss 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
     77      1.63  augustss 	  0,
     78      1.63  augustss 	  0,
     79      1.63  augustss 	  UMATCH_VENDOR_PRODUCT,
     80      1.63  augustss 	  NULL, NULL
     81      1.63  augustss 	},
     82      1.63  augustss 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_ATAPI },
     83      1.63  augustss 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
     84      1.63  augustss 	  0,
     85      1.63  augustss 	  0,
     86      1.63  augustss 	  UMATCH_VENDOR_PRODUCT,
     87      1.63  augustss 	  NULL, NULL
     88      1.63  augustss 	},
     89      1.63  augustss 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_DRIVEV2_5 },
     90      1.63  augustss 	  UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
     91      1.63  augustss 	  0,
     92      1.63  augustss 	  0,
     93      1.63  augustss 	  UMATCH_VENDOR_PRODUCT,
     94      1.63  augustss 	  NULL, NULL
     95      1.63  augustss 	},
     96      1.63  augustss 
     97       1.1   gehenna 	{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_USBCABLE },
     98       1.1   gehenna 	  UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
     99      1.49   mycroft 	  0,
    100      1.56   mycroft 	  0,
    101       1.1   gehenna 	  UMATCH_VENDOR_PRODUCT,
    102       1.1   gehenna 	  umass_init_insystem, NULL
    103      1.32  augustss 	},
    104      1.32  augustss 
    105      1.58   mycroft 	{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_EUSB },
    106      1.58   mycroft 	  UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
    107      1.58   mycroft 	  0,
    108      1.58   mycroft 	  0,
    109      1.58   mycroft 	  UMATCH_VENDOR_PRODUCT,
    110      1.58   mycroft 	  umass_init_shuttle, NULL
    111      1.58   mycroft 	},
    112      1.58   mycroft 
    113      1.58   mycroft 	/*
    114      1.62       wiz 	 * These work around genuine device bugs -- returning the wrong info in
    115      1.58   mycroft 	 * the CSW block.
    116      1.58   mycroft 	 */
    117       1.1   gehenna 	{ { USB_VENDOR_OLYMPUS, USB_PRODUCT_OLYMPUS_C1 },
    118       1.1   gehenna 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    119       1.1   gehenna 	  UMASS_QUIRK_WRONG_CSWSIG,
    120       1.7  augustss 	  0,
    121      1.59   mycroft 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    122      1.23   gehenna 	  NULL, NULL
    123      1.23   gehenna 	},
    124       1.1   gehenna 	{ { USB_VENDOR_SCANLOGIC, USB_PRODUCT_SCANLOGIC_SL11R },
    125      1.58   mycroft 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    126      1.28       erh 	  UMASS_QUIRK_WRONG_CSWTAG,
    127       1.7  augustss 	  0,
    128      1.59   mycroft 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    129      1.64   kivinen 	  NULL, NULL
    130      1.64   kivinen 	},
    131      1.64   kivinen 	{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_ORCA },
    132      1.64   kivinen 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    133      1.64   kivinen 	  UMASS_QUIRK_WRONG_CSWTAG,
    134      1.64   kivinen 	  0,
    135      1.67   mycroft 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    136       1.1   gehenna 	  NULL, NULL
    137       1.1   gehenna 	},
    138       1.1   gehenna 
    139      1.58   mycroft 	/*
    140      1.58   mycroft 	 * Some Sony cameras advertise a subclass code of 0xff, so we force it
    141      1.58   mycroft 	 * to the correct value iff necessary.
    142      1.58   mycroft 	 */
    143      1.26       cjs 	{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_DSC },
    144      1.25       cjs 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    145      1.71  christos 	  UMASS_QUIRK_RBC_PAD_TO_12,
    146      1.43    martin 	  0,
    147      1.43    martin 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    148      1.43    martin 	  NULL, umass_fixup_sony
    149      1.57   mycroft 	},
    150      1.57   mycroft 
    151      1.57   mycroft 	/*
    152      1.66   mycroft 	 * Stupid device reports itself as SFF-8070, but actually returns a UFI
    153      1.66   mycroft 	 * interrupt descriptor.  - mycroft, 2004/06/28
    154      1.66   mycroft 	 */
    155      1.66   mycroft 	{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_40_MS },
    156      1.66   mycroft 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UFI,
    157      1.66   mycroft 	  0,
    158      1.66   mycroft 	  0,
    159      1.67   mycroft 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    160      1.66   mycroft 	  NULL, NULL
    161      1.66   mycroft 	},
    162      1.66   mycroft 
    163      1.66   mycroft 	/*
    164      1.75     rmind 	 * The SONY Portable GPS strage device almost hangs up when request
    165      1.75     rmind 	 * UR_BBB_GET_MAX_LUN - disable the query logic.
    166      1.75     rmind 	 */
    167      1.75     rmind 	{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_GPS_CS1 },
    168      1.75     rmind 	  UMASS_WPROTO_BBB, UMASS_CPROTO_UNSPEC,
    169      1.75     rmind 	  UMASS_QUIRK_NOGETMAXLUN,
    170      1.75     rmind 	  0,
    171      1.75     rmind 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    172      1.75     rmind 	  NULL, NULL
    173      1.75     rmind 	},
    174      1.75     rmind 
    175      1.75     rmind 	/*
    176      1.57   mycroft 	 * The DiskOnKey does not reject commands it doesn't recognize in a
    177      1.57   mycroft 	 * sane way -- rather than STALLing the bulk pipe, it continually NAKs
    178      1.57   mycroft 	 * until we time out.  To prevent being screwed by this, for now we
    179      1.57   mycroft 	 * disable 10-byte MODE SENSE the klugy way.  - mycroft, 2003/10/16
    180      1.57   mycroft 	 */
    181      1.57   mycroft 	{ { USB_VENDOR_MSYSTEMS, USB_PRODUCT_MSYSTEMS_DISKONKEY },
    182      1.57   mycroft 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    183      1.57   mycroft 	  0,
    184      1.57   mycroft 	  PQUIRK_NOBIGMODESENSE,
    185      1.59   mycroft 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    186      1.57   mycroft 	  NULL, NULL
    187      1.57   mycroft 	},
    188      1.57   mycroft 	{ { USB_VENDOR_MSYSTEMS, USB_PRODUCT_MSYSTEMS_DISKONKEY2 },
    189      1.57   mycroft 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    190      1.57   mycroft 	  0,
    191      1.57   mycroft 	  PQUIRK_NOBIGMODESENSE,
    192      1.59   mycroft 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    193      1.36  augustss 	  NULL, NULL
    194       1.4  augustss 	},
    195      1.69      cube 	{ { USB_VENDOR_MSYSTEMS, USB_PRODUCT_MSYSTEMS_DISKONKEY3 },
    196      1.69      cube 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    197      1.69      cube 	  0,
    198      1.69      cube 	  PQUIRK_NOBIGMODESENSE,
    199      1.69      cube 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
    200      1.69      cube 	  NULL, NULL
    201      1.69      cube 	},
    202  1.79.2.1     rmind 	/* Some Sigmatel-based devices don't like all SCSI commands */
    203      1.74   mlelstv 	{ { USB_VENDOR_SIGMATEL, USB_PRODUCT_SIGMATEL_MUSICSTICK },
    204      1.74   mlelstv 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    205      1.74   mlelstv 	  0,
    206      1.74   mlelstv 	  PQUIRK_NODOORLOCK | PQUIRK_NOSYNCCACHE,
    207      1.74   mlelstv 	  UMATCH_VENDOR_PRODUCT,
    208      1.74   mlelstv 	  NULL, NULL
    209      1.74   mlelstv 	},
    210      1.74   mlelstv 	{ { USB_VENDOR_SIGMATEL, USB_PRODUCT_SIGMATEL_I_BEAD100 },
    211      1.74   mlelstv 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    212      1.74   mlelstv 	  0,
    213      1.74   mlelstv 	  PQUIRK_NODOORLOCK | PQUIRK_NOSYNCCACHE,
    214      1.74   mlelstv 	  UMATCH_VENDOR_PRODUCT,
    215      1.74   mlelstv 	  NULL, NULL
    216      1.74   mlelstv 	},
    217      1.74   mlelstv 	{ { USB_VENDOR_SIGMATEL, USB_PRODUCT_SIGMATEL_I_BEAD150 },
    218      1.74   mlelstv 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    219      1.74   mlelstv 	  0,
    220      1.74   mlelstv 	  PQUIRK_NODOORLOCK | PQUIRK_NOSYNCCACHE,
    221      1.74   mlelstv 	  UMATCH_VENDOR_PRODUCT,
    222      1.74   mlelstv 	  NULL, NULL
    223      1.74   mlelstv 	},
    224  1.79.2.1     rmind 	{ { USB_VENDOR_PHILIPS, USB_PRODUCT_PHILIPS_SA235 },
    225  1.79.2.1     rmind 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    226  1.79.2.1     rmind 	  0,
    227  1.79.2.1     rmind 	  PQUIRK_NODOORLOCK | PQUIRK_NOSYNCCACHE,
    228  1.79.2.1     rmind 	  UMATCH_VENDOR_PRODUCT,
    229  1.79.2.1     rmind 	  NULL, NULL
    230  1.79.2.1     rmind 	},
    231  1.79.2.1     rmind 	/* Creative Nomad MuVo, NetBSD PR 30389, FreeBSD PR 53094 */
    232  1.79.2.1     rmind 	{ { USB_VENDOR_CREATIVE, USB_PRODUCT_CREATIVE_NOMAD },
    233  1.79.2.1     rmind 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    234  1.79.2.1     rmind 	  0,
    235  1.79.2.1     rmind 	  PQUIRK_NODOORLOCK | PQUIRK_NOSYNCCACHE,
    236  1.79.2.1     rmind 	  UMATCH_VENDOR_PRODUCT,
    237  1.79.2.1     rmind 	  NULL, NULL
    238  1.79.2.1     rmind 	},
    239  1.79.2.1     rmind 
    240  1.79.2.1     rmind 	/* iRiver iFP-[135]xx players fail on PREVENT/ALLOW, see PR 25440 */
    241  1.79.2.1     rmind 	{ { USB_VENDOR_IRIVER, USB_PRODUCT_IRIVER_IFP_1XX },
    242  1.79.2.1     rmind 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    243  1.79.2.1     rmind 	  0,
    244  1.79.2.1     rmind 	  PQUIRK_NODOORLOCK,
    245  1.79.2.1     rmind 	  UMATCH_VENDOR_PRODUCT,
    246  1.79.2.1     rmind 	  NULL, NULL
    247  1.79.2.1     rmind 	},
    248  1.79.2.1     rmind 	{ { USB_VENDOR_IRIVER, USB_PRODUCT_IRIVER_IFP_3XX },
    249  1.79.2.1     rmind 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    250  1.79.2.1     rmind 	  0,
    251  1.79.2.1     rmind 	  PQUIRK_NODOORLOCK,
    252  1.79.2.1     rmind 	  UMATCH_VENDOR_PRODUCT,
    253  1.79.2.1     rmind 	  NULL, NULL
    254  1.79.2.1     rmind 	},
    255  1.79.2.1     rmind 	{ { USB_VENDOR_IRIVER, USB_PRODUCT_IRIVER_IFP_5XX },
    256  1.79.2.1     rmind 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    257  1.79.2.1     rmind 	  0,
    258  1.79.2.1     rmind 	  PQUIRK_NODOORLOCK,
    259  1.79.2.1     rmind 	  UMATCH_VENDOR_PRODUCT,
    260  1.79.2.1     rmind 	  NULL, NULL
    261  1.79.2.1     rmind 	},
    262  1.79.2.1     rmind 
    263      1.77       wiz 	/* Meizu M6 doesn't like synchronize-cache, see PR 40442 */
    264      1.77       wiz 	{ { USB_VENDOR_MEIZU, USB_PRODUCT_MEIZU_M6_SL },
    265      1.77       wiz 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
    266      1.77       wiz 	  0,
    267      1.77       wiz 	  PQUIRK_NOSYNCCACHE,
    268      1.77       wiz 	  UMATCH_VENDOR_PRODUCT,
    269      1.77       wiz 	  NULL, NULL
    270      1.77       wiz 	},
    271       1.1   gehenna };
    272       1.1   gehenna 
    273       1.1   gehenna const struct umass_quirk *
    274       1.1   gehenna umass_lookup(u_int16_t vendor, u_int16_t product)
    275       1.1   gehenna {
    276       1.6  augustss 	return ((const struct umass_quirk *)
    277       1.6  augustss 		usb_lookup(umass_quirks, vendor, product));
    278       1.1   gehenna }
    279       1.1   gehenna 
    280       1.1   gehenna Static usbd_status
    281       1.1   gehenna umass_init_insystem(struct umass_softc *sc)
    282       1.1   gehenna {
    283       1.1   gehenna 	usbd_status err;
    284       1.1   gehenna 
    285       1.1   gehenna 	err = usbd_set_interface(sc->sc_iface, 1);
    286       1.1   gehenna 	if (err) {
    287       1.1   gehenna 		DPRINTF(UDMASS_USB,
    288       1.1   gehenna 			("%s: could not switch to Alt Interface 1\n",
    289       1.1   gehenna 			USBDEVNAME(sc->sc_dev)));
    290       1.1   gehenna 		return (err);
    291       1.1   gehenna 	}
    292       1.1   gehenna 
    293       1.1   gehenna 	return (USBD_NORMAL_COMPLETION);
    294       1.1   gehenna }
    295       1.1   gehenna 
    296       1.1   gehenna Static usbd_status
    297       1.1   gehenna umass_init_shuttle(struct umass_softc *sc)
    298       1.1   gehenna {
    299       1.1   gehenna 	usb_device_request_t req;
    300       1.1   gehenna 	u_int8_t status[2];
    301       1.1   gehenna 
    302       1.1   gehenna 	/* The Linux driver does this */
    303       1.1   gehenna 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
    304       1.1   gehenna 	req.bRequest = 1;
    305       1.1   gehenna 	USETW(req.wValue, 0);
    306       1.1   gehenna 	USETW(req.wIndex, sc->sc_ifaceno);
    307       1.1   gehenna 	USETW(req.wLength, sizeof(status));
    308       1.1   gehenna 
    309       1.1   gehenna 	return (usbd_do_request(sc->sc_udev, &req, &status));
    310      1.25       cjs }
    311      1.25       cjs 
    312      1.25       cjs Static void
    313      1.25       cjs umass_fixup_sony(struct umass_softc *sc)
    314      1.25       cjs {
    315      1.25       cjs 	usb_interface_descriptor_t *id;
    316      1.25       cjs 
    317      1.25       cjs 	id = usbd_get_interface_descriptor(sc->sc_iface);
    318      1.53   mycroft 	if (id->bInterfaceSubClass == 0xff)
    319      1.71  christos 		sc->sc_cmd = UMASS_CPROTO_RBC;
    320       1.1   gehenna }
    321