Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/omamobile-device-tegu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ packaged yet. What is here is what runs on in-tree drivers.
| `uwsm/env.d/omamobile-tegu-graphics` | `/usr/share/uwsm/env.d` | The session's side of the graphics start, sourced by uwsm (it walks `XDG_DATA_DIRS` too; a user's `~/.config/uwsm/env` runs after it): the KMS device from `/run/omamobile-tegu-display-card`, hardware GL when `/run/omamobile-tegu-gpu-ready.json` exists and llvmpipe otherwise, so a phone whose GPU did not come up still gets a desktop |
| `vendor/modprobe.d/omamobile-tegu-guards.conf` | `/usr/lib/modprobe.d` | Keeps those drivers (and the Wi-Fi, PCIe and NFC ones, for the day they are in tree) from autoloading ahead of the guard. No `install` lines: they would break the guard's own modprobe |
| `vendor/modprobe.d/omamobile-tegu-display.conf`, `omamobile-tegu-clk-acpm.conf` | `/usr/lib/modprobe.d` | 120 Hz as the ceiling and the panel really off on DPMS (the DSI commands themselves are allowed by the graphics start, for google-tg4c only); the GPU DVFS ceiling at 890 MHz |
| `bin/omamobile-tegu-aoc-start` + `vendor/systemd/system/omamobile-tegu-aoc.service` + `vendor/modprobe.d/omamobile-tegu-aoc.conf` | `/usr/bin`, `/usr/lib/systemd/system` (not enabled), `/usr/lib/modprobe.d` | Boots the AoC (audio and sensor DSP) hang-safe: Trusty, the GSA, the AoC drivers, `aoc-tegu.bin`, then waits for its 93 services. Ships disabled: see below |
| `bin/omamobile-tegu-aoc-start` + `vendor/systemd/system/omamobile-tegu-aoc.service` + `vendor/modprobe.d/omamobile-tegu-aoc.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled; also `omamobile-aoc.service`), `/usr/lib/modprobe.d` | Boots the AoC (audio and sensor DSP) hang-safe: Trusty, the GSA, the AoC drivers, `aoc-tegu.bin`, waits for its 93 services, then loads the TAS2572 amplifiers. See below |
| `bin/omamobile-bt-addr` + `vendor/systemd/system/omamobile-bt-addr@.service` + `vendor/udev/rules.d/80-omamobile-bt-addr.rules` | `/usr/bin`, `/usr/lib/systemd/system`, `/usr/lib/udev/rules.d` | Gives the BCM4383 its real Bluetooth address from the bootloader's device tree when the controller appears, powering it on once first (set on a never-powered controller, the kernel withdraws the index for good). The Pixel 7 Pro's script, with the extra waits the 9a needed |
| `bin/omamobile-tegu-usb-rescue` + `src/tegu-tcpc-switch.c` + `vendor/systemd/system/omamobile-tegu-usb-rescue.service` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link) | Closes the MAX77779's USB data switch after a cable replug while no Type-C driver owns the chip; with one loaded it exits. The helper reads the chip's identity and VBUS before its one write and never forces an address a driver holds |
| `bin/omamobile-tegu-charge-limit` + `vendor/udev/rules.d/75-omamobile-tegu-charger.rules` | `/usr/bin`, `/usr/lib/udev/rules.d` | Applies `/etc/omamobile/charge-limit` (a percentage, say `80`) to the charger when it appears; charging stops there and starts again 5 below. No file: charge to 100 % |
| `bin/omamobile-tegu-charge-limit` + `vendor/udev/rules.d/75-omamobile-tegu-charger.rules` | `/usr/bin`, `/usr/lib/udev/rules.d` | Applies `/etc/omamobile/charge-limit` (a percentage, say `80`): charging stops there and starts again 5 below. With the kernel's `max77779-charger` driver, which has charge inhibit and no end threshold, udev runs it on every battery change and it switches `charge_behaviour` between `inhibit-charge` and `auto` by the battery's capacity. No file: charge to 100 % |
| `vendor/systemd/system-sleep/omamobile-tegu-wifi` | `/usr/lib/systemd/system-sleep` | Keeps Wi-Fi loaded across s2idle when `/etc/omamobile/wifi-keep-across-sleep` exists (the chip reloads its firmware on resume and iwd reconnects), otherwise unloads and reloads brcmfmac around the sleep; after a sleep that lost Wi-Fi it unloads for the rest of the boot. It reloads the in-tree `brcmfmac`; a phone still running an out-of-tree build of it keeps its own hook until the Wi-Fi series lands |
| `vendor/systemd/system-sleep/omamobile-tegu-nfc` | `/usr/lib/systemd/system-sleep` | Stops neard's poll loop before a sleep (polling through s2idle reset the palmtop; with it stopped, 35 of 35 cycles woke), reads `Polling` back and logs it, and starts the loop again after the wake if it was on. Powering the ST54L off as well, the workaround for a controller that did not answer on I2C after a wake (issue #132; fixed by linux-omarchy-mobile #131), runs only while `/etc/omamobile/nfc-power-off-across-sleep` exists: off by default, since its record is one wake that needed the power key and one that worked. Log: `/var/log/omamobile/nfc-sleep.log` |
| `vendor/systemd/system/linux-modules-cleanup.service.d/10-omamobile-tegu.conf` | `/usr/lib/systemd/system` | Holds off Arch's old-module cleanup: our kernels come as module tarballs, not pacman packages, and the next-boot and rollback trees must stay |
Expand Down Expand Up @@ -67,15 +67,17 @@ watchdog runs from boot, so a hung graphics start ends in a reset and the
marker. The public tegu DTS carries `panic=10` but not that, so on it a
hang that does not panic ends at the power key (held about 30 s).

## The AoC start ships disabled
## The AoC start at boot

`omamobile-tegu-aoc-start` is the Pixel 7 Pro's AoC start with the 9a's
names (`154b0000.aoc`, `aoc-tegu.bin`, 93 services, the sensors' USF
channel through `aoc_channel_dev`). It needs a kernel whose device tree
enables the AoC, GSA and Trusty nodes; today the bring-up turns them on
with out-of-tree overlay modules, and so `omamobile-tegu-aoc.service` has
no wants link. Once a kernel enables them, `systemctl enable
omamobile-tegu-aoc.service` and reboot. A step that returns and fails is
channel through `aoc_channel_dev`), plus the TAS2572 amplifiers once the
AoC is online. It runs at every boot (a wants link) and answers to
`omamobile-aoc.service`, the name the sensor proxy and the fingerprint
service order themselves after. It needs a kernel whose device tree
enables the AoC, GSA and Trusty nodes (the kernel branch `tegu-dt-aoc`);
on a device tree without the AoC node the unit's condition skips it, so
the bring-up's overlay boots are unaffected. A step that returns and fails is
named in the journal and clears the marker (a load that came back is not a
hang; `test/aoc-start` checks this). Only a boot that hangs in the start
leaves the marker, and then the next boot leaves the AoC off until
Expand Down
12 changes: 7 additions & 5 deletions packages/omamobile-device-tegu/bin/omamobile-tegu-aoc-start
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# aoc_alsa_dev before aoc_char_dev, which takes every service still free).
# 4. The firmware load (aoc-tegu.bin), then wait for the 93 services and
# the sensor channel.
# The TAS2572 amplifiers come up from the device tree through the tas2781
# codec driver; the card's UCM profile (omamobile-audio) does the routing.
# 5. The TAS2572 amplifiers (snd_soc_tas2781_i2c) from their device-tree
# nodes; the card's UCM profile (omamobile-audio) does the routing.
#
# This waits for a kernel whose device tree enables the AoC, GSA and Trusty
# nodes: today they are turned on by out-of-tree overlay modules that no
# package can ship, so the unit has no wants link (README.md).
# The unit starts this at every boot (a wants link) and is also
# omamobile-aoc.service, the name the sensor proxy and fingerprint units
# use. On a device tree without the AoC node it does nothing.
# A marker is written and synced before any of it, and removed at the end,
# after a step that returned and failed too (that is not a hang). If a boot
# hangs here, the next one finds the marker and leaves the AoC off;
Expand Down Expand Up @@ -115,6 +115,8 @@ for _ in $(seq 150); do
log "up: $(head -1 "$node/services"), firmware $(head -1 "$node/revision" 2>/dev/null)"
for _ in $(seq 25); do [[ -e $root/dev/acd-com.google.usf ]] && break; sleep 0.2; done
[[ -e $root/dev/acd-com.google.usf ]] || log "no /dev/acd-com.google.usf (sensors unavailable)"
# 5. The speaker amplifiers, now that the AoC's back end is there
modprobe snd_soc_tas2781_i2c || log "the TAS2572 amplifiers did not load (no speakers)"
finish; exit 0
fi
sleep 0.2
Expand Down
64 changes: 52 additions & 12 deletions packages/omamobile-device-tegu/bin/omamobile-tegu-charge-limit
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,65 @@
# SPDX-License-Identifier: MIT
# Pixel 9a charge limit: /etc/omamobile/charge-limit holds the percentage at
# which charging stops (say 80); the charger starts again 5 below it. No
# file, or not a number from 1 to 100: charge to 100 %. Run by udev when the
# MAX77779 charger appears (75-omamobile-tegu-charger.rules), and by hand
# after editing the file.
# file, or not a number from 1 to 100: charge to 100 %.
#
# A charger with charge_control_end_threshold takes the limit itself. The
# kernel's max77779-charger driver offers charge_behaviour instead, so for
# it this script holds charging off (inhibit-charge) from the limit and lets
# it run again (auto) 5 below, by the battery's capacity. udev runs it when
# the charger appears and on every battery change
# (75-omamobile-tegu-charger.rules); run it by hand after editing the file.
set -uo pipefail

root=${OMAMOBILE_TEGU_ROOT:-}
if [[ -n $root ]]; then
[[ $root == /* && $root != / && -d $root ]] || exit 2
fi
file=$root/etc/omamobile/charge-limit
threshold=$root/sys/class/power_supply/max77779-charger/charge_control_end_threshold
supply=$root/sys/class/power_supply
threshold=$supply/max77779-charger/charge_control_end_threshold
behaviour=$supply/max77779-charger/charge_behaviour
capacity=$supply/max77779-battery/capacity
log() { echo "omamobile-tegu-charge-limit: $*"; }

[[ -s $file ]] || exit 0
[[ -w $threshold ]] || { log "no charger threshold to set"; exit 0; }
limit=$(tr -d ' \t\n' < "$file")
if [[ ! $limit =~ ^[0-9]+$ ]] || (( 10#$limit < 1 || 10#$limit > 100 )); then
log "$file is not a percentage from 1 to 100; no limit"
exit 1
limit=100
if [[ -s $file ]]; then
limit=$(tr -d ' \t\n' < "$file")
if [[ ! $limit =~ ^[0-9]+$ ]] || (( 10#$limit < 1 || 10#$limit > 100 )); then
log "$file is not a percentage from 1 to 100; no limit"
[[ -w $behaviour ]] && echo auto > "$behaviour"
exit 1
fi
limit=$((10#$limit))
fi
echo "$((10#$limit))" > "$threshold" || { log "the charger refused $limit"; exit 1; }
log "charge limit $(cat "$threshold") %"

if [[ -w $threshold ]]; then
[[ -s $file ]] || exit 0
echo "$limit" > "$threshold" || { log "the charger refused $limit"; exit 1; }
log "charge limit $(cat "$threshold") %"
exit 0
fi

if [[ ! -w $behaviour ]]; then
[[ -s $file ]] && log "no charger to limit"
exit 0
fi
want=
if (( limit >= 100 )); then
want=auto
elif [[ -r $capacity ]]; then
level=$(tr -d ' \t\n' < "$capacity")
[[ $level =~ ^[0-9]+$ ]] || { log "the battery reports no capacity"; exit 0; }
if (( level >= limit )); then want=inhibit-charge
elif (( level <= limit - 5 )); then want=auto
fi
else
log "no battery capacity; charging left as it is"
exit 0
fi
[[ -n $want ]] || exit 0
current=$(grep -o '\[[a-z-]*\]' "$behaviour" 2>/dev/null | tr -d '[]')
[[ -n $current ]] || current=$(tr -d ' \t\n' < "$behaviour")
[[ $current == "$want" ]] && exit 0
echo "$want" > "$behaviour" || { log "the charger refused $want"; exit 1; }
log "charge limit $limit %: $want"
4 changes: 2 additions & 2 deletions packages/omamobile-device-tegu/install
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# Stage omamobile-device-tegu into DESTDIR. Never activates anything: the
# graphics start and the USB rescue are enabled by vendor wants links, as
# omarchy-mac does; the AoC start ships with no link (see README.md).
# graphics start, the USB rescue and the AoC start are enabled by vendor
# wants links, as omarchy-mac does (see README.md).
# ./install DESTDIR [BUILDDIR] (BUILDDIR holds the compiled C tools)
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
Expand Down
12 changes: 9 additions & 3 deletions packages/omamobile-device-tegu/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ for unit in omamobile-tegu-graphics omamobile-tegu-usb-rescue; do
[[ $(readlink "$tmp/root/usr/lib/systemd/system/multi-user.target.wants/$unit.service") == ../$unit.service ]] \
|| fail "$unit is enabled by a vendor wants link"
done
[[ ! -e $tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service ]] \
|| fail "the AoC start ships disabled (no wants link)"
# The AoC start runs at every boot (its condition skips a DTB without the
# node), and answers to omamobile-aoc.service for the sensor and fp units.
[[ $(readlink "$tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service") == ../omamobile-tegu-aoc.service ]] \
|| fail "the AoC start is enabled by a vendor wants link"
[[ $(readlink "$tmp/root/usr/lib/systemd/system/omamobile-aoc.service") == omamobile-tegu-aoc.service ]] \
|| fail "omamobile-aoc.service names the 9a's AoC start"
grep -qx 'ConditionPathExists=/sys/bus/platform/devices/154b0000.aoc' vendor/systemd/system/omamobile-tegu-aoc.service \
|| fail "the AoC start is skipped without the AoC node"
grep -q 'KERNEL=="sda", MODE="0000"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \
|| fail "the whole-disk node is made inaccessible"
grep -q 'ID_PART_ENTRY_NAME}!="userdata"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \
Expand Down Expand Up @@ -151,7 +157,7 @@ done
for m in panthor gs_decon cs40l26_vibra leds_lm3644 max77779_battery hci_uart; do
grep -qE "modprobe $m\b" bin/omamobile-tegu-graphics-start || fail "the graphics guard no longer loads $m"
done
for m in gsa gs201_aoc_sysmmu mailbox_wc aoc_core aoc_channel_dev aoc_alsa_dev aoc_char_dev; do
for m in trusty_core trusty_log trusty_ipc trusty_virtio gsa gs201_aoc_sysmmu mailbox_wc aoc_core aoc_channel_dev aoc_alsa_dev aoc_char_dev snd_soc_tas2781_i2c; do
grep -qx "blacklist $m" vendor/modprobe.d/omamobile-tegu-aoc.conf \
|| fail "$m is loaded by the AoC guard but not blacklisted"
done
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-device-tegu/test/aoc-start
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ loads() { grep -v '^synced$' "$TEST_LOG" | tr '\n' ' ' | sed 's/ $//'; }

reset
out=$("$script")
[[ $(loads) == "trusty_core trusty_log trusty_ipc trusty_virtio gsa gs201_aoc_sysmmu mailbox_wc aoc_core aoc_channel_dev aoc_alsa_dev aoc_char_dev" ]] \
[[ $(loads) == "trusty_core trusty_log trusty_ipc trusty_virtio gsa gs201_aoc_sysmmu mailbox_wc aoc_core aoc_channel_dev aoc_alsa_dev aoc_char_dev snd_soc_tas2781_i2c" ]] \
|| fail "load order: $(loads)"
[[ $(cat "$node/firmware") == aoc-tegu.bin ]] || fail "the firmware request names aoc-tegu.bin"
[[ ! -e $marker ]] || fail "a finished start leaves the marker"
Expand Down
17 changes: 17 additions & 0 deletions packages/omamobile-device-tegu/test/charge-limit
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,20 @@ rm -f "$threshold"
echo 80 > "$file"
"$script" >/dev/null || fail "a missing charger is an error"
echo 'ok - charge-limit: percentages only, the charger otherwise untouched'

# The kernel's driver: no threshold, charge_behaviour instead, by capacity.
b=$OMAMOBILE_TEGU_ROOT/sys/class/power_supply/max77779-charger/charge_behaviour
c=$OMAMOBILE_TEGU_ROOT/sys/class/power_supply/max77779-battery/capacity
mkdir -p "${c%/*}"
level() { echo "$1" > "$c"; "$script" >/dev/null || fail "capacity $1 failed"; }
echo '[auto] inhibit-charge force-discharge' > "$b"; echo 80 > "$file"
level 79; [[ $(cat "$b") == '[auto] inhibit-charge force-discharge' ]] || fail "79 of 80 changed the charger"
level 80; [[ $(cat "$b") == inhibit-charge ]] || fail "80 of 80 did not inhibit"
level 77; [[ $(cat "$b") == inhibit-charge ]] || fail "77 of 80 resumed inside the 5-point band"
level 75; [[ $(cat "$b") == auto ]] || fail "75 of 80 did not resume"
rm -f "$file"; echo inhibit-charge > "$b"; level 90
[[ $(cat "$b") == auto ]] || fail "no file left charging inhibited"
echo abc > "$file"; echo inhibit-charge > "$b"; echo 90 > "$c"
"$script" >/dev/null 2>&1 && fail "abc was accepted"
[[ $(cat "$b") == auto ]] || fail "a bad file left charging inhibited"
echo 'ok - charge-limit: charge_behaviour holds charging off from the limit to 5 below'
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# SPDX-License-Identifier: MIT
# AoC: only omamobile-tegu-aoc-start (or a bring-up runbook) loads these, in
# order. Explicit modprobe still works.
# Trusty starts the AoC; its nodes come with the AoC's in the device tree.
blacklist trusty_core
blacklist trusty_log
blacklist trusty_ipc
blacklist trusty_virtio
blacklist gsa
blacklist gs201_aoc_sysmmu
blacklist mailbox_wc
Expand All @@ -11,3 +16,6 @@ blacklist aoc_char_dev
# in ahead of the order above; the start script loads it with the others.
blacklist aoc_alsa_dev
blacklist aoc_alsa_dev_util
# The TAS2572 amplifiers: loaded after the AoC is online, so the card and
# its UCM profile find the AoC's back end ready.
blacklist snd_soc_tas2781_i2c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SPDX-License-Identifier: MIT
# The AoC (audio and sensor DSP) at boot, through the hang-safe
# omamobile-tegu-aoc-start. Not enabled by the package: the Pixel 9a kernel
# does not yet enable the AoC, GSA and Trusty nodes in its device tree (they
# are turned on by out-of-tree overlay modules in the bring-up), so the
# script would find nothing to do. Once a kernel enables them:
# systemctl enable omamobile-tegu-aoc.service
# The AoC modules are blacklisted for autoload (modprobe.d/omamobile-tegu-aoc.conf).
# omamobile-tegu-aoc-start, at every boot (the package's wants link) once the
# device tree has the AoC node; without it the condition skips the unit. It
# is also omamobile-aoc.service (a link beside it), the name the sensor proxy
# and the fingerprint service order themselves after. The AoC, Trusty and
# amplifier modules are blacklisted for autoload
# (modprobe.d/omamobile-tegu-aoc.conf) so only the script loads them.
[Unit]
Description=Boot the Pixel 9a AoC audio and sensor DSP (hang-safe)
After=local-fs.target systemd-modules-load.service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# SPDX-License-Identifier: MIT
# Omarchy Mobile: apply /etc/omamobile/charge-limit when the MAX77779 charger
# appears (omamobile-tegu-charge-limit).
# appears, and on every battery change: the kernel's charger driver limits by
# charge inhibit, so the script follows the battery's capacity
# (omamobile-tegu-charge-limit).
ACTION=="add", SUBSYSTEM=="power_supply", KERNEL=="max77779-charger", RUN+="/usr/bin/omamobile-tegu-charge-limit"
ACTION=="change", SUBSYSTEM=="power_supply", KERNEL=="max77779-battery", RUN+="/usr/bin/omamobile-tegu-charge-limit"
2 changes: 1 addition & 1 deletion packages/omamobile-device-tegu/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.2.2