X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/c634ca86ab3b6a1c2a9abcb9f01547368e07f963..c50b9b5fd8fb6b28fc0ba9d928aa1a80d17724d9:/src/adafruit_blinka/microcontroller/alias.py diff --git a/src/adafruit_blinka/microcontroller/alias.py b/src/adafruit_blinka/microcontroller/alias.py index ab5067e..3686919 100644 --- a/src/adafruit_blinka/microcontroller/alias.py +++ b/src/adafruit_blinka/microcontroller/alias.py @@ -3,7 +3,8 @@ # SPDX-License-Identifier: MIT """ -Device Tree Alias Functions +Functions to find aliases for all hardware, +including those defined in the device tree. """ from typing import Optional @@ -23,3 +24,15 @@ def get_dts_alias(device: str) -> Optional[str]: if match: return match.group(1).upper() return None + + +def get_pwm_chipid(device: str): + """Get the PWM Chip ID""" + for chipid in range(32): + pwm_sys_path = "/sys/class/pwm/pwmchip{}".format(chipid) + if not os.path.exists(pwm_sys_path): + continue + if device in os.path.realpath(pwm_sys_path): + alias = "PWM" + str(chipid) + return alias + return None