purism-librem5: fix ship mode on Linux 6.3 and higher (MR 4128)

Taken from https://source.puri.sm/Librem5/librem5-base/-/merge_requests/353

Closes https://gitlab.com/postmarketOS/pmaports/-/issues/2130

Co-authored-by: Oliver Smith <ollieparanoid@postmarketos.org>

[ci:skip-build] already built successfully in CI
This commit is contained in:
Newbyte 2023-05-29 12:04:02 +02:00 committed by Clayton Craft
parent b2e5ad1670
commit bc0ff89fdc
No known key found for this signature in database
GPG key ID: 4A4CED6D7EDF950A
2 changed files with 66 additions and 2 deletions

View file

@ -0,0 +1,62 @@
From c9b9f583fbbab90a96fe5fd33735a7bb4a1c018c Mon Sep 17 00:00:00 2001
From: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Date: Thu, 16 Mar 2023 00:15:03 +0100
Subject: [PATCH 1/2] shipmode: Enable Hi-Z mode using kernel interface
Since kernel 6.3, bq25890 driver allows to enable Hi-Z via sysfs.
---
default/shipmode/l5-poweroff-shipmode | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/default/shipmode/l5-poweroff-shipmode b/default/shipmode/l5-poweroff-shipmode
index bbe42e3..a7a849a 100755
--- a/default/shipmode/l5-poweroff-shipmode
+++ b/default/shipmode/l5-poweroff-shipmode
@@ -24,6 +24,6 @@ fi
# Only continue setting ship mode when running on battery.
# Connecting a charger will turn on the phone. The battery will
# not have been discharged in the meantime though:
-i2cset -f -y 3 0x6a 0x00 0x88
+echo 0 > /sys/class/power_supply/bq25890-charger/online
# shut off the battery with 10-15 second delay
i2cset -f -y 3 0x6a 0x09 0x6e
--
GitLab
From 0dccc96deedb59420f679026392723b7c1850a15 Mon Sep 17 00:00:00 2001
From: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Date: Sat, 6 May 2023 16:53:10 +0200
Subject: [PATCH 2/2] shipmode: Fix the bq25890 sysfs path for recent kernels
Since Linux 6.3 bq25890 supports having multiple instances and
therefore the name in sysfs has changed. Adjust the script
to use the new name.
---
default/shipmode/l5-poweroff-shipmode | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/default/shipmode/l5-poweroff-shipmode b/default/shipmode/l5-poweroff-shipmode
index a7a849a..a1df624 100755
--- a/default/shipmode/l5-poweroff-shipmode
+++ b/default/shipmode/l5-poweroff-shipmode
@@ -15,7 +15,7 @@ fi
# when turned off. Disconnecting the charger later would of course
# result in the "old" behaviour of slowly discharging while powered off
# because ship mode is not set:
-charging=$(cat /sys/class/power_supply/bq25890-charger/online)
+charging=$(cat /sys/class/power_supply/bq25890-charger-0/online)
if [ "$charging" -eq "1" ]; then
echo 'Charger connected. Not setting ship mode.'
exit 0
@@ -24,6 +24,6 @@ fi
# Only continue setting ship mode when running on battery.
# Connecting a charger will turn on the phone. The battery will
# not have been discharged in the meantime though:
-echo 0 > /sys/class/power_supply/bq25890-charger/online
+echo 0 > /sys/class/power_supply/bq25890-charger-0/online
# shut off the battery with 10-15 second delay
i2cset -f -y 3 0x6a 0x09 0x6e
--
GitLab

View file

@ -3,7 +3,7 @@
# Co-Maintainer: Alistair Francis <alistair@alistair23.me>
# Co-Maintainer: Newbyte <newbyte@postmarketos.org>
pkgname=device-purism-librem5
pkgver=1.46
pkgver=1.47
pkgrel=0
_confver=60
_purismrel=1
@ -19,7 +19,7 @@ depends="
gnss-share
i2c-tools
iw
linux-purism-librem5
linux-purism-librem5>=6.3
mesa-egl
postmarketos-base
u-boot-librem5
@ -45,6 +45,7 @@ source="
l5-ship-mode.initd
l5-lockdown-support.initd
0002-pm-udev-Use-DEVPATH-instead-of-ID_PATH.patch
0003-fix-ship-mode-linux-6.3.patch
"
subpackages="
$pkgname-camera
@ -184,4 +185,5 @@ b45749fcddfd65a302b502bcabfa5828d1b63e45d844fd50e44009a756b919db20fe9526102947c0
c723764d507ccd4b04aa5ce79b1d1ebc131873cdc37a943cb0f92b8a08a3c69eb9e0d31fcd4589fd8c40a9676bae9897e4f12ec2ebe4db8214ac85669ef35a53 l5-ship-mode.initd
f4b314d553655f7975445ac0a33099923e20dabb082c07e2cf6a78e4118c143d777dd4ad2c09cbc388600bdefe8deb3073fbd15b238772ddf09c66ac46415590 l5-lockdown-support.initd
f70597afb93ca5a8bf1ff2414d77616e3820bb187120b252142af3d586f69fc1e71b438112f3c9173c86e81172f6a855f54e040b26d2591a04ee3510458c58d1 0002-pm-udev-Use-DEVPATH-instead-of-ID_PATH.patch
a075f3952dfdd4bcadc055f853b6d5206c5db4efcacfa27541653fd5a7daef6e753d6c7ed74fd1aad2a40837450fdac76fa04a61829e08bd938cc3548cbe8390 0003-fix-ship-mode-linux-6.3.patch
"