boot: add support for button commands
authorCaleb Connolly <caleb.connolly@linaro.org>
Tue, 9 Jan 2024 11:51:09 +0000 (11:51 +0000)
committerTom Rini <trini@konsulko.com>
Tue, 13 Feb 2024 20:38:49 +0000 (15:38 -0500)
commite761035b64235db8930eb15d2703dc3f43e99224
tree55a006d2199d296ed551840a84eaeab7ab64158f
parent348ea878508de90fdcc5a051cabe05d190e40e35
boot: add support for button commands

With the relatively new button API in U-Boot, it's now much easier to
model the common usecase of mapping arbitrary actions to different
buttons during boot - for example entering fastboot mode, setting some
additional kernel cmdline arguments, or booting with a custom recovery
ramdisk, to name a few.

Historically, this functionality has been implemented in board code,
making it fixed for a given U-Boot binary and requiring the code be
duplicated and modified for every board.

Implement a generic abstraction to run an arbitrary command during boot
when a specific button is pressed. The button -> command mapping is
configured via environment variables with the following format:

  button_cmd_N_name=<button label>
  button_cmd_N=<command to run>

Where N is the mapping number starting from 0. For example:

  button_cmd_0_name=vol_down
  button_cmd_0=fastboot usb 0

This will cause the device to enter fastboot mode if volume down is held
during boot.

After we enter the cli loop the button commands are no longer valid,
this allows the buttons to additionally be used for navigating a boot
menu.

Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # Tegra30
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
boot/Kconfig
common/Makefile
common/button_cmd.c [new file with mode: 0644]
common/main.c
doc/usage/environment.rst
include/button.h