]>
git.ipfire.org Git - thirdparty/systemd.git/blob - tools/chromiumos/gen_autosuspend_rules.py
2 # -*- coding: utf-8 -*-
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.
8 """Autosuspend udev rule generator
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
15 from __future__
import print_function
17 # List of USB devices (vendorid:productid) for which it is safe to enable
21 # Host Controllers and internal hubs
23 # Linux Host Controller (UHCI) (most older x86 boards)
25 # Linux Host Controller (EHCI) (all boards)
27 # Linux Host Controller (XHCI) (most newer boards)
29 # SMSC (Internal HSIC Hub) (most Exynos boards)
31 # Intel (Rate Matching Hub) (all x86 boards)
33 # Intel (Internal Hub?) (peppy, falco)
35 # Genesys Logic (Internal Hub) (rambi)
55 # Foxlink? (butterfly)
57 # Foxlink? (butterfly)
65 # IMC Networks (squawks)
69 # (C-13HDO10B39N) (alex)
71 # (C-10HDP11538N) (lumpy)
75 # (C-03FFM12339N) (daisy)
77 # (C-10HDO13531N) (peach)
85 # Bluetooth Host Controller
101 # Atheros (stumpy, stout)
103 # Atheros (AR3011) (mario, alex, zgb)
107 # Atheros (butterfly)
115 # Intel (rambi, samus)
117 # Intel (strago, glados)
129 # Huawei (ME936) (kip)
131 # Fibocom (L850-GL) (coral, nautilus, sarien)
137 # Genesys (SD card reader) (lumpy, link, peppy)
139 # Realtek (SD card reader) (mario, alex)
141 # Realtek (SD card reader) (helios)
143 # Realtek (SD card reader) (falco)
151 # Yubico.com (HID firmware)
159 # Google USB-C to 3.5mm Digital Headphone Jack Adapter 'Mir'
161 # Google USB-C to 3.5mm Digital Headphone Jack Adapter 'Mir' (HID only)
163 # Google USB-C to 3.5mm Digital Headphone Jack Adapter 2018 'Condor'
165 # Google Pixel USB-C Earbuds 'Blackbird'
167 # Libratone Q Adapt In-Ear USB-C Earphones, Made for Google
169 # Moshi USB-C to 3.5 mm Adapter/Charger, Made for Google
171 # Moshi USB-C to 3.5 mm Adapter/Charger, Made for Google (HID only)
173 # AiAiAi TMA-2 C60 Cable, Made for Google
175 # Apple USB-C to 3.5mm Headphone Jack Adapter
179 # List of PCI devices (vendorid:deviceid) for which it is safe to enable
191 # SPT PCH xHCI controller
193 # CNP PCH xHCI controller
217 # Communication controller
221 # Serial bus controller
243 # NVMe KUS030205M-B001
267 ################################################################################
270 ACTION!="add", GOTO="autosuspend_end"
271 SUBSYSTEM!="i2c|pci|usb", GOTO="autosuspend_end"
273 SUBSYSTEM=="i2c", GOTO="autosuspend_i2c"
274 SUBSYSTEM=="pci", GOTO="autosuspend_pci"
275 SUBSYSTEM=="usb", GOTO="autosuspend_usb"
278 LABEL="autosuspend_i2c"
279 ATTR{name}=="cyapa", ATTR{power/control}="on", GOTO="autosuspend_end"
280 GOTO="autosuspend_end"
283 LABEL="autosuspend_pci"
285 GOTO="autosuspend_end"
288 LABEL="autosuspend_usb"
290 GOTO="autosuspend_end"
293 LABEL="autosuspend_enable"
294 TEST=="power/control", ATTR{power/control}="auto", GOTO="autosuspend_end"
296 LABEL="autosuspend_end"
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
))
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
))
313 print(UDEV_RULE
% {'pci_rules': pci_rules
, 'usb_rules': usb_rules
})
316 if __name__
== '__main__':