1 /*
2 * USB device quirk handling logic and table
3 *
4 * Copyright (c) 2007 Oliver Neukum
5 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation, version 2.
10 *
11 *
12 */
13
14 #include <linux/usb.h>
15 #include <linux/usb/quirks.h>
16 #include <linux/usb/hcd.h>
17 #include "usb.h"
18
19 /* Lists of quirky USB devices, split in device quirks and interface quirks.
20 * Device quirks are applied at the very beginning of the enumeration process,
21 * right after reading the device descriptor. They can thus only match on device
22 * information.
23 *
24 * Interface quirks are applied after reading all the configuration descriptors.
25 * They can match on both device and interface information.
26 *
27 * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
28 * interface quirks, as they only influence the enumeration process which is run
29 * before processing the interface quirks.
30 *
31 * Please keep the lists ordered by:
32 * 1) Vendor ID
33 * 2) Product ID
34 * 3) Class ID
35 */
36 static const struct usb_device_id usb_quirk_list[] = {
37 /* CBM - Flash disk */
38 { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
39
40 /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */
41 { USB_DEVICE(0x0218, 0x0201), .driver_info =
42 USB_QUIRK_CONFIG_INTF_STRINGS },
43
44 /* WORLDE easy key (easykey.25) MIDI controller */
45 { USB_DEVICE(0x0218, 0x0401), .driver_info =
46 USB_QUIRK_CONFIG_INTF_STRINGS },
47
48 /* HP 5300/5370C scanner */
49 { USB_DEVICE(0x03f0, 0x0701), .driver_info =
50 USB_QUIRK_STRING_FETCH_255 },
51
52 /* HP v222w 16GB Mini USB Drive */
53 { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
54
55 /* Creative SB Audigy 2 NX */
56 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
57
58 /* USB3503 */
59 { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
60
61 /* Microsoft Wireless Laser Mouse 6000 Receiver */
62 { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
63
64 /* Microsoft LifeCam-VX700 v2.0 */
65 { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
66
67 /* Microsoft Surface Dock Ethernet (RTL8153 GigE) */
68 { USB_DEVICE(0x045e, 0x07c6), .driver_info = USB_QUIRK_NO_LPM },
69
70 /* Cherry Stream G230 2.0 (G85-231) and 3.0 (G85-232) */
71 { USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME },
72
73 /* Logitech HD Webcam C270 */
74 { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME },
75
76 /* Logitech HD Pro Webcams C920, C920-C, C922, C925e and C930e */
77 { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
78 { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
79 { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
80 { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
81 { USB_DEVICE(0x046d, 0x085c), .driver_info = USB_QUIRK_DELAY_INIT },
82
83 /* Logitech ConferenceCam CC3000e */
84 { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
85 { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
86
87 /* Logitech PTZ Pro Camera */
88 { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
89
90 /* Logitech Screen Share */
91 { USB_DEVICE(0x046d, 0x086c), .driver_info = USB_QUIRK_NO_LPM },
92
93 /* Logitech Quickcam Fusion */
94 { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
95
96 /* Logitech Quickcam Orbit MP */
97 { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
98
99 /* Logitech Quickcam Pro for Notebook */
100 { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
101
102 /* Logitech Quickcam Pro 5000 */
103 { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
104
105 /* Logitech Quickcam OEM Dell Notebook */
106 { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
107
108 /* Logitech Quickcam OEM Cisco VT Camera II */
109 { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
110
111 /* Logitech Harmony 700-series */
112 { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
113
114 /* Philips PSC805 audio device */
115 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
116
117 /* Plantronic Audio 655 DSP */
118 { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
119
120 /* Plantronic Audio 648 USB */
121 { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
122
123 /* Artisman Watchdog Dongle */
124 { USB_DEVICE(0x04b4, 0x0526), .driver_info =
125 USB_QUIRK_CONFIG_INTF_STRINGS },
126
127 /* Microchip Joss Optical infrared touchboard device */
128 { USB_DEVICE(0x04d8, 0x000c), .driver_info =
129 USB_QUIRK_CONFIG_INTF_STRINGS },
130
131 /* CarrolTouch 4000U */
132 { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
133
134 /* CarrolTouch 4500U */
135 { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
136
137 /* Samsung Android phone modem - ID conflict with SPH-I500 */
138 { USB_DEVICE(0x04e8, 0x6601), .driver_info =
139 USB_QUIRK_CONFIG_INTF_STRINGS },
140
141 /* Elan Touchscreen */
142 { USB_DEVICE(0x04f3, 0x0089), .driver_info =
143 USB_QUIRK_DEVICE_QUALIFIER },
144
145 { USB_DEVICE(0x04f3, 0x009b), .driver_info =
146 USB_QUIRK_DEVICE_QUALIFIER },
147
148 { USB_DEVICE(0x04f3, 0x010c), .driver_info =
149 USB_QUIRK_DEVICE_QUALIFIER },
150
151 { USB_DEVICE(0x04f3, 0x0125), .driver_info =
152 USB_QUIRK_DEVICE_QUALIFIER },
153
154 { USB_DEVICE(0x04f3, 0x016f), .driver_info =
155 USB_QUIRK_DEVICE_QUALIFIER },
156
157 { USB_DEVICE(0x04f3, 0x0381), .driver_info =
158 USB_QUIRK_NO_LPM },
159
160 { USB_DEVICE(0x04f3, 0x21b8), .driver_info =
161 USB_QUIRK_DEVICE_QUALIFIER },
162
163 /* Roland SC-8820 */
164 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
165
166 /* Edirol SD-20 */
167 { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
168
169 /* Alcor Micro Corp. Hub */
170 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
171
172 /* appletouch */
173 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
174
175 /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
176 { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
177
178 /* ELSA MicroLink 56K */
179 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME },
180
181 /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
182 { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
183
184 /* Avision AV600U */
185 { USB_DEVICE(0x0638, 0x0a13), .driver_info =
186 USB_QUIRK_STRING_FETCH_255 },
187
188 /* Saitek Cyborg Gold Joystick */
189 { USB_DEVICE(0x06a3, 0x0006), .driver_info =
190 USB_QUIRK_CONFIG_INTF_STRINGS },
191
192 /* Agfa SNAPSCAN 1212U */
193 { USB_DEVICE(0x06bd, 0x0001), .driver_info = USB_QUIRK_RESET_RESUME },
194
195 /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
196 { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
197
198 /* Guillemot Webcam Hercules Dualpix Exchange*/
199 { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
200
201 /* Guillemot Hercules DJ Console audio card (BZ 208357) */
202 { USB_DEVICE(0x06f8, 0xb000), .driver_info =
203 USB_QUIRK_ENDPOINT_BLACKLIST },
204
205 /* Midiman M-Audio Keystation 88es */
206 { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
207
208 /* SanDisk Ultra Fit and Ultra Flair */
209 { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM },
210 { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM },
211
212 /* M-Systems Flash Disk Pioneers */
213 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
214
215 /* Baum Vario Ultra */
216 { USB_DEVICE(0x0904, 0x6101), .driver_info =
217 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
218 { USB_DEVICE(0x0904, 0x6102), .driver_info =
219 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
220 { USB_DEVICE(0x0904, 0x6103), .driver_info =
221 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
222
223 /* Keytouch QWERTY Panel keyboard */
224 { USB_DEVICE(0x0926, 0x3333), .driver_info =
225 USB_QUIRK_CONFIG_INTF_STRINGS },
226
227 /* Kingston DataTraveler 3.0 */
228 { USB_DEVICE(0x0951, 0x1666), .driver_info = USB_QUIRK_NO_LPM },
229
230 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
231 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
232
233 /* ELMO L-12F document camera */
234 { USB_DEVICE(0x09a1, 0x0028), .driver_info = USB_QUIRK_DELAY_CTRL_MSG },
235
236 /* Broadcom BCM92035DGROM BT dongle */
237 { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
238
239 /* MAYA44USB sound device */
240 { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
241
242 /* ASUS Base Station(T100) */
243 { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
244 USB_QUIRK_IGNORE_REMOTE_WAKEUP },
245
246 /* Realtek hub in Dell WD19 (Type-C) */
247 { USB_DEVICE(0x0bda, 0x0487), .driver_info = USB_QUIRK_NO_LPM },
248 { USB_DEVICE(0x0bda, 0x5487), .driver_info = USB_QUIRK_RESET_RESUME },
249
250 /* Generic RTL8153 based ethernet adapters */
251 { USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM },
252
253 /* SONiX USB DEVICE Touchpad */
254 { USB_DEVICE(0x0c45, 0x7056), .driver_info =
255 USB_QUIRK_IGNORE_REMOTE_WAKEUP },
256
257 /* Action Semiconductor flash disk */
258 { USB_DEVICE(0x10d6, 0x2200), .driver_info =
259 USB_QUIRK_STRING_FETCH_255 },
260
261 /* SKYMEDI USB_DRIVE */
262 { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
263
264 /* Razer - Razer Blade Keyboard */
265 { USB_DEVICE(0x1532, 0x0116), .driver_info =
266 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
267
268 /* Lenovo ThinkPad USB-C Dock Gen2 Ethernet (RTL8153 GigE) */
269 { USB_DEVICE(0x17ef, 0xa387), .driver_info = USB_QUIRK_NO_LPM },
270
271 /* BUILDWIN Photo Frame */
272 { USB_DEVICE(0x1908, 0x1315), .driver_info =
273 USB_QUIRK_HONOR_BNUMINTERFACES },
274
275 /* Protocol and OTG Electrical Test Device */
276 { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
277 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
278
279 /* Corsair K70 RGB */
280 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT |
281 USB_QUIRK_DELAY_CTRL_MSG },
282
283 /* Corsair Strafe */
284 { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
285 USB_QUIRK_DELAY_CTRL_MSG },
286
287 /* Corsair Strafe RGB */
288 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
289 USB_QUIRK_DELAY_CTRL_MSG },
290
291 /* Corsair K70 LUX RGB */
292 { USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT },
293
294 /* Corsair K70 LUX */
295 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
296
297 /* Corsair K70 RGB RAPDIFIRE */
298 { USB_DEVICE(0x1b1c, 0x1b38), .driver_info = USB_QUIRK_DELAY_INIT |
299 USB_QUIRK_DELAY_CTRL_MSG },
300
301 /* MIDI keyboard WORLDE MINI */
302 { USB_DEVICE(0x1c75, 0x0204), .driver_info =
303 USB_QUIRK_CONFIG_INTF_STRINGS },
304
305 /* Acer C120 LED Projector */
306 { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
307
308 /* Blackmagic Design Intensity Shuttle */
309 { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
310
311 /* Blackmagic Design UltraStudio SDI */
312 { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
313
314 /* Hauppauge HVR-950q */
315 { USB_DEVICE(0x2040, 0x7200), .driver_info =
316 USB_QUIRK_CONFIG_INTF_STRINGS },
317
318 /* Raydium Touchscreen */
319 { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM },
320
321 { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
322
323 { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
324
325 /* DJI CineSSD */
326 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
327
328 /* INTEL VALUE SSD */
329 { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
330
331 /* novation SoundControl XL */
332 { USB_DEVICE(0x1235, 0x0061), .driver_info = USB_QUIRK_RESET_RESUME },
333
334 { } /* terminating entry must be last */
335 };
336
337 static const struct usb_device_id usb_interface_quirk_list[] = {
338 /* Logitech UVC Cameras */
339 { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
340 .driver_info = USB_QUIRK_RESET_RESUME },
341
342 { } /* terminating entry must be last */
343 };
344
345 static const struct usb_device_id usb_amd_resume_quirk_list[] = {
346 /* Lenovo Mouse with Pixart controller */
347 { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
348
349 /* Pixart Mouse */
350 { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
351 { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
352 { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
353 { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
354
355 /* Logitech Optical Mouse M90/M100 */
356 { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
357
358 { } /* terminating entry must be last */
359 };
360
361 /*
362 * Entries for blacklisted endpoints that should be ignored when parsing
363 * configuration descriptors.
364 *
365 * Matched for devices with USB_QUIRK_ENDPOINT_BLACKLIST.
366 */
367 static const struct usb_device_id usb_endpoint_blacklist[] = {
368 { USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x01 },
369 { USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x81 },
370 { }
371 };
372
usb_endpoint_is_blacklisted(struct usb_device * udev,struct usb_host_interface * intf,struct usb_endpoint_descriptor * epd)373 bool usb_endpoint_is_blacklisted(struct usb_device *udev,
374 struct usb_host_interface *intf,
375 struct usb_endpoint_descriptor *epd)
376 {
377 const struct usb_device_id *id;
378 unsigned int address;
379
380 for (id = usb_endpoint_blacklist; id->match_flags; ++id) {
381 if (!usb_match_device(udev, id))
382 continue;
383
384 if (!usb_match_one_id_intf(udev, intf, id))
385 continue;
386
387 address = id->driver_info;
388 if (address == epd->bEndpointAddress)
389 return true;
390 }
391
392 return false;
393 }
394
usb_match_any_interface(struct usb_device * udev,const struct usb_device_id * id)395 static bool usb_match_any_interface(struct usb_device *udev,
396 const struct usb_device_id *id)
397 {
398 unsigned int i;
399
400 for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
401 struct usb_host_config *cfg = &udev->config[i];
402 unsigned int j;
403
404 for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
405 struct usb_interface_cache *cache;
406 struct usb_host_interface *intf;
407
408 cache = cfg->intf_cache[j];
409 if (cache->num_altsetting == 0)
410 continue;
411
412 intf = &cache->altsetting[0];
413 if (usb_match_one_id_intf(udev, intf, id))
414 return true;
415 }
416 }
417
418 return false;
419 }
420
usb_amd_resume_quirk(struct usb_device * udev)421 static int usb_amd_resume_quirk(struct usb_device *udev)
422 {
423 struct usb_hcd *hcd;
424
425 hcd = bus_to_hcd(udev->bus);
426 /* The device should be attached directly to root hub */
427 if (udev->level == 1 && hcd->amd_resume_bug == 1)
428 return 1;
429
430 return 0;
431 }
432
__usb_detect_quirks(struct usb_device * udev,const struct usb_device_id * id)433 static u32 __usb_detect_quirks(struct usb_device *udev,
434 const struct usb_device_id *id)
435 {
436 u32 quirks = 0;
437
438 for (; id->match_flags; id++) {
439 if (!usb_match_device(udev, id))
440 continue;
441
442 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
443 !usb_match_any_interface(udev, id))
444 continue;
445
446 quirks |= (u32)(id->driver_info);
447 }
448
449 return quirks;
450 }
451
452 /*
453 * Detect any quirks the device has, and do any housekeeping for it if needed.
454 */
usb_detect_quirks(struct usb_device * udev)455 void usb_detect_quirks(struct usb_device *udev)
456 {
457 udev->quirks = __usb_detect_quirks(udev, usb_quirk_list);
458
459 /*
460 * Pixart-based mice would trigger remote wakeup issue on AMD
461 * Yangtze chipset, so set them as RESET_RESUME flag.
462 */
463 if (usb_amd_resume_quirk(udev))
464 udev->quirks |= __usb_detect_quirks(udev,
465 usb_amd_resume_quirk_list);
466
467 if (udev->quirks)
468 dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
469 udev->quirks);
470
471 #ifdef CONFIG_USB_DEFAULT_PERSIST
472 if (!(udev->quirks & USB_QUIRK_RESET))
473 udev->persist_enabled = 1;
474 #else
475 /* Hubs are automatically enabled for USB-PERSIST */
476 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
477 udev->persist_enabled = 1;
478 #endif /* CONFIG_USB_DEFAULT_PERSIST */
479 }
480
usb_detect_interface_quirks(struct usb_device * udev)481 void usb_detect_interface_quirks(struct usb_device *udev)
482 {
483 u32 quirks;
484
485 quirks = __usb_detect_quirks(udev, usb_interface_quirk_list);
486 if (quirks == 0)
487 return;
488
489 dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
490 quirks);
491 udev->quirks |= quirks;
492 }
493