quirks.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. #include <linux/usb.h>
  14. #include <linux/usb/quirks.h>
  15. #include <linux/usb/hcd.h>
  16. #include "usb.h"
  17. /* Lists of quirky USB devices, split in device quirks and interface quirks.
  18. * Device quirks are applied at the very beginning of the enumeration process,
  19. * right after reading the device descriptor. They can thus only match on device
  20. * information.
  21. *
  22. * Interface quirks are applied after reading all the configuration descriptors.
  23. * They can match on both device and interface information.
  24. *
  25. * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
  26. * interface quirks, as they only influence the enumeration process which is run
  27. * before processing the interface quirks.
  28. *
  29. * Please keep the lists ordered by:
  30. * 1) Vendor ID
  31. * 2) Product ID
  32. * 3) Class ID
  33. */
  34. static const struct usb_device_id usb_quirk_list[] = {
  35. /* CBM - Flash disk */
  36. { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
  37. /* HP 5300/5370C scanner */
  38. { USB_DEVICE(0x03f0, 0x0701), .driver_info =
  39. USB_QUIRK_STRING_FETCH_255 },
  40. /* Creative SB Audigy 2 NX */
  41. { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
  42. /* Microsoft Wireless Laser Mouse 6000 Receiver */
  43. { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
  44. /* Microsoft LifeCam-VX700 v2.0 */
  45. { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
  46. /* Logitech HD Pro Webcams C920 and C930e */
  47. { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
  48. { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
  49. /* Logitech Quickcam Fusion */
  50. { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
  51. /* Logitech Quickcam Orbit MP */
  52. { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
  53. /* Logitech Quickcam Pro for Notebook */
  54. { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
  55. /* Logitech Quickcam Pro 5000 */
  56. { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
  57. /* Logitech Quickcam OEM Dell Notebook */
  58. { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
  59. /* Logitech Quickcam OEM Cisco VT Camera II */
  60. { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
  61. /* Logitech Harmony 700-series */
  62. { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
  63. /* Philips PSC805 audio device */
  64. { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
  65. /* Artisman Watchdog Dongle */
  66. { USB_DEVICE(0x04b4, 0x0526), .driver_info =
  67. USB_QUIRK_CONFIG_INTF_STRINGS },
  68. /* Microchip Joss Optical infrared touchboard device */
  69. { USB_DEVICE(0x04d8, 0x000c), .driver_info =
  70. USB_QUIRK_CONFIG_INTF_STRINGS },
  71. /* CarrolTouch 4000U */
  72. { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
  73. /* CarrolTouch 4500U */
  74. { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
  75. /* Samsung Android phone modem - ID conflict with SPH-I500 */
  76. { USB_DEVICE(0x04e8, 0x6601), .driver_info =
  77. USB_QUIRK_CONFIG_INTF_STRINGS },
  78. /* Elan Touchscreen */
  79. { USB_DEVICE(0x04f3, 0x0089), .driver_info =
  80. USB_QUIRK_DEVICE_QUALIFIER },
  81. { USB_DEVICE(0x04f3, 0x009b), .driver_info =
  82. USB_QUIRK_DEVICE_QUALIFIER },
  83. { USB_DEVICE(0x04f3, 0x010c), .driver_info =
  84. USB_QUIRK_DEVICE_QUALIFIER },
  85. { USB_DEVICE(0x04f3, 0x016f), .driver_info =
  86. USB_QUIRK_DEVICE_QUALIFIER },
  87. /* Roland SC-8820 */
  88. { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
  89. /* Edirol SD-20 */
  90. { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
  91. /* Alcor Micro Corp. Hub */
  92. { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
  93. /* appletouch */
  94. { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
  95. /* Avision AV600U */
  96. { USB_DEVICE(0x0638, 0x0a13), .driver_info =
  97. USB_QUIRK_STRING_FETCH_255 },
  98. /* Saitek Cyborg Gold Joystick */
  99. { USB_DEVICE(0x06a3, 0x0006), .driver_info =
  100. USB_QUIRK_CONFIG_INTF_STRINGS },
  101. /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
  102. { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
  103. /* Guillemot Webcam Hercules Dualpix Exchange*/
  104. { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
  105. /* Midiman M-Audio Keystation 88es */
  106. { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
  107. /* M-Systems Flash Disk Pioneers */
  108. { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
  109. /* Keytouch QWERTY Panel keyboard */
  110. { USB_DEVICE(0x0926, 0x3333), .driver_info =
  111. USB_QUIRK_CONFIG_INTF_STRINGS },
  112. /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
  113. { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
  114. /* Broadcom BCM92035DGROM BT dongle */
  115. { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
  116. /* MAYA44USB sound device */
  117. { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
  118. /* Action Semiconductor flash disk */
  119. { USB_DEVICE(0x10d6, 0x2200), .driver_info =
  120. USB_QUIRK_STRING_FETCH_255 },
  121. /* SKYMEDI USB_DRIVE */
  122. { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
  123. /* Razer - Razer Blade Keyboard */
  124. { USB_DEVICE(0x1532, 0x0116), .driver_info =
  125. USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
  126. /* BUILDWIN Photo Frame */
  127. { USB_DEVICE(0x1908, 0x1315), .driver_info =
  128. USB_QUIRK_HONOR_BNUMINTERFACES },
  129. /* INTEL VALUE SSD */
  130. { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
  131. /* USB3503 */
  132. { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
  133. /* ASUS Base Station(T100) */
  134. { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
  135. USB_QUIRK_IGNORE_REMOTE_WAKEUP },
  136. { } /* terminating entry must be last */
  137. };
  138. static const struct usb_device_id usb_interface_quirk_list[] = {
  139. /* Logitech UVC Cameras */
  140. { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
  141. .driver_info = USB_QUIRK_RESET_RESUME },
  142. { } /* terminating entry must be last */
  143. };
  144. static const struct usb_device_id usb_amd_resume_quirk_list[] = {
  145. /* Lenovo Mouse with Pixart controller */
  146. { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
  147. /* Pixart Mouse */
  148. { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
  149. { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
  150. { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
  151. /* Logitech Optical Mouse M90/M100 */
  152. { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
  153. { } /* terminating entry must be last */
  154. };
  155. static bool usb_match_any_interface(struct usb_device *udev,
  156. const struct usb_device_id *id)
  157. {
  158. unsigned int i;
  159. for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
  160. struct usb_host_config *cfg = &udev->config[i];
  161. unsigned int j;
  162. for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
  163. struct usb_interface_cache *cache;
  164. struct usb_host_interface *intf;
  165. cache = cfg->intf_cache[j];
  166. if (cache->num_altsetting == 0)
  167. continue;
  168. intf = &cache->altsetting[0];
  169. if (usb_match_one_id_intf(udev, intf, id))
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. static int usb_amd_resume_quirk(struct usb_device *udev)
  176. {
  177. struct usb_hcd *hcd;
  178. hcd = bus_to_hcd(udev->bus);
  179. /* The device should be attached directly to root hub */
  180. if (udev->level == 1 && hcd->amd_resume_bug == 1)
  181. return 1;
  182. return 0;
  183. }
  184. static u32 __usb_detect_quirks(struct usb_device *udev,
  185. const struct usb_device_id *id)
  186. {
  187. u32 quirks = 0;
  188. for (; id->match_flags; id++) {
  189. if (!usb_match_device(udev, id))
  190. continue;
  191. if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
  192. !usb_match_any_interface(udev, id))
  193. continue;
  194. quirks |= (u32)(id->driver_info);
  195. }
  196. return quirks;
  197. }
  198. /*
  199. * Detect any quirks the device has, and do any housekeeping for it if needed.
  200. */
  201. void usb_detect_quirks(struct usb_device *udev)
  202. {
  203. udev->quirks = __usb_detect_quirks(udev, usb_quirk_list);
  204. /*
  205. * Pixart-based mice would trigger remote wakeup issue on AMD
  206. * Yangtze chipset, so set them as RESET_RESUME flag.
  207. */
  208. if (usb_amd_resume_quirk(udev))
  209. udev->quirks |= __usb_detect_quirks(udev,
  210. usb_amd_resume_quirk_list);
  211. if (udev->quirks)
  212. dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
  213. udev->quirks);
  214. #ifdef CONFIG_USB_DEFAULT_PERSIST
  215. if (!(udev->quirks & USB_QUIRK_RESET))
  216. udev->persist_enabled = 1;
  217. #else
  218. /* Hubs are automatically enabled for USB-PERSIST */
  219. if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
  220. udev->persist_enabled = 1;
  221. #endif /* CONFIG_USB_DEFAULT_PERSIST */
  222. }
  223. void usb_detect_interface_quirks(struct usb_device *udev)
  224. {
  225. u32 quirks;
  226. quirks = __usb_detect_quirks(udev, usb_interface_quirk_list);
  227. if (quirks == 0)
  228. return;
  229. dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
  230. quirks);
  231. udev->quirks |= quirks;
  232. }