librem_mini,librem_mini_v2: Don't use three values for auto poweron

PureBoot doesn't have any other three-valued settings and this doesn't
present very well in the config UI.

Instead make this a two-valued setting; drop the mode that forces the
EC setting to "stay off" at every boot because this is the default.

When disabling automatic power-on, disable the EC BRAM setting too.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2023-03-25 10:49:15 -04:00
parent 5e555359a4
commit e9a5b27e6c
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114
5 changed files with 57 additions and 32 deletions

View File

@ -1,22 +1,16 @@
#!/bin/ash
#!/bin/bash
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 is set, always set the EC BRAM setting during
# boot. It persists as long as the RTC battery is set, but set it during every
# boot for robustness in case the battery is temporarily removed, or the user
# toggles in config-gui and then does not flash, etc.
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
set_ec_poweron.sh y
fi
# Don't disable the setting in the EC BRAM though if CONFIG_AUTOMATIC_POWERON
# is not enabled. The default is disabled anyway, and the OS could configure
# it.

View File

@ -0,0 +1,16 @@
#!/bin/bash
# Set the EC BRAM setting for automatic power-on.
# If $1 is 'y', enable automatic power-on. Otherwise, disable it.
# EC BRAM bank 1
BRAMADDR=0x360
BRAMDATA=0x361
outb "$BRAMADDR" 0x29 # Select byte at offset 29h
if [ "$1" = "y" ]; then
outb "$BRAMDATA" 0x00 # 0 -> automatic power-on
else
outb "$BRAMDATA" 0x01 # 1 -> stay off
fi

View File

@ -1,22 +1,16 @@
#!/bin/ash
#!/bin/bash
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 is set, always set the EC BRAM setting during
# boot. It persists as long as the RTC battery is set, but set it during every
# boot for robustness in case the battery is temporarily removed, or the user
# toggles in config-gui and then does not flash, etc.
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
set_ec_poweron.sh y
fi
# Don't disable the setting in the EC BRAM though if CONFIG_AUTOMATIC_POWERON
# is not enabled. The default is disabled anyway, and the OS could configure
# it.

View File

@ -0,0 +1,16 @@
#!/bin/bash
# Set the EC BRAM setting for automatic power-on.
# If $1 is 'y', enable automatic power-on. Otherwise, disable it.
# EC BRAM bank 1
BRAMADDR=0x360
BRAMDATA=0x361
outb "$BRAMADDR" 0x29 # Select byte at offset 29h
if [ "$1" = "y" ]; then
outb "$BRAMDATA" 0x00 # 0 -> automatic power-on
else
outb "$BRAMDATA" 0x01 # 1 -> stay off
fi

View File

@ -435,6 +435,11 @@ while true; do
set_user_config "CONFIG_AUTOMATIC_POWERON" "n"
# Disable the EC BRAM setting too, otherwise it persists until
# manually disabled. On the off chance the user does not actually
# flash this change, we'll enable it again during boot.
set_ec_poweron.sh n
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