From a80d4712c6bda35370653eea575d22568256c7c5 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 11:03:52 -0643 Subject: [PATCH 1/3] omamobile-device-tegu 0.2.1: the charge limit works with the kernel's charger driver The merged max77779-charger driver has charge inhibit and no end threshold, so the charge limit wrote nothing. The script now switches charge_behaviour between inhibit-charge and auto by the battery's capacity, from the limit to 5 below, and udev runs it on every battery change. --- packages/omamobile-device-tegu/README.md | 2 +- .../bin/omamobile-tegu-charge-limit | 64 +++++++++++++++---- .../omamobile-device-tegu/test/charge-limit | 17 +++++ .../rules.d/75-omamobile-tegu-charger.rules | 5 +- packages/omamobile-device-tegu/version | 2 +- 5 files changed, 75 insertions(+), 15 deletions(-) diff --git a/packages/omamobile-device-tegu/README.md b/packages/omamobile-device-tegu/README.md index f5bf326e3..7fa9a0e9a 100644 --- a/packages/omamobile-device-tegu/README.md +++ b/packages/omamobile-device-tegu/README.md @@ -17,7 +17,7 @@ packaged yet. What is here is what runs on in-tree drivers. | `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-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 | diff --git a/packages/omamobile-device-tegu/bin/omamobile-tegu-charge-limit b/packages/omamobile-device-tegu/bin/omamobile-tegu-charge-limit index ed95353a3..c370a3961 100755 --- a/packages/omamobile-device-tegu/bin/omamobile-tegu-charge-limit +++ b/packages/omamobile-device-tegu/bin/omamobile-tegu-charge-limit @@ -2,9 +2,14 @@ # 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:-} @@ -12,15 +17,50 @@ 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" diff --git a/packages/omamobile-device-tegu/test/charge-limit b/packages/omamobile-device-tegu/test/charge-limit index 6e9c3d16e..344ea4032 100755 --- a/packages/omamobile-device-tegu/test/charge-limit +++ b/packages/omamobile-device-tegu/test/charge-limit @@ -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' diff --git a/packages/omamobile-device-tegu/vendor/udev/rules.d/75-omamobile-tegu-charger.rules b/packages/omamobile-device-tegu/vendor/udev/rules.d/75-omamobile-tegu-charger.rules index ed60bab49..0d1c8acf1 100644 --- a/packages/omamobile-device-tegu/vendor/udev/rules.d/75-omamobile-tegu-charger.rules +++ b/packages/omamobile-device-tegu/vendor/udev/rules.d/75-omamobile-tegu-charger.rules @@ -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" diff --git a/packages/omamobile-device-tegu/version b/packages/omamobile-device-tegu/version index 0ea3a944b..0c62199f1 100644 --- a/packages/omamobile-device-tegu/version +++ b/packages/omamobile-device-tegu/version @@ -1 +1 @@ -0.2.0 +0.2.1 From 25a266ffd28c984bce8c33b330c95d79d9a99c84 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 12:21:24 -0647 Subject: [PATCH 2/3] omamobile-device-tegu 0.2.2: the AoC starts at boot from the device tree With the kernel branch tegu-dt-aoc the device tree enables Trusty, the GSA and the AoC, so the AoC start gets its wants link and answers to omamobile-aoc.service, which the sensor proxy and the fingerprint service name. Trusty and the TAS2572 amplifier driver are blacklisted too, and the amplifiers load once the AoC is online. --- packages/omamobile-device-tegu/README.md | 16 +++++++++------- .../bin/omamobile-tegu-aoc-start | 12 +++++++----- packages/omamobile-device-tegu/install | 4 ++-- packages/omamobile-device-tegu/test/all | 12 +++++++++--- packages/omamobile-device-tegu/test/aoc-start | 2 +- .../vendor/modprobe.d/omamobile-tegu-aoc.conf | 8 ++++++++ .../omamobile-tegu-aoc.service | 1 + .../vendor/systemd/system/omamobile-aoc.service | 1 + .../systemd/system/omamobile-tegu-aoc.service | 12 ++++++------ packages/omamobile-device-tegu/version | 2 +- 10 files changed, 45 insertions(+), 25 deletions(-) create mode 120000 packages/omamobile-device-tegu/vendor/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service create mode 120000 packages/omamobile-device-tegu/vendor/systemd/system/omamobile-aoc.service diff --git a/packages/omamobile-device-tegu/README.md b/packages/omamobile-device-tegu/README.md index 7fa9a0e9a..68824d6ed 100644 --- a/packages/omamobile-device-tegu/README.md +++ b/packages/omamobile-device-tegu/README.md @@ -14,7 +14,7 @@ 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`): 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 % | @@ -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 diff --git a/packages/omamobile-device-tegu/bin/omamobile-tegu-aoc-start b/packages/omamobile-device-tegu/bin/omamobile-tegu-aoc-start index b81e28fd5..636eb7f2e 100755 --- a/packages/omamobile-device-tegu/bin/omamobile-tegu-aoc-start +++ b/packages/omamobile-device-tegu/bin/omamobile-tegu-aoc-start @@ -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; @@ -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 diff --git a/packages/omamobile-device-tegu/install b/packages/omamobile-device-tegu/install index 0d6921be2..049fa4c1d 100755 --- a/packages/omamobile-device-tegu/install +++ b/packages/omamobile-device-tegu/install @@ -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]}")" diff --git a/packages/omamobile-device-tegu/test/all b/packages/omamobile-device-tegu/test/all index 62bab9a55..2473899d7 100755 --- a/packages/omamobile-device-tegu/test/all +++ b/packages/omamobile-device-tegu/test/all @@ -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" \ @@ -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 diff --git a/packages/omamobile-device-tegu/test/aoc-start b/packages/omamobile-device-tegu/test/aoc-start index d83cd0ff2..75fd1d386 100755 --- a/packages/omamobile-device-tegu/test/aoc-start +++ b/packages/omamobile-device-tegu/test/aoc-start @@ -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" diff --git a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-aoc.conf b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-aoc.conf index ef470fc35..28cbe4bf3 100644 --- a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-aoc.conf +++ b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-aoc.conf @@ -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 @@ -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 diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service b/packages/omamobile-device-tegu/vendor/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service new file mode 120000 index 000000000..235f93c1b --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service @@ -0,0 +1 @@ +../omamobile-tegu-aoc.service \ No newline at end of file diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-aoc.service b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-aoc.service new file mode 120000 index 000000000..c2449e5ac --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-aoc.service @@ -0,0 +1 @@ +omamobile-tegu-aoc.service \ No newline at end of file diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-aoc.service b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-aoc.service index 87966fd84..550a7e66c 100644 --- a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-aoc.service +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-aoc.service @@ -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 diff --git a/packages/omamobile-device-tegu/version b/packages/omamobile-device-tegu/version index 0c62199f1..ee1372d33 100644 --- a/packages/omamobile-device-tegu/version +++ b/packages/omamobile-device-tegu/version @@ -1 +1 @@ -0.2.1 +0.2.2 From a72ce01b781777c39bc2df0e9f3ae1dacfd24bf7 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:10:35 -0647 Subject: [PATCH 3/3] omamobile-device-tegu 0.2.3: NFC at boot, and the 9a's own setup-system With the NFC clock pad in clk-exynos-clkout and the node in the device tree, the graphics start loads nxp_nci_i2c as its last hang-safe step and waits for nfc0. A 9a omamobile-setup-system, as the 7 Pro's, enables the sensor proxy and the NFC link opener; not fingerprint, speaker protection or GNSS yet. --- packages/omamobile-device-tegu/README.md | 1 + .../bin/omamobile-setup-system | 30 +++++++++++++++++++ .../bin/omamobile-tegu-graphics-start | 25 ++++++++++++++-- packages/omamobile-device-tegu/test/all | 4 ++- .../omamobile-device-tegu/test/graphics-start | 14 +++++++++ .../modprobe.d/omamobile-tegu-guards.conf | 4 +-- .../system/omamobile-tegu-graphics.service | 4 +-- packages/omamobile-device-tegu/version | 2 +- 8 files changed, 75 insertions(+), 9 deletions(-) create mode 100755 packages/omamobile-device-tegu/bin/omamobile-setup-system diff --git a/packages/omamobile-device-tegu/README.md b/packages/omamobile-device-tegu/README.md index 68824d6ed..cba5a95ca 100644 --- a/packages/omamobile-device-tegu/README.md +++ b/packages/omamobile-device-tegu/README.md @@ -18,6 +18,7 @@ packaged yet. What is here is what runs on in-tree drivers. | `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`): 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 % | +| `bin/omamobile-setup-system` | `/usr/bin` | System setup for Omarchy's lifecycle (omamobile-firstboot runs it): UTF-8 locale, timezone, NTP, and enables the sensor proxy and the NFC link opener (`omamobile-nfc-open`). Not the fingerprint service, speaker protection or the GNSS socket yet (see the script) | | `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 | diff --git a/packages/omamobile-device-tegu/bin/omamobile-setup-system b/packages/omamobile-device-tegu/bin/omamobile-setup-system new file mode 100755 index 000000000..c06887bba --- /dev/null +++ b/packages/omamobile-device-tegu/bin/omamobile-setup-system @@ -0,0 +1,30 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Omarchy Mobile's system setup for the Pixel 9a: what a platform's +# "setup-system" step does in Omarchy's lifecycle contract (omamobile-firstboot +# runs it). Runs as root; safe to rerun. The same as the Pixel 7 Pro's, with +# the 9a's own list of services. +# omamobile-setup-system [timezone] +set -euo pipefail + +# UTF-8 locale (Qt and Omarchy's tools expect one) +sed -i 's/^#\(en_US.UTF-8 UTF-8\)/\1/' /etc/locale.gen +locale-gen >/dev/null +echo "LANG=en_US.UTF-8" > /etc/locale.conf + +# Time: no battery-backed clock is used yet, so keep NTP on +if [[ -n ${1:-} ]]; then + ln -sf "/usr/share/zoneinfo/$1" /etc/localtime +fi +systemctl enable --now systemd-timesyncd >/dev/null 2>&1 || true + +# The phone's services from the other Omarchy Mobile packages: enabled here, +# once, because packages don't enable units themselves (this package ships +# its own boot units as .wants links). Not on the 9a yet: the fingerprint +# service (its first start writes Trusty's secure storage), speaker +# protection (the 7 Pro's CS35L41s; the 9a's TAS2572s need none of it), and +# the GNSS socket, whose session starts the modem, whose PCIe link still hangs +# the SoC after some minutes (device/tegu/MODEM-PLAN.md). +for unit in omamobile-sensor-proxy.service omamobile-nfc-open.service; do + systemctl cat "$unit" >/dev/null 2>&1 && systemctl enable "$unit" >/dev/null 2>&1 || true +done diff --git a/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start b/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start index 4550601ce..ef55ab99e 100755 --- a/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start +++ b/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: MIT -# Bring up the Pixel 9a's GPU, display, haptics, torch, battery gauge and -# Bluetooth controller at boot, hang-safe. All six drivers are in the kernel +# Bring up the Pixel 9a's GPU, display, haptics, torch, battery gauge, +# Bluetooth controller and NFC at boot, hang-safe. All seven drivers are in the kernel # tree and blacklisted for autoload (modprobe.d/omamobile-tegu-guards.conf), # so this script is the only thing that loads them, in this order, after a # marker has been written and synced. Each step keys on its own device node @@ -42,6 +42,8 @@ gauge=$root/sys/class/power_supply/max77779-battery haptics_node=$dt/soc/usi@10c900c0/i2c@10c90000/haptic-driver@43 torch_node=$dt/soc/usi@108b00c0/i2c@108b0000/led-controller@63 bluetooth_node=$dt/soc/usi@155d00c0/serial@155d0000/bluetooth +nfc_node=$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8 +nfc=$root/sys/class/nfc/nfc0 log() { echo "omamobile-tegu-graphics: $*"; } loaded() { [[ -d $root/sys/module/$1 ]]; } @@ -76,7 +78,7 @@ case ${1:-} in esac if [[ -e $marker ]]; then - log "the last start ($(cat "$marker" 2>/dev/null)) never finished; the GPU, display, haptics, torch, gauge and Bluetooth stay off this boot." + log "the last start ($(cat "$marker" 2>/dev/null)) never finished; the GPU, display, haptics, torch, gauge, Bluetooth and NFC stay off this boot." log "after checking the previous boot's log, retry with: omamobile-tegu-graphics-start --retry" exit 0 fi @@ -200,6 +202,23 @@ else log "no Bluetooth in this DTB; skipped" fi +# NFC: nxp-nci on the haptics' bus, with the PMU's NFC clock pad as its +# reference clock (clk-exynos-clkout); without the clock the ST54L doesn't +# answer on I2C, so the node names it and the driver turns it on. +# Only a node that names its clock: a bring-up DTB without it leaves NFC to +# its own scripts. +if enabled "$nfc_node" && [[ -e $nfc_node/clocks ]]; then + phase nfc + if ! modprobe nxp_nci_i2c; then + skip NFC "nxp_nci_i2c failed (see dmesg)" + else + for _ in $(seq 20); do [[ -e $nfc ]] && break; sleep 0.25; done + if [[ -e $nfc ]]; then up+="${up:+, }NFC"; else skip NFC "no nfc0 after the driver loaded (see dmesg)"; fi + fi +else + log "no NFC with its clock in this DTB; skipped" +fi + finish log "up: ${up:-nothing}" if [[ -n $failed ]]; then diff --git a/packages/omamobile-device-tegu/test/all b/packages/omamobile-device-tegu/test/all index 2473899d7..1b3a66cac 100755 --- a/packages/omamobile-device-tegu/test/all +++ b/packages/omamobile-device-tegu/test/all @@ -76,7 +76,7 @@ for f in usr/bin/reboot-to usr/bin/tegu-tcpc-switch \ usr/bin/omamobile-tegu-usb-rescue usr/lib/systemd/system/omamobile-tegu-usb-rescue.service \ usr/bin/omamobile-bt-addr usr/lib/systemd/system/omamobile-bt-addr@.service \ usr/lib/udev/rules.d/80-omamobile-bt-addr.rules \ - usr/bin/omamobile-tegu-charge-limit usr/lib/udev/rules.d/75-omamobile-tegu-charger.rules \ + usr/bin/omamobile-tegu-charge-limit usr/bin/omamobile-setup-system usr/lib/udev/rules.d/75-omamobile-tegu-charger.rules \ usr/lib/modprobe.d/omamobile-tegu-guards.conf usr/lib/modprobe.d/omamobile-tegu-aoc.conf \ usr/lib/modprobe.d/omamobile-tegu-display.conf usr/lib/modprobe.d/omamobile-tegu-clk-acpm.conf \ usr/lib/systemd/system-sleep/omamobile-tegu-wifi usr/lib/systemd/system-sleep/omamobile-tegu-nfc \ @@ -176,6 +176,8 @@ grep -q 'chosen/config/bt_addr' bin/omamobile-bt-addr || fail "the Bluetooth add grep -q 'HandlePowerKey' -r vendor && fail "no power-key policy from this package (omamobile-shell owns it on tegu)" pass "the Bluetooth address is read at run time" +grep -c '^for unit in omamobile-sensor-proxy.service omamobile-nfc-open.service; do$' bin/omamobile-setup-system >/dev/null || fail "setup-system enables the sensor proxy and the NFC opener" +grep -qE 'omamobile-(fp|gnss-nmea|speaker-protection)' <(grep '^for unit' bin/omamobile-setup-system) && fail "setup-system must not enable fingerprint, GNSS or speaker protection on the 9a" for t in test/graphics-start test/aoc-start test/usb-rescue test/sleep-hooks test/charge-limit; do "$t" || fail "$t" done diff --git a/packages/omamobile-device-tegu/test/graphics-start b/packages/omamobile-device-tegu/test/graphics-start index e214d690e..ae69a723e 100755 --- a/packages/omamobile-device-tegu/test/graphics-start +++ b/packages/omamobile-device-tegu/test/graphics-start @@ -44,6 +44,7 @@ case $1 in set -- "$@" "allow_tx=$(cat "$TEST_ROOT/sys/module/gs_dsim_cmd/parameters/allow_tx" 2>/dev/null || echo none)" ;; leds_lm3644) mkdir -p "$TEST_ROOT/sys/class/leds/white:torch"; echo "${TORCH_LIT:-0}" > "$TEST_ROOT/sys/class/leds/white:torch/brightness" ;; max77779_battery) mkdir -p "$TEST_ROOT/sys/class/power_supply/max77779-battery"; echo 77 > "$TEST_ROOT/sys/class/power_supply/max77779-battery/capacity" ;; + nxp_nci_i2c) mkdir -p "$TEST_ROOT/sys/class/nfc/nfc0" ;; esac echo "$*" >> "$TEST_LOG" EOF @@ -177,4 +178,17 @@ out=$("$script") # A bad argument "$script" --bogus >/dev/null 2>&1 && fail "a bad argument is accepted" +# NFC: with its node, nxp_nci_i2c loads last and nfc0 counts as up; without +# the node it is skipped (the cases above) +reset +mkdir -p "$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8"; : > "$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8/clocks" +out=$("$script") +[[ $(loads) == "$all nxp_nci_i2c" ]] || fail "NFC load order: $(loads)" +[[ $out == *", Bluetooth, NFC"* ]] || fail "NFC summary: $out" +reset; out=$(FAIL_MODULE=nxp_nci_i2c "$script" || true) +[[ $out == *"nxp_nci_i2c failed"* && ! -e $marker ]] || fail "a failed NFC load is skipped and clears the marker: $out" +# a node without its clock (the bring-up DTB) is left alone +rm -f "$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8/clocks"; reset; out=$("$script") +[[ $(loads) == "$all" && $out == *"no NFC with its clock"* ]] || fail "an NFC node without clocks must be skipped: $(loads)" +rm -rf "$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8" echo 'ok - graphics-start: marker first, order kept, failures skipped and named, allow_tx for google-tg4c only, --retry works' diff --git a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf index c1f91e335..f81cfa230 100644 --- a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf +++ b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Loaded only by the package's hang-safe scripts, in their order, after a -# marker is written: omamobile-tegu-graphics-start (the first six) and, once -# a kernel ships them in tree, the Wi-Fi and NFC starts. Blacklisting only +# marker is written: omamobile-tegu-graphics-start (the first six, and +# nxp_nci_i2c for NFC) and, once a kernel ships them in tree, the Wi-Fi start. Blacklisting only # stops udev from autoloading them ahead of the guard; "modprobe panthor" # still works. No "install X /bin/false" lines: those break the guard's own # modprobe. diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service index b14a5d188..944e2b436 100644 --- a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# The GPU, display, haptics, torch, gauge and Bluetooth controller at boot, +# The GPU, display, haptics, torch, gauge, Bluetooth controller and NFC at boot, # enabled by the vendor multi-user.target.wants link. The drivers are # blacklisted for autoload (modprobe.d/omamobile-tegu-guards.conf), so this # hang-safe script is the only thing that loads them; if a start hangs, the @@ -8,7 +8,7 @@ # ConditionPathExists=| lines are ORed by systemd: a DTB with the display # but no GPU still gets its display. [Unit] -Description=Bring up the Pixel 9a GPU, display, haptics, torch, gauge and Bluetooth (hang-safe) +Description=Bring up the Pixel 9a GPU, display, haptics, torch, gauge, Bluetooth and NFC (hang-safe) After=local-fs.target systemd-modules-load.service Before=display-manager.service ConditionPathExists=|/sys/bus/platform/devices/1f000000.gpu diff --git a/packages/omamobile-device-tegu/version b/packages/omamobile-device-tegu/version index ee1372d33..717903969 100644 --- a/packages/omamobile-device-tegu/version +++ b/packages/omamobile-device-tegu/version @@ -1 +1 @@ -0.2.2 +0.2.3