How to get the status of the GPIO port in the Uboot module?

Core Board: TX2 NX
Carrier Board: Jetson_Xavier_NX
Linux Jetson version:R32.7.1
The GPIO port information is as follows:

The code to get the status of the GPIO port is as follows:
gpio_request(172, “GPIO172”);
printf("gpio GPIO 172 status: %2d ", gpio_get_value(172));
Whether the GPIO port is pulled high or low, the printed status is displayed as 0,

Please help to check whether the method to get the GPIO port status is correct?

hello donglinhui2006,

you may also interrupt uboot, using the command-line to check the GPIO status. i.e. # gpio status <gpionum>

gpio <input|set|clear|toggle> <pin>
    - input/set/clear/toggle the specified pin
gpio status [-a] [<bank> | <pin>]  - show [all/claimed] GPIOs

Hello JerryChang, is there any problem with the implementation of the code I mentioned above?

hello donglinhui2006,

gpio_request() has deprecated, please use dm_gpio_request() to request a GPIO manually.
you may see-also the header file, u-boot/include/asm-generic/gpio.h. thanks

Hello JerryChang, the status of the GIPO port can be read correctly now, thank you very much! !