GPIO control on Xavier nx with register writes

Device: Xavier Nx

To toggle GPIO pins, the basic approach is to write 1 or 0 to the “/sys/class/gpio/gpioxxx/value” file.

Above approach is fine but being a file operation it is quite slow and not appropriate for very fast operations.

I guess we can also do some register level operations to toggle the GPIO and that will be a much faster approach. Could someone please suggest what needs to be done to control GPIO output with register writes ? I was able to refer to some discussions on doing the same task on Jetson Nano but it looks like Xavier needs some other approach.

hello msd11,

please refer to python library, Jetson GPIO for the samples that enables the use of Jetson’s GPIOs.
you may also see Topic 144550, for several ways to access GPIOs. such as, kernel APIs, python scripts, C++ samples.
thanks

Pardon me for late response but things have started to move in the regards of this issue.

Python library again uses file operations.

I wanted to be able to manipulate registers to control GPIOs i-e mmap operation with GPIO registers.

To be able to play with GPIO registers, the first step will be to find out the register addresses.

I used the links from Topic 144550 to write a script to read/modify xavier nx’s registers.

On referring to Xavier technical reference manual, I tried to figure out the GPIO registers but it seemed little complicated.

For an example, I was able to successfully figure out the address of PWM’s1 register and used mmap operations to turn it off.
(1) Table in the section 3.1.2 System Address Map (Page 42 ) mentions,
PWM1 0x03280000 0x0328ffff SYSTEM

(2) So, we have the start address of PWM1 register and now we need bit wise description of the register to be able to control the PWM.

(3) Section 10.7.3 PWM Registers contains the bit wise description and using the info from the two sections mentioned above, I was able to manipulate the correct bit to turn off/onPWM.

This looks fine, but my goal is to be able to control GPIOs with register writes (lets say GPIO11 for example).

Following the same steps as I did for PWM, I started looking for GPIO register addresses corresponding to GPIO11 in section 3.1.2. Jetson_Xavier_NX_Pinmux_Configuration_Template_v1.06.xlsm mentions full description for gpio11 as GPIO3_PQ.06.

So , thinking logically, I tried to locate GPIO3 in the section 3.1.2 of TRM but found numerous GPIO3s over there, namely, GPIO_CTL0_GPIO3, GPIO_CTL1_GPIO3, etc.

So how to figure out which address should I consult from all of these CTLX_GPIO3 addresses available ?

and, if this is done then how to find GPIO register description just like there is one for PWM registers in section 10.7.3 of xavier’s TRM ?

hello msd11,

you may refer to tegra19x-mb1-pinmux-p3668-a01.cfg for the register address.
for example, GPIO3_PQ.06.
pinmux.0x02430030 = 0x00000000; # GPIO soc_gpio42_pq6
thanks

Hey Jerry, thanks for replying


image

I checked out the file you shared. As far as I could understand these registers are configuration registers for the pins, like configuring them as GPIO/SFIO etc. but these registers don’t offer the control over setting the GPIO high/low or setting the GPIO as input or output .

How to locate these registers ? Can it be located using TRM or kernel source ?

hello msd11,

you’ll need to refer to the PADCTL_A0 for the base address, 0x02430000,
and, please adding offsets for the register address.

Hello Jerry,

If I am right then the registers which you have suggested are pinmux registers which are used to configure pin properties,

But my use case is:
I have allready configured the GPIO using file operations (as in Jetson GPIO) and now all I need to do is to make the GPIO output value HIGH or LOW (i-e /sys/class/gpio/gpio266/value should read 1 or 0) and I need help in locating the register or a bit which I should toggle so that the output at corresponding GPIO turns HIGH or LOW.

Summary:

  1. configure a GPIO as output & other pinmux settings —done
  2. Make the GPIO, HIGH —need help

@JerryChang

can you toggle the pin as following to configure it as high?
echo out > direction && echo 1 > value