Skip to content
Merged
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
19 changes: 11 additions & 8 deletions packages/omamobile-device-tegu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ 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 % |
| `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 |
Expand Down Expand Up @@ -67,15 +68,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
30 changes: 30 additions & 0 deletions packages/omamobile-device-tegu/bin/omamobile-setup-system
Original file line number Diff line number Diff line change
@@ -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
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"
25 changes: 22 additions & 3 deletions packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 ]]; }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
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
16 changes: 12 additions & 4 deletions packages/omamobile-device-tegu/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand 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" \
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 All @@ -170,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
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
Loading