文章目录
1 查看当前系统gpio配置信息
sudo cat /sys/kernel/debug/gpio
2 orin / nano gpio
2.1 GPIO 映射表
orin 平台提供了一个 xls 表,可通过它生成dtb 设备树,同样可以看到管脚的定义:
Jetson_Orin_NX_and_Orin_Nano_series_Pinmux_Config_Template.xlsm
2.2 nano 平台对外提供的2排端口表
https://jetsonhacks.com/nvidia-jetson-orin-nano-gpio-header-pinout/
3 配置GPIO 电平
3.1 通过指令配置普通GPIO高电平
配置gpio 9为高电平
nano@orin-nano:/sys/class/gpio$ sudo -s
[sudo] password for nano:
root@orin-nano:/sys/class/gpio# echo 492 > /sys/class/gpio/export
root@orin-nano:/sys/class/gpio# ls
export gpiochip316 gpiochip348 PAC.06 unexport
root@orin-nano:/sys/class/gpio/PAC.06# echo out > direction
root@orin-nano:/sys/class/gpio/PAC.06# echo 1 > value
root@orin-nano:/sys/class/gpio/PAC.06#
cat /sys/kernel/debug/gpio
3.2 通过设备树配置普通GPIO高电平
3.3 配置特定 gpio 高电平 GPIO_AON
AON 特定管脚,使用的宏, GPIO6 代表的就是 CC , 3
/*
* Copyright (c) 2021-2023, Fangzhu Tech Corp. All rights reserved.
* Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <t234-common-modules/tegra234-camera-imx459-a00.dtsi>
#include "dt-bindings/clock/tegra234-clock.h"
#define CAM0_PWDN TEGRA234_MAIN_GPIO(H, 6) //Pin93 --- UART4_CTS L49/397 - MAX9296_1 PWDN
#define CAM1_PWDN TEGRA234_MAIN_GPIO(H, 3) //Pin95 --- UART4_TX L5/394 - MAX9296_2 PWDN
#define CAM2_PWDN TEGRA234_MAIN_GPIO(AC, 0) //Pin90 --- GPIO15 F10/486 - MAX9296_3 PWDN
#define CAM3_PWDN TEGRA234_MAIN_GPIO(AC, 1) //Pin92 --- GPIO16 E9/487 - MAX9296_4 PWDN
#define CAM_I2C_MUX TEGRA234_AON_GPIO(CC, 3) //配置GPIO6 为高电平
#define GPIO_09 TEGRA234_MAIN_GPIO(AC, 6) //GPIO09
#define CAMERA_I2C_MUX_BUS(x) (0x1E + x)
/* camera control gpio definitions */
/ {
gpio@2200000 {
cam-pwdn-high {
gpio-hog;
output-high;
gpios = <CAM0_PWDN 0 CAM1_PWDN 0
CAM2_PWDN 0 CAM3_PWDN 0>;
label = "cam0-pwdn", "cam1-pwdn",
"cam2-pwdn", "cam3-pwdn";
};
};
gpio@c2f0000{
cam-i2cmux-high{
gpio-hog;
output-high;
gpios = <CAM_I2C_MUX 0>;
label = "cam-i2c-mux";
};
};
i2c@3180000 {
imx459_1a@1a {
/* Define any required hw resources needed by driver */
/* ie. clocks, io pins, power sources */
clocks = <&bpmp_clks TEGRA234_CLK_EXTPERIPH1>,
<&bpmp_clks TEGRA234_CLK_EXTPERIPH1>;
clock-names = "extperiph1", "pllp_grtba";
mclk = "extperiph1";
channel = <0>;
};
imx459_1b@1b {
/* Define any required hw resources needed by driver */
/* ie. clocks, io pins, power sources */
clocks = <&bpmp_clks TEGRA234_CLK_EXTPERIPH1>,
<&bpmp_clks TEGRA234_CLK_EXTPERIPH1>;
clock-names = "extperiph1", "pllp_grtba";
mclk = "extperiph1";
channel = <1>;
};
};
};