| 1 |
#!/usr/bin/env python3 |
| 2 |
# SPDX-License-Identifier: BSD-3-Clause |
| 3 |
# -*- coding: utf-8 -*- |
| 4 |
|
| 5 |
# Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 6 |
# Use of this source code is governed by a BSD-style license that can be |
| 7 |
# found in the LICENSES/BSD-3-Clause.txt file. |
| 8 |
|
| 9 |
"""Autosuspend udev rule generator |
| 10 |
|
| 11 |
This script is executed at build time to generate udev rules. The |
| 12 |
resulting rules file is installed on the device, the script itself |
| 13 |
is not. |
| 14 |
""" |
| 15 |
|
| 16 |
# List of USB devices (vendorid:productid) for which it is safe to enable |
| 17 |
# autosuspend. |
| 18 |
USB_IDS = [] |
| 19 |
|
| 20 |
# Host Controllers and internal hubs |
| 21 |
USB_IDS += [ |
| 22 |
# Linux Host Controller (UHCI) (most older x86 boards) |
| 23 |
"1d6b:0001", |
| 24 |
# Linux Host Controller (EHCI) (all boards) |
| 25 |
"1d6b:0002", |
| 26 |
# Linux Host Controller (XHCI) (most newer boards) |
| 27 |
"1d6b:0003", |
| 28 |
# SMSC (Internal HSIC Hub) (most Exynos boards) |
| 29 |
"0424:3503", |
| 30 |
# Intel (Rate Matching Hub) (all x86 boards) |
| 31 |
"05e3:0610", |
| 32 |
# Intel (Internal Hub?) (peppy, falco) |
| 33 |
"8087:0024", |
| 34 |
# Genesys Logic (Internal Hub) (rambi) |
| 35 |
"8087:8000", |
| 36 |
# Microchip (Composite HID + CDC) (kefka) |
| 37 |
"04d8:0b28", |
| 38 |
] |
| 39 |
|
| 40 |
# Webcams |
| 41 |
USB_IDS += [ |
| 42 |
# Chicony (zgb) |
| 43 |
"04f2:b1d8", |
| 44 |
# Chicony (mario) |
| 45 |
"04f2:b262", |
| 46 |
# Chicony (stout) |
| 47 |
"04f2:b2fe", |
| 48 |
# Chicony (butterfly) |
| 49 |
"04f2:b35f", |
| 50 |
# Chicony (rambi) |
| 51 |
"04f2:b443", |
| 52 |
# Chicony (glados) |
| 53 |
"04f2:b552", |
| 54 |
# LiteOn (spring) |
| 55 |
"058f:b001", |
| 56 |
# Foxlink? (butterfly) |
| 57 |
"05c8:0351", |
| 58 |
# Foxlink? (butterfly) |
| 59 |
"05c8:0355", |
| 60 |
# Cheng Uei? (falco) |
| 61 |
"05c8:036e", |
| 62 |
# SuYin (parrot) |
| 63 |
"064e:d251", |
| 64 |
# Realtek (falco) |
| 65 |
"0bda:571c", |
| 66 |
# IMC Networks (squawks) |
| 67 |
"13d3:5657", |
| 68 |
# Sunplus (parrot) |
| 69 |
"1bcf:2c17", |
| 70 |
# (C-13HDO10B39N) (alex) |
| 71 |
"2232:1013", |
| 72 |
# (C-10HDP11538N) (lumpy) |
| 73 |
"2232:1017", |
| 74 |
# (Namuga) (link) |
| 75 |
"2232:1033", |
| 76 |
# (C-03FFM12339N) (daisy) |
| 77 |
"2232:1037", |
| 78 |
# (C-10HDO13531N) (peach) |
| 79 |
"2232:1056", |
| 80 |
# (NCM-G102) (samus) |
| 81 |
"2232:6001", |
| 82 |
# Acer (stout) |
| 83 |
"5986:0299", |
| 84 |
] |
| 85 |
|
| 86 |
# Bluetooth Host Controller |
| 87 |
USB_IDS += [ |
| 88 |
# Hon-hai (parrot) |
| 89 |
"0489:e04e", |
| 90 |
# Hon-hai (peppy) |
| 91 |
"0489:e056", |
| 92 |
# Hon-hai (Kahlee) |
| 93 |
"0489:e09f", |
| 94 |
# QCA6174A (delan) |
| 95 |
"0489:e0a2", |
| 96 |
# LiteOn (parrot) |
| 97 |
"04ca:3006", |
| 98 |
# LiteOn (aleena) |
| 99 |
"04ca:3016", |
| 100 |
# LiteOn (scarlet) |
| 101 |
"04ca:301a", |
| 102 |
# Realtek (blooglet) |
| 103 |
"0bda:b00c", |
| 104 |
# Atheros (stumpy, stout) |
| 105 |
"0cf3:3004", |
| 106 |
# Atheros (AR3011) (mario, alex, zgb) |
| 107 |
"0cf3:3005", |
| 108 |
# Atheros (stumyp) |
| 109 |
"0cf3:3007", |
| 110 |
# Atheros (butterfly) |
| 111 |
"0cf3:311e", |
| 112 |
# Atheros (scarlet) |
| 113 |
"0cf3:e300", |
| 114 |
# Marvell (rambi) |
| 115 |
"1286:2046", |
| 116 |
# Marvell (gru) |
| 117 |
"1286:204e", |
| 118 |
# Intel (rambi, samus) |
| 119 |
"8087:07dc", |
| 120 |
# Intel (strago, glados) |
| 121 |
"8087:0a2a", |
| 122 |
# Intel (octopus) |
| 123 |
"8087:0aaa", |
| 124 |
# Intel (hatch) |
| 125 |
"8087:0026", |
| 126 |
# Intel (atlas) |
| 127 |
"8087:0025", |
| 128 |
] |
| 129 |
|
| 130 |
# WWAN (LTE) |
| 131 |
USB_IDS += [ |
| 132 |
# Huawei (ME936) (kip) |
| 133 |
"12d1:15bb", |
| 134 |
# Quectel (EM060) |
| 135 |
"2c7c:0128", |
| 136 |
# Fibocom (L850-GL) (coral, nautilus, sarien) |
| 137 |
"2cb7:0007", |
| 138 |
# Fibocom (NL668, NL652) |
| 139 |
"2cb7:01a0", |
| 140 |
# Fibocom (FM101-GL) (mbim) |
| 141 |
"2cb7:01a2", |
| 142 |
# Fibocom (FM101-GL) (adb) |
| 143 |
"2cb7:01a4", |
| 144 |
# Rolling Wireless (RW101) |
| 145 |
"33f8:01a2", |
| 146 |
# Rolling Wireless (RW135) |
| 147 |
"33f8:0115", |
| 148 |
# Rolling Wireless (RW135R) |
| 149 |
"33f8:1003", |
| 150 |
# Rolling Wireless (RW350R USB) |
| 151 |
"33f8:0802", |
| 152 |
# NetPrisma (LCUK54) |
| 153 |
"3731:0100", |
| 154 |
] |
| 155 |
|
| 156 |
# Mass Storage |
| 157 |
USB_IDS += [ |
| 158 |
# Genesys (SD card reader) (lumpy, link, peppy) |
| 159 |
"05e3:0727", |
| 160 |
# Realtek (SD card reader) (mario, alex) |
| 161 |
"0bda:0138", |
| 162 |
# Realtek (SD card reader) (helios) |
| 163 |
"0bda:0136", |
| 164 |
# Realtek (SD card reader) (falco) |
| 165 |
"0bda:0177", |
| 166 |
# Realtek (SD card reader) (pirrha) |
| 167 |
"0bda:0129", |
| 168 |
] |
| 169 |
|
| 170 |
# Security Key |
| 171 |
USB_IDS += [ |
| 172 |
# Yubico.com |
| 173 |
"1050:0211", |
| 174 |
# Yubico.com (HID firmware) |
| 175 |
"1050:0200", |
| 176 |
# Google Titan key |
| 177 |
"18d1:5026", |
| 178 |
] |
| 179 |
|
| 180 |
# USB Audio devices |
| 181 |
USB_IDS += [ |
| 182 |
# Google USB-C to 3.5mm Digital Headphone Jack Adapter 'Mir' |
| 183 |
"18d1:5025", |
| 184 |
# Google USB-C to 3.5mm Digital Headphone Jack Adapter 'Mir' (HID only) |
| 185 |
"18d1:5029", |
| 186 |
# Google USB-C to 3.5mm Digital Headphone Jack Adapter 2018 'Condor' |
| 187 |
"18d1:5034", |
| 188 |
# Google Pixel USB-C Earbuds 'Blackbird' |
| 189 |
"18d1:5033", |
| 190 |
# Libratone Q Adapt In-Ear USB-C Earphones, Made for Google |
| 191 |
"03eb:2433", |
| 192 |
# Moshi USB-C to 3.5 mm Adapter/Charger, Made for Google |
| 193 |
"282b:48f0", |
| 194 |
# Moshi USB-C to 3.5 mm Adapter/Charger, Made for Google (HID only) |
| 195 |
"282b:0026", |
| 196 |
# AiAiAi TMA-2 C60 Cable, Made for Google |
| 197 |
"0572:1a08", |
| 198 |
# Apple USB-C to 3.5mm Headphone Jack Adapter |
| 199 |
"05ac:110a", |
| 200 |
] |
| 201 |
|
| 202 |
# RGB Keyboard |
| 203 |
USB_IDS += [ |
| 204 |
# Google Prism |
| 205 |
"18d1:5022", |
| 206 |
] |
| 207 |
|
| 208 |
# List of PCI devices (vendorid:deviceid) for which it is safe to enable |
| 209 |
# autosuspend. |
| 210 |
PCI_IDS = [] |
| 211 |
|
| 212 |
# Intel |
| 213 |
PCI_IDS += [ |
| 214 |
# Host bridge |
| 215 |
"8086:590c", |
| 216 |
# i915 |
| 217 |
"8086:591e", |
| 218 |
# proc_thermal |
| 219 |
"8086:1903", |
| 220 |
# SPT PCH xHCI controller |
| 221 |
"8086:9d2f", |
| 222 |
# CNP PCH xHCI controller |
| 223 |
"8086:9ded", |
| 224 |
# intel_pmc_core |
| 225 |
"8086:9d21", |
| 226 |
# i801_smbus |
| 227 |
"8086:9d23", |
| 228 |
# iwlwifi |
| 229 |
"8086:095a", |
| 230 |
# GMM |
| 231 |
"8086:1911", |
| 232 |
# Thermal |
| 233 |
"8086:9d31", |
| 234 |
# MME |
| 235 |
"8086:9d3a", |
| 236 |
# CrOS EC |
| 237 |
"8086:9d4b", |
| 238 |
# PCH SPI |
| 239 |
"8086:9d24", |
| 240 |
# SATA |
| 241 |
"8086:02d3", |
| 242 |
# RAM memory |
| 243 |
"8086:02ef", |
| 244 |
# ISA bridge |
| 245 |
"8086:0284", |
| 246 |
# Communication controller |
| 247 |
"8086:02e0", |
| 248 |
# Network controller |
| 249 |
"8086:02f0", |
| 250 |
# Serial bus controller |
| 251 |
"8086:02a4", |
| 252 |
# USB controller |
| 253 |
"8086:02ed", |
| 254 |
# JSL xHCI controller |
| 255 |
"8086:4ded", |
| 256 |
# Volteer xHCI controller |
| 257 |
"8086:a0ed", |
| 258 |
# Brya xHCI controller |
| 259 |
"8086:51ed", |
| 260 |
# ADL-N PCH xHCI controller |
| 261 |
"8086:54ed", |
| 262 |
# Graphics |
| 263 |
"8086:9b41", |
| 264 |
# DSP |
| 265 |
"8086:02f9", |
| 266 |
# Host bridge |
| 267 |
"8086:9b61", |
| 268 |
# Host bridge |
| 269 |
"8086:9b71", |
| 270 |
# PCI Bridge |
| 271 |
"8086:02b0", |
| 272 |
# i915 (atlas) |
| 273 |
"8086:591c", |
| 274 |
# iwlwifi (atlas) |
| 275 |
"8086:2526", |
| 276 |
# i915 (kefka) |
| 277 |
"8086:22b1", |
| 278 |
# proc_thermal (kefka) |
| 279 |
"8086:22dc", |
| 280 |
# xchi_hdc (kefka) |
| 281 |
"8086:22b5", |
| 282 |
# snd_hda (kefka) |
| 283 |
"8086:2284", |
| 284 |
# pcieport (kefka) |
| 285 |
"8086:22c8", |
| 286 |
"8086:22cc", |
| 287 |
# lpc_ich (kefka) |
| 288 |
"8086:229c", |
| 289 |
# iosf_mbi_pci (kefka) |
| 290 |
"8086:2280", |
| 291 |
# Host bridge (nami) |
| 292 |
"8086:5904", |
| 293 |
"8086:5914", |
| 294 |
# Graphics (nami) |
| 295 |
"8086:5906", |
| 296 |
"8086:5917", |
| 297 |
# ISA bridge (nami) |
| 298 |
"8086:9d4e", |
| 299 |
# wifi 7265 (nami) |
| 300 |
"8086:095b", |
| 301 |
# Graphics (brya) |
| 302 |
"8086:46a8", |
| 303 |
# Core 12G GNA (brya) |
| 304 |
"8086:464f", |
| 305 |
# PCH Shared SRAM (brya) |
| 306 |
"8086:51ef", |
| 307 |
# PCH eSPI (brya) |
| 308 |
"8086:5182", |
| 309 |
"8086:4601", |
| 310 |
# Core 12G DTT (brya) |
| 311 |
"8086:461d", |
| 312 |
# Wifi (Brya) |
| 313 |
"8086:51f0", |
| 314 |
# PCH SPI (brya) |
| 315 |
"8086:51a4", |
| 316 |
] |
| 317 |
|
| 318 |
# Samsung |
| 319 |
PCI_IDS += [ |
| 320 |
# NVMe KUS030205M-B001 |
| 321 |
"144d:a806", |
| 322 |
# NVMe MZVLB256HAHQ |
| 323 |
"144d:a808", |
| 324 |
# NVMe MZ9LQ256HBJD-00BH1 (brya) |
| 325 |
"144d:a809", |
| 326 |
] |
| 327 |
|
| 328 |
# Lite-on |
| 329 |
PCI_IDS += [ |
| 330 |
# 3C07110288 |
| 331 |
"14a4:9100", |
| 332 |
] |
| 333 |
|
| 334 |
# Seagate |
| 335 |
PCI_IDS += [ |
| 336 |
# ZP256CM30011 |
| 337 |
"7089:5012", |
| 338 |
] |
| 339 |
|
| 340 |
# Kingston |
| 341 |
PCI_IDS += [ |
| 342 |
# RBUSNS8154P3128GJ3 |
| 343 |
"2646:5008", |
| 344 |
] |
| 345 |
|
| 346 |
# Genesys Logic |
| 347 |
PCI_IDS += [ |
| 348 |
# SD Host Controller (brya) |
| 349 |
"17a0:9755", |
| 350 |
] |
| 351 |
|
| 352 |
# Phison |
| 353 |
PCI_IDS += [ |
| 354 |
# E13 NVMe Controller (redrix) |
| 355 |
"1987:5013", |
| 356 |
# E18 PCIe4 NVMe Controller (vell) |
| 357 |
"1987:5018", |
| 358 |
] |
| 359 |
|
| 360 |
# Do not edit below this line. ################################################# |
| 361 |
|
| 362 |
UDEV_RULE = """\ |
| 363 |
ACTION!="add", GOTO="autosuspend_end" |
| 364 |
SUBSYSTEM!="i2c|pci|usb", GOTO="autosuspend_end" |
| 365 |
|
| 366 |
SUBSYSTEM=="i2c", GOTO="autosuspend_i2c" |
| 367 |
SUBSYSTEM=="pci", GOTO="autosuspend_pci" |
| 368 |
SUBSYSTEM=="usb", GOTO="autosuspend_usb" |
| 369 |
|
| 370 |
# I2C rules |
| 371 |
LABEL="autosuspend_i2c" |
| 372 |
ATTR{name}=="cyapa", ATTR{power/control}="on", GOTO="autosuspend_end" |
| 373 |
GOTO="autosuspend_end" |
| 374 |
|
| 375 |
# PCI rules |
| 376 |
LABEL="autosuspend_pci" |
| 377 |
%(pci_rules)s\ |
| 378 |
GOTO="autosuspend_end" |
| 379 |
|
| 380 |
# USB rules |
| 381 |
LABEL="autosuspend_usb" |
| 382 |
%(usb_rules)s\ |
| 383 |
GOTO="autosuspend_end" |
| 384 |
|
| 385 |
# Enable autosuspend |
| 386 |
LABEL="autosuspend_enable" |
| 387 |
TEST=="power/control", ATTR{power/control}="auto", GOTO="autosuspend_end" |
| 388 |
|
| 389 |
LABEL="autosuspend_end" |
| 390 |
""" |
| 391 |
|
| 392 |
|
| 393 |
def main(): |
| 394 |
pci_rules = "" |
| 395 |
for dev_ids in PCI_IDS: |
| 396 |
vendor, device = dev_ids.split(":") |
| 397 |
pci_rules += ( |
| 398 |
'ATTR{vendor}=="0x%s", ATTR{device}=="0x%s", ' |
| 399 |
'GOTO="autosuspend_enable"\n' % (vendor, device) |
| 400 |
) |
| 401 |
|
| 402 |
usb_rules = "" |
| 403 |
for dev_ids in USB_IDS: |
| 404 |
vid, pid = dev_ids.split(":") |
| 405 |
usb_rules += ( |
| 406 |
'ATTR{idVendor}=="%s", ATTR{idProduct}=="%s", ' |
| 407 |
'GOTO="autosuspend_enable"\n' % (vid, pid) |
| 408 |
) |
| 409 |
|
| 410 |
print(UDEV_RULE % {"pci_rules": pci_rules, "usb_rules": usb_rules}) |
| 411 |
|
| 412 |
|
| 413 |
if __name__ == "__main__": |
| 414 |
main() |