Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Zero2/Hardware/GPIO"

(Created page with "{{Zero2_header}} {{Languages|Zero2/Hardware/GPIO}} Radxa Zero 2 > Hardware > GPIO == <span id="gpio">General pur...")
 
 
(25 intermediate revisions by 2 users not shown)
Line 12: Line 12:
 
|- style="font-weight:bold; text-align:center; background-color:#F2F2F2;"
 
|- style="font-weight:bold; text-align:center; background-color:#F2F2F2;"
 
! GPIO number
 
! GPIO number
 +
! Function6
 +
! Function5
 
! Function4
 
! Function4
 
! Function3
 
! Function3
Line 23: Line 25:
 
! Function3
 
! Function3
 
! Function4
 
! Function4
 +
! Function5
 +
! Function6
 
! GPIO number
 
! GPIO number
 
|-
 
|-
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 36: Line 42:
 
|  
 
|  
 
|  
 
|  
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
 
|-
 
|-
 
| 490
 
| 490
 +
|
 
|  
 
|  
 
|  
 
|  
 
| I2C_EE_M3_SDA
 
| I2C_EE_M3_SDA
 +
| WORLD_SYNC
 
| GPIOA_14
 
| GPIOA_14
 
| style="background-color:#008000; color:#FFF;" | 3
 
| style="background-color:#008000; color:#FFF;" | 3
Line 48: Line 58:
 
| style="background-color:#F00;" | 4
 
| style="background-color:#F00;" | 4
 
| +5.0V
 
| +5.0V
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 54: Line 66:
 
|-
 
|-
 
| 491
 
| 491
 +
|
 
|  
 
|  
 
|  
 
|  
 
| I2C_EE_M3_SCL
 
| I2C_EE_M3_SCL
 +
| IR_REMOTE_IN
 
| GPIOA_15
 
| GPIOA_15
 
| style="background-color:#008000; color:#FFF;" | 5
 
| style="background-color:#008000; color:#FFF;" | 5
Line 62: Line 76:
 
| style="background-color:#000; color:#FFF" | 6
 
| style="background-color:#000; color:#FFF" | 6
 
| GND
 
| GND
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 67: Line 83:
 
|  
 
|  
 
|-
 
|-
| 415
+
| 429
| I2C_AO_S0_SDA
+
|  
| UART_AO_B_RX
+
| TDMC_DIN0
| I2C_AO_M0_SDA
+
| TDMC_D0
| GPIOAO_3
+
| TSIN_B_VALID
 +
| PWM_D
 +
| GPIOZ_2
 
| style="background-color:#008000; color:#FFF;" | 7
 
| style="background-color:#008000; color:#FFF;" | 7
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 8
 
| style="background-color:#008000; color:#FFF;" | 8
 
| GPIOAO_0
 
| GPIOAO_0
| style="background-color:#FFA500;" | UART_AO_A_TXD
+
| UART_AO_A_TX
 +
|
 +
|  
 
|  
 
|  
 
|  
 
|  
 
| 412
 
| 412
 
|-
 
|-
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 90: Line 112:
 
| style="background-color:#008000; color:#FFF;" | 10
 
| style="background-color:#008000; color:#FFF;" | 10
 
| GPIOAO_1
 
| GPIOAO_1
| style="background-color:#FFA500;" | UART_AO_A_RXD
+
| UART_AO_A_RX
 +
|
 +
|  
 
|  
 
|  
 
|  
 
|  
 
| 413
 
| 413
 
|-
 
|-
| 414
+
| 430
| I2C_AO_S0_SCL
+
|  
| UART_AO_B_TX
+
|  
| I2C_AO_M0_SCL
+
| TDMC_DIN1
| GPIOAO_2
+
| TDMC_D1
 +
| TSIN_B_SOP
 +
| GPIOZ_3
 
| style="background-color:#008000; color:#FFF;" | 11
 
| style="background-color:#008000; color:#FFF;" | 11
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 12
 
| style="background-color:#008000; color:#FFF;" | 12
| GPIOX_9
+
| GPIOA_1
| SPI_A_MISO
+
| TDMB_SCLK
 +
| TDMB_SLV_SCLK
 
|  
 
|  
 
|  
 
|  
| 501
+
|  
 +
| 477
 
|-
 
|-
| 503
+
| 431
 
|  
 
