May I ask if pin124, pin126, pin127, and pin128 can be used as regular GPIO

Our electronic engineer connected several IO interfaces of the VS1053B chip to these pins, but I don’t know how to write or read values to these pins。

Hi zhang_ruiwu,

Are you using the devkit or custom board for Jetson Nano?
What’s your Jetpack version in use?

You could configure pins as GPIO through pinmux spreadsheet, and use sysfs to control them.

VS1053B seems a multi-format audio codec chip.
You might need to port their driver on Jetson Nano, you could get the sample code or porting guide from your vendor.

I am using a custom board.
I tried to export the GPIO files for these IO ports, but an error was reported.

sudo echo 126 > export
echo: write error: Invalid argument

JetPack Version: 4.6.3

Could you share the result of the following command?

$ sudo 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   (                    |sysfs               ) in  lo
 gpio-4   (                    |sysfs               ) in  lo
 gpio-5   (                    |sysfs               ) in  hi
 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           |sysfs               ) out lo
 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 (                    )
 gpio-202 (                    |pwm-fan-tach        ) in  hi IRQ
 gpio-203 (                    |vdd-3v3-sd          ) out lo
 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              |sysfs               ) in  lo
 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 hi
 gpio-511 (                    |avdd-io-edp-1v05    ) out lo

where do you run this command?

Could you refer to the following steps to export gpio-126?

$ sudo su
# echo 126 > /sys/class/gpio/export

When I export the pins I mentioned, the system will report an error: “echo: write error: Invalid argument”.
But if I export gpio-79, there’s no problem.
Do I need to modify the device tree before exporting gpio.

 gpio-126 (                    )

Since there’s gpio-126 in your /sys/kernel/debug/gpio, it should be export.

May I know what’s you use case?
Have you configure the pinmux before using these pins?

I haven’t configured the pinmux.
The hardware connection is like this:
image
Connected to VS1053B through 4 GPIO ports and SPI for driving VS1053B.

image

It seems you misunderstanding the GPIO ID.

Let me take GPIO03 (126) as example.
From pinmux spreadsheet you would find it as following


PI.02 would be mapping to gpio-66 (8*8+2) which could be derived from tegra-gpio.h.

So, you should use the following command to export GPIO03 (the pin126 you mean)

$ sudo su
# echo 66 > /sys/class/gpio/export

Thank you. I tried it and it was okay. But I want to know how I know how pins and GPIOs are mapped.

Please download the pinmux spreadsheet(an excel file) for your board from download center.

Thank you.
Based on pinmux, I calculated that pin124, pin126, pin127, and pin128 correspond to GPIO-62, GPIO-66, GPIO-65, and GPIO-63
When I exported GPIO-65, an error occurred:

nano@nano:/sys/class/gpio$ sudo echo 65 > /sys/class/gpio/export
echo: write error: Device or resource busy

So I executed the following command to check the GPIO usage status.

nano@nano:/sys/class/gpio/gpio66$ sudo cat /sys/kernel/debug/gpio

The result:
image
What should I do?

How do you configure pin127(gpio-65) in your pinmux spreadsheet?

It might be caused from another driver is using this pin already.
Please check your device tree or change to another pin.

I haven’t configured Pinmux before, it should be the default configuration

I noticed that the configuration of GPIO-03 differs significantly from the other several, is it related to this?

It seems be configured as Bidirectional/Z in pinmux spreadsheet.
You could configure it as Output/Drive 0 as other pins if you want to use it as GPIO.

Thank you! Could you help provide a tutorial on modifying the device tree?