Detect hardware buttons in U-boot

Hello all,

As we know,
The TX1/TX2 has four hardware buttons such as POWER, RECOVERY, RESET, SLEEP.
Does anyone know how to get the SLEEP button status (pressed or released) in U-Boot?
Thanks a lot.

hello IsaHung,

may i have more details about why you’re going to detect hardware buttons from u-boot?
is there any use-case you could share to us?
thanks

Hello Jerry,

Thanks for your reply.
We want to implement a new feature for changing the rootfs path to other partition for a specific usage.
So we think the hardware button event is a good choice for us to trigger the signal during the U-Boot period.
Would you give us some suggestions to how to get the SLEEP button status?
Thanks a lot!

hello IsaHung,

there are functions in U-Boot to read GPIO state, e.g. gpio_direction_input() and gpio_get_value().
please have the modification to add code which calls those.
thanks

Hello Jerry,

Thanks for the information.
I had used these functions before,
but I do not know the GPIO mapping to SLEEP button in U-Boot.
It seems GPIO 314 is the sleep button in the kernel.
But U-Boot does not have this port.
Do you know which file should I modify?
Thank you very much.

hello IsaHung,

there’s GPIO mapping formulas, the GPIO numbers is calculated in the kernel stage.
please check [Tegra Linux Driver Package TX2 Adaptation Guide]-> [GPIO changes] for more details.
please refer to pinmux spreadsheet for the GPIO pin number.
thanks