How Set GPIO Port on latest uefi for Jetpack 7.2

Hi NV:

We add a piece of code used to control GPIO159 in InstallGpioProtocols() on TegraGpioDxe.c in r36.4.3 UEFI version,

The code is below list:

EMBEDDED_GPIO_PIN gpio33 = GPIO(0xF1, 44);

Status = gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid,NULL,(VOID **)&mGpioProtocol);

if (EFI_ERROR(Status)) {

DEBUG ((DEBUG_ERROR, “Locate GPIO protocol failed: %r\n”, Status));

return Status;

}

Status = mGpioProtocol->Set(mGpioProtocol, gpio33, GPIO_MODE_OUTPUT_0) ;

gBS->Stall(50 * 1000);

Status = mGpioProtocol->Set(mGpioProtocol, gpio33, GPIO_MODE_OUTPUT_1) ;

if (EFI_ERROR(Status)) {

DEBUG ((DEBUG_ERROR, “Set GPIO failed: %r\n”, Status));

return Status;

}
It can work correctly on Jetpack 6.2 with this UEFI bin.

However , we want to port this code into latest UEFI with Jetpack 7.2.

But it show error message below list:

Set GPIO failed: Not Found

TegraGpioDxe:

ASSERT_EFI_ERROR (Status = Not Found)

ASSERT [DebugStatusCodeDxe] [TegraGpioDxe] DeviceDiscoveryDriverLib.c(873): !(((RETURN_STATUS)(Status)) >= 0x8000000000000000ULL)

We have confirmed that the phandle value of gpio@2200000 in JetPack 7.2 is 0xF1, and the corresponding DTSI has been updated to configure this GPIO as an output.

However, the GPIO still does not behave as expected with the latest UEFI source.

Is there any additional GPIO initialization, configuration, or UEFI-specific procedure that needs to be added for this setting to take effect?

Please advise if there is anything else we need to configure in the latest UEFI implementation.
Thanks

Rolance

Hi rolance_li,

Are you using the devkit or custom board for AGX Orin?

This is likely because JP7.2 UEFI is not using the same GPIO description as your JP6.2 build.
In UEFI, the GPIO ID depends on the GPIO controller phandle in the UEFI/bootloader DTB, not only the kernel DTB, so please confirm that 0xF1 is the phandle of gpio@2200000 in the UEFI-used DTB.

You can refer to the following thread for using GPIO in UEFI.
AGX xavier with Jetpack 5.1.1:How do I get GPIO status in UEFI? - #8 by KevinFFF

Please also make sure the JP7.2 pinmux and gpio-default BCT files were updated and fully reflashed, because changing only the kernel DTSI is not enough for UEFI-stage GPIO control.

Hi Kevin:

We are using devkit on customer baord for AGX Orin. And it worked fine with R36.4.3 UEFI version that we modified GP159 with Jetpack 6.2.
Could you please advise where the GPIO controller phandle is defined or configured in the UEFI/bootloader DTB?

Thanks

Rolance

The GPIO controller phandle is defined in the UEFI/bootloader DTB node itself, typically gpio@2200000 for main GPIO on AGX Orin, not in TegraGpioDxe directly.
Please check the DTB specified by TBCDTB_FILE, since that DTB is used by UEFI/bootloader rather than the kernel DTB.
You can decompile that bootloader DTB and verify the phandle property under gpio@2200000.

Hi Kevin:

After we checked the DTB specified by TBCDTB_FILE , we found the phandle vaule that is different between kernel DTB , after we modified phandle from TBCDTB file , it can work correctly.

Thanks for your help.

Rolance