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