-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #891 from Dangku/main
support bananapi m4berry, m4zero and f3
- Loading branch information
Showing
13 changed files
with
570 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Pin definitions for the Banana Pi F3.""" | ||
|
||
from adafruit_blinka.microcontroller.spacemit.k1 import pin | ||
|
||
# I2C | ||
I2C4_SCL = pin.I2C4_SCL | ||
I2C4_SDA = pin.I2C4_SDA | ||
|
||
# Default I2C | ||
SCL = I2C4_SCL | ||
SDA = I2C4_SDA | ||
|
||
# UART | ||
UART0_TX = pin.UART0_TX | ||
UART0_RX = pin.UART0_RX | ||
|
||
# Default UART | ||
TX = UART0_TX | ||
RX = UART0_RX | ||
TXD = UART0_TX | ||
RXD = UART0_RX | ||
|
||
# SPI | ||
SPI3_MOSI = pin.SPI3_MOSI | ||
SPI3_MISO = pin.SPI3_MISO | ||
SPI3_SCLK = pin.SPI3_SCLK | ||
SPI3_CS0 = pin.SPI3_CS0 | ||
|
||
# Default SPI | ||
MOSI = SPI3_MOSI | ||
MISO = SPI3_MISO | ||
SCLK = SPI3_SCLK | ||
CS = SPI3_CS0 | ||
|
||
# Pinout reference: | ||
# https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Berry#BPI-M4_Berry_40-pin_header | ||
D3 = pin.GPIO_52 | ||
D5 = pin.GPIO_51 | ||
D7 = pin.GPIO_70 | ||
D8 = pin.GPIO_47 | ||
D10 = pin.GPIO_48 | ||
D11 = pin.GPIO_71 | ||
D12 = pin.GPIO_74 | ||
D13 = pin.GPIO_72 | ||
D15 = pin.GPIO_73 | ||
D16 = pin.GPIO_91 | ||
D18 = pin.GPIO_92 | ||
D19 = pin.GPIO_77 | ||
D21 = pin.GPIO_78 | ||
D22 = pin.GPIO_49 | ||
D23 = pin.GPIO_75 | ||
D24 = pin.GPIO_76 | ||
D26 = pin.GPIO_50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Pin definitions for the Banana Pi M4 Berry.""" | ||
|
||
from adafruit_blinka.microcontroller.allwinner.h618 import pin | ||
|
||
# I2C | ||
I2C3_SCL = pin.TWI3_SCL | ||
I2C3_SDA = pin.TWI3_SDA | ||
I2C4_SCL = pin.TWI4_SCL | ||
I2C4_SDA = pin.TWI4_SDA | ||
|
||
# Default I2C | ||
SCL = I2C4_SCL | ||
SDA = I2C4_SDA | ||
|
||
# UART | ||
UART1_TX = pin.UART1_TX | ||
UART1_RX = pin.UART1_RX | ||
UART5_TX = pin.UART5_TX | ||
UART5_RX = pin.UART5_RX | ||
|
||
# Default UART | ||
TX = UART1_TX | ||
RX = UART1_RX | ||
TXD = UART1_TX | ||
RXD = UART1_RX | ||
|
||
# SPI | ||
SPI1_MOSI = pin.SPI1_MOSI | ||
SPI1_MISO = pin.SPI1_MISO | ||
SPI1_SCLK = pin.SPI1_SCLK | ||
SPI1_CS0 = pin.SPI1_CS0 | ||
|
||
# Default SPI | ||
MOSI = SPI1_MOSI | ||
MISO = SPI1_MISO | ||
SCLK = SPI1_SCLK | ||
CS = SPI1_CS0 | ||
|
||
# Pinout reference: | ||
# https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Berry#BPI-M4_Berry_40-pin_header | ||
D3 = pin.PG16 | ||
D5 = pin.PG15 | ||
D7 = pin.PG19 | ||
D8 = pin.PG6 | ||
D10 = pin.PG7 | ||
D11 = pin.PH2 | ||
D12 = pin.PG11 | ||
D13 = pin.PH3 | ||
D15 = pin.PG2 | ||
D16 = pin.PG8 | ||
D18 = pin.PG9 | ||
D19 = pin.PH7 | ||
D21 = pin.PH8 | ||
D22 = pin.PG1 | ||
D23 = pin.PH6 | ||
D24 = pin.PH5 | ||
D26 = pin.PH9 | ||
D27 = pin.PG18 | ||
D28 = pin.PG17 | ||
D29 = pin.PG3 | ||
D31 = pin.PG4 | ||
D32 = pin.PG0 | ||
D33 = pin.PG5 | ||
D35 = pin.PG12 | ||
D36 = pin.PH4 | ||
D37 = pin.PG10 | ||
D38 = pin.PG14 | ||
D40 = pin.PG13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Pin definitions for the Banana Pi M4 Zero.""" | ||
|
||
from adafruit_blinka.microcontroller.allwinner.h618 import pin | ||
|
||
# I2C | ||
I2C0_SCL = pin.TWI0_SCL | ||
I2C0_SDA = pin.TWI0_SDA | ||
I2C1_SCL = pin.TWI1_SCL | ||
I2C1_SDA = pin.TWI1_SDA | ||
|
||
# Default I2C | ||
SCL = I2C0_SCL | ||
SDA = I2C0_SDA | ||
|
||
# UART | ||
UART4_TX = pin.UART4_TX | ||
UART4_RX = pin.UART4_RX | ||
UART5_TX = pin.UART5_TX | ||
UART5_RX = pin.UART5_RX | ||
|
||
# Default UART | ||
TX = UART4_TX | ||
RX = UART4_RX | ||
TXD = UART4_TX | ||
RXD = UART4_RX | ||
|
||
# SPI | ||
SPI1_MOSI = pin.SPI1_MOSI | ||
SPI1_MISO = pin.SPI1_MISO | ||
SPI1_SCLK = pin.SPI1_SCLK | ||
SPI1_CS0 = pin.SPI1_CS0 | ||
|
||
# Default SPI | ||
MOSI = SPI1_MOSI | ||
MISO = SPI1_MISO | ||
SCLK = SPI1_SCLK | ||
CS = SPI1_CS0 | ||
|
||
# Pinout reference: | ||
# https://wiki.banana-pi.org/Banana_Pi_BPI-M4_Zero#BPI-M4_Zero_40-pin_header | ||
D3 = pin.PI6 | ||
D5 = pin.PI5 | ||
D7 = pin.PI12 | ||
D8 = pin.PI13 | ||
D10 = pin.PI14 | ||
D11 = pin.PH2 | ||
D12 = pin.PI1 | ||
D13 = pin.PH3 | ||
D15 = pin.PI11 | ||
D16 = pin.PI15 | ||
D18 = pin.PI16 | ||
D19 = pin.PH7 | ||
D21 = pin.PH8 | ||
D22 = pin.PC2 | ||
D23 = pin.PH6 | ||
D24 = pin.PH5 | ||
D26 = pin.PH9 | ||
D27 = pin.PI8 | ||
D28 = pin.PI7 | ||
D29 = pin.PI10 | ||
D31 = pin.PI9 | ||
D32 = pin.PH4 | ||
D33 = pin.PH10 | ||
D35 = pin.PI2 | ||
D36 = pin.PC7 | ||
D37 = pin.PI0 | ||
D38 = pin.PI4 | ||
D40 = pin.PI3 |
4 changes: 4 additions & 0 deletions
4
src/adafruit_blinka/microcontroller/allwinner/h618/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Definition for the AllWinner H618 chip""" |
163 changes: 163 additions & 0 deletions
163
src/adafruit_blinka/microcontroller/allwinner/h618/pin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Allwinner H618 Pin Names""" | ||
import re | ||
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin | ||
|
||
|
||
def find_gpiochip_number(target_label): | ||
"""Get correct gpiochip number, legacy kernel and mainline kernel are different""" | ||
try: | ||
with open("/sys/kernel/debug/gpio", "r") as f: | ||
lines = f.readlines() | ||
except FileNotFoundError: | ||
print("The file /sys/kernel/debug/gpio does not exist.") | ||
return None | ||
|
||
gpiochip_number = None | ||
for line in lines: | ||
if target_label in line: | ||
match = re.search(r"gpiochip(\d+)", line) | ||
if match: | ||
gpiochip_number = match.group(1) | ||
break | ||
|
||
return gpiochip_number | ||
|
||
|
||
if find_gpiochip_number("300b000.pinctrl"): | ||
__chip_num = 1 | ||
else: | ||
__chip_num = 0 | ||
|
||
PC0 = Pin((__chip_num, 64)) | ||
SPI0_SCLK = PC0 | ||
PC1 = Pin((__chip_num, 65)) | ||
PC2 = Pin((__chip_num, 66)) | ||
SPI0_MOSI = PC2 | ||
PC3 = Pin((__chip_num, 67)) | ||
SPI0_CS0 = PC3 | ||
PC4 = Pin((__chip_num, 68)) | ||
SPI0_MISO = PC4 | ||
PC5 = Pin((__chip_num, 69)) | ||
PC6 = Pin((__chip_num, 70)) | ||
PC7 = Pin((__chip_num, 71)) | ||
PC8 = Pin((__chip_num, 72)) | ||
PC9 = Pin((__chip_num, 73)) | ||
PC10 = Pin((__chip_num, 74)) | ||
PC11 = Pin((__chip_num, 75)) | ||
PC12 = Pin((__chip_num, 76)) | ||
PC13 = Pin((__chip_num, 77)) | ||
PC14 = Pin((__chip_num, 78)) | ||
PC15 = Pin((__chip_num, 79)) | ||
|
||
PF0 = Pin((__chip_num, 160)) | ||
PF1 = Pin((__chip_num, 161)) | ||
PF2 = Pin((__chip_num, 162)) | ||
PF3 = Pin((__chip_num, 163)) | ||
PF4 = Pin((__chip_num, 164)) | ||
PF5 = Pin((__chip_num, 165)) | ||
PF6 = Pin((__chip_num, 166)) | ||
|
||
PG0 = Pin((__chip_num, 192)) | ||
PG1 = Pin((__chip_num, 193)) | ||
PG2 = Pin((__chip_num, 194)) | ||
PG3 = Pin((__chip_num, 195)) | ||
PG4 = Pin((__chip_num, 196)) | ||
PG5 = Pin((__chip_num, 197)) | ||
PG6 = Pin((__chip_num, 198)) | ||
UART1_TX = PG6 | ||
PG7 = Pin((__chip_num, 199)) | ||
UART1_RX = PG7 | ||
PG8 = Pin((__chip_num, 200)) | ||
PG9 = Pin((__chip_num, 201)) | ||
PG10 = Pin((__chip_num, 202)) | ||
PG11 = Pin((__chip_num, 203)) | ||
PG12 = Pin((__chip_num, 204)) | ||
PG13 = Pin((__chip_num, 205)) | ||
PG14 = Pin((__chip_num, 206)) | ||
PG15 = Pin((__chip_num, 207)) | ||
TWI4_SCL = PG15 | ||
PG16 = Pin((__chip_num, 208)) | ||
TWI4_SDA = PG16 | ||
PG17 = Pin((__chip_num, 209)) | ||
TWI3_SCL = PG17 | ||
PG18 = Pin((__chip_num, 210)) | ||
TWI3_SDA = PG18 | ||
PG19 = Pin((__chip_num, 211)) | ||
PWM1 = PG19 | ||
|
||
PH0 = Pin((__chip_num, 224)) | ||
PH1 = Pin((__chip_num, 225)) | ||
PH2 = Pin((__chip_num, 226)) | ||
UART5_TX = PH2 | ||
PH3 = Pin((__chip_num, 227)) | ||
UART5_RX = PH3 | ||
PH4 = Pin((__chip_num, 228)) | ||
PH5 = Pin((__chip_num, 229)) | ||
UART2_TX = PH5 | ||
SPI1_CS0 = PH5 | ||
PH6 = Pin((__chip_num, 230)) | ||
UART2_RX = PH6 | ||
SPI1_SCLK = PH6 | ||
PH7 = Pin((__chip_num, 231)) | ||
SPI1_MOSI = PH7 | ||
PH8 = Pin((__chip_num, 232)) | ||
SPI1_MISO = PH8 | ||
PH9 = Pin((__chip_num, 233)) | ||
SPI1_CS1 = PH9 | ||
PH10 = Pin((__chip_num, 234)) | ||
|
||
PI0 = Pin((__chip_num, 256)) | ||
PI1 = Pin((__chip_num, 257)) | ||
PI2 = Pin((__chip_num, 258)) | ||
PI3 = Pin((__chip_num, 259)) | ||
PI4 = Pin((__chip_num, 260)) | ||
PI5 = Pin((__chip_num, 261)) | ||
TWI0_SCL = PI5 | ||
PI6 = Pin((__chip_num, 262)) | ||
TWI0_SDA = PI6 | ||
PI7 = Pin((__chip_num, 263)) | ||
TWI1_SCL = PI7 | ||
PI8 = Pin((__chip_num, 264)) | ||
TWI1_SDA = PI8 | ||
PI9 = Pin((__chip_num, 265)) | ||
UART3_TX = PI9 | ||
PI10 = Pin((__chip_num, 266)) | ||
UART3_RX = PI10 | ||
PI11 = Pin((__chip_num, 267)) | ||
PI12 = Pin((__chip_num, 268)) | ||
PWM2 = PI12 | ||
PI13 = Pin((__chip_num, 269)) | ||
UART4_TX = PI13 | ||
PI14 = Pin((__chip_num, 270)) | ||
UART4_RX = PI14 | ||
PI15 = Pin((__chip_num, 271)) | ||
PI16 = Pin((__chip_num, 272)) | ||
|
||
i2cPorts = ( | ||
(0, TWI0_SCL, TWI0_SDA), | ||
(1, TWI1_SCL, TWI1_SDA), | ||
(3, TWI3_SCL, TWI3_SDA), | ||
(4, TWI4_SCL, TWI4_SDA), | ||
) | ||
# ordered as spiId, sckId, mosiId, misoId | ||
spiPorts = ( | ||
(0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO), | ||
(1, SPI1_SCLK, SPI1_MOSI, SPI1_MISO), | ||
) | ||
# ordered as uartId, txId, rxId | ||
uartPorts = ( | ||
(1, UART1_TX, UART1_RX), | ||
(2, UART2_TX, UART2_RX), | ||
(3, UART3_TX, UART3_RX), | ||
(4, UART4_TX, UART4_RX), | ||
(5, UART5_TX, UART5_RX), | ||
) | ||
|
||
# SysFS pwm outputs, pwm channel and pin in first tuple | ||
pwmOuts = [ | ||
((0, 1), PWM1), | ||
((0, 2), PWM2), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Definition of all Spacemit chips""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
"""Definition for the Spacemit K1 chip""" |
Oops, something went wrong.