device-pine64-pinetab: shutdown on critical battery (MR 2193)

The PMIC AXP803 sends an interrupt to the A64 CPU when the
battery is critical low. This wakes up the tablet at ~10%
battery level, but UPower wasn't configured to add upon
this interrupt as the action level was way lower.
Therefore, the PMIC performed a hard shutdown when the
battery level dropped further, which may cause data loss.
This commit is contained in:
Dylan Van Assche 2021-05-24 18:17:59 +02:00 committed by Oliver Smith
parent cfb5d41bdf
commit ead17254db
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 108 additions and 2 deletions

View file

@ -3,8 +3,8 @@
# Co-Maintainer: Martijn Braam <martijn@brixit.nl>
pkgname=device-pine64-pinetab
pkgdesc="PINE64 PineTab"
pkgver=0.9
pkgrel=1
pkgver=0.10
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
@ -26,6 +26,7 @@ subpackages="
$pkgname-phosh
$pkgname-nonfree-firmware:nonfree_firmware
$pkgname-plasma-mobile:plasma_mobile
$pkgname-upower
"
install="$pkgname.post-install"
source="
@ -40,6 +41,7 @@ source="
ucm/HiFi.conf
ucm/PineTab.conf
weston.ini
UPower.conf
"
prepare() {
@ -148,6 +150,15 @@ plasma_mobile() {
install -Dm644 "$srcdir"/kirigami-lowpower.sh "$subpkgdir"/etc/profile.d/kirigami-lowpower.sh
}
upower() {
install_if="$pkgname=$pkgver-r$pkgrel upower"
mkdir "$subpkgdir"
# Shutdown when PMIC reports critical battery level
install -Dm644 "$srcdir"/UPower.conf -t \
"$subpkgdir"/etc/UPower/UPower.conf
}
sha512sums="
8d1ef04911f1cfa7eda8185f4f4d807af23105a7c8f23d8c18f02afeccd8ab124de70c2e2760c154a3128fe3793447039fb0abf37aa496f597d27051e275033e 99-pinetab-keyboard.hwdb
a884cdb677d40f733fde5ce57fc2740a29a9f8a4a62d9ac327710a650d0d21d378226653e50d67cd0765f6e6cb81e6a243a92905d0ce8b8d8ab751abb69a79d5 deviceinfo
@ -160,4 +171,5 @@ f4b5509fd6a8b23f3667f5e7262b3a19c607a37cb9eaf7d0e93eb826d45c26ec12df4810879bacb8
a2fd8037c9a1af000f31c7005436d791525317f818c553d1e2f472b4df76c71d769ecbf67b369a478bea720a6215eaa9fb6a26ba218ac9410513e2345ebe7b4c HiFi.conf
3bdf9d4c41058680d488d9b4a2ac5fd693ceddc5f319a577480546f8af7d9d64c9d3196e73cb0c00e793697eef4ad075c88c3d274702a5387c15945bc749d844 PineTab.conf
6374ef977eab14b71fa88057ebd52ca03035e387e5f41504598a990f24b2e92bccd2db476c545dc541000e08fccdecb6f1cd63e25b5835df706269e0384dacc7 weston.ini
ed0e03f7e1c0348c06be9a7922414469245604ce813bbf0c8910ef211cb993bbb0d0d4615c9c961d50712415f85d6b73e0cf02780ac784666aac56e4889341e4 UPower.conf
"

View file

@ -0,0 +1,94 @@
# Only the system vendor should modify this file, ordinary users
# should not have to change anything.
[UPower]
# Enable the Watts Up Pro device.
#
# The Watts Up Pro contains a generic FTDI USB device without a specific
# vendor and product ID. When we probe for WUP devices, we can cause
# the user to get a perplexing "Device or resource busy" error when
# attempting to use their non-WUP device.
#
# The generic FTDI device is known to also be used on:
#
# - Sparkfun FT232 breakout board
# - Parallax Propeller
#
# default=false
EnableWattsUpPro=false
# Don't poll the kernel for battery level changes.
#
# Some hardware will send us battery level changes through
# events, rather than us having to poll for it. This option
# allows disabling polling for hardware that sends out events.
#
# default=false
NoPollBatteries=false
# Do we ignore the lid state
#
# Some laptops are broken. The lid state is either inverted, or stuck
# on or off. We can't do much to fix these problems, but this is a way
# for users to make the laptop panel vanish, a state that might be used
# by a couple of user-space daemons. On Linux systems, see also
# logind.conf(5).
#
# default=false
IgnoreLid=false
# Policy for warnings and action based on battery levels
#
# Whether battery percentage based policy should be used. The default
# is to use the time left, change to true to use the percentage, which
# should work around broken firmwares. It is also more reliable than
# the time left (frantically saving all your files is going to use more
# battery than letting it rest for example).
# default=true
UsePercentageForPolicy=true
# When UsePercentageForPolicy is true, the levels at which UPower will
# consider the battery low, critical, or take action for the critical
# battery level.
#
# This will also be used for batteries which don't have time information
# such as that of peripherals.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# PercentageLow=10
# PercentageCritical=3
# PercentageAction=2
PercentageLow=20
PercentageCritical=17
PercentageAction=15
# When UsePercentageForPolicy is false, the time remaining at which UPower
# will consider the battery low, critical, or take action for the critical
# battery level.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# TimeLow=1200
# TimeCritical=300
# TimeAction=120
TimeLow=1200
TimeCritical=300
TimeAction=120
# The action to take when "TimeAction" or "PercentageAction" above has been
# reached for the batteries (UPS or laptop batteries) supplying the computer
#
# Possible values are:
# PowerOff
# Hibernate
# HybridSleep
#
# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used
CriticalPowerAction=PowerOff