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