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
9 changes: 6 additions & 3 deletions packages/omamobile-device-tegu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packaged yet. What is here is what runs on in-tree drivers.

| Path | Installs to | What it does |
| --- | --- | --- |
| `bin/omamobile-tegu-graphics-start` + `vendor/systemd/system/omamobile-tegu-graphics.service` + `display-manager.service.d/10-omamobile-tegu.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link) | Loads the GPU (panthor), the display controller (gs_decon), haptics (cs40l26_vibra), the torch (leds_lm3644), the battery gauge (max77779_battery) and the Bluetooth controller (hci_uart) at boot, in that order, after writing and syncing a marker. Each step keys on its own device node (`1f000000.gpu`, `19470000.display-controller`, the device-tree nodes of the rest), and the unit runs when the GPU or the display controller exists, so a DTB with the display but no GPU still gets its display. A load or bind that returns but fails (panthor without `mali_csffw.bin`, say) is logged and skipped, the rest still loads, and the marker is cleared; the unit then ends failed, and `--retry` tries the skipped steps again. Only a boot that hangs in a step leaves the marker: the next boot keeps all six off and says so, and `omamobile-tegu-graphics-start --retry` goes on from the step that failed (on the same boot too: the drivers already loaded stay as they are). Before `gs_decon`, and only when the command line says `exynos_drm.panel_name=google-tg4c`, it turns `gs_dsim_cmd.allow_tx` on, so the panel's DSI commands (brightness, sleep, 120 Hz; kernel #90) go to the panel the bring-up tested and no other: on another panel the display stays read-only at 60 Hz. The display manager waits for it. It also writes `/run/omamobile-tegu-display-card` (the display controller's DRM node by path, since the GPU may take card0) and, when the GPU came up, `/run/omamobile-tegu-gpu-ready.json` |
| `bin/omamobile-tegu-graphics-start` + `vendor/systemd/system/omamobile-tegu-graphics.service` + `display-manager.service.d/10-omamobile-tegu.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link) | Loads the GPU (panthor), the display controller (gs_decon), haptics (cs40l26_vibra), the torch (leds_lm3644), the battery gauge (max77779_battery), the Bluetooth controller (hci_uart), NFC (nxp_nci_i2c) and Wi-Fi (the zumapro PCIe host `pcie_zumapro`, then `brcmfmac`, only with the host's node, the Wi-Fi DMA pool and the BCM4383 firmware) at boot, in that order, after writing and syncing a marker. Each step keys on its own device node (`1f000000.gpu`, `19470000.display-controller`, the device-tree nodes of the rest), and the unit runs when the GPU or the display controller exists, so a DTB with the display but no GPU still gets its display. A load or bind that returns but fails (panthor without `mali_csffw.bin`, say) is logged and skipped, the rest still loads, and the marker is cleared; the unit then ends failed, and `--retry` tries the skipped steps again. Only a boot that hangs in a step leaves the marker, and there is one marker for every step: a hang in the last step, Wi-Fi, also keeps the GPU and the display off on the next boot, so a boot with no display after a Wi-Fi hang is this marker, not a display fault. The next boot keeps all of them off and says so, and `omamobile-tegu-graphics-start --retry` goes on from the step that failed (on the same boot too: the drivers already loaded stay as they are). Before `gs_decon`, and only when the command line says `exynos_drm.panel_name=google-tg4c`, it turns `gs_dsim_cmd.allow_tx` on, so the panel's DSI commands (brightness, sleep, 120 Hz; kernel #90) go to the panel the bring-up tested and no other: on another panel the display stays read-only at 60 Hz. The display manager waits for it. It also writes `/run/omamobile-tegu-display-card` (the display controller's DRM node by path, since the GPU may take card0) and, when the GPU came up, `/run/omamobile-tegu-gpu-ready.json` |
| `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 |
Expand All @@ -19,6 +19,7 @@ packaged yet. What is here is what runs on in-tree drivers.
| `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-cpuidle` | `/usr/lib/systemd/system-sleep` | Keeps the CPUs out of core power-down (every `*-sleep` cpuidle state) for the length of a sleep and puts each state back as it was afterwards. With core power-down allowed, the S2MPG14 raised an event that hadn't happened (an early RTC alarm, or a power key release) about a second into every s2idle, so no sleep lasted; with WFI only, a sleep lasts until its wake. See device/tegu/SLEEP-PLAN.md S1 |
| `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 All @@ -39,8 +40,10 @@ runs the package tests in a scratch root (`OMAMOBILE_TEGU_ROOT`), with no
phone and no hardware.

The package does not mark the boot slot successful (Derek decides how that
works on the 9a), does not start Wi-Fi, NFC, the modem, the charger driver
or the cameras, and carries no vendor files and no per-phone data.
works on the 9a) and does not start the modem. NFC and Wi-Fi come up from
the graphics start when the device tree describes them, and the charger and
the cameras load from the device tree on their own. It carries no vendor
files and no per-phone data.

## What the kernel command line has to stop carrying

Expand Down
34 changes: 32 additions & 2 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,
# Bluetooth controller and NFC at boot, hang-safe. All seven drivers are in the kernel
# Bluetooth controller, NFC and Wi-Fi at boot, hang-safe. All nine 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 @@ -44,6 +44,9 @@ 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
wifi_pcie=$root/sys/bus/platform/devices/13120000.pcie
wifi_pool=$dt/reserved-memory/wifi-dma-pool
wifi_fw=$root/usr/lib/firmware/brcm/brcmfmac4383-pcie.bin

log() { echo "omamobile-tegu-graphics: $*"; }
loaded() { [[ -d $root/sys/module/$1 ]]; }
Expand Down Expand Up @@ -78,7 +81,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, Bluetooth and NFC stay off this boot."
log "the last start ($(cat "$marker" 2>/dev/null)) never finished; the GPU, display, haptics, torch, gauge, Bluetooth, NFC and Wi-Fi 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 @@ -219,6 +222,33 @@ else
log "no NFC with its clock in this DTB; skipped"
fi

# Wi-Fi: the zumapro PCIe host for channel 1 (pcie_zumapro, whose probe
# brings the link up), then the BCM4383 on brcmfmac. Only with the host's
# node, the restricted DMA pool the endpoint needs, and the owner's firmware
# (tools/extract-vendor-firmware). Never unloaded: a reboot undoes it.
if [[ -e $wifi_pcie && -e $wifi_pool && -e $wifi_fw ]]; then
phase wifi
if ! modprobe pcie_zumapro; then
skip Wi-Fi "pcie_zumapro failed (see dmesg)"
else
for _ in $(seq 20); do [[ -e $root/sys/bus/pci/devices/0000:01:00.0 ]] && break; sleep 0.25; done
if [[ ! -e $root/sys/bus/pci/devices/0000:01:00.0 ]]; then
skip Wi-Fi "no Wi-Fi endpoint on the PCIe link (see dmesg)"
elif ! modprobe brcmfmac; then
skip Wi-Fi "brcmfmac failed (see dmesg)"
else
wl=
for _ in $(seq 60); do
for d in "$root"/sys/class/net/wl*; do [[ -e $d ]] && wl=${d##*/} && break; done
[[ -n $wl ]] && break; sleep 0.5
done
if [[ -n $wl ]]; then up+="${up:+, }Wi-Fi ($wl)"; else skip Wi-Fi "brcmfmac brought up no interface (see dmesg)"; fi
fi
fi
else
log "no Wi-Fi host, DMA pool or BCM4383 firmware in this boot; skipped"
fi

finish
log "up: ${up:-nothing}"
if [[ -n $failed ]]; then
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-device-tegu/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ 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
for t in test/graphics-start test/aoc-start test/usb-rescue test/sleep-hooks test/cpuidle-hook test/charge-limit; do
"$t" || fail "$t"
done
pass "the scripts behave in a scratch root"
27 changes: 27 additions & 0 deletions packages/omamobile-device-tegu/test/cpuidle-hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# The cpuidle sleep hook in a scratch root: every "*-sleep" state is
# disabled before the sleep and put back as it was after; WFI is untouched;
# a post with nothing saved does nothing.
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
hook=$PWD/vendor/systemd/system-sleep/omamobile-tegu-cpuidle
fail() { printf 'not ok - cpuidle-hook: %s\n' "$1" >&2; exit 1; }
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
export OMAMOBILE_TEGU_ROOT=$tmp/root
mkdir -p "$tmp/bin"; printf '#!/bin/bash\nexit 0\n' > "$tmp/bin/logger"; chmod +x "$tmp/bin/logger"
export PATH=$tmp/bin:$PATH
mk() { local d=$OMAMOBILE_TEGU_ROOT/sys/devices/system/cpu/cpu$1/cpuidle/state$2; mkdir -p "$d"; echo "$3" > "$d/name"; echo "$4" > "$d/disable"; }
for c in 0 1 2 3; do mk $c 0 WFI 0; mk $c 1 cpu-a520-sleep 0; done
for c in 4 5 6; do mk $c 0 WFI 0; mk $c 1 cpu-a720-sleep 0; done
mk 7 0 WFI 0; mk 7 1 cpu-x4-sleep 1 # already off by hand: stays off after
d() { cat "$OMAMOBILE_TEGU_ROOT/sys/devices/system/cpu/cpu$1/cpuidle/state$2/disable"; }
"$hook" post
[[ $(d 0 1) == 0 ]] || fail "a post with nothing saved changed a state"
"$hook" pre
for c in 0 1 2 3 4 5 6 7; do [[ $(d $c 1) == 1 ]] || fail "cpu$c's sleep state not disabled before the sleep"; [[ $(d $c 0) == 0 ]] || fail "cpu$c's WFI touched"; done
"$hook" post
for c in 0 1 2 3 4 5 6; do [[ $(d $c 1) == 0 ]] || fail "cpu$c's sleep state not restored"; done
[[ $(d 7 1) == 1 ]] || fail "a state that was off before the sleep was turned on after it"
[[ ! -e $OMAMOBILE_TEGU_ROOT/run/omamobile/cpuidle-before-sleep ]] || fail "the saved list was left behind"
echo "ok - cpuidle-hook: core power-down off for the sleep and restored after"
13 changes: 13 additions & 0 deletions packages/omamobile-device-tegu/test/graphics-start
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ case $1 in
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" ;;
pcie_zumapro) mkdir -p "$TEST_ROOT/sys/bus/pci/devices/0000:01:00.0" ;;
brcmfmac) mkdir -p "$TEST_ROOT/sys/class/net/wlan0" ;;
esac
echo "$*" >> "$TEST_LOG"
EOF
Expand Down Expand Up @@ -191,4 +193,15 @@ reset; out=$(FAIL_MODULE=nxp_nci_i2c "$script" || true)
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"
# Wi-Fi: with the host node, the DMA pool and the firmware, pcie_zumapro
# then brcmfmac load last and wlan0 counts as up; a missing endpoint skips it
reset
mkdir -p "$devices/13120000.pcie" "$dt/reserved-memory/wifi-dma-pool" "$OMAMOBILE_TEGU_ROOT/usr/lib/firmware/brcm"
: > "$OMAMOBILE_TEGU_ROOT/usr/lib/firmware/brcm/brcmfmac4383-pcie.bin"
out=$("$script")
[[ $(loads) == "$all pcie_zumapro brcmfmac" ]] || fail "Wi-Fi load order: $(loads)"
[[ $out == *", Wi-Fi (wlan0)"* ]] || fail "Wi-Fi summary: $out"
reset; rm -rf "$OMAMOBILE_TEGU_ROOT/sys/bus/pci"; out=$(FAIL_MODULE=pcie_zumapro "$script" || true)
[[ $out == *"pcie_zumapro failed"* && $(loads) != *brcmfmac* && ! -e $marker ]] || fail "a failed host load skips brcmfmac: $out"
rm -rf "$devices/13120000.pcie" "$dt/reserved-memory" "$OMAMOBILE_TEGU_ROOT/usr/lib/firmware" "$OMAMOBILE_TEGU_ROOT/sys/bus/pci"
echo 'ok - graphics-start: marker first, order kept, failures skipped and named, allow_tx for google-tg4c only, --retry works'
Original file line number Diff line number Diff line change
@@ -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
# nxp_nci_i2c for NFC) and, once a kernel ships them in tree, the Wi-Fi start. Blacklisting only
# marker is written: omamobile-tegu-graphics-start (the first six, then
# nxp_nci_i2c for NFC and pcie_zumapro and brcmfmac for Wi-Fi). 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# systemd-sleep hook: keep the Pixel 9a's CPUs out of core power-down while
# the palmtop sleeps (device/tegu/SLEEP-PLAN.md S1).
#
# In s2idle with the CPUs' power-down state (cpuidle state "cpu-*-sleep",
# PSCI core power-down) allowed, the S2MPG14 raised an event that hadn't
# happened about a second in (an early RTC alarm, or a power key release
# nobody made), and every sleep ended there. With only WFI allowed, a 30 s
# sleep lasted until its alarm. So before the sleep this disables every
# "*-sleep" cpuidle state, remembering what it was, and afterwards puts each
# one back as it found it.
# OMAMOBILE_TEGU_ROOT: a scratch root for the package tests.
root=${OMAMOBILE_TEGU_ROOT:-}
SAVED=$root/run/omamobile/cpuidle-before-sleep

