How to set a GPIO as an interrupt pin and test if the interrupt function is working properly in Orin NX?

Hi
Here is my device version:

Software part of jetson-stats 4.3.2 - (c) 2024, Raffaello Bonghi
Model: NVIDIA Orin NX Developer Kit - Jetpack 5.1.3 [L4T 35.5.0]
NV Power Mode[2]: 15W
Serial Number: [XXX Show with: jetson_release -s XXX]
Hardware:
 - P-Number: p3767-0001
 - Module: NVIDIA Jetson Orin NX (8GB ram)
Platform:
 - Distribution: Ubuntu 20.04 focal
 - Release: 5.10.192-tegra
jtop:
 - Version: 4.3.2
sh: 0: getcwd() failed: Input/output error
 - Service: Active
Libraries:
 - CUDA: 11.4.315
 - cuDNN: 8.6.0.166
 - TensorRT: 8.5.2.2
 - VPI: 2.4.8
 - Vulkan: 1.3.204
 - OpenCV: 4.5.4 - with CUDA: NO

I need to receive PPS signals from the GPS module.
Can I use the PPS module in the Linux kernel to implement this feature?

Or I need to choose a gpio to set as interrupt(I choose GPIO3_PY.03 to test)? I need to set this pin as a rising edge trigger interrupt. Which device tree file should I modify it in?
I already set this gpio direction to in:

