mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-19 21:17:55 +00:00
librem_mini/librem_mini_v2: Add automatic power-on setting
Mini v1/v2's EC can automatically power on the system when power is applied, based on a value in EC BRAM. Add a configuration setting to optionally set this value. Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
parent
d148d3136a
commit
2d3ecfa41e
22
boards/librem_mini/initrd/bin/board-init.sh
Executable file
22
boards/librem_mini/initrd/bin/board-init.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/ash
|
||||
set -o pipefail
|
||||
|
||||
. /tmp/config
|
||||
|
||||
# Set the Mini v2 EC's automatic power-on setting.
|
||||
# CONFIG_AUTOMATIC_POWERON is three-valued:
|
||||
# y - enable automatic power on in EC
|
||||
# n - disable automatic power on in EC
|
||||
# <blank> - don't configure EC, could be configured from OS
|
||||
|
||||
# EC BRAM bank 1
|
||||
BRAMADDR=0x360
|
||||
BRAMDATA=0x361
|
||||
|
||||
if [ "$CONFIG_AUTOMATIC_POWERON" = "y" ]; then
|
||||
outb "$BRAMADDR" 0x29 # Select byte at offset 29h
|
||||
outb "$BRAMDATA" 0x00 # 0 -> automatic power on
|
||||
elif [ "$CONFIG_AUTOMATIC_POWERON" = "n" ]; then
|
||||
outb "$BRAMADDR" 0x29 # Select byte at offset 29h
|
||||
outb "$BRAMDATA" 0x01 # 1 -> stay off
|
||||
fi
|
@ -11,6 +11,7 @@ CONFIG_CRYPTSETUP2=y
|
||||
CONFIG_FLASHROM=y
|
||||
CONFIG_FLASHTOOLS=y
|
||||
CONFIG_GPG2=y
|
||||
CONFIG_IOPORT=y
|
||||
CONFIG_KEXEC=y
|
||||
CONFIG_UTIL_LINUX=y
|
||||
CONFIG_LVM2=y
|
||||
@ -42,3 +43,4 @@ export CONFIG_AUTO_BOOT_TIMEOUT=5
|
||||
export CONFIG_ROOT_DEV="/dev/nvme0n1p2"
|
||||
export CONFIG_ROOT_DIRLIST="bin boot lib sbin usr"
|
||||
export CONFIG_ROOT_CHECK_AT_BOOT="n"
|
||||
export CONFIG_SUPPORT_AUTOMATIC_POWERON=y
|
||||
|
22
boards/librem_mini_v2/initrd/bin/board-init.sh
Executable file
22
boards/librem_mini_v2/initrd/bin/board-init.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/ash
|
||||
set -o pipefail
|
||||
|
||||
. /tmp/config
|
||||
|
||||
# Set the Mini v2 EC's automatic power-on setting.
|
||||
# CONFIG_AUTOMATIC_POWERON is three-valued:
|
||||
# y - enable automatic power on in EC
|
||||
# n - disable automatic power on in EC
|
||||
# <blank> - don't configure EC, could be configured from OS
|
||||
|
||||
# EC BRAM bank 1
|
||||
BRAMADDR=0x360
|
||||
BRAMDATA=0x361
|
||||
|
||||
if [ "$CONFIG_AUTOMATIC_POWERON" = "y" ]; then
|
||||
outb "$BRAMADDR" 0x29 # Select byte at offset 29h
|
||||
outb "$BRAMDATA" 0x00 # 0 -> automatic power on
|
||||
elif [ "$CONFIG_AUTOMATIC_POWERON" = "n" ]; then
|
||||
outb "$BRAMADDR" 0x29 # Select byte at offset 29h
|
||||
outb "$BRAMDATA" 0x01 # 1 -> stay off
|
||||
fi
|
@ -43,3 +43,4 @@ export CONFIG_AUTO_BOOT_TIMEOUT=5
|
||||
export CONFIG_ROOT_DEV="/dev/nvme0n1p2"
|
||||
export CONFIG_ROOT_DIRLIST="bin boot lib sbin usr"
|
||||
export CONFIG_ROOT_CHECK_AT_BOOT="n"
|
||||
export CONFIG_SUPPORT_AUTOMATIC_POWERON=y
|
||||
|
@ -33,6 +33,7 @@ while true; do
|
||||
RESTRICTED_BOOT="$(load_config_value CONFIG_RESTRICTED_BOOT)"
|
||||
BASIC_NO_AUTOMATIC_DEFAULT="$(load_config_value CONFIG_BASIC_NO_AUTOMATIC_DEFAULT)"
|
||||
BASIC_USB_AUTOBOOT="$(load_config_value CONFIG_BASIC_USB_AUTOBOOT)"
|
||||
AUTOMATIC_POWERON="$(load_config_value CONFIG_AUTOMATIC_POWERON)"
|
||||
|
||||
dynamic_config_options=()
|
||||
|
||||
@ -53,6 +54,12 @@ while true; do
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "$CONFIG_SUPPORT_AUTOMATIC_POWERON" = "y" ]; then
|
||||
dynamic_config_options+=( \
|
||||
'N' " $(get_config_display_action "$AUTOMATIC_POWERON") Automatic Power-On" \
|
||||
)
|
||||
fi
|
||||
|
||||
unset menu_choice
|
||||
whiptail $BG_COLOR_MAIN_MENU --title "Config Management Menu" \
|
||||
--menu "This menu lets you change settings for the current BIOS session.\n\nAll changes will revert after a reboot,\n\nunless you also save them to the running BIOS." 0 80 10 \
|
||||
@ -390,6 +397,31 @@ while true; do
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
"N" )
|
||||
if [ "$AUTOMATIC_POWERON" = "n" ]; then
|
||||
if (whiptail --title 'Enable automatic power-on?' \
|
||||
--yesno "The system will boot automatically when power is applied.
|
||||
\n\nDo you want to proceed?" 0 80) then
|
||||
|
||||
toggle_config /etc/config.user "CONFIG_AUTOMATIC_POWERON"
|
||||
combine_configs
|
||||
|
||||
whiptail --title 'Config change successful' \
|
||||
--msgbox "Automatic power-on enabled;\nsave the config change and reboot for it to go into effect." 0 80
|
||||
fi
|
||||
else
|
||||
if (whiptail --title 'Disable automatic power-on?' \
|
||||
--yesno "The system will stay off when power is applied.
|
||||
\n\nDo you want to proceed?" 0 80) then
|
||||
|
||||
toggle_config /etc/config.user "CONFIG_AUTOMATIC_POWERON"
|
||||
combine_configs
|
||||
|
||||
whiptail --title 'Config change successful' \
|
||||
--msgbox "Automatic power-on disabled;\nsave the config change and reboot for it to go into effect." 0 80
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user