The GPIO direction cannot be output in the device tree and the initial state cannot be set to High

Hi.
I want to output the direction of gpio13 in the device tree and set the initial state to High.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/adaptation_and_bringup_nano.html#wwpID0E0VP0HA

I modified the dts file by following the steps in “To update the kernel DTB alone” above.

The following changes have been made to the converted dts file.

Move pe6 to common.

  common {
  	linux,phandle = <0x3d>;
  	phandle = <0x3d>;

  	pe6 {                                                                              
  		nvidia,pins = "pe6";
  		nvidia,function = "rsvd0";
  		nvidia,pull = <0x1>;
  		nvidia,tristate = <0x1>;
  		nvidia,enable-input = <0x0>;
  	};

Added 0x26 to gpio-output-high.

gpio@6000d000 {

  default {
  	gpio-input = <0x5 0xbc 0xbd 0xbe 0xc1 0xa9 0xca 0x3a 0x3d 0x3e 0x41 0xe4>;
  	gpio-output-low = <0x97 0x98 0xcb 0x38 0x3b 0x3c 0x3f 0x40 0x42>;
  	gpio-output-high = <0x26 0x6 0xbb 0xe7>;
  	linux,phandle = <0x41>;
  	phandle = <0x41>;
  };

Looking at the contents of 「/proc/device-tree/gpio@6000d000」, this was the contents of the tool.
And, High is not output from GPIO13 pin.
Are there any settings missing in the device tree?

hello k-irisa,

this pin, GPIO13/GPIO3_PE.06 is by default configured as input and PD.
you’ll see device tree settings as following,

		gpio_default: default {
			gpio-input = <
				...
				TEGRA_GPIO(E, 6)

you can have configuration through pinmux spreadsheets to update the settings,
or, please use Jetson-IO pyhton tool to Configuring the 40-Pin Expansion Header.
thanks

hello JerryChang.

I configured using pinmux spreadsheets and updated the settings, but GPIO13 / GPIO3_PE.06 did not output High.

The modified device tree.

  gpio_default: default {
  	gpio-output-high = <
  		...
  		TEGRA_GPIO(E, 6)

I want to respond by updating the device tree.

hello k-irisa,

had you overwrite the dtsi files, re-build and device tree binary, and re-flash the DTB partition to verify the results?

hello JerryChang

Yes, I confirmed it with reference to the following.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/adaptation_and_bringup_nano.html#wwpID0E0VP0HA

hello k-irisa,

it’s device tree to include the settings, could you please disassembler the dtb file into text file for examination.
for example, $ dtc -I dtb -O dts -o output.txt tegra210.dtb

hello JerryChang.

Attach the disassembled dts.
tegra210-p3448-0000-p3449-0000-b00.dts (327.0 KB)

hello k-irisa,

note, below formula shows the gpio number calculation,

#define TEGRA_GPIO_PORT_E 4
...

#define TEGRA_GPIO(port, offset) \
  	((TEGRA_GPIO_PORT_##port * 8) + offset)

so, the gpio number of TEGRA_GPIO(E, 6) is… 4 * 8 + 6 = 38 = 0x26
it shows you’re having TEGRA_GPIO(E, 6) as gpio-output-high.
for example,

		default {
			gpio-input = <0xd8 0xc 0xd 0xe 0xf 0xe8 0x95 0x5 0xbc 0xbd 0xbe 0xc1 0xc2 0xa8 0xa9 0xc8 0xca 0x4d 0x4e 0x4c 0x4f 0x32 0x33 0x10 0x11 0x12 0x13 0x14 0x3a 0x3d 0x3e 0x41 0xe4>;
			gpio-output-low = <0x97 0x98 0xcb 0x38 0x3b 0x3c 0x3f 0x40 0x42>;
			gpio-output-high = <0x26 0x6 0xbb 0xe7>;

hello JerryChang.

so, the gpio number of TEGRA_GPIO(E, 6) is… 4 * 8 + 6 = 38 = 0x26
it shows you’re having TEGRA_GPIO(E, 6) as gpio-output-high.

With the device tree I attached, the output of “GPIO13 / GPIO3_PE.06” should be High, right?
But that’s not the case.

The contents of “proc / device-tree / gpio @ 6000d000 / default / gpio-output-high” when using this device tree are as follows, and it seems that Linux can recognize the device tree settings.

/proc/device-tree/gpio@6000d000/default$ hexdump gpio-output-high
0000000 0000 2600 0000 0600 0000 bb00 0000 e700
0000010

hello k-irisa,

I don’t understand, what’s the failure here. did you probe the pin and it’s not act as high state actually ?

hello JerryChang.

The failure here is that the pin does not go high state at boot time.
I probed the pin, but it didn’t go high state.

hello k-irisa,

please also refer to Jetson Nano Boot Flow. it’s kernel stage to configure the pin state through device tree settings.
I assume you’ll see the expect pin state after it boot into linux, right?

hello JerryChang.

Thank you for giving me the information.

I assume you’ll see the expect pin state after it boot into linux, right?

Even after booting Linux, the pin output did not go high.
There are some pins that I want to control when starting Linux, so I want to be able to control them in the device tree.

hello k-irisa,

there’s TXB level shifters, and there are some considerations that must be considered when using the signals that come from (or go to) these level shifters.
please access applications note for reference, Nano’s 40-Pin Expansion Header GPIO Usage Considerations.
thanks

hello JerryChang.

Thank you for giving me the information.

I read Nano’s 40-Pin Expansion Header GPIO Usage Considerations, but it didn’t say that control was needed.
It says that the TXB0108 will do a level shift between the Jetson Nano and the 40-PIN, but it says it will always be enabled when the power is turned on.
Do you need control of TXB0108?

Hi k-irisa,
Can you provide me the output of following from Nano’s terminal after you made the changes in device tree.
cat /sys/kernel/debug/gpio
echo 38 > /sys/class/gpio/export
cat /sys/class/gpio/gpio38/direction
cat /sys/class/gpio/gpio38/value

hello shgarg.

The result of the command.

cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-255, parent: platform/6000d000.gpio, tegra-gpio:
 gpio-0   (                    )
 gpio-1   (                    )
 gpio-2   (                    |pcie_wake           ) in  hi
 gpio-3   (                    )
 gpio-4   (                    )
 gpio-5   (                    )
 gpio-6   (                    |system-suspend-gpio ) out hi
 gpio-7   (                    )
 gpio-8   (                    )
 gpio-9   (                    )
 gpio-10  (                    )
 gpio-11  (                    )
 gpio-12  (SPI1_MOSI           )
 gpio-13  (SPI1_MISO           )
 gpio-14  (SPI1_SCK            )
 gpio-15  (SPI1_CS0            )
 gpio-16  (SPI0_MOSI           )
 gpio-17  (SPI0_MISO           )
 gpio-18  (SPI0_SCK            )
 gpio-19  (SPI0_CS0            )
 gpio-20  (SPI0_CS1            )
 gpio-21  (                    )
 gpio-22  (                    )
 gpio-23  (                    )
 gpio-24  (                    )
 gpio-25  (                    )
 gpio-26  (                    )
 gpio-27  (                    )
 gpio-28  (                    )
 gpio-29  (                    )
 gpio-30  (                    )
 gpio-31  (                    )
 gpio-32  (                    )
 gpio-33  (                    )
 gpio-34  (                    )
 gpio-35  (                    )
 gpio-36  (                    )
 gpio-37  (                    )
 gpio-38  (GPIO13              )
 gpio-39  (                    )
 gpio-40  (                    )
 gpio-41  (                    )
 gpio-42  (                    )
 gpio-43  (                    )
 gpio-44  (                    )
 gpio-45  (                    )
 gpio-46  (                    )
 gpio-47  (                    )
 gpio-48  (                    )
 gpio-49  (                    )
 gpio-50  (UART1_RTS           )
 gpio-51  (UART1_CTS           )
 gpio-52  (                    )
 gpio-53  (                    )
 gpio-54  (                    )
 gpio-55  (                    )
 gpio-56  (                    )
 gpio-57  (                    )
 gpio-58  (                    )
 gpio-59  (                    )
 gpio-60  (                    )
 gpio-61  (                    )
 gpio-62  (                    )
 gpio-63  (                    )
 gpio-64  (                    |i2c-mux-gpio        ) out hi
 gpio-65  (                    |?                   ) out hi
 gpio-66  (                    )
 gpio-67  (                    )
 gpio-68  (                    )
 gpio-69  (                    )
 gpio-70  (                    )
 gpio-71  (                    )
 gpio-72  (                    )
 gpio-73  (                    )
 gpio-74  (                    )
 gpio-75  (                    )
 gpio-76  (I2S0_FS             )
 gpio-77  (I2S0_DIN            )
 gpio-78  (I2S0_DOUT           )
 gpio-79  (I2S0_SCLK           )
 gpio-80  (                    )
 gpio-81  (                    )
 gpio-82  (                    )
 gpio-83  (                    )
 gpio-84  (                    )
 gpio-85  (                    )
 gpio-86  (                    )
 gpio-87  (                    )
 gpio-88  (                    )
 gpio-89  (                    )
 gpio-90  (                    )
 gpio-91  (                    )
 gpio-92  (                    )
 gpio-93  (                    )
 gpio-94  (                    )
 gpio-95  (                    )
 gpio-96  (                    )
 gpio-97  (                    )
 gpio-98  (                    )
 gpio-99  (                    )
 gpio-100 (                    )
 gpio-101 (                    )
 gpio-102 (                    )
 gpio-103 (                    )
 gpio-104 (                    )
 gpio-105 (                    )
 gpio-106 (                    )
 gpio-107 (                    )
 gpio-108 (                    )
 gpio-109 (                    )
 gpio-110 (                    )
 gpio-111 (                    )
 gpio-112 (                    )
 gpio-113 (                    )
 gpio-114 (                    )
 gpio-115 (                    )
 gpio-116 (                    )
 gpio-117 (                    )
 gpio-118 (                    )
 gpio-119 (                    )
 gpio-120 (                    )
 gpio-121 (                    )
 gpio-122 (                    )
 gpio-123 (                    )
 gpio-124 (                    )
 gpio-125 (                    )
 gpio-126 (                    )
 gpio-127 (                    )
 gpio-128 (                    )
 gpio-129 (                    )
 gpio-130 (                    )
 gpio-131 (                    )
 gpio-132 (                    )
 gpio-133 (                    )
 gpio-134 (                    )
 gpio-135 (                    )
 gpio-136 (                    )
 gpio-137 (                    )
 gpio-138 (                    )
 gpio-139 (                    )
 gpio-140 (                    )
 gpio-141 (                    )
 gpio-142 (                    )
 gpio-143 (                    )
 gpio-144 (                    )
 gpio-145 (                    )
 gpio-146 (                    )
 gpio-147 (                    )
 gpio-148 (                    )
 gpio-149 (GPIO01              )
 gpio-150 (                    )
 gpio-151 (                    )
 gpio-152 (                    )
 gpio-153 (                    )
 gpio-154 (                    )
 gpio-155 (                    )
 gpio-156 (                    )
 gpio-157 (                    )
 gpio-158 (                    )
 gpio-159 (                    )
 gpio-160 (                    )
 gpio-161 (                    )
 gpio-162 (                    )
 gpio-163 (                    )
 gpio-164 (                    )
 gpio-165 (                    )
 gpio-166 (                    )
 gpio-167 (                    )
 gpio-168 (GPIO07              )
 gpio-169 (                    )
 gpio-170 (                    )
 gpio-171 (                    )
 gpio-172 (                    )
 gpio-173 (                    )
 gpio-174 (                    )
 gpio-175 (                    )
 gpio-176 (                    )
 gpio-177 (                    )
 gpio-178 (                    )
 gpio-179 (                    )
 gpio-180 (                    )
 gpio-181 (                    )
 gpio-182 (                    )
 gpio-183 (                    )
 gpio-184 (                    )
 gpio-185 (                    )
 gpio-186 (                    )
 gpio-187 (                    )
 gpio-188 (                    )
 gpio-189 (                    |Power               ) in  hi IRQ
 gpio-190 (                    |Forcerecovery       ) in  hi IRQ
 gpio-191 (                    )
 gpio-192 (                    )
 gpio-193 (                    )
 gpio-194 (GPIO12              )
 gpio-195 (                    )
 gpio-196 (                    )
 gpio-197 (                    )
 gpio-198 (                    )
 gpio-199 (                    )
 gpio-200 (GPIO11              )
 gpio-201 (                    |cd                  ) in  lo IRQ
 gpio-202 (                    |pwm-fan-tach        ) in  hi IRQ
 gpio-203 (                    |vdd-3v3-sd          ) out hi
 gpio-204 (                    )
 gpio-205 (                    )
 gpio-206 (                    )
 gpio-207 (                    )
 gpio-208 (                    )
 gpio-209 (                    )
 gpio-210 (                    )
 gpio-211 (                    )
 gpio-212 (                    )
 gpio-213 (                    )
 gpio-214 (                    )
 gpio-215 (                    )
 gpio-216 (GPIO09              )
 gpio-217 (                    )
 gpio-218 (                    )
 gpio-219 (                    )
 gpio-220 (                    )
 gpio-221 (                    )
 gpio-222 (                    )
 gpio-223 (                    )
 gpio-224 (                    )
 gpio-225 (                    |hdmi2.0_hpd         ) in  hi IRQ
 gpio-226 (                    )
 gpio-227 (                    )
 gpio-228 (                    |extcon:extcon@1     ) in  hi IRQ
 gpio-229 (                    )
 gpio-230 (                    )
 gpio-231 (                    |?                   ) out hi
 gpio-232 (SPI1_CS1            )
 gpio-233 (                    )
 gpio-234 (                    )
 gpio-235 (                    )
 gpio-236 (                    )
 gpio-237 (                    )
 gpio-238 (                    )
 gpio-239 (                    )

gpiochip1: GPIOs 504-511, parent: platform/max77620-gpio, max77620-gpio, can sleep:
 gpio-505 (                    |spmic-default-output) out hi
 gpio-507 (                    |vdd-3v3-sys         ) out hi
 gpio-510 (                    |enable              ) out lo
 gpio-511 (                    |avdd-io-edp-1v05    ) out lo
echo 38 > /sys/class/gpio/export
cat /sys/class/gpio/gpio38/direction
in
cat /sys/class/gpio/gpio38/value
0

Hi k-irisa,
It looks like something is wrong with your steps.
I followed these steps and i can see it output-high.
In gpio dtsi:
gpio-output-high = <
TEGRA_GPIO(E, 6) // This is added

In pinmux file:
pe6 {
nvidia,pins = “pe6”;nvidia,function = “rsvd0”;
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
};
Compile these changes and update kernel dtb in the final tree : Linux_for_Tegra/kernel/dtb/
and flash.

Check if you also have made the same changes.
My final dtb contents:
Dumped using dtc command to change dtb to dts:
pe6 {
nvidia,pins = “pe6”;
nvidia,function = “rsvd0”;
nvidia,pull = <0x0>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x0>;
};
gpio-output-high = <0x6 0xbb 0xe7 0x26>;

hello shgarg.

The procedure is the same, and dtc is the same.
I have two DeveloperKits and neither of them reflected the device tree.

However, I found a way for the device tree to reflect.
Flushing the DTB to the PR1 partition reflected the device tree.
I ran it below.

sudo ./flash.sh -k RP1  jetson-nano-qspi-sd mmcblk0p1

The question is, RP1 is listed as a partition to store the boot device tree, is that okay?