device-pine64-pinephone: do not rely on modem-power from kernel (MR 1815)
This adds eg25-manager for managing modem power in userspace instead of relying on the modem-power stuff in the kernel. The userspace eg25-manager has proven to be more reliable than using modem-power. An older setup-modem script is installed for ofono, since eg25-manager cannot interface with ofono (yet). The eg25 init script was removed since it only dealt with configuring the modem-power driver in the kernel [ci:skip-build]: already built successfully in CI
This commit is contained in:
parent
c175be405a
commit
d0588c4046
4 changed files with 138 additions and 39 deletions
|
@ -4,17 +4,19 @@
|
|||
# Co-Maintainer: Bart Ribbers <bribbers@disroot.org>
|
||||
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
|
||||
pkgname=device-pine64-pinephone
|
||||
pkgver=0.15
|
||||
pkgver=0.16
|
||||
pkgrel=0
|
||||
pkgdesc="PINE64 PinePhone"
|
||||
url="https://postmarketos.org"
|
||||
license="MIT"
|
||||
arch="aarch64"
|
||||
options="!check !archcheck"
|
||||
subpackages="$pkgname-nonfree-firmware:nonfree_firmware $pkgname-phosh"
|
||||
subpackages="$pkgname-nonfree-firmware:nonfree_firmware $pkgname-phosh $pkgname-ofono"
|
||||
depends="
|
||||
alsa-ucm-conf
|
||||
atinout
|
||||
eg25-manager
|
||||
eg25-manager-openrc
|
||||
gpsd
|
||||
linux-postmarketos-allwinner
|
||||
mesa-dri-gallium
|
||||
|
@ -36,8 +38,8 @@ source="deviceinfo
|
|||
ucm/PinePhone.conf
|
||||
ucm/HiFi.conf
|
||||
ucm/VoiceCall.conf
|
||||
eg25.initd
|
||||
setup-modem.sh
|
||||
setup-modem.sh.ofono
|
||||
asound.conf
|
||||
"
|
||||
# workaround to purge the -elogind subpackage that was previously
|
||||
|
@ -87,13 +89,20 @@ package() {
|
|||
"$pkgdir"/usr/share/alsa/ucm2/PinePhone/VoiceCall.conf
|
||||
|
||||
# Modem
|
||||
install -Dm755 "$srcdir"/eg25.initd "$pkgdir"/etc/init.d/eg25
|
||||
install -Dm755 "$srcdir"/setup-modem.sh \
|
||||
"$pkgdir"/usr/bin/pinephone_setup-modem
|
||||
install -Dm644 "$srcdir"/90-modem-eg25.rules -t "$pkgdir"/usr/lib/udev/rules.d/
|
||||
|
||||
}
|
||||
|
||||
ofono() {
|
||||
pkgdesc="ofono support"
|
||||
install_if="$pkgname=$pkgver-r$pkgrel ofono"
|
||||
replaces="$pkgname"
|
||||
install -Dm755 "$srcdir"/setup-modem.sh.ofono \
|
||||
"$subpkgdir"/usr/bin/pinephone_setup-modem
|
||||
}
|
||||
|
||||
nonfree_firmware() {
|
||||
pkgdesc="Wifi, Bluetooth and Autofocus firmware"
|
||||
depends="linux-firmware-rtlwifi linux-firmware-rtl_bt firmware-pine64-rtl8723bt firmware-pine64-ov5640"
|
||||
|
@ -117,6 +126,6 @@ ccbc83b84b5028bc2c8e526759004ce71b50b2675ecffee98f5676c70a3332197a231ff9d2fd4644
|
|||
e852b48a687f9b2a0eca444aa3d00a1818aead9f5e5d28e070b51c9d6f8ec648e66f1d88e2bfa94d74533f9ffb9aacc1703da2a06693f85fa04ff97fd7528012 PinePhone.conf
|
||||
420c0053c7eb115065a2a30ce7e669f05bda0dd7f416633e4917ed50db46a52ce0b613b2452bcd12d2813cf0401b0a1b489306b0f0e77e5b46a2a2e46368d6a2 HiFi.conf
|
||||
5bb910286b2e224aaee0bc08d18d75d9d6466f6c83ef8939036cf0f6aba6a8bcb56d114002d88eb6ed8266d03ee599fbac2f5b43e786b86b7c2eda10547a3878 VoiceCall.conf
|
||||
db57bd1613ae988a05df86fa962352145f480e1a4e5a0ff921e734cf35ecd755b7f14775a70bb31a7e875813cbc7a4722202cf76023f1b15862bbd5390d0b757 eg25.initd
|
||||
fa063e2863afc48e627acc1a5b213a81499ba1dd30325f74f118a44e3964aec7e597b1f4bd318b7cf5bf14f27daf88e6ad9fc277ab106cbbe1189fdcc650d5c1 setup-modem.sh
|
||||
0c81d758e1bcb56ed2cdaf91124121ebbd4dd7a5e25f02a7685b837faf660949d05f6b07b39a1c6a9ca22a7029cdcf3c6dac8f1038e37c8a34cb7c5702e9df51 setup-modem.sh.ofono
|
||||
5736444fd38ab4351d148ae96c479085f469bd1e51a692fb1827f8ac921a584389f7696985e1fba21c2deac88709910531f4ece282f45ff54e590c2b54b84ba3 asound.conf"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
rc-update add eg25 default
|
||||
rc-update add eg25-manager default
|
||||
rc-update add gpsd default
|
||||
rc-update add gpsd_pinephone default
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
description="Starting EG25 WWAN module"
|
||||
|
||||
depend()
|
||||
{
|
||||
before ofono
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
ebegin "Enabling EG25 WWAN module"
|
||||
echo 1 > /sys/class/modem-power/modem-power/device/powered
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
if [ -d /sys/class/modem-power/modem-power ]; then
|
||||
ebegin "Disabling EG25 WWAN module (modem_power)"
|
||||
echo 0 > /sys/class/modem-power/modem-power/device/powered
|
||||
eend $?
|
||||
else
|
||||
# Keep legacy code path for shutdown of old kernel after upgrade
|
||||
ebegin "Disabling EG25 WWAN module (legacy)"
|
||||
echo 1 > /sys/class/gpio/gpio68/value
|
||||
echo 1 > /sys/class/gpio/gpio232/value
|
||||
|
||||
echo 1 > /sys/class/gpio/gpio35/value && sleep 2 && echo 0 > /sys/class/gpio/gpio35/value
|
||||
sleep 30 # Wait for the module to power off
|
||||
eend 0
|
||||
fi
|
||||
}
|
123
device/main/device-pine64-pinephone/setup-modem.sh.ofono
Normal file
123
device/main/device-pine64-pinephone/setup-modem.sh.ofono
Normal file
|
@ -0,0 +1,123 @@
|
|||
#!/bin/sh
|
||||
|
||||
log() {
|
||||
echo "$@" | logger -t "postmarketOS:modem-setup"
|
||||
}
|
||||
|
||||
# Current modem routing
|
||||
#
|
||||
# 1 - Digital PCM
|
||||
# 1 - I2S slave
|
||||
# 0 - Primary mode (short sync)
|
||||
# 1 - 256kHz clock (256kHz / 16bit = 16k samples/s)
|
||||
# 0 - 16bit linear format
|
||||
# 0 - 8k sample/s
|
||||
# 1 - 1 slot
|
||||
# 1 - map to first slot (the only slot)
|
||||
#
|
||||
QDAI_CONFIG="1,1,0,1,0,0,1,1"
|
||||
QCFG_RISIGNALTYPE_CONFIG="physical"
|
||||
QMBNCFG_CONFIG="1"
|
||||
QCFG_IMS_CONFIG="1"
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
DEV="/dev/EG25.AT"
|
||||
else
|
||||
DEV="$1"
|
||||
fi
|
||||
|
||||
# When running this script from udev the modem might not be fully initialized
|
||||
# yet, so give it some time to initialize
|
||||
#
|
||||
# We'll try to query for the firmware version for 15 seconds after which we'll
|
||||
# consider the initialization failed
|
||||
|
||||
log "Waiting for the modem to initialize"
|
||||
INITIALIZED=false
|
||||
for second in $(seq 1 15)
|
||||
do
|
||||
if echo "AT+QDAI?" | atinout - $DEV - | grep -q OK
|
||||
then
|
||||
INITIALIZED=true
|
||||
break
|
||||
fi
|
||||
|
||||
log "Waited for $second seconds..."
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if $INITIALIZED
|
||||
then
|
||||
log "Modem initialized"
|
||||
else
|
||||
log "Modem failed to initialize"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read current config
|
||||
QDAI_ACTUAL_CONFIG=$(echo "AT+QDAI?" | atinout - $DEV -)
|
||||
QCFG_RISIGNALTYPE_ACTUAL_CONFIG=$(echo 'AT+QCFG="risignaltype"' | atinout - $DEV -)
|
||||
QMBNCFG_ACTUAL_CONFIG=$(echo 'AT+QMBNCFG="AutoSel"' | atinout - $DEV -)
|
||||
QCFG_IMS_ACTUAL_CONFIG=$(echo 'AT+QCFG="ims"' | atinout - $DEV -)
|
||||
|
||||
if echo $QDAI_ACTUAL_CONFIG | grep -q $QDAI_CONFIG && \
|
||||
echo $QCFG_RISIGNALTYPE_ACTUAL_CONFIG | grep -q $QCFG_RISIGNALTYPE_CONFIG && \
|
||||
echo $QMBNCFG_ACTUAL_CONFIG | grep -q $QMBNCFG_CONFIG && \
|
||||
echo $QCFG_IMS_ACTUAL_CONFIG | grep -q $QCFG_IMS_CONFIG
|
||||
then
|
||||
log "Modem already configured"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Modem not configured, we need to send it the digital interface configuration,
|
||||
# then reboot it
|
||||
|
||||
# Configure audio
|
||||
RET=$(echo "AT+QDAI=$QDAI_CONFIG" | atinout - $DEV -)
|
||||
|
||||
if ! echo $RET | grep -q OK
|
||||
then
|
||||
log "Failed to configure audio: $RET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Configure ring device
|
||||
RET=$(echo "AT+QCFG=\"risignaltype\",\"$QCFG_RISIGNALTYPE_CONFIG\"" | atinout - $DEV -)
|
||||
|
||||
if ! echo $RET | grep -q OK
|
||||
then
|
||||
log "Failed to configure modem ring wakeup: $RET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Configure VoLTE auto selecting profile
|
||||
RET=$(echo "AT+QMBNCFG=\"AutoSel\",$QMBNCFG_CONFIG" | atinout - $DEV -)
|
||||
|
||||
if ! echo $RET | grep -q OK
|
||||
then
|
||||
log "Failed to enable VoLTE profile auto selecting: $RET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Enable VoLTE
|
||||
RET=$(echo "AT+QCFG=\"ims\",$QCFG_IMS_CONFIG" | atinout - $DEV -)
|
||||
|
||||
if ! echo $RET | grep -q OK
|
||||
then
|
||||
log "Failed to enable VoLTE: $RET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Reset module
|
||||
# 1 Set the mode to full functionality (vs 4: no RF, and 1: min functionality)
|
||||
# 1 Reset the modem before changing mode (only available with 1 above)
|
||||
#
|
||||
RET=$(echo "AT+CFUN=1,1" | atinout - $DEV -)
|
||||
|
||||
if ! echo $RET | grep -q OK
|
||||
then
|
||||
log "Failed to reset the module: $RET"
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in a new issue