]>
Commit | Line | Data |
---|---|---|
5fd54ace | 1 | // SPDX-License-Identifier: GPL-2.0 |
7ceec1f1 ON |
2 | /* |
3 | * USB device quirk handling logic and table | |
4 | * | |
5 | * Copyright (c) 2007 Oliver Neukum | |
6 | * Copyright (c) 2007 Greg Kroah-Hartman <[email protected]> | |
7ceec1f1 ON |
7 | */ |
8 | ||
027bd6ca | 9 | #include <linux/moduleparam.h> |
7ceec1f1 ON |
10 | #include <linux/usb.h> |
11 | #include <linux/usb/quirks.h> | |
7868943d | 12 | #include <linux/usb/hcd.h> |
7ceec1f1 ON |
13 | #include "usb.h" |
14 | ||
027bd6ca KHF |
15 | struct quirk_entry { |
16 | u16 vid; | |
17 | u16 pid; | |
18 | u32 flags; | |
19 | }; | |
20 | ||
21 | static DEFINE_MUTEX(quirk_mutex); | |
22 | ||
23 | static struct quirk_entry *quirk_list; | |
24 | static unsigned int quirk_count; | |
25 | ||
26 | static char quirks_param[128]; | |
27 | ||
28 | static int quirks_param_set(const char *val, const struct kernel_param *kp) | |
29 | { | |
30 | char *p, *field; | |
31 | u16 vid, pid; | |
32 | u32 flags; | |
33 | size_t i; | |
a0305014 KHF |
34 | int err; |
35 | ||
36 | err = param_set_copystring(val, kp); | |
37 | if (err) | |
38 | return err; | |
027bd6ca KHF |
39 | |
40 | mutex_lock(&quirk_mutex); | |
41 | ||
a0305014 | 42 | if (!*val) { |
027bd6ca KHF |
43 | quirk_count = 0; |
44 | kfree(quirk_list); | |
45 | quirk_list = NULL; | |
46 | goto unlock; | |
47 | } | |
48 | ||
49 | for (quirk_count = 1, i = 0; val[i]; i++) | |
50 | if (val[i] == ',') | |
51 | quirk_count++; | |
52 | ||
53 | if (quirk_list) { | |
54 | kfree(quirk_list); | |
55 | quirk_list = NULL; | |
56 | } | |
57 | ||
58 | quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry), | |
59 | GFP_KERNEL); | |
60 | if (!quirk_list) { | |
16c4cb19 | 61 | quirk_count = 0; |
027bd6ca KHF |
62 | mutex_unlock(&quirk_mutex); |
63 | return -ENOMEM; | |
64 | } | |
65 | ||
66 | for (i = 0, p = (char *)val; p && *p;) { | |
67 | /* Each entry consists of VID:PID:flags */ | |
68 | field = strsep(&p, ":"); | |
69 | if (!field) | |
70 | break; | |
71 | ||
72 | if (kstrtou16(field, 16, &vid)) | |
73 | break; | |
74 | ||
75 | field = strsep(&p, ":"); | |
76 | if (!field) | |
77 | break; | |
78 | ||
79 | if (kstrtou16(field, 16, &pid)) | |
80 | break; | |
81 | ||
82 | field = strsep(&p, ","); | |
83 | if (!field || !*field) | |
84 | break; | |
85 | ||
86 | /* Collect the flags */ | |
87 | for (flags = 0; *field; field++) { | |
88 | switch (*field) { | |
89 | case 'a': | |
90 | flags |= USB_QUIRK_STRING_FETCH_255; | |
91 | break; | |
92 | case 'b': | |
93 | flags |= USB_QUIRK_RESET_RESUME; | |
94 | break; | |
95 | case 'c': | |
96 | flags |= USB_QUIRK_NO_SET_INTF; | |
97 | break; | |
98 | case 'd': | |
99 | flags |= USB_QUIRK_CONFIG_INTF_STRINGS; | |
100 | break; | |
101 | case 'e': | |
102 | flags |= USB_QUIRK_RESET; | |
103 | break; | |
104 | case 'f': | |
105 | flags |= USB_QUIRK_HONOR_BNUMINTERFACES; | |
106 | break; | |
107 | case 'g': | |
108 | flags |= USB_QUIRK_DELAY_INIT; | |
109 | break; | |
110 | case 'h': | |
111 | flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL; | |
112 | break; | |
113 | case 'i': | |
114 | flags |= USB_QUIRK_DEVICE_QUALIFIER; | |
115 | break; | |
116 | case 'j': | |
117 | flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP; | |
118 | break; | |
119 | case 'k': | |
120 | flags |= USB_QUIRK_NO_LPM; | |
121 | break; | |
122 | case 'l': | |
123 | flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL; | |
124 | break; | |
125 | case 'm': | |
126 | flags |= USB_QUIRK_DISCONNECT_SUSPEND; | |
127 | break; | |
4d8d5a39 KHF |
128 | case 'n': |
129 | flags |= USB_QUIRK_DELAY_CTRL_MSG; | |
130 | break; | |
781f0766 KHF |
131 | case 'o': |
132 | flags |= USB_QUIRK_HUB_SLOW_RESET; | |
133 | break; | |
027bd6ca KHF |
134 | /* Ignore unrecognized flag characters */ |
135 | } | |
136 | } | |
137 | ||
138 | quirk_list[i++] = (struct quirk_entry) | |
139 | { .vid = vid, .pid = pid, .flags = flags }; | |
140 | } | |
141 | ||
142 | if (i < quirk_count) | |
143 | quirk_count = i; | |
144 | ||
145 | unlock: | |
146 | mutex_unlock(&quirk_mutex); | |
147 | ||
a0305014 | 148 | return 0; |
027bd6ca KHF |
149 | } |
150 | ||
151 | static const struct kernel_param_ops quirks_param_ops = { | |
152 | .set = quirks_param_set, | |
153 | .get = param_get_string, | |
154 | }; | |
155 | ||
156 | static struct kparam_string quirks_param_string = { | |
157 | .maxlen = sizeof(quirks_param), | |
158 | .string = quirks_param, | |
159 | }; | |
160 | ||
16c4cb19 | 161 | device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644); |
027bd6ca KHF |
162 | MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks"); |
163 | ||
80da2e0d LP |
164 | /* Lists of quirky USB devices, split in device quirks and interface quirks. |
165 | * Device quirks are applied at the very beginning of the enumeration process, | |
166 | * right after reading the device descriptor. They can thus only match on device | |
167 | * information. | |
168 | * | |
169 | * Interface quirks are applied after reading all the configuration descriptors. | |
170 | * They can match on both device and interface information. | |
171 | * | |
172 | * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as | |
173 | * interface quirks, as they only influence the enumeration process which is run | |
174 | * before processing the interface quirks. | |
175 | * | |
176 | * Please keep the lists ordered by: | |
7ceec1f1 ON |
177 | * 1) Vendor ID |
178 | * 2) Product ID | |
179 | * 3) Class ID | |
7ceec1f1 ON |
180 | */ |
181 | static const struct usb_device_id usb_quirk_list[] = { | |
ce05916f ON |
182 | /* CBM - Flash disk */ |
183 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, | |
14f3546f | 184 | |
9b83a1c3 MD |
185 | /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */ |
186 | { USB_DEVICE(0x0218, 0x0201), .driver_info = | |
187 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
188 | ||
d9b2997e LL |
189 | /* WORLDE easy key (easykey.25) MIDI controller */ |
190 | { USB_DEVICE(0x0218, 0x0401), .driver_info = | |
191 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
192 | ||
7ceec1f1 | 193 | /* HP 5300/5370C scanner */ |
14f3546f AS |
194 | { USB_DEVICE(0x03f0, 0x0701), .driver_info = |
195 | USB_QUIRK_STRING_FETCH_255 }, | |
e6a20ff9 | 196 | |
3180dabe KL |
197 | /* HP v222w 16GB Mini USB Drive */ |
198 | { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT }, | |
199 | ||
b68a42b1 ON |
200 | /* Creative SB Audigy 2 NX */ |
201 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, | |
202 | ||
81099f97 HG |
203 | /* USB3503 */ |
204 | { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, | |
205 | ||
263e80b4 HG |
206 | /* Microsoft Wireless Laser Mouse 6000 Receiver */ |
207 | { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME }, | |
208 | ||
bc009eca AF |
209 | /* Microsoft LifeCam-VX700 v2.0 */ |
210 | { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, | |
211 | ||
7f038d25 | 212 | /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */ |
e0429362 | 213 | { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, |
a1279ef7 | 214 | { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, |
e0429362 | 215 | { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, |
7f038d25 | 216 | { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT }, |
e0429362 | 217 | |
72194739 VP |
218 | /* Logitech ConferenceCam CC3000e */ |
219 | { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT }, | |
220 | { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT }, | |
221 | ||
222 | /* Logitech PTZ Pro Camera */ | |
223 | { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT }, | |
224 | ||
e387ef5c LP |
225 | /* Logitech Quickcam Fusion */ |
226 | { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME }, | |
2394d67e | 227 | |
e387ef5c LP |
228 | /* Logitech Quickcam Orbit MP */ |
229 | { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME }, | |
2394d67e | 230 | |
e387ef5c LP |
231 | /* Logitech Quickcam Pro for Notebook */ |
232 | { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME }, | |
5b253d88 | 233 | |
e387ef5c LP |
234 | /* Logitech Quickcam Pro 5000 */ |
235 | { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME }, | |
2394d67e | 236 | |
e387ef5c LP |
237 | /* Logitech Quickcam OEM Dell Notebook */ |
238 | { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME }, | |
60c71ca9 | 239 | |
e387ef5c LP |
240 | /* Logitech Quickcam OEM Cisco VT Camera II */ |
241 | { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME }, | |
0d145d7d | 242 | |
93362a87 PD |
243 | /* Logitech Harmony 700-series */ |
244 | { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT }, | |
245 | ||
14f3546f AS |
246 | /* Philips PSC805 audio device */ |
247 | { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, | |
248 | ||
8484bf29 YWM |
249 | /* Plantronic Audio 655 DSP */ |
250 | { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME }, | |
251 | ||
252 | /* Plantronic Audio 648 USB */ | |
253 | { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME }, | |
254 | ||
47f19c0e PM |
255 | /* Artisman Watchdog Dongle */ |
256 | { USB_DEVICE(0x04b4, 0x0526), .driver_info = | |
257 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
258 | ||
92fc7a8b AS |
259 | /* Microchip Joss Optical infrared touchboard device */ |
260 | { USB_DEVICE(0x04d8, 0x000c), .driver_info = | |
261 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
262 | ||
304ab4ab ON |
263 | /* CarrolTouch 4000U */ |
264 | { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME }, | |
265 | ||
266 | /* CarrolTouch 4500U */ | |
267 | { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME }, | |
268 | ||
72a012ce MS |
269 | /* Samsung Android phone modem - ID conflict with SPH-I500 */ |
270 | { USB_DEVICE(0x04e8, 0x6601), .driver_info = | |
271 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
272 | ||
c68929f7 JH |
273 | /* Elan Touchscreen */ |
274 | { USB_DEVICE(0x04f3, 0x0089), .driver_info = | |
275 | USB_QUIRK_DEVICE_QUALIFIER }, | |
276 | ||
876af5d4 AG |
277 | { USB_DEVICE(0x04f3, 0x009b), .driver_info = |
278 | USB_QUIRK_DEVICE_QUALIFIER }, | |
279 | ||
a32c99e7 ON |
280 | { USB_DEVICE(0x04f3, 0x010c), .driver_info = |
281 | USB_QUIRK_DEVICE_QUALIFIER }, | |
282 | ||
dc703ec2 LG |
283 | { USB_DEVICE(0x04f3, 0x0125), .driver_info = |
284 | USB_QUIRK_DEVICE_QUALIFIER }, | |
285 | ||
d7499475 AG |
286 | { USB_DEVICE(0x04f3, 0x016f), .driver_info = |
287 | USB_QUIRK_DEVICE_QUALIFIER }, | |
288 | ||
25b1f9ac JS |
289 | { USB_DEVICE(0x04f3, 0x0381), .driver_info = |
290 | USB_QUIRK_NO_LPM }, | |
291 | ||
df36c5be AV |
292 | { USB_DEVICE(0x04f3, 0x21b8), .driver_info = |
293 | USB_QUIRK_DEVICE_QUALIFIER }, | |
294 | ||
b68a42b1 ON |
295 | /* Roland SC-8820 */ |
296 | { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME }, | |
297 | ||
298 | /* Edirol SD-20 */ | |
299 | { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME }, | |
300 | ||
bac6b032 ON |
301 | /* Alcor Micro Corp. Hub */ |
302 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, | |
303 | ||
90d95ef6 ON |
304 | /* appletouch */ |
305 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, | |
306 | ||
e43a12f1 KHF |
307 | /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */ |
308 | { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM }, | |
309 | ||
b9096d9f ON |
310 | /* ELSA MicroLink 56K */ |
311 | { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME }, | |
312 | ||
7496cfe5 KHF |
313 | /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ |
314 | { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM }, | |
315 | ||
598eff6d RR |
316 | /* Avision AV600U */ |
317 | { USB_DEVICE(0x0638, 0x0a13), .driver_info = | |
318 | USB_QUIRK_STRING_FETCH_255 }, | |
319 | ||
1662e3a7 AS |
320 | /* Saitek Cyborg Gold Joystick */ |
321 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = | |
322 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
323 | ||
35284b3d | 324 | /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */ |
2394d67e ON |
325 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, |
326 | ||
35284b3d ON |
327 | /* Guillemot Webcam Hercules Dualpix Exchange*/ |
328 | { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME }, | |
329 | ||
166cb70e SM |
330 | /* Midiman M-Audio Keystation 88es */ |
331 | { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME }, | |
332 | ||
86833691 LVS |
333 | /* M-Systems Flash Disk Pioneers */ |
334 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, | |
335 | ||
3243367b ST |
336 | /* Baum Vario Ultra */ |
337 | { USB_DEVICE(0x0904, 0x6101), .driver_info = | |
338 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, | |
339 | { USB_DEVICE(0x0904, 0x6102), .driver_info = | |
340 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, | |
341 | { USB_DEVICE(0x0904, 0x6103), .driver_info = | |
342 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, | |
343 | ||
3c18e30f AS |
344 | /* Keytouch QWERTY Panel keyboard */ |
345 | { USB_DEVICE(0x0926, 0x3333), .driver_info = | |
346 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
347 | ||
392e1d98 AS |
348 | /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */ |
349 | { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF }, | |
350 | ||
63ab71de ON |
351 | /* Broadcom BCM92035DGROM BT dongle */ |
352 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, | |
353 | ||
4294bca7 ON |
354 | /* MAYA44USB sound device */ |
355 | { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, | |
356 | ||
81099f97 HG |
357 | /* ASUS Base Station(T100) */ |
358 | { USB_DEVICE(0x0b05, 0x17e0), .driver_info = | |
359 | USB_QUIRK_IGNORE_REMOTE_WAKEUP }, | |
360 | ||
14f3546f AS |
361 | /* Action Semiconductor flash disk */ |
362 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = | |
363 | USB_QUIRK_STRING_FETCH_255 }, | |
8e80e753 | 364 | |
8dd8d2c9 DD |
365 | /* Huawei 4G LTE module */ |
366 | { USB_DEVICE(0x12d1, 0x15bb), .driver_info = | |
367 | USB_QUIRK_DISCONNECT_SUSPEND }, | |
368 | { USB_DEVICE(0x12d1, 0x15c3), .driver_info = | |
369 | USB_QUIRK_DISCONNECT_SUSPEND }, | |
370 | ||
86833691 LVS |
371 | /* SKYMEDI USB_DRIVE */ |
372 | { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME }, | |
7ceec1f1 | 373 | |
cd83ce9e JMI |
374 | /* Razer - Razer Blade Keyboard */ |
375 | { USB_DEVICE(0x1532, 0x0116), .driver_info = | |
376 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, | |
377 | ||
317149c6 HG |
378 | /* BUILDWIN Photo Frame */ |
379 | { USB_DEVICE(0x1908, 0x1315), .driver_info = | |
380 | USB_QUIRK_HONOR_BNUMINTERFACES }, | |
381 | ||
e5dff0e8 ML |
382 | /* Protocol and OTG Electrical Test Device */ |
383 | { USB_DEVICE(0x1a0a, 0x0200), .driver_info = | |
384 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, | |
385 | ||
781f0766 KHF |
386 | /* Terminus Technology Inc. Hub */ |
387 | { USB_DEVICE(0x1a40, 0x0101), .driver_info = USB_QUIRK_HUB_SLOW_RESET }, | |
388 | ||
7a1646d9 JS |
389 | /* Corsair K70 RGB */ |
390 | { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, | |
391 | ||
bba57edd NS |
392 | /* Corsair Strafe */ |
393 | { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT | | |
394 | USB_QUIRK_DELAY_CTRL_MSG }, | |
395 | ||
de3af5bf | 396 | /* Corsair Strafe RGB */ |
cb88a058 DK |
397 | { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | |
398 | USB_QUIRK_DELAY_CTRL_MSG }, | |
de3af5bf | 399 | |
a7711257 EP |
400 | /* Corsair K70 LUX RGB */ |
401 | { USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT }, | |
402 | ||
a0fea602 BR |
403 | /* Corsair K70 LUX */ |
404 | { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, | |
405 | ||
2811501e FB |
406 | /* MIDI keyboard WORLDE MINI */ |
407 | { USB_DEVICE(0x1c75, 0x0204), .driver_info = | |
408 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
409 | ||
32cb0b37 HG |
410 | /* Acer C120 LED Projector */ |
411 | { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, | |
412 | ||
ad87e032 AS |
413 | /* Blackmagic Design Intensity Shuttle */ |
414 | { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM }, | |
415 | ||
416 | /* Blackmagic Design UltraStudio SDI */ | |
417 | { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM }, | |
418 | ||
6836796d DH |
419 | /* Hauppauge HVR-950q */ |
420 | { USB_DEVICE(0x2040, 0x7200), .driver_info = | |
421 | USB_QUIRK_CONFIG_INTF_STRINGS }, | |
422 | ||
deefd242 KHF |
423 | /* Raydium Touchscreen */ |
424 | { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM }, | |
425 | ||
426 | { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM }, | |
427 | ||
f45681f9 TA |
428 | /* DJI CineSSD */ |
429 | { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, | |
430 | ||
81099f97 HG |
431 | /* INTEL VALUE SSD */ |
432 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, | |
433 | ||
7ceec1f1 ON |
434 | { } /* terminating entry must be last */ |
435 | }; | |
436 | ||
80da2e0d | 437 | static const struct usb_device_id usb_interface_quirk_list[] = { |
e387ef5c LP |
438 | /* Logitech UVC Cameras */ |
439 | { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0), | |
440 | .driver_info = USB_QUIRK_RESET_RESUME }, | |
441 | ||
80da2e0d LP |
442 | { } /* terminating entry must be last */ |
443 | }; | |
444 | ||
7868943d HR |
445 | static const struct usb_device_id usb_amd_resume_quirk_list[] = { |
446 | /* Lenovo Mouse with Pixart controller */ | |
447 | { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME }, | |
448 | ||
449 | /* Pixart Mouse */ | |
450 | { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME }, | |
451 | { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME }, | |
452 | { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME }, | |
e788787e | 453 | { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME }, |
7868943d HR |
454 | |
455 | /* Logitech Optical Mouse M90/M100 */ | |
456 | { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME }, | |
457 | ||
458 | { } /* terminating entry must be last */ | |
459 | }; | |
460 | ||
80da2e0d LP |
461 | static bool usb_match_any_interface(struct usb_device *udev, |
462 | const struct usb_device_id *id) | |
463 | { | |
464 | unsigned int i; | |
465 | ||
466 | for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) { | |
467 | struct usb_host_config *cfg = &udev->config[i]; | |
468 | unsigned int j; | |
469 | ||
470 | for (j = 0; j < cfg->desc.bNumInterfaces; ++j) { | |
471 | struct usb_interface_cache *cache; | |
472 | struct usb_host_interface *intf; | |
473 | ||
474 | cache = cfg->intf_cache[j]; | |
475 | if (cache->num_altsetting == 0) | |
476 | continue; | |
477 | ||
478 | intf = &cache->altsetting[0]; | |
479 | if (usb_match_one_id_intf(udev, intf, id)) | |
480 | return true; | |
481 | } | |
482 | } | |
483 | ||
484 | return false; | |
485 | } | |
486 | ||
00d5f289 | 487 | static int usb_amd_resume_quirk(struct usb_device *udev) |
7868943d HR |
488 | { |
489 | struct usb_hcd *hcd; | |
490 | ||
491 | hcd = bus_to_hcd(udev->bus); | |
492 | /* The device should be attached directly to root hub */ | |
493 | if (udev->level == 1 && hcd->amd_resume_bug == 1) | |
494 | return 1; | |
495 | ||
496 | return 0; | |
497 | } | |
498 | ||
027bd6ca KHF |
499 | static u32 usb_detect_static_quirks(struct usb_device *udev, |
500 | const struct usb_device_id *id) | |
7ceec1f1 | 501 | { |
80da2e0d | 502 | u32 quirks = 0; |
7ceec1f1 | 503 | |
80da2e0d LP |
504 | for (; id->match_flags; id++) { |
505 | if (!usb_match_device(udev, id)) | |
506 | continue; | |
507 | ||
508 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) && | |
509 | !usb_match_any_interface(udev, id)) | |
510 | continue; | |
511 | ||
512 | quirks |= (u32)(id->driver_info); | |
7ceec1f1 | 513 | } |
80da2e0d LP |
514 | |
515 | return quirks; | |
7ceec1f1 ON |
516 | } |
517 | ||
027bd6ca KHF |
518 | static u32 usb_detect_dynamic_quirks(struct usb_device *udev) |
519 | { | |
520 | u16 vid = le16_to_cpu(udev->descriptor.idVendor); | |
521 | u16 pid = le16_to_cpu(udev->descriptor.idProduct); | |
522 | int i, flags = 0; | |
523 | ||
524 | mutex_lock(&quirk_mutex); | |
525 | ||
526 | for (i = 0; i < quirk_count; i++) { | |
527 | if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) { | |
528 | flags = quirk_list[i].flags; | |
529 | break; | |
530 | } | |
531 | } | |
532 | ||
533 | mutex_unlock(&quirk_mutex); | |
534 | ||
535 | return flags; | |
536 | } | |
537 | ||
7ceec1f1 ON |
538 | /* |
539 | * Detect any quirks the device has, and do any housekeeping for it if needed. | |
540 | */ | |
541 | void usb_detect_quirks(struct usb_device *udev) | |
542 | { | |
027bd6ca | 543 | udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list); |
7868943d HR |
544 | |
545 | /* | |
546 | * Pixart-based mice would trigger remote wakeup issue on AMD | |
547 | * Yangtze chipset, so set them as RESET_RESUME flag. | |
548 | */ | |
549 | if (usb_amd_resume_quirk(udev)) | |
027bd6ca | 550 | udev->quirks |= usb_detect_static_quirks(udev, |
7868943d HR |
551 | usb_amd_resume_quirk_list); |
552 | ||
027bd6ca KHF |
553 | udev->quirks ^= usb_detect_dynamic_quirks(udev); |
554 | ||
7ceec1f1 ON |
555 | if (udev->quirks) |
556 | dev_dbg(&udev->dev, "USB quirks for this device: %x\n", | |
80da2e0d | 557 | udev->quirks); |
7ceec1f1 | 558 | |
4f482038 JW |
559 | #ifdef CONFIG_USB_DEFAULT_PERSIST |
560 | if (!(udev->quirks & USB_QUIRK_RESET)) | |
feccc30d AS |
561 | udev->persist_enabled = 1; |
562 | #else | |
4f482038 JW |
563 | /* Hubs are automatically enabled for USB-PERSIST */ |
564 | if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) | |
5d398779 | 565 | udev->persist_enabled = 1; |
4f482038 | 566 | #endif /* CONFIG_USB_DEFAULT_PERSIST */ |
7ceec1f1 | 567 | } |
80da2e0d LP |
568 | |
569 | void usb_detect_interface_quirks(struct usb_device *udev) | |
570 | { | |
571 | u32 quirks; | |
572 | ||
027bd6ca | 573 | quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list); |
80da2e0d LP |
574 | if (quirks == 0) |
575 | return; | |
576 | ||
577 | dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n", | |
578 | quirks); | |
579 | udev->quirks |= quirks; | |
580 | } | |
027bd6ca KHF |
581 | |
582 | void usb_release_quirk_list(void) | |
583 | { | |
584 | mutex_lock(&quirk_mutex); | |
585 | kfree(quirk_list); | |
586 | quirk_list = NULL; | |
587 | mutex_unlock(&quirk_mutex); | |
588 | } |