How to use Jetson Nano GPIO interrupts node in dts

Hi,
I have Jetson Nano board and would like to add I2C device to dts.
Would like to connect i2c sensor like below.
Here I need to help on how to identify the GPIOx_PINy to map the interrupt-parent and interrupts node.
I am new to Jetson Nano board and need help to enable this sensor.

MAX30102 I2C0 SDA J41.27
MAX30102 I2C0 SCL J41.28
MAX30102 INT pin → J14.7 (GPIO216)

i2c@7000c000 { /* i2c0 */
status = “okay”;
max30100@57 {
compatible = “maxim,max30102”;
reg = <0x57>;
maxim,red-led-current-microamp = <7000>;
maxim,ir-led-current-microamp = <7000>;
interrupt-parent = <&gpiox>;
interrupts = <y 2>;
};
};

Hi @titusec,

You posted to the General Graphics Programming forum. I will move this to the Jetson Nano section for support.

Regards,
Tom

Community Manager NVIDIA Developer Forums | NVIDIA

Thank you.
I am thinking we need to enable something like this, but not sure how can I enable for GPIO216 (J41.7)
Referred to this pinout.

Can you please help with this ? would like to understand the TEGRA_GPIO() how it works.

interrupt-parent = <&gpio>;
interrupts = <TEGRA_GPIO(xx, y) 2>;

Thanks for the help.

hello titusece,

would you like to control GPIO09 / AUD_MCLK / GPIO3_PBB.00?

Linux exposes GPIO as files through sysfs. you may using a user space application (not working in the kernel) then you could use epoll, poll, or select calls to wait for a state change on one or more file descriptors.

you may also refer to the developer guide, if the pin configuration is necessary.
please check Configuring the 40-Pin Expansion Header by using Jetson-IO tool to simplify the pin configuration.
thanks

Thanks JerryChang,
Eventually I would like to map any GPIO (from 40pin header) to driver using dts entry.
i2c@7000c000 { /* i2c0 */
status = “okay”;
max30100@57 {
compatible = “maxim,max30102”;
reg = <0x57>;
maxim,red-led-current-microamp = <7000>;
maxim,ir-led-current-microamp = <7000>;
interrupt-parent = <&gpio>;
interrupts = <X 2>;
};
};
I don’t know what to put in place of ‘X’
Any idea ?

And I am not doing it from user space. So sysfs is not helpful here.

If yes, then how can I use it in my dts entry (what need to be used instead of X & Y) ?
interrupt-parent = <&gpio>;
interrupts = <TEGRA_GPIO(X, Y) 2>;

hello titusece,

please assign GPIO to the device tree field.
for example,
GPIO3_PBB.00, it means TEGRA_GPIO(BB, 0);

you may also refer to below kernel sources for reference,
$L4T_Sources/r32.5/Linux_for_Tegra/source/public/kernel/kernel-4.9/include/dt-bindings/gpio/tegra-gpio.h
thanks

1 Like

Thanks JerryChang, able to compile now, but still my driver doesn’t seems to work for my i2c sensor.

From my kernel dmesg log: I have found that dts is used as ‘tegra210-p3448-0000-p3449-0000-b00.dts
[ 0.212522] DTS File Name: /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/arch/arm64/boot/dts/…/…/…/…/…/…/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0000-p3449-0000-b00.dts

I have connected my i2c sensor to J41.3 and J41.5 pins and modified my dts entry like below, but driver is not loaded and 0x57 i2c address is not occupied by driver yet. Is my changes are correct enough in correct dts for my Jetson Nano board ?

hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0000-p3449-0000-b00.dts

tegra210-p3448-0000-p3449-0000-b00.dts (3.9 KB)

i2c@7000c400 { // Titus: i2c1
	status = "okay";
	max30100@57 {
		status = "okay";
		compatible = "maxim,max30102";
		reg = <0x57>;
		maxim,red-led-current-microamp = <7000>;
		maxim,ir-led-current-microamp = <7000>;
		interrupt-parent = <&gpio>;
		interrupts = <200 2>;
	};
};

hello titusece,

please refer to Pinmux spreadsheets, it’s I2C2 for pin-3 and pin-5.
for example,

                        gen2_i2c_scl_pj2 {
                                nvidia,pins = "gen2_i2c_scl_pj2";
                                nvidia,function = "i2c2";
                                ...  
                        gen2_i2c_sda_pj3 {
                                nvidia,pins = "gen2_i2c_sda_pj3";
                                nvidia,function = "i2c2";

Thanks JerryChang.
Actually my dts changes are looks good, but I don’t see my dts changes under '/proc/device-tree" folder (i.e not loaded)
How can update the dtb manually ?
I just manually copied all dtbo files from “build/arch/arm64/boot/dts” into Jetson board (/boot/dts/ and /boot)
Is it correct ?
It is because I didn’t connect my Jetson board to Ubuntu PC for flashing binaries. (flash.sh)

is there any other way to upload the dtb files ?

hello titusece,

please check Flashing a Specific Partition; you may perform partition update (-k DTB) to flash only device tree blob instead of flashing the whole device.
or,
it’s CBoot functionality includes a default booting scan sequence, CBoot looks for /boot/extlinux/extlinux.conf configuration file. you may have assign FDT entry to make device tree blob loads from the path of FDT.
please check CBoot session for reference,
thanks

Thanks JerryChang.
Yes I can see my dts changes now. Thanks for your support.
But still GPIO is not working, pinmux need to be done ?
Right now using J41.7, J41.31 and J41.33 pins for GPIO input and output activity.
It seems I2C2 pinmux is good by default and able to detect my sensor already.
Can you please help to add pinmux in dts entry (before enable driver) ?
GPIO pinmux dts overlay code would be helpful.
Thanks for your support.

to summarize, here’re steps for using the Jetson Nano’s Pinmux spreadsheet.

  1. Download the pinmux spreadsheets from download center.
  2. Generate the dtsi file from pinmux spreadsheet. (you’ll generate 2 dtsi files)
  3. Copy these dtsi files to the ubuntu host
  4. Download the L4T Driver Package (BSP) Sources.
  5. un-tar the sources package
  6. Overwriting dtsi files for building.

Thanks JerryChang for the prompt help.