Direct Register Access Issue with Jetson Nano

I am trying to use this (github) to read input from the J.00 to J.07 registers as fast as possible by changing the code:

//  set up a pointer for convenient access -- this pointer is to the selected GPIO controller
    GPIO_mem volatile *pin = (GPIO_mem volatile *)((char *)base + (GPIO_2 & pagemask));

    pin->CNF[0] = 0x00ff;
    pin->OE[0] = 0xff;
    pin->OUT[0] = 0xff;
    //  pin->IN = 0x00; read only
    //  disable interrupts
    pin->INT_ENB[0] = 0x00;
    //  don't worry about these for now
    //pin->INT_STA[0] = 0x00;
    //pin->INT_LVL[0] = 0x000000;
    //pin->INT_CLR[0] = 0xffffff;

    fprintf(stderr, "press ctrl-C to stop\n");

    //  "blink" the output values
    uint8_t val = 0xff;
    while (true) {
        sleep(1);
        val = val ^ 0xff;
        pin->OUT[0] = val;
    }

to:

//  set up a pointer for convenient access -- this pointer is to the selected GPIO controller
    GPIO_mem volatile *pin = (GPIO_mem volatile *)((char *)base + (GPIO_3 & pagemask));

    pin->CNF[1] = 0x00ff;
    //pin->OE[1] = 0xff;
    //pin->OUT[0] = 0xff;
    //  pin->IN = 0x00; read only
    //  disable interrupts
    //pin->INT_ENB[1] = 0x00;
    //  don't worry about these for now
    //pin->INT_STA[0] = 0x00;
    //pin->INT_LVL[0] = 0x000000;
    //pin->INT_CLR[0] = 0xffffff;

    fprintf(stderr, "press ctrl-C to stop\n");

    //  "blink" the output values
    uint8_t val = 0xff;
    int cnt = 0;
    while (true) {
        
        printf("%d \n", pin->IN[1]);
    }

This code prints 2 ** i when pin J.0i is high. When I set any of pins J.00 to J.03 to high I get the expected output, but when I set any of pins J.04 to J.07 to high I get a seemingly random mix of 0 and the proper value as the output. Does anyone know why this could be? As a final note, pins J.00 to J.03 are I2C in SFIO mode and J.04 to J.07 are I2S in SFIO mode. All 8 pins are set to GPIO mode but this is the only difference I can discern.

hello ian.strothers,

are you able to control these pin via sysfs?
for example,
please enter the location of the GPIOs
# cd /sys/class/gpio
you should create node for your usage, let’s take J.04, gpio76 as an example,
# echo 76 > export
enable the node to enable the controls.
# cd /sys/class/gpio/gpio76
# echo out > direction
# echo 1 > value

besides,
you may also check tegra-gpio.h for the formula to calculate GPIO numbers.
it’s 9 * 8 + 4 = 76 for this pin, J.04.

#define TEGRA_GPIO_PORT_J 9
...

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