quirks.c 20 KB

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