NVIDIA GPIO

  • NVIDIA ORIN GPIO
  • NVIDIA Xavier GPIO

1.NVIDIA ORIN GPIO

  Identifying the GPIO Number

  If you designed your own carrier board, to translate from SOM connector pins to actual GPIO numbers, you must understand the following GPIO mapping formula. The translated GPIO numbers can be controlled by the driver.

  Because the Jetson module dynamically registers GPIOs, search the kernel messages to check the GPIO allocation ranges for each GPIO group. The command and resulting output are similar to the following:

root@jetson:/home/ubuntu# **dmesg** | **grep gpiochip**
[    5.726492] gpiochip0: registered GPIOs 348 to 511 on **tegra234-gpio**
[    5.732478] gpiochip1: registered GPIOs 316 to 347 on **tegra234-gpio-aon**

  As shown in the output above, there are two Jetson GPIO ports with different base indices:

  • tegra234-gpio, at base index 348
  • tegra234-gpio-aon, at base index 316

You can check the GPIO number in one of the following ways:

  • Using a calculation.

    Before you get started, you need to know how you plan to configure the offset at each available port.

  Here is the list of the tegra234 GPIO ports and offset mapping:
在这里插入图片描述

  • Search for the pin details from the Orin pinmux table (see Pinmux Changes).

    For example SOC_GPIO08, which is GPIO3_PB.00.

  • Identify the port as B and the Pin_offset as 0.

  • Calculate the pin number with the following formula:
    base + port_offset + pin_offset

  • Verify the following values:

    • The base is 348.
      This value comes from the kernel boot log, it is already noted tegra234-gpio, at base index 348.

    • port_offset of port B = 8
      This value comes from the tegra234 GPIO port and the offset mapping above.

    • pin_offset = 0

    • Pin number = 348 + 8 + 0 = 356

  • Using Kernel debugfs.

    • Search for the gpio pin in the Jetson AGX Orin pinmux table (see Pinmux Changes).
      For example, SOC_GPIO08, which is GPIO3_PB.00.

    • Follow the gpio debugfs look up that use the port and offset.
      cat /sys/kernel/debug/gpio | grep PB.00

    • The gpio number is mentioned in the first col as gpio-356.
      root@jetson:/home/ubuntu# cat /sys/kernel/debug/gpio | grep PB.00 gpio-356 (PB.00)

Note:
  To use a pin as GPIO, make sure that E_IO_HV field is disabled in corresponding pinmux register of the GPIO pin. You can disable the field 3.3V Tolerance Enable in pinmux spreadsheet and reflash the board with the updated pinmux file.

例如:
Jetson_AGX_Orin_Series_Pinmux_Config_Template_1.8

  • 设置H60 the field 3.3V Tolerance Disable
    在这里插入图片描述
    生成的pinmux文件:
  • nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
    在这里插入图片描述

2.Xavier Linux GPIO

linux/include/dt-bindings/gpio/tegra194-gpio.h

#ifndef _DT_BINDINGS_GPIO_TEGRA194_GPIO_H
#define _DT_BINDINGS_GPIO_TEGRA194_GPIO_H

#include <dt-bindings/gpio/gpio.h>

/* GPIOs implemented by main GPIO controller */
#define TEGRA194_MAIN_GPIO_PORT_A 0
#define TEGRA194_MAIN_GPIO_PORT_B 1
#define TEGRA194_MAIN_GPIO_PORT_C 2
#define TEGRA194_MAIN_GPIO_PORT_D 3
#define TEGRA194_MAIN_GPIO_PORT_E 4
#define TEGRA194_MAIN_GPIO_PORT_F 5
#define TEGRA194_MAIN_GPIO_PORT_G 6
#define TEGRA194_MAIN_GPIO_PORT_H 7
#define TEGRA194_MAIN_GPIO_PORT_I 8
#define TEGRA194_MAIN_GPIO_PORT_J 9
#define TEGRA194_MAIN_GPIO_PORT_K 10
#define TEGRA194_MAIN_GPIO_PORT_L 11
#define TEGRA194_MAIN_GPIO_PORT_M 12
#define TEGRA194_MAIN_GPIO_PORT_N 13
#define TEGRA194_MAIN_GPIO_PORT_O 14
#define TEGRA194_MAIN_GPIO_PORT_P 15
#define TEGRA194_MAIN_GPIO_PORT_Q 16
#define TEGRA194_MAIN_GPIO_PORT_R 17
#define TEGRA194_MAIN_GPIO_PORT_S 18
#define TEGRA194_MAIN_GPIO_PORT_T 19
#define TEGRA194_MAIN_GPIO_PORT_U 20
#define TEGRA194_MAIN_GPIO_PORT_V 21
#define TEGRA194_MAIN_GPIO_PORT_W 22
#define TEGRA194_MAIN_GPIO_PORT_X 23
#define TEGRA194_MAIN_GPIO_PORT_Y 24
#define TEGRA194_MAIN_GPIO_PORT_Z 25
#define TEGRA194_MAIN_GPIO_PORT_FF 26
#define TEGRA194_MAIN_GPIO_PORT_GG 27