states() {
local s
for s in "$root"/sys/devices/system/cpu/cpu[0-9]*/cpuidle/state[0-9]*; do
[[ -f $s/name && -f $s/disable ]] || continue
[[ $(cat "$s/name") == *-sleep ]] && echo "$s"
done
}

case ${1:-} in
pre)
mkdir -p "${SAVED%/*}"
: > "$SAVED.new"
n=0
while read -r s; do
echo "$s $(cat "$s/disable")" >> "$SAVED.new"
echo 1 > "$s/disable" && n=$((n + 1))
done < <(states)
mv "$SAVED.new" "$SAVED"
logger -t omamobile-tegu-cpuidle "core power-down off for the sleep ($n states)"
;;
post)
[[ -f $SAVED ]] || exit 0
while read -r s v; do
[[ -f $s/disable ]] && echo "$v" > "$s/disable"
done < "$SAVED"
rm -f "$SAVED"
logger -t omamobile-tegu-cpuidle "core power-down restored after the sleep"
;;
esac
exit 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
# The GPU, display, haptics, torch, gauge, Bluetooth controller and NFC at boot,
# The GPU, display, haptics, torch, gauge, Bluetooth controller, NFC and Wi-Fi 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
Expand All @@ -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, Bluetooth and NFC (hang-safe)
Description=Bring up the Pixel 9a GPU, display, haptics, torch, gauge, Bluetooth, NFC and Wi-Fi (hang-safe)
After=local-fs.target systemd-modules-load.service
Before=display-manager.service
ConditionPathExists=|/sys/bus/platform/devices/1f000000.gpu
Expand Down
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.3
0.2.5