gen_autosuspend_rules.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. # Copyright 2017 The Chromium OS Authors. All rights reserved.
  4. # Use of this source code is governed by a BSD-style license that can be
  5. # found in the LICENSE file.
  6. """Autosuspend udev rule generator
  7. This script is executed at build time to generate udev rules. The
  8. resulting rules file is installed on the device, the script itself
  9. is not.
  10. """
  11. from __future__ import print_function
  12. # List of USB devices (vendorid:productid) for which it is safe to enable
  13. # autosuspend.
  14. USB_IDS = []
  15. # Host Controllers and internal hubs
  16. USB_IDS += [
  17. # Linux Host Controller (UHCI) (most older x86 boards)
  18. '1d6b:0001',
  19. # Linux Host Controller (EHCI) (all boards)
  20. '1d6b:0002',
  21. # Linux Host Controller (XHCI) (most newer boards)
  22. '1d6b:0003',
  23. # SMSC (Internal HSIC Hub) (most Exynos boards)
  24. '0424:3503',
  25. # Intel (Rate Matching Hub) (all x86 boards)
  26. '05e3:0610',
  27. # Intel (Internal Hub?) (peppy, falco)
  28. '8087:0024',
  29. # Genesys Logic (Internal Hub) (rambi)
  30. '8087:8000',
  31. # Microchip (Composite HID + CDC) (kefka)
  32. '04d8:0b28',
  33. ]
  34. # Webcams
  35. USB_IDS += [
  36. # Chicony (zgb)
  37. '04f2:b1d8',
  38. # Chicony (mario)
  39. '04f2:b262',
  40. # Chicony (stout)
  41. '04f2:b2fe',
  42. # Chicony (butterfly)
  43. '04f2:b35f',
  44. # Chicony (rambi)
  45. '04f2:b443',
  46. # Chicony (glados)
  47. '04f2:b552',
  48. # LiteOn (spring)
  49. '058f:b001',
  50. # Foxlink? (butterfly)
  51. '05c8:0351',
  52. # Foxlink? (butterfly)
  53. '05c8:0355',
  54. # Cheng Uei? (falco)
  55. '05c8:036e',
  56. # SuYin (parrot)
  57. '064e:d251',
  58. # Realtek (falco)
  59. '0bda:571c',
  60. # IMC Networks (squawks)
  61. '13d3:5657',
  62. # Sunplus (parrot)
  63. '1bcf:2c17',
  64. # (C-13HDO10B39N) (alex)
  65. '2232:1013',
  66. # (C-10HDP11538N) (lumpy)
  67. '2232:1017',
  68. # (Namuga) (link)
  69. '2232:1033',
  70. # (C-03FFM12339N) (daisy)
  71. '2232:1037',
  72. # (C-10HDO13531N) (peach)
  73. '2232:1056',
  74. # (NCM-G102) (samus)
  75. '2232:6001',
  76. # Acer (stout)
  77. '5986:0299',
  78. ]
  79. # Bluetooth Host Controller
  80. USB_IDS += [
  81. # Hon-hai (parrot)
  82. '0489:e04e',
  83. # Hon-hai (peppy)
  84. '0489:e056',
  85. # Hon-hai (Kahlee)
  86. '0489:e09f',
  87. # QCA6174A (delan)
  88. '0489:e0a2',
  89. # LiteOn (parrot)
  90. '04ca:3006',
  91. # LiteOn (aleena)
  92. '04ca:3016',
  93. # LiteOn (scarlet)
  94. '04ca:301a',
  95. # Realtek (blooglet)
  96. '0bda:b00c',
  97. # Atheros (stumpy, stout)
  98. '0cf3:3004',
  99. # Atheros (AR3011) (mario, alex, zgb)
  100. '0cf3:3005',
  101. # Atheros (stumyp)
  102. '0cf3:3007',
  103. # Atheros (butterfly)
  104. '0cf3:311e',
  105. # Atheros (scarlet)
  106. '0cf3:e300',
  107. # Marvell (rambi)
  108. '1286:2046',
  109. # Marvell (gru)
  110. '1286:204e',
  111. # Intel (rambi, samus)
  112. '8087:07dc',
  113. # Intel (strago, glados)
  114. '8087:0a2a',
  115. # Intel (octopus)
  116. '8087:0aaa',
  117. # Intel (hatch)
  118. '8087:0026',
  119. # Intel (atlas)
  120. '8087:0025',
  121. ]
  122. # WWAN (LTE)
  123. USB_IDS += [
  124. # Huawei (ME936) (kip)
  125. '12d1:15bb',
  126. # Fibocom (L850-GL) (coral, nautilus, sarien)
  127. '2cb7:0007',
  128. ]
  129. # Mass Storage
  130. USB_IDS += [
  131. # Genesys (SD card reader) (lumpy, link, peppy)
  132. '05e3:0727',
  133. # Realtek (SD card reader) (mario, alex)
  134. '0bda:0138',
  135. # Realtek (SD card reader) (helios)
  136. '0bda:0136',
  137. # Realtek (SD card reader) (falco)
  138. '0bda:0177',
  139. ]
  140. # Security Key
  141. USB_IDS += [
  142. # Yubico.com
  143. '1050:0211',
  144. # Yubico.com (HID firmware)
  145. '1050:0200',
  146. # Google Titan key
  147. '18d1:5026',
  148. ]
  149. # USB Audio devices
  150. USB_IDS += [
  151. # Google USB-C to 3.5mm Digital Headphone Jack Adapter 'Mir'
  152. '18d1:5025',
  153. # Google USB-C to 3.5mm Digital Headphone Jack Adapter 'Mir' (HID only)
  154. '18d1:5029',
  155. # Google USB-C to 3.5mm Digital Headphone Jack Adapter 2018 'Condor'
  156. '18d1:5034',
  157. # Google Pixel USB-C Earbuds 'Blackbird'
  158. '18d1:5033',
  159. # Libratone Q Adapt In-Ear USB-C Earphones, Made for Google
  160. '03eb:2433',
  161. # Moshi USB-C to 3.5 mm Adapter/Charger, Made for Google
  162. '282b:48f0',
  163. # Moshi USB-C to 3.5 mm Adapter/Charger, Made for Google (HID only)
  164. '282b:0026',
  165. # AiAiAi TMA-2 C60 Cable, Made for Google
  166. '0572:1a08',
  167. # Apple USB-C to 3.5mm Headphone Jack Adapter
  168. '05ac:110a',
  169. ]
  170. # List of PCI devices (vendorid:deviceid) for which it is safe to enable
  171. # autosuspend.
  172. PCI_IDS = []
  173. # Intel
  174. PCI_IDS += [
  175. # Host bridge
  176. '8086:590c',
  177. # i915
  178. '8086:591e',
  179. # proc_thermal
  180. '8086:1903',
  181. # SPT PCH xHCI controller
  182. '8086:9d2f',
  183. # CNP PCH xHCI controller
  184. '8086:9ded',
  185. # intel_pmc_core
  186. '8086:9d21',
  187. # i801_smbus
  188. '8086:9d23',
  189. # iwlwifi
  190. '8086:095a',
  191. # GMM
  192. '8086:1911',
  193. # Thermal
  194. '8086:9d31',
  195. # MME
  196. '8086:9d3a',
  197. # CrOS EC
  198. '8086:9d4b',
  199. # PCH SPI
  200. '8086:9d24',
  201. # SATA
  202. '8086:02d3',
  203. # RAM memory
  204. '8086:02ef',
  205. # ISA bridge
  206. '8086:0284',
  207. # Communication controller
  208. '8086:02e0',
  209. # Network controller
  210. '8086:02f0',
  211. # Serial bus controller
  212. '8086:02a4',
  213. # USB controller
  214. '8086:02ed',
  215. # Graphics
  216. '8086:9b41',
  217. # DSP
  218. '8086:02f9',
  219. # Host bridge
  220. '8086:9b61',
  221. # Host bridge
  222. '8086:9b71',
  223. # PCI Bridge
  224. '8086:02b0',
  225. # i915 (atlas)
  226. '8086:591c',
  227. # iwlwifi (atlas)
  228. '8086:2526',
  229. # i915 (kefka)
  230. '8086:22b1',
  231. # proc_thermal (kefka)
  232. '8086:22dc',
  233. # xchi_hdc (kefka)
  234. '8086:22b5',
  235. # snd_hda (kefka)
  236. '8086:2284',
  237. # pcieport (kefka)
  238. '8086:22c8',
  239. '8086:22cc',
  240. # lpc_ich (kefka)
  241. '8086:229c',
  242. # iosf_mbi_pci (kefka)
  243. '8086:2280',
  244. ]
  245. # Samsung
  246. PCI_IDS += [
  247. # NVMe KUS030205M-B001
  248. '144d:a806',
  249. # NVMe MZVLB256HAHQ
  250. '144d:a808',
  251. ]
  252. # Lite-on
  253. PCI_IDS += [
  254. # 3C07110288
  255. '14a4:9100',
  256. ]
  257. # Seagate
  258. PCI_IDS += [
  259. # ZP256CM30011
  260. '7089:5012',
  261. ]
  262. # Kingston
  263. PCI_IDS += [
  264. # RBUSNS8154P3128GJ3
  265. '2646:5008',
  266. ]
  267. # Do not edit below this line. #################################################
  268. UDEV_RULE = """\
  269. ACTION!="add", GOTO="autosuspend_end"
  270. SUBSYSTEM!="i2c|pci|usb", GOTO="autosuspend_end"
  271. SUBSYSTEM=="i2c", GOTO="autosuspend_i2c"
  272. SUBSYSTEM=="pci", GOTO="autosuspend_pci"
  273. SUBSYSTEM=="usb", GOTO="autosuspend_usb"
  274. # I2C rules
  275. LABEL="autosuspend_i2c"
  276. ATTR{name}=="cyapa", ATTR{power/control}="on", GOTO="autosuspend_end"
  277. GOTO="autosuspend_end"
  278. # PCI rules
  279. LABEL="autosuspend_pci"
  280. %(pci_rules)s\
  281. GOTO="autosuspend_end"
  282. # USB rules
  283. LABEL="autosuspend_usb"
  284. %(usb_rules)s\
  285. GOTO="autosuspend_end"
  286. # Enable autosuspend
  287. LABEL="autosuspend_enable"
  288. TEST=="power/control", ATTR{power/control}="auto", GOTO="autosuspend_end"
  289. LABEL="autosuspend_end"
  290. """
  291. def main():
  292. pci_rules = ''
  293. for dev_ids in PCI_IDS:
  294. vendor, device = dev_ids.split(':')
  295. pci_rules += ('ATTR{vendor}=="0x%s", ATTR{device}=="0x%s", '
  296. 'GOTO="autosuspend_enable"\n' % (vendor, device))
  297. usb_rules = ''
  298. for dev_ids in USB_IDS:
  299. vid, pid = dev_ids.split(':')
  300. usb_rules += ('ATTR{idVendor}=="%s", ATTR{idProduct}=="%s", '
  301. 'GOTO="autosuspend_enable"\n' % (vid, pid))
  302. print(UDEV_RULE % {'pci_rules': pci_rules, 'usb_rules': usb_rules})
  303. if __name__ == '__main__':
  304. main()