spi1_cs0_pz6 {
				nvidia,pins = "spi1_cs0_pz6";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

I hope to receive guidance here,Thanks!

Hi jack.yan,

Are you using the devkit or custom board for Orin NX?

Why you said that you want to use PY.03 but you are configuring PZ.06?

I would suggest configuring pinmux from pinmux spreadsheet instead of modifying pinmux dtsi directly.

Yes, please refer to the following topics for this use case.
Can’t enable PPS on Jetson AGX Xavier - Jetson & Embedded Systems / Jetson AGX Xavier - NVIDIA Developer Forums
AGX Xavier PPS fetch timeout R35.2.1(R32.7.1 works fine) - Jetson & Embedded Systems / Jetson AGX Xavier - NVIDIA Developer Forums
Pps_gpio interrupt not asserted - Jetson & Embedded Systems / Jetson Orin NX - NVIDIA Developer Forums
PPS input to GPIO on Jetpack 6.1 - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums

Hi, KevinFFF:
Thanks for your reply.

We are currently using our own development board.

I choose PY.03 set to interrupt pin.

spi3_cs0_py3 {
				nvidia,pins = "spi3_cs0_py3";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

now ,I add pps_gpio to Linux_for_Tegra/source/public/hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3768-0000-a0.dtsi:

pps: pps_gpio 
	{
		compatible = "pps-gpio";
		gpios = <&gpio TEGRA234_MAIN_GPIO(Y, 3) GPIO_ACTIVE_HIGH>;
		status = "okay";
		interrupts = <TEGRA234_MAIN_GPIO(Y, 3) IRQ_TYPE_EDGE_RISING>;
		assert-falling-edge;
		interrupt-parent = <&gpio>;
	};

then make failed:

  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0008-p3737-0000.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-p3509-a02.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0001-p3768-0000-a0.dtb
/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3768-0000-a0.dtsi:345.2-352.4: ERROR (phandle_references): /pps_gpio: Reference to non-existent node or label "gpio"

/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3768-0000-a0.dtsi:345.2-352.4: ERROR (phandle_references): /pps_gpio: Reference to non-existent node or label "gpio"

ERROR: Input tree has errors, aborting (use -f to force output)
make[2]: *** [/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/boot/dts/Makefile:80: arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0001-p3768-0000-a0.dtb] Error 2
make[2]: *** Waiting for unfinished jobs....
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0003-p3509-a02.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0004-p3509-a02.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0001-p3509-a02.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0003-p3768-0000-a0.dtb
/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3768-0000-a0.dtsi:345.2-352.4: ERROR (phandle_references): /pps_gpio: Reference to non-existent node or label "gpio"

/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3768-0000-a0.dtsi:345.2-352.4: ERROR (phandle_references): /pps_gpio: Reference to non-existent node or label "gpio"

ERROR: Input tree has errors, aborting (use -f to force output)
make[2]: *** [/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/boot/dts/Makefile:80: arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0003-p3768-0000-a0.dtb] Error 2
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-as-p3767-0001-p3509-a02.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0003-p3509-a02.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0004-p3509-a02.dtb
make[1]: *** [/home/yan/nvidia/nvidia_sdk/JetPack_5.1.3_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/source/public/kernel/kernel-5.10/Makefile:1419: dtbs] Error 2
make: *** [Makefile:220: __sub-make] Error 2

Is there any problem with the data format I added here?

Since you are using Jetpack 5.1.3(L4T r35.5.0), please specify &tegra_main_gpio instead of &gpio in device tree.

Hi,KevinFFF:
Thanks for your replay.
Dmesg query PPS loading error occurred:

nvidia@nvidia-desktop:~$ sudo dmesg | grep pps
[    1.333500] pps_core: LinuxPPS API ver. 1 registered
[    1.338461] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    3.986464] pps pps0: new PPS source ktimer
[    3.990771] pps pps0: ktimer PPS source registered
[    3.995700] pps_ldisc: PPS line discipline registered
[    4.000955] pps-gpio pps_gpio: failed to request PPS GPIO
[    4.006493] pps-gpio: probe of pps_gpio failed with error -22
[    9.643250] pps pps1: new PPS source ptp0

dmesg file:
dmesg.log (69.8 KB)
check PGPIO_PY.03:

root@nvidia-desktop:~# cat /sys/kernel/debug/gpio | grep PY.03
 gpio-473 (PY.03               )
root@nvidia-desktop:~# 
root@nvidia-desktop:~# cat /sys/kernel/debug/gpio | grep PY.03
 gpio-473 (PY.03               )
root@nvidia-desktop:~# echo 473 > /sys/class/gpio/export 
root@nvidia-desktop:~# 
root@nvidia-desktop:~# cd /sys/class/gpio/PY.03
root@nvidia-desktop:/sys/class/gpio/PY.03# cat direction 
in
root@nvidia-desktop:/sys/class/gpio/PY.03# cat edge 
none
root@nvidia-desktop:/sys/class/gpio/PY.03# ls
active_low  device  direction  edge  power  subsystem  uevent  value

gpio config:

spi3_cs0_py3 {
				nvidia,pins = "spi3_cs0_py3";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

check interrupts:

root@nvidia-desktop:/sys/class/gpio/PY.03# cat /proc/interrupts 
           CPU0       CPU1       CPU2       CPU3       
  9:          0          0          0          0     GICv3  25 Level     vgic
 11:          0          0          0          0     GICv3  30 Level     kvm guest ptimer
 12:          0          0          0          0     GICv3  27 Level     kvm guest vtimer
 13:      92569      60568      58880      56418     GICv3  26 Level     arch_timer
 18:          0          0          0          0     GICv3 255 Level     mc_status
 20:          0          0          0          0     GICv3 202 Level     arm-smmu global fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault
 21:          0          0          0          0     GICv3 264 Level     arm-smmu global fault, arm-smmu-context-fault
 22:          0          0          0          0     GICv3 272 Level     arm-smmu global fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault
 23:          0          0          0          0     GICv3 270 Level     arm-smmu global fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault, arm-smmu-context-fault
 24:          0          0          0          0     GICv3 274 Level     arm-smmu global fault, arm-smmu-context-fault
 25:          0          0          0          0     GICv3 263 Level     13a00000.cbb-fabric
 26:          0          0          0          0     GICv3 204 Level     c600000.aon-fabric
 27:          0          0          0          0     GICv3 206 Level     d600000.bpmp-fabric
 28:          0          0          0          0     GICv3 413 Level     de00000.dce-fabric
 29:          0          0          0          0     GICv3 207 Level     be00000.rce-fabric
 30:          0          0          0          0     GICv3 205 Level     b600000.sce-fabric
 31:          0          0          0          0     GICv3 368 Level     tegra-p2u-intr
 32:          0          0          0          0     GICv3 369 Level     tegra-p2u-intr
 33:          0          0          0          0     GICv3 370 Level     tegra-p2u-intr
 34:          0          0          0          0     GICv3 371 Level     tegra-p2u-intr
 35:          0          0          0          0     GICv3 372 Level     tegra-p2u-intr
 36:          0          0          0          0     GICv3 373 Level     tegra-p2u-intr
 37:          0          0          0          0     GICv3 374 Level     tegra-p2u-intr
 38:          0          0          0          0     GICv3 375 Level     tegra-p2u-intr
 39:          0          0          0          0     GICv3 376 Level     tegra-p2u-intr
 40:          0          0          0          0     GICv3 377 Level     tegra-p2u-intr
 41:          0          0          0          0     GICv3 378 Level     tegra-p2u-intr
 42:          0          0          0          0     GICv3 379 Level     tegra-p2u-intr
 43:          0          0          0          0     GICv3 380 Level     tegra-p2u-intr
 44:          0          0          0          0     GICv3 381 Level     tegra-p2u-intr
 45:          0          0          0          0     GICv3 382 Level     tegra-p2u-intr
 46:          0          0          0          0     GICv3 383 Level     tegra-p2u-intr
 47:          0          0          0          0     GICv3 235 Level     tegra-p2u-intr
 48:          0          0          0          0     GICv3 252 Level     tegra-p2u-intr
 49:          0          0          0          0     GICv3 253 Level     tegra-p2u-intr
 50:          0          0          0          0     GICv3 254 Level     tegra-p2u-intr
 51:          0          0          0          0     GICv3 140 Level     tegra-p2u-intr
 52:          0          0          0          0     GICv3 141 Level     tegra-p2u-intr
 53:          0          0          0          0     GICv3 142 Level     tegra-p2u-intr
 54:          0          0          0          0     GICv3 143 Level     tegra-p2u-intr
 55:          0          0          0          0     GICv3  77 Level     tegra-pcie-intr, PCIe PME, aerdrv
 57:          0          0          0          0     GICv3  83 Level     tegra-pcie-intr, PCIe PME, aerdrv
 59:          0          0          0          0     GICv3 386 Level     tegra-pcie-intr
 61:          0          0          0          0     GICv3 388 Level     tegra-pcie-intr, PCIe PME, aerdrv
 63:          0          0          0          0     GICv3 390 Level     tegra-pcie-intr, PCIe PME, aerdrv
 67:        671          0          0          0     GICv3 317 Level     uart-pl011
 68:          0          0          0          0     GICv3 152 Level     3c00000.tegra-hsp
 69:          0          0          0          0     GICv3  68 Level     3210000.spi
 70:          0          0          0          0     GICv3  70 Level     3230000.spi
 71:         51          0          0          0     GICv3  57 Level     3160000.i2c
 72:         78          0          0          0     GICv3  58 Level     c240000.i2c
 73:          2          0          0          0     GICv3  59 Level     3180000.i2c
 74:          0          0          0          0     GICv3  60 Level     3190000.i2c
 75:          0          0          0          0     GICv3  62 Level     31b0000.i2c
 76:          0          0          0          0     GICv3  63 Level     31c0000.i2c
 77:          0          0          0          0     GICv3  64 Level     c250000.i2c
 78:          0          0          0          0     GICv3  65 Level     31e0000.i2c
 80:          0          0          0          0     GICv3 108 Level     gpcdma.0
 81:          0          0          0          0     GICv3 109 Level     gpcdma.1
 82:          0          0          0          0     GICv3 110 Level     gpcdma.2
 83:          0          0          0          0     GICv3 111 Level     gpcdma.3
 84:          0          0          0          0     GICv3 112 Level     gpcdma.4
 85:          0          0          0          0     GICv3 113 Level     gpcdma.5
 86:          0          0          0          0     GICv3 114 Level     gpcdma.6
 87:          0          0          0          0     GICv3 115 Level     gpcdma.7
 88:          0          0          0          0     GICv3 116 Level     gpcdma.8
 89:          0          0          0          0     GICv3 117 Level     gpcdma.9
 90:          0          0          0          0     GICv3 118 Level     gpcdma.10
 91:          0          0          0          0     GICv3 119 Level     gpcdma.11
 92:          0          0          0          0     GICv3 120 Level     gpcdma.12
 93:          0          0          0          0     GICv3 121 Level     gpcdma.13
 94:          0          0          0          0     GICv3 122 Level     gpcdma.14
 95:          0          0          0          0     GICv3 123 Level     gpcdma.15
 96:          0          0          0          0     GICv3 124 Level     gpcdma.16
 97:          0          0          0          0     GICv3 125 Level     gpcdma.17
 98:          0          0          0          0     GICv3 126 Level     gpcdma.18
 99:          0          0          0          0     GICv3 127 Level     gpcdma.19
113:       5554          0          0          0     GICv3  92 Level     snd_hda_tegra
114:          0          0          0          0     GICv3  51 Level     bc00000.rtcpu
115:        196          0          0          0     GICv3 242 Level     d230000.actmon
116:          0          0          0          0     GICv3  23 Level     arm-pmu
117:          0          0          0          0     GICv3 579 Level     arm_dsu_0
118:          0          0          0          0     GICv3 580 Level     arm_dsu_1
119:          0          0          0          0     GICv3 581 Level     arm_dsu_2
120:          0          0          0          0     GICv3 583 Level     scf-pmu
121:          0          0          0          0     GICv3 398 Level     e860000.psc
122:          0          0          0          0     GICv3 399 Level     e860000.psc
123:          0          0          0          0     GICv3 400 Level     e860000.psc
124:          0          0          0          0     GICv3 401 Level     e860000.psc
125:          0          0          0          0     GICv3 402 Level     e860000.psc
126:          0          0          0          0     GICv3 403 Level     e860000.psc
127:          0          0          0          0     GICv3 404 Level     e860000.psc
128:          0          0          0          0     GICv3 405 Level     e860000.psc
129:     232083          0          0          0     GICv3 480 Level     host_syncpt
130:          0          0          0          0     GICv3 481 Level     host_syncpt
131:          0          0          0          0     GICv3 482 Level     host_syncpt
132:          0          0          0          0     GICv3 483 Level     host_syncpt
133:          0          0          0          0     GICv3 484 Level     host_syncpt
134:          0          0          0          0     GICv3 485 Level     host_syncpt
135:          0          0          0          0     GICv3 486 Level     host_syncpt
136:          0          0          0          0     GICv3 487 Level     host_syncpt
137:          0          0          0          0     GICv3 295 Level     host_status
138:          0          0          0          0     GICv3 238 Level     vic
139:          0          0          0          0     GICv3 260 Level     tsec_riscv_irq
140:          0          0          0          0     GICv3 266 Level     pva-isr
141:          0          0          0          0     GICv3 464 Level     pva-isr
142:          0          0          0          0     GICv3 465 Level     pva-isr
143:          0          0          0          0     GICv3 466 Level     pva-isr
144:          0          0          0          0     GICv3 467 Level     pva-isr
145:          0          0          0          0     GICv3 468 Level     pva-isr
146:          0          0          0          0     GICv3 469 Level     pva-isr
147:          0          0          0          0     GICv3 470 Level     pva-isr
148:          0          0          0          0     GICv3 471 Level     pva-isr
149:          0          0          0          0     GICv3 268 Level     nvdla0
150:      11330          0          0          0     GICv3 165 Level     c150000.tegra-hsp
154:      47718          0          0          0     GICv3 208 Level     3c00000.tegra-hsp
162:          1          0          0          0     GICv3 160 Level     3d00000.tegra-hsp
167:        116          0          0          0     GICv3 214 Level     b950000.tegra-hsp
171:          0          0          0          0     GICv3 316 Level     tegra-se-nvrng
224:         13          0          0          0     GICv3  39 Level     2190000.watchdog
228:          0          0          0          0     GICv3 199 Level     3610000.xhci
229:       2202          0          0          0     GICv3 198 Level     3550000.xudc
230:       3864          0          0          0     GICv3 195 Level     xhci-hcd:usb1
231:          0          0          0          0     GICv3 196 Level     3610000.xhci
232:          0          0          0          0     GICv3 100 Level     gk20a_stall
233:         29          0          0          0     GICv3 102 Level     gk20a_stall
234:       2493          0          0          0     GICv3 103 Level     gk20a_stall
235:          0          0          0          0     GICv3  99 Level     gk20a_nonstall
236:          0          0          0          0     GICv3 408 Level     tegra_dce_isr
237:       6784          0          0          0     GICv3 409 Level     tegra_dce_isr
245:          0          0          0          0  c360000.pmc  73 Level     tegra_rtc
246:          1          0          0          0  c360000.pmc  24 Level     nvvrs-pseq-irq
247:          1          0          0          0  nvvrs-pseq-irq   3 Edge      rtc-alarm
249:         45          0          0          0  agic-controller  73 Edge    
250:         23          0          0          0  agic-controller  64 Edge    
252:         22          0          0          0  agic-controller  94 Edge    
262:       3538          0          0          0  agic-controller  32 Level     dma1chan0
263:         53          0          0          0  agic-controller  33 Level   
294:         17          0          0          0       MSI 537395200 Edge      nvme0q0
295:       2770          0          0          0       MSI 537395201 Edge      nvme0q1
296:          0       4485          0          0       MSI 537395202 Edge      nvme0q2
297:          0          0       5833          0       MSI 537395203 Edge      nvme0q3
298:          0          0          0       5223       MSI 537395204 Edge      nvme0q4
299:          0          0          0          0       MSI 537395205 Edge      nvme0q5
300:          0          0          0          0       MSI 537395206 Edge      nvme0q6
301:          0          0          0          0       MSI 1208483840 Edge      eth0
302:        198          0          0          0       MSI 1208483841 Edge      eth0-TxRx-0
303:        198          0          0          0       MSI 1208483842 Edge      eth0-TxRx-1
304:        198          0          0          0       MSI 1208483843 Edge      eth0-TxRx-2
305:        198          0          0          0       MSI 1208483844 Edge      eth0-TxRx-3
307:          0          0          0          0  c360000.pmc  83 Edge      sw-wake
308:          0          0          0          0      gpio  35 Edge      force-recovery
309:          0          0          0          0      gpio  27 Edge      power-key
310:     224769          0          0          0       MSI 1074266112 Edge      eth1
311:          2          0          0          0      gpio 131 Level     1-0025
IPI0:    120021     222795     224000     219754       Rescheduling interrupts
IPI1:      4709       5094       5396       3392       Function call interrupts
IPI2:         0          0          0          0       CPU stop interrupts
IPI3:         0          0          0          0       CPU stop (for crash dump) interrupts
IPI4:         0          0          0          0       Timer broadcast interrupts
IPI5:     14942       6963       7748       7041       IRQ work interrupts
IPI6:         0          0          0          0       CPU wake-up interrupts
Err:          0

my pps config:

pps: pps_gpio 
    {
        compatible = "pps-gpio";
        gpios = <&tegra_main_gpio TEGRA234_MAIN_GPIO(Y, 3) GPIO_ACTIVE_HIGH>;
        status = "okay";
        interrupts = <TEGRA234_MAIN_GPIO(Y, 3) IRQ_TYPE_EDGE_RISING>;
        assert-falling-edge;
        interrupt-parent = <&tegra_main_gpio>;
    };

ppstest:

root@nvidia-desktop:/sys/class/gpio/PY.03# ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1744961675.606500352, sequence: 688 - clear  0.000000000, sequence: 0
source 0 - assert 1744961676.634516256, sequence: 689 - clear  0.000000000, sequence: 0
source 0 - assert 1744961677.654493376, sequence: 690 - clear  0.000000000, sequence: 0
^C
root@nvidia-desktop:/sys/class/gpio/PY.03# 
root@nvidia-desktop:/sys/class/gpio/PY.03# ppstest /dev/pps1
trying PPS source "/dev/pps1"
found PPS source "/dev/pps1"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
^C

It seems that PPS is not working correctly.

It seems the PPS GPIO is not loaded correctly.
Have you configured PY.03 as Input/Int PD in pinmux spreadsheet?

Please run the following command to check if the GPIO has been requested by PPS driver correctly.

$ sudo cat /sys/kernel/debug/gpio|grep PY.03

Hi, KevinFFF:
I have added the query for gpio in my reply, I set gpio to input/Int PU:

I set to input/Int PD, and test again, There are the same errors:

root@nvidia-desktop:~# echo 473 > /sys/class/gpio/export
root@nvidia-desktop:~# 
root@nvidia-desktop:~# cd /sys/class/gpio/PY.03
root@nvidia-desktop:/sys/class/gpio/PY.03# cat direction 
in
root@nvidia-desktop:/sys/class/gpio/PY.03# ls
active_low  device  direction  edge  power  subsystem  uevent  value
root@nvidia-desktop:/sys/class/gpio/PY.03# cat edge 
none
root@nvidia-desktop:/sys/class/gpio/PY.03# cat active_low 
0
root@nvidia-desktop:/sys/class/gpio/PY.03# cat value 
0

Set interrupt configuration file:Uploading: tegra234-p3768-0000-a0.dtsi.txt…

spi3_cs0_py3 {
				nvidia,pins = "spi3_cs0_py3";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

I set the pps_gpio config in .config:

CONFIG_PPS_CLIENT_KTIMER=y
CONFIG_PPS_CLIENT_LDISC=y
CONFIG_PPS_CLIENT_GPIO=y

After I set it up, I compiled the Linux kernel using nvbuild.sh, and then checked the configuration again using make memoconfig. I found that config change to PPS_CLIENT_CPIO=m. It seems that my configuration is not working, I modified Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/configs/tegra_defconfig:
defconfig.txt (32.5 KB)

Here is my make step:

Linux_for_Tegra/source/public/kernel/kernel-5.10#make ARCH=arm64 mrproper
Linux_for_Tegra/source/public/kernel/kernel-5.10#cd ../..
Linux_for_Tegra/source/public#./nvbuild.sh -o $PWD/kernel_out

After successful compilation, check Linux_for_Tegra/source/public/kernel/kernel-5.10/.config:

CONFIG_PPS=y
# CONFIG_PPS_DEBUG is not set

#
# PPS clients support
#
# CONFIG_PPS_CLIENT_KTIMER is not set
CONFIG_PPS_CLIENT_LDISC=m
CONFIG_PPS_CLIENT_PARPORT=m
CONFIG_PPS_CLIENT_GPIO=m

Why haven’t my modifications in the tegra_defconfig file been synchronized?
This is the device tree file I decompiled using the dts command:
output.dts.txt (433.1 KB)
PPS configuration in decompiled device tree file:

pps_gpio {
		compatible = "pps-gpio";
		gpios = <0x50 0x93 0x00>;
		status = "okay";
		interrupts = <0x93 0x01>;
		assert-rising-edge;
		interrupt-parent = <0x50>;
		phandle = <0x49c>;
	};

Check GPIO-PY.03 using the gpioinfo command:

root@nvidia-desktop:/sys/class/gpio/PZ.07# gpioinfo | grep PY.03
	line 125:      "PY.03"       unused   input  active-high

Do you configure them in pinmux spreadsheet and generate pinmux/gpio dtsi to apply the change?
Or you just modify the dtsi manually?

Your device tree used for pps-gpio looks good to me.
Please check why PY.03 can’t be requested from pps driver correctly.
You can also measure it from scope to check if there’s any signal during boot up.

Please refer to the steps in the following thread to update kernel config.
orinNano Kernel added other driver, and need to modify the device tree, how do I need to operate - #20 by KevinFFF

Hi,KevinFFF:

After I generated the gpio configuration file using the pinmux table,I replaced the changes in the gpio file with the Linux_for_Tegra/bootloader/tegra234-mb1-bct-gpio-p3767-hdami-a03.dtsi file and the changes in the pinmux file with the Linux_for_Tegra/bootloader/t186ref/BCT/tegra234-mb1-bct-pnmux-p3767-hdami-a03.dtsi file, Then, I burned the device using l4t_initrd_flash.sh and testing.

I have set PY.03 as the input and used an oscilloscope to measure that it has always been at a low level. I have set PY.03 to out to correctly configure the high and low levels.

nvidia@nvidia-desktop:~$ sudo zcat /proc/config.gz |grep PPS
CONFIG_PPS=y
# CONFIG_PPS_DEBUG is not set
# PPS clients support
CONFIG_PPS_CLIENT_KTIMER=y
CONFIG_PPS_CLIENT_LDISC=y
CONFIG_PPS_CLIENT_GPIO=y
# PPS generators support
CONFIG_NVPPS=m
nvidia@nvidia-desktop:~$

Adding print debugging found that the error was due to the return value of gpiod_ get_index function:

struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
						    const char *con_id,
						    unsigned int idx,
						    enum gpiod_flags flags)
{
	struct gpio_desc **dr;
	struct gpio_desc *desc;
	dev_warn(dev, "[yan pps][%s %d]\n", __FILE__, __LINE__);
	desc = gpiod_get_index(dev, con_id, idx, flags);
	if (IS_ERR(desc))
	{
		dev_err(dev, "[yan pps][%s %d]err\n", __FILE__, __LINE__);
		return desc;
	}

Have you also checked the PPS source? There should be PPS signal if your PPS source works as expected.
Are you connecting a GPS module as PPS source?

Please share the full dmesg after you add these debug messages.

Hi,KevinFFF:

Now I am not connecting the GPS module, but setting GPIO_PZ.07 as the output and testing it by controlling the high and low levels of this pin output.
dmesg log:
dmesg.log (79.3 KB)

[    0.578529] pps_ldisc: PPS line discipline registered
[    0.578532] pps_parport: parallel port PPS client
[    0.581433] pps-gpio pps_gpio: GPIO lookup for consumer (null)
[    0.581446] pps-gpio pps_gpio: [test]No GPIO consumer (null) found
[    0.581450] pps-gpio pps_gpio: [yan pps][drivers/gpio/gpiolib-devres.c 105]err
[    0.581453] pps-gpio pps_gpio: gpio_pin:fffffffffffffdfb
[    0.581455] pps-gpio pps_gpio: failed to request PPS GPIO
[    0.581462] pps-gpio: probe of pps_gpio failed with error -22

Does PY.03 support being set as an interrupt pin? Check the settings of PY.03, it doesn’t seem like an interrupt.

root@nvidia-desktop:~# cat /sys/kernel/debug/gpio |grep PY.03
 gpio-473 (PY.03               )
root@nvidia-desktop:~# 
root@nvidia-desktop:~# echo 473 > /sys/class/gpio/export 
root@nvidia-desktop:~# cd /sys/class/gpio/
gpiochip316/ gpiochip348/ PY.03/       
root@nvidia-desktop:~# cd /sys/class/gpio/PY.03
root@nvidia-desktop:/sys/class/gpio/PY.03# cat direction 
in
root@nvidia-desktop:/sys/class/gpio/PY.03# cat edge 
none

Hi:
I found on the forum that it is necessary to set PPS_CLIENT_CPIO=m, and after setting it, insmod pps-gpio.ko:

[   90.745923] pps-gpio pps_gpio: GPIO lookup for consumer (null)
[   90.752054] pps-gpio pps_gpio: [test],ret:0
[   90.757408] pps-gpio pps_gpio: GPIO lookup for consumer echo
[   90.763429] pps-gpio pps_gpio: [test]No GPIO consumer echo found
[   90.769717] pps-gpio pps_gpio: [yan pps][drivers/gpio/gpiolib-devres.c 105]err
[   90.778025] irq: IRQ313: trimming hierarchy from :interrupt-controller@f400000-1
[   90.780086] pps_core: source pps_gpio.-1 got cdev (245:1)
[   90.780099] pps pps1: new PPS source pps_gpio.-1
[   90.780163] pps pps1: Registered IRQ 313 as PPS source
root@nvidia-desktop:/home/nvidia/code# ls /dev/pps*
/dev/pps0  /dev/pps1

root@nvidia-desktop:/home/nvidia/code# cat /proc/interrupts |grep 313
313:          0          0          0          0      gpio 125 Edge      pps_gpio.-1

root@nvidia-desktop:/sys/class/gpio/PZ.07# cat /sys/kernel/debug/gpio |grep PY.03
 gpio-473 (PY.03               |(null)              ) in  lo IRQ

Then I set PZ.07 as the output and connected with PY.03. I used the command to continuously set the level of PZ.07:

root@nvidia-desktop:/home/nvidia/code# echo 485 > /sys/class/gpio/export 
root@nvidia-desktop:/home/nvidia/code# cd /sys/class/gpio/PZ.07
root@nvidia-desktop:/sys/class/gpio/PZ.07# cat direction 
out
root@nvidia-desktop:/sys/class/gpio/PZ.07# cat value 
0
root@nvidia-desktop:/sys/class/gpio/PZ.07# echo 1 > value 
root@nvidia-desktop:/sys/class/gpio/PZ.07# echo 0 > value

Using pptest to read /dev/pps0 always timed out:

root@nvidia-desktop:~# ppstest /dev/pps0 
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)

Where else is it set correctly now?

Good catch!

Please check with /dev/pps1 instead.

# ppstest /dev/pps1

Hi, KevinFFF:

thank you for your patient answer. Tested/dev/pps1 and it works normally now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.