How to set GPIO AON pinmux configuration?

Hello,

I need to set an input and output GPIO in 40 pin header port using AON GPIO.

The AON GPIO for 40 pin header are:

Pin GPIO
31  GPIO3_PAA.00
29  GPIO3_PAA.01
33  GPIO3_PAA.02
37  GPIO3_PAA.03
32  GPIO3_PBB.00
16  GPIO3_PBB.01

Trying to set the output value manually using the command line, For example:

nvidia@tegra-ubuntu:~$ sudo gpiofind PB.00
gpiochip0 8
nvidia@tegra-ubuntu:~$ sudo gpioset --mode=wait gpiochip0 8=1
^C
nvidia@tegra-ubuntu:~$ sudo gpioset --mode=wait gpiochip0 8=0

Measuring the voltage level I have seen the Pin 32 is always high. it seems the GPIO is not working but had the same result for other GPIOs tested including Main GPIOs.

Changing the pinmux configuration for Main GPIOs, it solves the problem, This change let me set the Pin 15 as and output and Pin 22 as and input and both working correctly:

diff --git a/hardware/nvidia/t23x/nv-public/tegra234.dtsi b/hardware/nvidia/t23x/nv-public/tegra234.dtsi
index f909b93..0832b19 100644
--- a/hardware/nvidia/t23x/nv-public/tegra234.dtsi
+++ b/hardware/nvidia/t23x/nv-public/tegra234.dtsi
@@ -111,10 +111,52 @@
                        gpio-controller;
                        gpio-ranges = <&pinmux 0 0 164>;
                };
