PinePhone Volume Keys
Volume keys are connected via a resistor ladder to a low resolution ADC, which detects voltage changes and determines which key is pressed by measuring the voltage.
Using volume keys to affect the boot process (U-Boot)
I wrote an experimental patch for U-Boot. The patch will not be accepted upstream in this form, it's too PinePhone specific. It would need to be changed to use the device model, and to be more generic.
It checks the volume keys status and records it to the environment variable that can be accessed from U-Boot's boot script.
You can the use code like this in your U-Boot script to make boot choices based on volume keys status:
if test x$volume_key = xup ; then # choice when pressing volume up key elif test x$volume_key = xdown ; then # choice when pressing volume down key else # default choice fi
Reading volume keys status in Linux
You can get generic information on this page.