|  
| I2C_EE_M1_SCL
+
|  
| SPI_A_SCLK
+
| TDMC_DIN2
| GPIOX_11
+
| TDMC_D2
 +
| TSIN_B_DIN0
 +
| GPIOZ_4
 
| style="background-color:#008000; color:#FFF;" | 13
 
| style="background-color:#008000; color:#FFF;" | 13
 
|  
 
|  
 
| style="background-color:#000; color:#FFF" | 14
 
| style="background-color:#000; color:#FFF" | 14
 
| GND
 
| GND
 +
|
 
|  
 
|  
 
|  
 
|  
Line 123: Line 154:
 
|  
 
|  
 
|-
 
|-
 +
| 432
 
|  
 
|  
 
|  
 
|  
|  
+
| TDMC_DIN3
|  
+
| TDMC_D3
| SARADC_CH1
+
| TSIN_B_CLK
 +
| GPIOZ_5
 
| style="background-color:#008000; color:#FFF;" | 15
 
| style="background-color:#008000; color:#FFF;" | 15
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 16
 
| style="background-color:#008000; color:#FFF;" | 16
| GPIOX_10
+
| GPIOZ_8
| SPI_A_SS0
+
| ETH_RGMII_TX_CLK
| I2C_EE_M1_SDA
+
| BT656_A_DIN4
|  
+
| TSIN_B_DIN2
| 502
+
| MCLK_1
 +
| I2C_EE_M0_SCL
 +
| 435
 
|-
 
|-
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 145: Line 182:
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 18
 
| style="background-color:#008000; color:#FFF;" | 18
| GPIOX_8
+
| GPIOZ_6
| SPI_A_MOSI
+
| TSIN_B_FAIL
| PWM_C
+
| TDMC_FS
 +
| TDMC_SLV_FS
 
|  
 
|  
| 500
+
|  
 +
| 433
 
|-
 
|-
 
| 447
 
| 447
 +
|
 +
|
 
|  
 
|  
 
| SPI_B_MOSI
 
| SPI_B_MOSI
Line 160: Line 201:
 
| style="background-color:#000; color:#FFF" | 20
 
| style="background-color:#000; color:#FFF" | 20
 
| GND
 
| GND
 +
|
 
|  
 
|  
 
|  
 
|  
Line 166: Line 208:
 
|-
 
|-
 
| 448
 
| 448
 +
| TDMB_DIN3
 +
| TDMB_D3
 
| PWM_F
 
| PWM_F
 
| SPI_B_MISO
 
| SPI_B_MISO
Line 173: Line 217:
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 22
 
| style="background-color:#008000; color:#FFF;" | 22
| GPIOC_7
+
| GPIOZ_9
| -
+
| ETH_TXEN
 +
| BT656_A_DIN5
 +
| TSIN_B_DIN3
 
|  
 
|  
 
|  
 
|  
| 475
+
| 436
 
|-
 
|-
 
| 450
 
| 450
 +
|
 +
| PWM_B
 
| I2C_EE_M1_SCL
 
| I2C_EE_M1_SCL
 
| SPI_B_SCLK
 
| SPI_B_SCLK
Line 191: Line 239:
 
| SPI_B_SS0
 
| SPI_B_SS0
 
| I2C_EE_M1_SDA
 
| I2C_EE_M1_SDA
 +
| IR_REMOTE_OUT
 +
|
 
| 449
 
| 449
 
|-
 
|-
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 206: Line 258:
 
|  
 
|  
 
|  
 
|  
|-
 
| 415
 
| I2C_AO_S0_SDA
 
| UART_AO_B_RX
 
| I2C_AO_M0_SDA
 
| GPIOAO_3
 
| style="background-color:#00F; color:#FFF;" | 27
 
 
|  
 
|  
| style="background-color:#00F; color:#FFF;" | 28
 
| GPIOAO_2
 
| I2C_AO_M0_SCL
 
| UART_AO_B_TX
 
| I2C_AO_S0_SCL
 
| 414
 
 
|-
 
|-
 +
| 427
 
|  
 
|  
 
|  
 
|  
 
|  
 
|  
 +
| PWM_B
 +
| I2C_EE_M0_SDA
 +
| GPIOZ_0
 +
| style="background-color:#008000; color:#FFF;" | 27
 
|  
 
|  
| NC
+
| style="background-color:#008000; color:#FFF;" | 28
 +
| GPIOZ_1
 +
| I2C_EE_M0_SCL
 +
| PWM_C
 +
|
 +
 +
|
 +
| 428
 +
|-
 +
| 419
 +
|
 +
|
 +
| TDMB_SLV_FS
 +
| TDMB_FS
 +
| TSIN_A_DIN0
 +
| GPIOAO_7
 
| style="background-color:#008000; color:#FFF;" | 29
 
| style="background-color:#008000; color:#FFF;" | 29
 
|  
 
|  
 
| style="background-color:#000; color:#FFF" | 30
 
| style="background-color:#000; color:#FFF" | 30
 
| GND
 
| GND
 +
|
 
|  
 
|  
 
|  
 
|  
Line 235: Line 295:
 
|  
 
|  
 
|-
 
|-
 +
| 480
 
|  
 
|  
 
|  
 
|  
|  
+
| PWM_D
|  
+
| TDMB_DIN1
| NC
+
| TDMB_D1
 +
| GPIOA_4
 
| style="background-color:#008000; color:#FFF;" | 31
 
| style="background-color:#008000; color:#FFF;" | 31
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 32
 
| style="background-color:#008000; color:#FFF;" | 32
| GPIOAO_4
+
| GPIOA_0
| PWMAO_C
+
| MCLK_0
 
|  
 
|  
 
|  
 
|  
| 416
 
|-
 
 
|  
 
|  
 
|  
 
|  
 +
| 476
 +
|-
 +
| 420
 
|  
 
|  
|  
+
| TDMB_SLV_SCLK
| NC
+
| TDMB_SCLK
 +
| TSIN_A_CLK
 +
| UART_AO_B_TX
 +
| GPIOAO_8
 
| style="background-color:#008000; color:#FFF;" | 33
 
| style="background-color:#008000; color:#FFF;" | 33
 
|  
 
|  
 
| style="background-color:#000; color:#FFF" | 34
 
| style="background-color:#000; color:#FFF" | 34
 
| GND
 
| GND
 +
|
 
|  
 
|  
 
|  
 
|  
Line 263: Line 330:
 
|  
 
|  
 
|-
 
|-
| 420
+
| 478
 
|  
 
|  
 
|  
 
|  
| UART_AO_B_TX
+
|  
| GPIOAO_8
+
| TDMB_SLV_FS
 +
| TDMB_FS
 +
| GPIOA_2
 
| style="background-color:#008000; color:#FFF;" | 35
 
| style="background-color:#008000; color:#FFF;" | 35
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 36
 
| style="background-color:#008000; color:#FFF;" | 36
| GPIOH_8
+
| GPIOA_3
| -
+
| TDMB_D0
 +
| TDMB_DIN0
 
|  
 
|  
 
|  
 
|  
| 451
+
|  
 +
| 479
 
|-
 
|-
 
| 421
 
| 421
 
|  
 
|  
|  
+
| MCLK_0
 +
| TSIN_A_VALID
 
| UART_AO_B_RX
 
| UART_AO_B_RX
 +
| IR_REMOTE_OUT
 
| GPIOAO_9
 
| GPIOAO_9
 
| style="background-color:#008000; color:#FFF;" | 37
 
| style="background-color:#008000; color:#FFF;" | 37
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 38
 
| style="background-color:#008000; color:#FFF;" | 38
| GPIOAO_10
+
| GPIOA_5
| PWMAO_D
+
| PDM_DIN3
 +
| TDMB_DIN2
 +
| TDMB_D2
 
|  
 
|  
 
|  
 
|  
| 422
+
| 481
 
|-
 
|-
 +
|
 +
|
 
|  
 
|  
 
|  
 
|  
Line 299: Line 376:
 
|  
 
|  
 
| style="background-color:#008000; color:#FFF;" | 40
 
| style="background-color:#008000; color:#FFF;" | 40
| GPIOAO_11
+
| GPIOZ_7
| PWMAO_A
+
| I2C_EE_M0_SDA
 +
| TSIN_B_DIN1
 +
| TDMC_SCLK
 +
| TDMC_SLV_SCLK
 
|  
 
|  
|  
+
|434
| 423
+
 
|}
 
|}
  
 
=== More details about 40-pin Header ===
 
=== More details about 40-pin Header ===
* Pins marked with orange color are designed for debug console.
+
 
* I2C: x3; I2C_EE_M1 (/dev/i2c-1), I2C_EE_M3 (/dev/i2c-3), I2C_AO_M0 (/dev/i2c-4)
+
The device number listed below is for reference only. Depending on how many devices you have enabled the number for each can change.
* PWM: x3; PWMAO_A, PWM_C
+
 
* SPI: x2; SPI_A (/dev/spi0.0), SPI_B(/dev/spi1.0)
+
I2C devices (3)
* UART: x3; UART_AO_A (/dev/ttyAML0), UART_AO_B (/dev/ttyAML1), UART_EE_C (/dev/ttyAML4)
+
* I2C_EE_M0 (/dev/i2c-0)
* Pin#22 (GPIOC_7) and Pin#36 (GPIOH_8) are not available in the user space.
+
* I2C_EE_M1 (/dev/i2c-1)
 +
* I2C_EE_M3 (/dev/i2c-3)
 +
 
 +
I2S device (1)
 +
* TDMB
 +
 
 +
PWM devices (4)
 +
* PWM_B (/sys/class/pwm/pwmchip6/pwm1)
 +
* PWM_C (/sys/class/pwm/pwmchip4/pwm0)
 +
* PWM_D (/sys/class/pwm/pwmchip4/pwm1)
 +
* PWM_F (/sys/class/pwm/pwmchip2/pwm1)
 +
 
 +
To use PWM_C and PWM_D together, please use <code>meson-g12b-pwm-c-d-gpioz-1-2</code> overlay instead of individual overlays.
 +
 
 +
UART devices (3)
 +
* UART_AO_A (/dev/ttyAML0)
 +
* UART_AO_B (/dev/ttyAML6)
 +
* UART_EE_C (/dev/ttyAML7)
 +
if you  enable UART_AO_B only or only enable UART_EE_C, the UART device is /dev/ttyAML6, if you enable UART_AO_B and UART_EE_C at the same time,
 +
the device of UART_AO_B is /dev/ttyAML6, and UART_EE_C is /dev/ttyAML7
 +
 
 +
SPI device (1)
 +
* SPI_B (/dev/spidev0.0)
  
 
=== GPIO number ===
 
=== GPIO number ===
* GPIOs are grouped in two banks, GPIO AO domain and GPIO EE domain
 
** AO domain: GPIOAO_0 - GPIOAO_11
 
** EE domain: GPIOA_14 - GPIOA_15 | GPIOH_0 - GPIOH_8 | GPIOX_0 - GPIOX_19
 
* UARTs
 
** AO domain: UARTAO_A | UARTAO_B
 
** EE domain: UART_A | UART_B | UART_C
 
  
 
{| class="wikitable"  
 
{| class="wikitable"  
Line 382: Line 477:
  
 
The base is 492 and the offset is 10. So the GPIOX_10's GPIO number is 492+10=502.
 
The base is 492 and the offset is 10. So the GPIOX_10's GPIO number is 492+10=502.
 +
 +
We recommend you to use [[gpiod]] and libmraa, which support accessing GPIO pins by 40-pin header number, instead of SoC defined GPIO number.

Latest revision as of 03:20, 17 November 2022

 Radxa Zero 2 >  Hardware >  GPIO

General purpose input-output (GPIO) connector

Radxa Zero 2 has a 40-pin expansion header. Each pin is distinguished by color.

GPIO number Function6 Function5 Function4 Function3 Function2 Function1 Pin# Pin# Function1 Function2 Function3 Function4 Function5 Function6 GPIO number
+3.3V 1 2 +5.0V
490 I2C_EE_M3_SDA WORLD_SYNC GPIOA_14 3 4 +5.0V
491 I2C_EE_M3_SCL IR_REMOTE_IN GPIOA_15 5 6 GND
429 TDMC_DIN0 TDMC_D0 TSIN_B_VALID PWM_D GPIOZ_2 7 8 GPIOAO_0 UART_AO_A_TX 412
GND 9 10 GPIOAO_1 UART_AO_A_RX 413
430 TDMC_DIN1 TDMC_D1 TSIN_B_SOP GPIOZ_3 11 12 GPIOA_1 TDMB_SCLK TDMB_SLV_SCLK 477
431 TDMC_DIN2 TDMC_D2 TSIN_B_DIN0 GPIOZ_4 13 14 GND
432 TDMC_DIN3 TDMC_D3 TSIN_B_CLK GPIOZ_5 15 16 GPIOZ_8 ETH_RGMII_TX_CLK BT656_A_DIN4 TSIN_B_DIN2 MCLK_1 I2C_EE_M0_SCL 435
+3.3V 17 18 GPIOZ_6 TSIN_B_FAIL TDMC_FS TDMC_SLV_FS 433
447 SPI_B_MOSI UART_EE_C_RTS GPIOH_4 19 20 GND
448 TDMB_DIN3 TDMB_D3 PWM_F SPI_B_MISO UART_EE_C_CTS GPIOH_5 21 22 GPIOZ_9 ETH_TXEN BT656_A_DIN5 TSIN_B_DIN3 436
450 PWM_B I2C_EE_M1_SCL SPI_B_SCLK UART_EE_C_TX GPIOH_7 23 24 GPIOH_6 UART_EE_C_RX SPI_B_SS0 I2C_EE_M1_SDA IR_REMOTE_OUT 449
GND 25 26 SARADC_CH2
427 PWM_B I2C_EE_M0_SDA GPIOZ_0 27 28 GPIOZ_1 I2C_EE_M0_SCL PWM_C 428
419 TDMB_SLV_FS TDMB_FS TSIN_A_DIN0 GPIOAO_7 29 30 GND
480 PWM_D TDMB_DIN1 TDMB_D1 GPIOA_4 31 32 GPIOA_0 MCLK_0 476
420 TDMB_SLV_SCLK TDMB_SCLK TSIN_A_CLK UART_AO_B_TX GPIOAO_8 33 34 GND
478 TDMB_SLV_FS TDMB_FS GPIOA_2 35 36 GPIOA_3 TDMB_D0 TDMB_DIN0 479
421 MCLK_0 TSIN_A_VALID UART_AO_B_RX IR_REMOTE_OUT GPIOAO_9 37 38 GPIOA_5 PDM_DIN3 TDMB_DIN2 TDMB_D2 481
GND 39 40 GPIOZ_7 I2C_EE_M0_SDA TSIN_B_DIN1 TDMC_SCLK TDMC_SLV_SCLK 434

More details about 40-pin Header

The device number listed below is for reference only. Depending on how many devices you have enabled the number for each can change.

I2C devices (3)

  • I2C_EE_M0 (/dev/i2c-0)
  • I2C_EE_M1 (/dev/i2c-1)
  • I2C_EE_M3 (/dev/i2c-3)

I2S device (1)

  • TDMB

PWM devices (4)

  • PWM_B (/sys/class/pwm/pwmchip6/pwm1)
  • PWM_C (/sys/class/pwm/pwmchip4/pwm0)
  • PWM_D (/sys/class/pwm/pwmchip4/pwm1)
  • PWM_F (/sys/class/pwm/pwmchip2/pwm1)

To use PWM_C and PWM_D together, please use meson-g12b-pwm-c-d-gpioz-1-2 overlay instead of individual overlays.

UART devices (3)

  • UART_AO_A (/dev/ttyAML0)
  • UART_AO_B (/dev/ttyAML6)
  • UART_EE_C (/dev/ttyAML7)

if you enable UART_AO_B only or only enable UART_EE_C, the UART device is /dev/ttyAML6, if you enable UART_AO_B and UART_EE_C at the same time, the device of UART_AO_B is /dev/ttyAML6, and UART_EE_C is /dev/ttyAML7

SPI device (1)

  • SPI_B (/dev/spidev0.0)

GPIO number

GPIO Chip
GPIO Name
Base Offset Formula
First GPIOAO_x 412 0-11 Base + Offset
First GPIOE_x 424 0-2 Base + Offset
Second GPIOZ_x 427 0-15 Base + Offset
Second GPIOH_x 443 0-8 Base + Offset
Second BOOT_x 452 0-15 Base + Offset
Second GPIOC_x 468 0-7 Base + Offset
Second GPIOA_x 476 0-15 Base + Offset
Second GPIOX_x 492 0-19 Base + Offset

Take GPIOX_10 as an example.

The base is 492 and the offset is 10. So the GPIOX_10's GPIO number is 492+10=502.

We recommend you to use gpiod and libmraa, which support accessing GPIO pins by 40-pin header number, instead of SoC defined GPIO number.