#define TEGRA194_MAIN_GPIO(port, offset) \
    ((TEGRA194_MAIN_GPIO_PORT_##port * 8) + offset)

/* GPIOs implemented by AON GPIO controller */
#define TEGRA194_AON_GPIO_PORT_AA 0
#define TEGRA194_AON_GPIO_PORT_BB 1
#define TEGRA194_AON_GPIO_PORT_CC 2
#define TEGRA194_AON_GPIO_PORT_DD 3
#define TEGRA194_AON_GPIO_PORT_EE 4

#define TEGRA194_AON_GPIO(port, offset) \
    ((TEGRA194_AON_GPIO_PORT_##port * 8) + offset)

#endif

基地值:

tegra-gpio, at base index 288
tegra-gpio-aon, at base index 248

查看 Jetson AGX Xavier Pinmux表格, 对应 GPIO3_PZ.03
tegra194-gpio.h定义:
#define TEGRA194_MAIN_GPIO_PORT_Z 25

TEGRA194_MAIN_GPIO, 即tegra-gpio, 基值为288
Linux GPIO计算结果: 25*8 + 288 + 3 = 491

refer to
  https://docs.nvidia.com/jetson/archives/r35.1/DeveloperGuide/text/HR/JetsonModuleAdaptationAndBringUp/JetsonAgxOrinSeries.html#pinmux-changes

### NVIDIA Orin 平台上的 GPIO 配置与使用 在NVIDIA Orin平台上,GPIO模式设置需遵循特定的标准。模式应被设定为`GPIO.BOARD`, `GPIO.BCM`, `GPIO.CVM`, `GPIO.TEGRA_SOC` 或者 `None`之一[^1]。 对于具体信号的配置和读取操作,在Orin平台下通常通过访问指定子目录来完成。该子目录用于配置并读取具体的GPIO信号[^2]。例如,当需要控制某个GPIO引脚的状态时,可以通过文件系统中的相应路径来进行写入或读取操作: ```bash echo "high" > /sys/class/gpio/gpio4/value # 设置GPIO4为高电平 cat /sys/class/gpio/gpio4/value # 读取GPIO4当前状态 ``` 针对ARM Linux内核环境下的硬件驱动开发工作涉及到编写适用于目标板件特性的驱动程序以及调试过程中遇到的各种问题。这同样适用于基于NVIDIA Orin架构的产品线,其中包含了对GPIO接口的支持实现[^3]。 为了更好地理解如何在NVIDIA Orin上进行GPIO编程,下面给出一段Python代码片段作为示范,展示怎样利用RPi.GPIO库(或其他兼容库)初始化并操控GPIO端口: ```python import RPi.GPIO as GPIO # 使用BCM编号方式定义管脚 GPIO.setmode(GPIO.TEGRA_SOC) # 设定GPIO0_PCC1 (TEGRA_SOC 编号) 输出方向,并拉低初始电位 pin = 'GPIO_PE7' GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, GPIO.LOW) try: while True: pass finally: GPIO.cleanup() # 清理资源 ``` 需要注意的是上述例子假设存在一个支持Tegra SoC命名约定版本的RPi.GPIO扩展包;实际应用中可能需要根据具体情况调整导入模块名称或者其他细节部分。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值