Configuring GPIO via DMA

I’ve been searching for a method to configure the GPIO on J41 header without using sysfs by directly changing the registers directly. I’ve found the base address for each GPIO ports from the TRM but how do I find the correct offset for a particular GPIO?

I’ve tried methods linked by @valentis and @snarky but it is not quite there yet. The address for the GPIO referenced within does not seem correct via /sys/kernel/debug/gpio

Thanks.

Please check this node for the address.

sudo -s
/sys/kernel/debug# cat tegra_pinctrl_reg

Hi, I was able to check the node but it did not help me. Let me give you a bit more information of what I’m trying to do.
I’m trying to use GPIO14 as an output to a simple LED circuit to practice accessing/configurating the GPIO via mmap(). This is the code I am trying to understand and it only works once I export GPIO14 via sysfs and set the output to OUT.

https://github.com/valentis/jetson-nano-gpio-example/blob/master/led.cpp (I edited GPIO12 to GPIO14 address on my side)

However I am able to see the values of the register changing with the code with/without exporting the GPIO. I’m assuming the “export” function in sysfs is enabling the clock to the GPIO controller that the code is missing?

Thanks for the help.

Hi Dang.Nguyen,

How about using fd and write/read to operate the export step in your code too?

int fd;
    //Open port/sys/class/gpio echo 48 > export
    fd = open(SYSFS_GPIO_EXPORT, O_WRONLY);
    if(fd == -1)
    {
        printf("ERR: Radio hard reset pin open error.\n");
        return EXIT_FAILURE;
    }

    write(fd, SYSFS_GPIO_RST_PIN_VAL ,sizeof(SYSFS_GPIO_RST_PIN_VAL));  //SYSFS_GPIO_RST_PIN_VAL=48

Yes, I suppose I could do that for the time being. However I would still like to know why the GPIO requires exporting when the PWM pin 33 does not via mmap. Could it be a pin mux issue?

No, I don’t think it is pinmux related issue. Our pinmux only tells the bootloader whether each pin is a gpio or sfio. Since this is in bootlaoder, it should have nothing to do with your application which runs in userspace.

Your problem is more related to the gpio framework of linux kernel.