X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/0548bc42ebc6e42c373a27783d5c3e41516c065c..de652f72b1884328ee22ec36deaa6320addd32e7:/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py diff --git a/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py b/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py index 635d816..82fa6ea 100644 --- a/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py +++ b/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py @@ -1,14 +1,16 @@ -from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin -import gpiod -import re +""" +G12A, G12B, and SM1 Common Definitions +Ref: +Linux kernel 4.9.y (hardkernel) + linux/include/dt-bindings/gpio/meson-g12a-gpio.h +Linux kernel 5.4.y (mainline) + linux/include/dt-bindings/gpio/meson-g12a-gpio.h + linux/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +""" -# G12A, G12B, and SM1 -# Ref: -# Linux kernel 4.9.y (hardkernel) -# linux/include/dt-bindings/gpio/meson-g12a-gpio.h -# Linux kernel 5.4.y (mainline) -# linux/include/dt-bindings/gpio/meson-g12a-gpio.h -# linux/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +import re +import gpiod +from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin chip0 = gpiod.Chip("0") chip1 = gpiod.Chip("1") @@ -96,20 +98,21 @@ SPI0_MOSI = GPIOX_8 SPI0_CS0 = GPIOX_10 # ordered as spiId, sckId, mosiId, misoId -spiPorts = ((0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO), ) +spiPorts = ((0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO),) UART1_TX = GPIOX_12 UART1_RX = GPIOX_13 # ordered as uartId, txId, rxId -uartPorts = ((1, UART1_TX, UART1_RX), ) +uartPorts = ((1, UART1_TX, UART1_RX),) def get_dts_alias(device: str) -> str: + """Get the Device Tree Alias""" uevent_path = "/sys/bus/platform/devices/" + device + "/uevent" - with open(uevent_path, 'r') as fd: + with open(uevent_path, "r") as fd: pattern = r"^OF_ALIAS_0=(.*)$" - uevent = fd.read().split('\n') + uevent = fd.read().split("\n") for line in uevent: match = re.search(pattern, line) if match: