X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/c3bfd01efa31a426ec6eb258598b1871bb04a178..db9616f6d0c1e0889f6e67c611c898ad43f9bc35:/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py diff --git a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py index d367e27..a32a077 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py +++ b/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py @@ -1,9 +1,12 @@ # SPDX-FileCopyrightText: 2022 Kenneth Ryerson +# SPDX-FileCopyrightText: 2023 Steve Jeong for Hardkernel # # SPDX-License-Identifier: MIT """A Pin class for use with Rockchip RK3566.""" +from adafruit_blinka.agnostic import detector +from adafruit_blinka.microcontroller.alias import get_dts_alias, get_pwm_chipid from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin GPIO0_A2 = Pin((0, 2)) @@ -11,9 +14,13 @@ GPIO0_A4 = Pin((0, 4)) GPIO0_A5 = Pin((0, 5)) GPIO0_B1 = Pin((0, 9)) GPIO0_B2 = Pin((0, 10)) +GPIO0_B3 = Pin((0, 11)) +GPIO0_B4 = Pin((0, 12)) GPIO0_B5 = Pin((0, 13)) GPIO0_B6 = Pin((0, 14)) GPIO0_B7 = Pin((0, 15)) +GPIO0_C0 = Pin((0, 16)) +GPIO0_C1 = Pin((0, 17)) GPIO0_C2 = Pin((0, 18)) GPIO0_C3 = Pin((0, 19)) GPIO0_C5 = Pin((0, 21)) @@ -38,13 +45,32 @@ GPIO1_D7 = Pin((1, 31)) GPIO2_A0 = Pin((2, 0)) GPIO2_A1 = Pin((2, 1)) GPIO2_A2 = Pin((2, 2)) +GPIO2_A3 = Pin((2, 3)) +GPIO2_A4 = Pin((2, 4)) +GPIO2_A5 = Pin((2, 5)) +GPIO2_A6 = Pin((2, 6)) +GPIO2_A7 = Pin((2, 7)) +GPIO2_B0 = Pin((2, 8)) +GPIO2_B1 = Pin((2, 9)) +GPIO2_B2 = Pin((2, 10)) +GPIO2_B3 = Pin((2, 11)) +GPIO2_B4 = Pin((2, 12)) +GPIO2_B5 = Pin((2, 13)) +GPIO2_B6 = Pin((2, 14)) +GPIO2_B7 = Pin((2, 15)) +GPIO2_C0 = Pin((3, 16)) GPIO2_C3 = Pin((2, 19)) GPIO2_C4 = Pin((2, 20)) GPIO2_C5 = Pin((2, 21)) GPIO2_C6 = Pin((2, 22)) +GPIO3_A1 = Pin((3, 1)) +GPIO3_A2 = Pin((3, 2)) +GPIO3_A3 = Pin((3, 3)) +GPIO3_A4 = Pin((3, 4)) GPIO3_A5 = Pin((3, 5)) GPIO3_A6 = Pin((3, 6)) GPIO3_A7 = Pin((3, 7)) +GPIO3_B0 = Pin((3, 8)) GPIO3_B1 = Pin((3, 9)) GPIO3_B2 = Pin((3, 10)) GPIO3_B3 = Pin((3, 11)) @@ -91,6 +117,8 @@ ADC_AIN3 = 37 # I2C I2C0_SCL = GPIO0_B1 I2C0_SDA = GPIO0_B2 +I2C1_SCL = GPIO0_B3 +I2C1_SDA = GPIO0_B4 I2C2_SCL_M0 = GPIO0_B5 I2C2_SDA_M0 = GPIO0_B6 I2C2_SCL_M1 = GPIO4_B5 @@ -129,23 +157,71 @@ PWM0 = GPIO0_B7 PWM1 = GPIO0_C7 # ordered as i2cId, SCL, SDA -i2cPorts = ( +i2cPorts = [ + (1, I2C1_SCL, I2C1_SDA), (2, I2C2_SCL_M0, I2C2_SDA_M0), (3, I2C3_SCL_M0, I2C3_SDA_M0), (5, I2C5_SCL_M0, I2C5_SDA_M0), -) +] # ordered as spiId, sckId, mosiId, misoId -spiPorts = ( +spiPorts = [ (3, SPI3_CLK_M0, SPI3_MOSI_M0, SPI3_MISO_M0), (3, SPI3_CLK_M1, SPI3_MOSI_M1, SPI3_MISO_M1), -) +] # SysFS pwm outputs, pwm channel and pin in first tuple -pwmOuts = ( +pwmOuts = [ ((0, 0), PWM0), ((0, 0), PWM1), -) +] + +uartPorts = [] # SysFS analog inputs, Ordered as analog analogInId, device, and channel -analogIns = ((ADC_AIN3, 0, 3),) +analogIns = [ + (ADC_AIN3, 0, 3), +] + +board = detector.board.id +if board in ("ODROID_M1S"): + analogIns.append((40, 0, 2)) + alias = get_dts_alias("fe5c0000.i2c") + if alias is not None: + globals()[alias + "_SCL"] = GPIO3_B5 + globals()[alias + "_SDA"] = GPIO3_B6 + i2cPorts.append((int(alias[-1]), GPIO3_B5, GPIO3_B6)) + alias = get_pwm_chipid("fdd70010.pwm") + if alias is not None: + globals()["PWM" + alias] = GPIO0_B5 + pwmOuts.append(((int(alias[-1]), 0), GPIO0_B5)) + alias = get_pwm_chipid("fdd70020.pwm") + if alias is not None: + globals()["PWM" + alias] = GPIO0_B6 + pwmOuts.append(((int(alias[-1]), 0), GPIO0_B6)) + alias = get_pwm_chipid("fdd70030.pwm") + if alias is not None: + globals()["PWM" + alias] = GPIO0_C2 + pwmOuts.append(((int(alias[-1]), 0), GPIO0_C2)) + alias = get_dts_alias("fe620000.spi") + if alias is not None: + globals()[alias + "_CLK"] = GPIO3_C3 + globals()[alias + "_MOSI"] = GPIO3_C1 + globals()[alias + "_MISO"] = GPIO3_C2 + spiPorts.append((int(alias[-1]), GPIO3_C3, GPIO3_C1, GPIO3_C2)) + alias = get_dts_alias("fdd50000.serial") + if alias is not None: + globals()[alias + "_TX"] = GPIO0_C1 + globals()[alias + "_RX"] = GPIO0_C0 + uartPorts.append((int(alias[-1]), GPIO0_C1, GPIO0_C0)) + alias = get_dts_alias("fe6a0000.serial") + if alias is not None: + globals()[alias + "_TX"] = GPIO2_A4 + globals()[alias + "_RX"] = GPIO2_A3 + uartPorts.append((int(alias[-1]), GPIO2_A4, GPIO2_A3)) + +analogIns = tuple(analogIns) +i2cPorts = tuple(i2cPorts) +pwmOuts = tuple(pwmOuts) +spiPorts = tuple(spiPorts) +uartPorts = tuple(uartPorts)