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