-
+#include <dt-bindings/pinctrl/pinctrl-tegra.h>
                pinmux: pinmux@2430000 {
                        compatible = "nvidia,tegra234-pinmux";
                        reg = <0x0 0x2430000 0x0 0x19100>;
+                       pinctrl-names = "default";
+                       pinctrl-0 = <&jetson_io_pinmux>;
+                       jetson_io_pinmux: exp-header-pinmux {
+                               hdr40-pin15 { /* Output */
+                                       nvidia,pins = "soc_gpio39_pn1";
+                                       nvidia,function = "gp";
+                                       nvidia,pin-group = "pwm1";
+                                       nvidia,tristate = <TEGRA_PIN_DISABLE>;
+                                       nvidia,enable-input = <TEGRA_PIN_DISABLE>;
+                               };
+                               hdr40-pin22 { /* Input */
+                                       nvidia,pins = "spi3_miso_py1";
+                                       nvidia,function = "gp";
+                                       nvidia,tristate = <TEGRA_PIN_DISABLE>;
+                                       nvidia,enable-input = <TEGRA_PIN_ENABLE>;
+                               };
+                       };
                };
 
                gpcdma: dma-controller@2600000 {

I have tried to apply a similar pinmux configuration for AON GPIOs, but this configuration doesn’t allow me to control the GPIO as output. For example, this is the configuration applied to pin32.

diff --git a/hardware/nvidia/t23x/nv-public/tegra234.dtsi b/hardware/nvidia/t23x/nv-public/tegra234.dtsi
index f909b93..0832b19 100644
--- a/hardware/nvidia/t23x/nv-public/tegra234.dtsi
+++ b/hardware/nvidia/t23x/nv-public/tegra234.dtsi
@@ -1853,6 +1912,35 @@
                pinmux_aon: pinmux@c300000 {
                        compatible = "nvidia,tegra234-pinmux-aon";
                        reg = <0x0 0xc300000 0x0 0x4000>;
+                       pinctrl-names = "default";
+                       pinctrl-0 = <&jetson_io_pinmux_aon>;
+                       jetson_io_pinmux_aon: exp-header-pinmux {
+                               hdr40-pin16 { /* Input */
+                                       nvidia,pins = "can1_en_pbb1";
+                                       nvidia,tristate = <TEGRA_PIN_DISABLE>;
+                                       nvidia,enable-input = <TEGRA_PIN_ENABLE>;
+                               };
+                               hdr40-pin32 { /* Output */
+                                       nvidia,pins = "can1_stb_pbb0";
+                                       nvidia,tristate = <TEGRA_PIN_DISABLE>;
+                                       nvidia,enable-input = <TEGRA_PIN_DISABLE>;
+                               };
+                               
+                       };
                };
 
                pwm4: pwm@c340000 {

Do you know why I can’t control the AON GPIO?

Regards,
-Manuel

Hi ManuelLeiva,

Are you working on a devkit or custom board for AGX Orin?
What’s the Jetpack verison in use?

Have you tried to configure them in pinmux spreadsheet instead of modifying them in device tree directly?
Which AON_GPIO pin you would like to control? We can check the specific pin and verify if it could be controlled.

Hi Kevin,

I am using a Devkit, Jetpack 6, I have not tried using pinmux spreadsheet, since it doesn’t work in ubuntu, but at least for previous jetpacks, changing the DT was enough to get the GPIO working.

I want to test the HTE test driver, then I need to use 2 AON GPIOs, (input and output). I can use any AON GPIO of the 40 pin header.

The AON GPIOs for 40 pin header are:

Pin GPIO
31  GPIO3_PAA.00
29  GPIO3_PAA.01
33  GPIO3_PAA.02
37  GPIO3_PAA.03
32  GPIO3_PBB.00
16  GPIO3_PBB.01

Thanks.

It’s okay if you know how to configure it in dtsi.

Have you configured them in both pinmux and gpio dtsi?
e.g. if you want to control PAA.00 like the following one

You should have the following in pinmux dtsi.

			can0_dout_paa0 {
				nvidia,pins = "can0_dout_paa0";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_NONE>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
			};

and the following in gpio.dtsi:

	gpio@c2f0000 {
		gpio-init-names = "default";
		gpio-init-0 = <&gpio_aon_default>;

		gpio_aon_default: default {
			gpio-input = <
				..
				>;
			gpio-output-low = <
				TEGRA234_AON_GPIO(AA, 0)

Hi Kevin,

I have seen some interesting result.

These are the changes applied.

hardware/nvidia/t23x/nv-public/tegra234.dtsi

#define GPIO_CAN0_DOUT TEGRA234_AON_GPIO(AA, 0)
#define GPIO_GPIO09    TEGRA234_AON_GPIO(BB, 0)

		gpio_aon: gpio@c2f0000 {
			compatible = "nvidia,tegra234-gpio-aon";
			reg-names = "security", "gpio";
			reg = <0x0 0x0c2f0000 0x0 0x1000>,
			      <0x0 0x0c2f1000 0x0 0x1000>;
			interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
			#interrupt-cells = <2>;
			interrupt-controller;
			#gpio-cells = <2>;
			gpio-controller;
			gpio-ranges = <&pinmux_aon 0 0 32>;

			hte-output-high { /* PIN 31 */
				gpio-hog;
				output-low;
				gpios = <GPIO_CAN0_DOUT 0>;
				label = "hte-out";
			};

			aon-output-high { /* PIN 32 */
				gpio-hog;
				output-low;
				gpios = <GPIO_GPIO09 0>;
				label = "aon-out";
			};
. . .
		pinmux_aon: pinmux@c300000 {
			compatible = "nvidia,tegra234-pinmux-aon";
			reg = <0x0 0xc300000 0x0 0x4000>;
			pinctrl-names = "default";
			pinctrl-0 = <&jetson_io_pinmux_aon>;
			jetson_io_pinmux_aon: exp-header-pinmux {
				can0_dout_paa0 {
					nvidia,pins = "can0_dout_paa0";
					nvidia,function = "rsvd1";
					nvidia,pull = <TEGRA_PIN_PULL_NONE>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_DISABLE>;
				};

				can1_stb_pbb0 {
					nvidia,pins = "can1_stb_pbb0";
					nvidia,function = "rsvd1";
					nvidia,pull = <TEGRA_PIN_PULL_NONE>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_DISABLE>;
				};
			};
		};

The changes applied to gpio@c2f0000 are based on the changes applied by other dtsi files. for example:

nvidia/t23x/nv-public/nv-platform/tegra234-camera-p3785.dtsi

#define CAM0_PWDN	TEGRA234_AON_GPIO(AA, 4)

/ {
	gpio@c2f0000 {
		camera-control-output-high {
			gpio-hog;
			output-high;
			gpios = <CAM0_PWDN 0>;
			label = "cam0-pwdn";
		};
	};

Checking gpioinfo or /sys/kernel/debug/gpio I see the configuration is applied

nvidia@tegra-ubuntu:~$ sudo dmesg | grep -e hte-output -e aon-output
[    1.825440] gpio-316 (hte-output-high): hogged as output/low
[    1.825467] gpio-324 (aon-output-high): hogged as output/low

nvidia@tegra-ubuntu:~$ sudo gpioinfo | grep -e PAA.00 -e PBB.00 
[sudo] password for nvidia: 
	line   0:     "PAA.00" "hte-output-high" output active-high [used]
	line   8:     "PBB.00" "aon-output-high" output active-high [used]
nvidia@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/gpio  | grep -e PAA.00 -e PBB.00
 gpio-316 (PAA.00              |hte-output-high     ) out lo 
 gpio-324 (PBB.00              |aon-output-high     ) out lo 

but If I tried to use the GPIO from a driver it fails to get the GPIO:

[    7.655192] tegra_hte_test bus@0:hte_test: failed to get gpio out
[    7.655202] tegra_hte_test: probe of bus@0:hte_test failed with error -22

If I tried to use the GPIO from user space:

nvidia@tegra-ubuntu:~$ sudo gpiofind PAA.00
gpiochip1 0
nvidia@tegra-ubuntu:~$ sudo gpioset  gpiochip1 0=1
gpioset: error setting the GPIO line values: Device or resource busy

It says, device busy.

If I remove the node:

           hte-output-high { /* PIN 31 */
				gpio-hog;
				output-low;
				gpios = <GPIO_CAN0_DOUT 0>;
				label = "hte-out";
			};

Now the driver can get the GPIO and also I can use it from user space (removing the driver)

nvidia@tegra-ubuntu:~$ sudo rmmod hte-tegra194-test
nvidia@tegra-ubuntu:~$ sudo gpioset  gpiochip1 0=1
nvidia@tegra-ubuntu:~$ sudo gpioset  gpiochip1 0=0

Is this expected?

But I have seen the changes ingpio@c2f0000 are not required,

I can set the GPIO output using --mode=wait For example:

sudo gpioset --mode=wait gpiochip1 0=1

It seems the expected result that gpio-hog has pulled the pin so that gpiod can not control it.

Yes, you can also just using --mode=wait to keep its controlling state.

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