From 704f52cf5b28401118d3ba9939e2df8b4e88f30a Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 19:08:29 -0647 Subject: [PATCH 1/9] device/tegu: the USB-C host-mode bring-up setup, with a runbook The 10-28 host-mode run depended on a DT fragment and an RT9470 boost module that weren't in any public tree. This publishes both as they ran, with what they build on, a gated runbook with the swap timer, and what is still unknown. --- device/tegu/usb-host/Makefile | 1 + device/tegu/usb-host/README.md | 42 ++++++++ device/tegu/usb-host/tegu-rt9471-boost.c | 121 +++++++++++++++++++++++ device/tegu/usb-host/usb-host.dtsi | 51 ++++++++++ 4 files changed, 215 insertions(+) create mode 100644 device/tegu/usb-host/Makefile create mode 100644 device/tegu/usb-host/README.md create mode 100644 device/tegu/usb-host/tegu-rt9471-boost.c create mode 100644 device/tegu/usb-host/usb-host.dtsi diff --git a/device/tegu/usb-host/Makefile b/device/tegu/usb-host/Makefile new file mode 100644 index 000000000..dfeb8189f --- /dev/null +++ b/device/tegu/usb-host/Makefile @@ -0,0 +1 @@ +obj-m += tegu-rt9471-boost.o diff --git a/device/tegu/usb-host/README.md b/device/tegu/usb-host/README.md new file mode 100644 index 000000000..2c6382f81 --- /dev/null +++ b/device/tegu/usb-host/README.md @@ -0,0 +1,42 @@ +# USB-C host mode on the Pixel 9a: the bring-up setup + +These are the parts of the 2026-10-28 host-mode run (NOTES, "USB-C host mode through TCPM") that aren't in a public tree yet. They're published so the run can be reproduced. They are bring-up files, not proposals for the kernel: the RT9470 boost will go upstream in whatever shape derekross/linux-omarchy-mobile#124 settles on (mainline `rt9471` with an optional interrupt, or an OTG-only driver). + +| File | What | +| --- | --- | +| `usb-host.dtsi` | The DT fragment ("ot2"): the RT9470's OTG boost on `hsi2c10`, the MAX77779 charger's `chgin-otg` regulator over it, the TCPC as a dual-role port that prefers sink with that regulator as `vbus-supply`, and the graph from the connector to dwc3's role switch. The source PDO is stock's (fixed 5 V, 900 mA). | +| `tegu-rt9471-boost.c`, `Makefile` | The RT9470 as an OTG boost only: a regulator on `OTG_EN` (FUNCTION 0x02 bit 1). At probe it turns off JEITA (0x0C bit 7) and the I2C watchdog (TOP 0x01 bits 1:0). With either one on, VBUS collapsed under the boost. | + +## What it builds on + +- The kernel the palmtop ran: `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, the integration tree. It carries the MAX77779 TCPC in `tcpci_maxim` (kernel #97, merged), the board's TCPC and fuel gauge nodes (kernel #119), the eUSB2 repeater (kernel #118) and the MAX77779 charger (kernel #92). +- The charger's `chgin-otg` regulator, kernel #124. The run used a superset of that driver (blob `1c71542965b0`), whose OTG code matches #124's head before the review changes (`f70a184098c3`). +- The `tcpci_maxim` module on the palmtop also had three bring-up parameters (`src_cmd`, `keep_sink`, `no_autodischarge`). All three were off by default and off in the run, so its behaviour was #97's. + +## Runbook + +Attended only: the drive swap takes out the laptop, which is the only link. Every step that can lose USB has a timer armed first. + +1. **Build** (laptop or build machine): `make -C M=$PWD ARCH=arm64 LLVM=1 W=1 modules` builds `tegu-rt9471-boost.ko`. Add `usb-host.dtsi` to the board DTB after `zumapro-tegu.dts`'s own nodes. + *Expect:* a clean build and a DTB that passes `dtc` with no new warnings. *Risk:* none. +2. **Install the module** under `/usr/lib/modules/$(uname -r)/updates/otg/`, run `depmod -a`, and re-pin the curated autostart manifest if it pins that directory. + *Expect:* `modinfo tegu-rt9471-boost` resolves. *Risk:* none (nothing loads yet). +3. **Boot the DTB** with `bin/omamobile push` only, never a `flash`, with slot B already marked successful, and with the one-boot DTB dead-man armed (`tegu-dtb-deadman`: the good DTB comes back if the boot loses USB). + *Expect:* `regulator.*` entries named `otg-boost` and `chgin-otg`, both `disabled`; the port is a sink, and the laptop charges the palmtop and reaches it over SSH. + *Stop if:* SSH doesn't come back within 2 minutes (the dead-man restores the DTB). + *Rollback:* push the previous DTB. *Risk:* medium (a boot). +4. **Arm the swap timer**, then swap the cable for the drive: + `systemd-run --unit=x-deadman --on-active=300 systemctl reboot` + *Expect:* the port becomes a source, `otg-boost` and `chgin-otg` read `enabled`, VBUS holds near 5.2 V, and the drive enumerates (`lsblk` shows it on `usb`). + *Stop if:* the drive doesn't enumerate within a minute: plug the laptop back in. +5. **Back to the laptop**, then over a fresh login (`tools/phone-ssh --fresh`) `systemctl stop x-deadman.timer`. + *Expect:* the port is a sink again, `CHG_CNFG_00` reads 0x05, and the palmtop charges. + *Rollback for 4 and 5:* the timer reboots the palmtop 5 minutes after it was armed, and the boot comes back as a sink. + +In the 10-28 run the swaps were attended (W4HO at the palmtop). The protection then was each sampling script's own dead-man rather than this timer: with no USB gadget configured 6 to 8 minutes after the cable came out, it unloaded `tcpci_maxim` and set the role switch back to device. The laptop came back as a sink every time, so it never fired. + +## Not known yet + +- **What a warm reboot with host mode on leaves behind.** With the RT9470's watchdog off, nothing turns its boost off after a crash. The OTG bit and `ICSTAT` before any driver loads haven't been read after a warm reboot with the drive attached, so whether VBUS stays out across one is unknown. +- **Why JEITA tripped.** JEITA reading "hot" is an inference: the RT9470's TS pin may have no thermistor on it. It isn't confirmed. Google's tegu tree leaves `en-jeita` commented out. +- **Whether the RT9470 charges under our kernel.** Its CE comes from the MAX77779's sGPIO 7, which hasn't been read. On the charger with the battery full (2026-10-28 evening), `FUNCTION` read 0x41 (`CHG_EN` set) and `ICSTAT` 0xf1 (IC state 1, VBUS ready, not charging). With JEITA off, the RT9470 has no temperature cut-off of its own, which matters only if it charges. diff --git a/device/tegu/usb-host/tegu-rt9471-boost.c b/device/tegu/usb-host/tegu-rt9471-boost.c new file mode 100644 index 000000000..cffd70486 --- /dev/null +++ b/device/tegu/usb-host/tegu-rt9471-boost.c @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Bring-up only, not for upstream: the Pixel 9a's RT9470 (run by Google's + * rt9471 driver) as an OTG boost only, a regulator on its OTG_EN bit + * (FUNCTION 0x02 bit 1), which the MAX77779 charger enables to give a USB-C + * device VBUS. Probe reads the device id and turns off JEITA (0x0C bit 7) + * and the I2C watchdog (TOP 0x01 bits 1:0): with either on, VBUS collapsed + * under the boost. With the watchdog off, nothing turns the boost off after + * a crash. The charger part of the chip (charging, BC1.2, its interrupts) + * is left alone. + * + * Registers from mainline rt9471.c and Google's GPL rt9471_charger.h + * (google-modules/bms at 183509aff980). + */ + +#include +#include +#include +#include +#include +#include +#include + +#define RT9471_REG_OTGCFG 0x00 +#define RT9471_REG_TOP 0x01 +#define RT9471_WDT GENMASK(1, 0) +#define RT9471_REG_FUNC 0x02 +#define RT9471_OTGEN BIT(1) +#define RT9471_REG_INFO 0x0b +#define RT9471_REG_JEITA 0x0c +#define RT9471_JEITA_EN BIT(7) +#define RT9471_DEVID GENMASK(6, 3) + +static bool rt9471_boost_writeable(struct device *dev, unsigned int reg) +{ + return reg == RT9471_REG_FUNC || reg == RT9471_REG_TOP || + reg == RT9471_REG_JEITA; +} + +static const struct regmap_config rt9471_boost_regmap = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0x12, + .writeable_reg = rt9471_boost_writeable, + .cache_type = REGCACHE_NONE, +}; + +static const struct regulator_ops rt9471_boost_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, +}; + +static const struct regulator_desc rt9471_boost_desc = { + .name = "rt9471-otg-boost", + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .ops = &rt9471_boost_ops, + .fixed_uV = 5000000, + .n_voltages = 1, + .enable_reg = RT9471_REG_FUNC, + .enable_mask = RT9471_OTGEN, + .enable_time = 5000, +}; + +static int rt9471_boost_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct regulator_config cfg = {}; + struct regulator_dev *rdev; + struct regmap *map; + unsigned int info; + int ret; + + map = devm_regmap_init_i2c(client, &rt9471_boost_regmap); + if (IS_ERR(map)) + return PTR_ERR(map); + + ret = regmap_read(map, RT9471_REG_INFO, &info); + if (ret) + return dev_err_probe(dev, ret, "no answer\n"); + /* RT9470 0x9, RT9470D 0xa, RT9471 0xd, RT9471D 0xe */ + switch (FIELD_GET(RT9471_DEVID, info)) { + case 0x9: case 0xa: case 0xd: case 0xe: + break; + default: + return dev_err_probe(dev, -ENODEV, "unknown id %#x\n", info); + } + dev_info(dev, "id %#lx\n", FIELD_GET(RT9471_DEVID, info)); + + ret = regmap_update_bits(map, RT9471_REG_JEITA, RT9471_JEITA_EN, 0) ?: + regmap_update_bits(map, RT9471_REG_TOP, RT9471_WDT, 0); + if (ret) + return dev_err_probe(dev, ret, "cannot turn off JEITA and the watchdog\n"); + + cfg.dev = dev; + cfg.regmap = map; + cfg.of_node = dev->of_node; + cfg.init_data = of_get_regulator_init_data(dev, dev->of_node, + &rt9471_boost_desc); + rdev = devm_regulator_register(dev, &rt9471_boost_desc, &cfg); + return PTR_ERR_OR_ZERO(rdev); +} + +static const struct of_device_id rt9471_boost_of_match[] = { + { .compatible = "omamobile,tegu-rt9471-boost" }, + { } +}; +MODULE_DEVICE_TABLE(of, rt9471_boost_of_match); + +static struct i2c_driver rt9471_boost_driver = { + .driver = { + .name = "tegu-rt9471-boost", + .of_match_table = rt9471_boost_of_match, + }, + .probe = rt9471_boost_probe, +}; +module_i2c_driver(rt9471_boost_driver); + +MODULE_DESCRIPTION("RT9471 OTG boost for the Pixel 9a's USB-C port"); +MODULE_LICENSE("GPL"); diff --git a/device/tegu/usb-host/usb-host.dtsi b/device/tegu/usb-host/usb-host.dtsi new file mode 100644 index 000000000..252450a72 --- /dev/null +++ b/device/tegu/usb-host/usb-host.dtsi @@ -0,0 +1,51 @@ + +/* + * USB-C host mode (ot2): the RT9470's OTG boost on hsi2c10, the MAX77779 + * charger's chgin-otg regulator on top of it (charger to standby, then the + * boost, as Google's ext-otg-only use case), the TCPC sourcing VBUS from + * it as a dual-role port that prefers sink, and the port's data role + * driving the dwc3 role switch. Source PDO from stock (fixed 5 V, 900 mA). + */ +&hsi2c10 { + otg_boost: regulator@5b { + compatible = "omamobile,tegu-rt9471-boost"; + reg = <0x5b>; + regulator-name = "otg-boost"; + }; +}; + +&hsi2c6 { + charger@69 { + compatible = "maxim,max77779-charger"; + reg = <0x69>; + otg-boost-supply = <&otg_boost>; + + chgin_otg: chgin-otg-regulator { + regulator-name = "chgin-otg"; + }; + }; +}; + +&usb_tcpc { + vbus-supply = <&chgin_otg>; + + connector { + power-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + + port { + typec_hs: endpoint { + remote-endpoint = <&usb_hs>; + }; + }; + }; +}; + +&usb { + port { + usb_hs: endpoint { + remote-endpoint = <&typec_hs>; + }; + }; +}; From 0eecd8fe90f826bb0d76852285ae0f9d11ac6553 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 20:15:21 -0647 Subject: [PATCH 2/9] device/tegu: USB-HOST-PLAN instead of the bring-up files Review: the device tree and the RT9470 module moved to the kernel bring-up branch (derekross/linux-omarchy-mobile#127). This leaves the plan with what the setup builds on, the dead-man and curated autostart explained, a runbook with the unbind and reset-without-shutdown measurements for #124, and the early RT9470 read as a one-boot unit. --- device/tegu/USB-HOST-PLAN.md | 120 +++++++++++++++++ device/tegu/usb-host/Makefile | 1 - device/tegu/usb-host/README.md | 42 ------ device/tegu/usb-host/tegu-rt9470-early-read | 30 +++++ .../usb-host/tegu-rt9470-early-read.service | 14 ++ device/tegu/usb-host/tegu-rt9471-boost.c | 121 ------------------ device/tegu/usb-host/usb-host.dtsi | 51 -------- 7 files changed, 164 insertions(+), 215 deletions(-) create mode 100644 device/tegu/USB-HOST-PLAN.md delete mode 100644 device/tegu/usb-host/Makefile delete mode 100644 device/tegu/usb-host/README.md create mode 100644 device/tegu/usb-host/tegu-rt9470-early-read create mode 100644 device/tegu/usb-host/tegu-rt9470-early-read.service delete mode 100644 device/tegu/usb-host/tegu-rt9471-boost.c delete mode 100644 device/tegu/usb-host/usb-host.dtsi diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md new file mode 100644 index 000000000..eca9cf933 --- /dev/null +++ b/device/tegu/USB-HOST-PLAN.md @@ -0,0 +1,120 @@ + +# Pixel 9a USB-C host mode: setup and runbook + +Status (2026-10-29): host mode worked end to end on 2026-10-28 (NOTES, "USB-C +host mode through TCPM"). This plan is the setup that run used and the +runbook for the next one, which adds two measurements for +derekross/linux-omarchy-mobile#124: unbinding the charger with a drive +attached, and a reset without shutdown with host mode on. The device tree and +the RT9470 module are on the kernel bring-up branch +derekross/linux-omarchy-mobile#127 (`tegu-usb-host-bringup` at `5dd15e31c`, not +for merge). The two boot helpers are in `device/tegu/usb-host/`. + +## What it builds on + +| Piece | Where | +| --- | --- | +| Board DT: fuel gauge, TCPC node | derekross/linux-omarchy-mobile#119 | +| `usi10`/`hsi2c10`, its pins, the RT9470 node, the TCPC as dual-role with `vbus-supply`, the graph to dwc3 | #127 (USI10 clocks: #102, merged) | +| RT9470 OTG boost module (`tegu-rt9471-boost`) | #127. JEITA and the watchdog are off only while the boost is enabled | +| MAX77779 charger and its `chgin-otg` regulator | #92, #124 (head `4970bcdc3820`) | +| MAX77779 TCPC in `tcpci_maxim` | #97 (merged) | +| eUSB2 repeater, PHY | #118, the integration tree | +| Kernel the palmtop runs | `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty` (integration tree) | + +The palmtop already boots a DTB with this setup (the "gn3" round), so the next +run boots no new DTB and needs no DTB dead-man. The `tegu-dtb-deadman` used +on 10-28 was a one-boot unit: if the gadget wasn't configured 180 s into an +armed boot, it wrote a known-good `vendor_kernel_boot` image (checked against +a stored sha256 first, and read back after) into `vendor_kernel_boot_b` from +the palmtop and rebooted. It is a second path writing slot B next to `bin/omamobile +push`. It stays unarmed, and it won't be used again unless that's agreed first. + +**The curated autostart** is the 9a's private bring-up startup +(`/usr/local/lib/omamobile-tegu-curated//curated-native-start.py`, +with a manifest of sha256 pins). It loads the display, GPU and touch modules +in order, refuses a pinned file that changed, and masks units the bring-up +doesn't run. It doesn't pin or load the USB-C modules: those load through +udev from their DT nodes. Re-pinning (recomputing the manifest's sha256 values +after a deliberate change) only matters when a pinned module changes. This +runbook changes none. + +## Runbook (attended, on the charger, W4HO at the palmtop) + +Forced restart if the palmtop hangs, also in a shutdown under the swap timer: +hold Power about 30 s until it is off, then press Power. Stop the run if slot +B isn't marked successful: this runbook doesn't mark it (marking is a separate +`devinfo` operation under the rules settled on #125), and nothing here +writes a boot partition. + +**H1. Precondition (read-only; risk none).** `tools/phone-ssh 'uname -r; +cat /proc/device-tree/__symbols__/otg_boost; for r in /sys/class/regulator/*; +do grep -H . $r/name; done | grep -E "otg-boost|chgin-otg"'`. +Expect: the release above, the `otg_boost` symbol, and both regulators. +Stop: either regulator missing (an older DTB). + +**H2. Modules for the run (risk low).** Blacklist the boost module, so its +node can't load it before the early read: `echo "blacklist tegu_rt9471_boost" +> /etc/modprobe.d/omamobile-tegu-otg-bringup.conf`. Install the boost module +from #127 (`597a2251…`) and the charger built from #124's head `4970bcdc3820` +(`e5a4c78e…`), both staged in `/var/lib/omamobile-tegu/usb-host/`, over +`/usr/lib/modules/$(uname -r)/updates/otg/`, keeping the old files as +`*.before-h2`, then `depmod -a`. These live under one release's `updates/`, +so after every `push` of a new kernel they must be rebuilt and reinstalled. +Rollback: put the `*.before-h2` files back and run `depmod -a`. + +**H3. Boot with the boost module held back (risk low).** Reboot, with kmsg +streamed to the laptop. Expect: the gadget comes up as before (it ran before +the TCPC node existed), the charger waits for `otg-boost-supply`, and the +TCPC waits for the charger. Stop: no SSH 3 minutes after the reboot (forced +restart, then H2's rollback). Then load the boost module by hand (`modprobe +tegu_rt9471_boost`) with kmsg streamed. Expect: `otg-boost` and `chgin-otg` +registered and disabled, and the TCPC probes as a sink with the laptop +attached. + +**H4. Unbind the charger with the drive attached (#124; risk medium).** +Arm the swap timer first: `systemd-run --unit=x-deadman --on-active=300 +systemctl reboot`. Swap the laptop for the drive. Expect host mode as on +10-28 (the drive enumerates). Then, from a script started before the swap, +unbind `max77779-charger` 20 s after the drive enumerates and log kmsg, +VBUS (TCPC 0x70/0x71) and `CHG_CNFG_00` (0xbc). Expect a clean kmsg, VBUS +at 0 and `CHG_CNFG_00` reading 0x05. Laptop back in. Over a fresh login +(`tools/phone-ssh --fresh`), stop the timer: `systemctl stop x-deadman.timer`. +Stop: the laptop doesn't come back as a sink before the timer fires. + +**H5. Reset without shutdown with host mode on (#124, #127; risk +medium-high).** Arm the early read for the next boot (`mkdir -p +/var/lib/omamobile-tegu/rt9470-early-read; touch +/var/lib/omamobile-tegu/rt9470-early-read/armed`; the script and unit are in +`device/tegu/usb-host/`). With the boost module blacklisted from H2, the read +runs before any RT9470 driver. Arm the swap timer, swap to the drive, and +from a script started before the swap, `echo b > /proc/sysrq-trigger` 20 s +after the drive enumerates. `systemctl reboot` would run the charger's +`.shutdown`, which turns the boost off, so it can't show what a crash leaves. +Then, with an inline USB-C meter between the palmtop and the drive: +- Expect: VBUS falls to 0 within the reboot. +- **Stop if VBUS is still up two minutes after the reset.** Don't plug the + laptop in (two sources on VBUS). Unplug the drive and report it. +- Otherwise put the laptop back in. The log `/var/log/omamobile/rt9470-early-read.log` + has the OTG bit (FUNCTION 0x02 bit 1) and ICSTAT before any driver, and + again at 60 s. If the boost had survived, a read at 60 s also shows + whether the regulator core's unused-regulator cleanup turned it off (only + if the module had loaded by then, which H2's blacklist prevents; a second + run without the blacklist would show it). + +**H6. Afterwards (risk low).** Remove `omamobile-tegu-otg-bringup.conf`, run +`depmod -a`, and reboot. The modules stay as installed in H2, unless H2's +rollback is wanted. + +## Not known yet + +- What a reset without shutdown leaves with host mode on (H5). +- Why JEITA tripped. "Read hot" is an inference: the TS pin may have no + thermistor on it. +- Whether the RT9470 charges under our kernel. Its CE comes from the + MAX77779's sGPIO 7, which hasn't been read. On the charger with the + battery full, FUNCTION read 0x41 (`CHG_EN` set) and ICSTAT 0xf1 (VBUS + ready, not charging). Since #127 turns JEITA off only while the boost is + on, this matters only in host mode. +- Where stock's source PDO (5 V, 900 mA in the run) comes from. It isn't + traced to a stock file yet. diff --git a/device/tegu/usb-host/Makefile b/device/tegu/usb-host/Makefile deleted file mode 100644 index dfeb8189f..000000000 --- a/device/tegu/usb-host/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m += tegu-rt9471-boost.o diff --git a/device/tegu/usb-host/README.md b/device/tegu/usb-host/README.md deleted file mode 100644 index 2c6382f81..000000000 --- a/device/tegu/usb-host/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# USB-C host mode on the Pixel 9a: the bring-up setup - -These are the parts of the 2026-10-28 host-mode run (NOTES, "USB-C host mode through TCPM") that aren't in a public tree yet. They're published so the run can be reproduced. They are bring-up files, not proposals for the kernel: the RT9470 boost will go upstream in whatever shape derekross/linux-omarchy-mobile#124 settles on (mainline `rt9471` with an optional interrupt, or an OTG-only driver). - -| File | What | -| --- | --- | -| `usb-host.dtsi` | The DT fragment ("ot2"): the RT9470's OTG boost on `hsi2c10`, the MAX77779 charger's `chgin-otg` regulator over it, the TCPC as a dual-role port that prefers sink with that regulator as `vbus-supply`, and the graph from the connector to dwc3's role switch. The source PDO is stock's (fixed 5 V, 900 mA). | -| `tegu-rt9471-boost.c`, `Makefile` | The RT9470 as an OTG boost only: a regulator on `OTG_EN` (FUNCTION 0x02 bit 1). At probe it turns off JEITA (0x0C bit 7) and the I2C watchdog (TOP 0x01 bits 1:0). With either one on, VBUS collapsed under the boost. | - -## What it builds on - -- The kernel the palmtop ran: `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, the integration tree. It carries the MAX77779 TCPC in `tcpci_maxim` (kernel #97, merged), the board's TCPC and fuel gauge nodes (kernel #119), the eUSB2 repeater (kernel #118) and the MAX77779 charger (kernel #92). -- The charger's `chgin-otg` regulator, kernel #124. The run used a superset of that driver (blob `1c71542965b0`), whose OTG code matches #124's head before the review changes (`f70a184098c3`). -- The `tcpci_maxim` module on the palmtop also had three bring-up parameters (`src_cmd`, `keep_sink`, `no_autodischarge`). All three were off by default and off in the run, so its behaviour was #97's. - -## Runbook - -Attended only: the drive swap takes out the laptop, which is the only link. Every step that can lose USB has a timer armed first. - -1. **Build** (laptop or build machine): `make -C M=$PWD ARCH=arm64 LLVM=1 W=1 modules` builds `tegu-rt9471-boost.ko`. Add `usb-host.dtsi` to the board DTB after `zumapro-tegu.dts`'s own nodes. - *Expect:* a clean build and a DTB that passes `dtc` with no new warnings. *Risk:* none. -2. **Install the module** under `/usr/lib/modules/$(uname -r)/updates/otg/`, run `depmod -a`, and re-pin the curated autostart manifest if it pins that directory. - *Expect:* `modinfo tegu-rt9471-boost` resolves. *Risk:* none (nothing loads yet). -3. **Boot the DTB** with `bin/omamobile push` only, never a `flash`, with slot B already marked successful, and with the one-boot DTB dead-man armed (`tegu-dtb-deadman`: the good DTB comes back if the boot loses USB). - *Expect:* `regulator.*` entries named `otg-boost` and `chgin-otg`, both `disabled`; the port is a sink, and the laptop charges the palmtop and reaches it over SSH. - *Stop if:* SSH doesn't come back within 2 minutes (the dead-man restores the DTB). - *Rollback:* push the previous DTB. *Risk:* medium (a boot). -4. **Arm the swap timer**, then swap the cable for the drive: - `systemd-run --unit=x-deadman --on-active=300 systemctl reboot` - *Expect:* the port becomes a source, `otg-boost` and `chgin-otg` read `enabled`, VBUS holds near 5.2 V, and the drive enumerates (`lsblk` shows it on `usb`). - *Stop if:* the drive doesn't enumerate within a minute: plug the laptop back in. -5. **Back to the laptop**, then over a fresh login (`tools/phone-ssh --fresh`) `systemctl stop x-deadman.timer`. - *Expect:* the port is a sink again, `CHG_CNFG_00` reads 0x05, and the palmtop charges. - *Rollback for 4 and 5:* the timer reboots the palmtop 5 minutes after it was armed, and the boot comes back as a sink. - -In the 10-28 run the swaps were attended (W4HO at the palmtop). The protection then was each sampling script's own dead-man rather than this timer: with no USB gadget configured 6 to 8 minutes after the cable came out, it unloaded `tcpci_maxim` and set the role switch back to device. The laptop came back as a sink every time, so it never fired. - -## Not known yet - -- **What a warm reboot with host mode on leaves behind.** With the RT9470's watchdog off, nothing turns its boost off after a crash. The OTG bit and `ICSTAT` before any driver loads haven't been read after a warm reboot with the drive attached, so whether VBUS stays out across one is unknown. -- **Why JEITA tripped.** JEITA reading "hot" is an inference: the RT9470's TS pin may have no thermistor on it. It isn't confirmed. Google's tegu tree leaves `en-jeita` commented out. -- **Whether the RT9470 charges under our kernel.** Its CE comes from the MAX77779's sGPIO 7, which hasn't been read. On the charger with the battery full (2026-10-28 evening), `FUNCTION` read 0x41 (`CHG_EN` set) and `ICSTAT` 0xf1 (IC state 1, VBUS ready, not charging). With JEITA off, the RT9470 has no temperature cut-off of its own, which matters only if it charges. diff --git a/device/tegu/usb-host/tegu-rt9470-early-read b/device/tegu/usb-host/tegu-rt9470-early-read new file mode 100644 index 000000000..5936cc53e --- /dev/null +++ b/device/tegu/usb-host/tegu-rt9470-early-read @@ -0,0 +1,30 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# tegu-rt9470-early-read: one boot only (armed by its marker), read the +# RT9470's OTG_EN (FUNCTION 0x02 bit 1), ICSTAT (0x0f) and STAT registers as +# early as the I2C bus allows, before any RT9470 driver loads, then again at +# 60 s of uptime. Read-only: i2cget only, no writes. USB-HOST-PLAN step H5. +set -u +A=/var/lib/omamobile-tegu/rt9470-early-read +L=/var/log/omamobile/rt9470-early-read.log; mkdir -p /var/log/omamobile +[[ -e $A/armed ]] || exit 0 +rm -f "$A/armed"; sync +log() { echo "$(awk '{print $1}' /proc/uptime)s $*" >> "$L"; } +bus= +for _ in $(seq 1 300); do + for d in /sys/bus/i2c/devices/i2c-*; do + readlink -f "$d" | grep -c 10ca0000 >/dev/null && { bus=${d##*-}; break 2; } + done + sleep 0.1 +done +[[ -n $bus ]] || { log "no hsi2c10 bus"; exit 1; } +read_all() { + local r out= + for r in 0x01 0x02 0x0c 0x0f 0x10 0x11 0x12 0x13; do + out+=" $r=$(i2cget -f -y "$bus" 0x5b "$r" 2>/dev/null || echo ?)" + done + log "$1: driver $(lsmod | grep -c '^tegu_rt9471_boost') vbus-bus$bus$out" +} +read_all early +while (( $(awk '{print int($1)}' /proc/uptime) < 60 )); do sleep 1; done +read_all at-60s diff --git a/device/tegu/usb-host/tegu-rt9470-early-read.service b/device/tegu/usb-host/tegu-rt9470-early-read.service new file mode 100644 index 000000000..9aaf8a26a --- /dev/null +++ b/device/tegu/usb-host/tegu-rt9470-early-read.service @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: MIT +[Unit] +Description=Pixel 9a: read the RT9470's boost state before its driver loads (one boot) +ConditionPathExists=/var/lib/omamobile-tegu/rt9470-early-read/armed +DefaultDependencies=no +After=systemd-udevd.service +Before=systemd-modules-load.service + +[Service] +Type=simple +ExecStart=/usr/local/sbin/tegu-rt9470-early-read + +[Install] +WantedBy=sysinit.target diff --git a/device/tegu/usb-host/tegu-rt9471-boost.c b/device/tegu/usb-host/tegu-rt9471-boost.c deleted file mode 100644 index cffd70486..000000000 --- a/device/tegu/usb-host/tegu-rt9471-boost.c +++ /dev/null @@ -1,121 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Bring-up only, not for upstream: the Pixel 9a's RT9470 (run by Google's - * rt9471 driver) as an OTG boost only, a regulator on its OTG_EN bit - * (FUNCTION 0x02 bit 1), which the MAX77779 charger enables to give a USB-C - * device VBUS. Probe reads the device id and turns off JEITA (0x0C bit 7) - * and the I2C watchdog (TOP 0x01 bits 1:0): with either on, VBUS collapsed - * under the boost. With the watchdog off, nothing turns the boost off after - * a crash. The charger part of the chip (charging, BC1.2, its interrupts) - * is left alone. - * - * Registers from mainline rt9471.c and Google's GPL rt9471_charger.h - * (google-modules/bms at 183509aff980). - */ - -#include -#include -#include -#include -#include -#include -#include - -#define RT9471_REG_OTGCFG 0x00 -#define RT9471_REG_TOP 0x01 -#define RT9471_WDT GENMASK(1, 0) -#define RT9471_REG_FUNC 0x02 -#define RT9471_OTGEN BIT(1) -#define RT9471_REG_INFO 0x0b -#define RT9471_REG_JEITA 0x0c -#define RT9471_JEITA_EN BIT(7) -#define RT9471_DEVID GENMASK(6, 3) - -static bool rt9471_boost_writeable(struct device *dev, unsigned int reg) -{ - return reg == RT9471_REG_FUNC || reg == RT9471_REG_TOP || - reg == RT9471_REG_JEITA; -} - -static const struct regmap_config rt9471_boost_regmap = { - .reg_bits = 8, - .val_bits = 8, - .max_register = 0x12, - .writeable_reg = rt9471_boost_writeable, - .cache_type = REGCACHE_NONE, -}; - -static const struct regulator_ops rt9471_boost_ops = { - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, - .is_enabled = regulator_is_enabled_regmap, -}; - -static const struct regulator_desc rt9471_boost_desc = { - .name = "rt9471-otg-boost", - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - .ops = &rt9471_boost_ops, - .fixed_uV = 5000000, - .n_voltages = 1, - .enable_reg = RT9471_REG_FUNC, - .enable_mask = RT9471_OTGEN, - .enable_time = 5000, -}; - -static int rt9471_boost_probe(struct i2c_client *client) -{ - struct device *dev = &client->dev; - struct regulator_config cfg = {}; - struct regulator_dev *rdev; - struct regmap *map; - unsigned int info; - int ret; - - map = devm_regmap_init_i2c(client, &rt9471_boost_regmap); - if (IS_ERR(map)) - return PTR_ERR(map); - - ret = regmap_read(map, RT9471_REG_INFO, &info); - if (ret) - return dev_err_probe(dev, ret, "no answer\n"); - /* RT9470 0x9, RT9470D 0xa, RT9471 0xd, RT9471D 0xe */ - switch (FIELD_GET(RT9471_DEVID, info)) { - case 0x9: case 0xa: case 0xd: case 0xe: - break; - default: - return dev_err_probe(dev, -ENODEV, "unknown id %#x\n", info); - } - dev_info(dev, "id %#lx\n", FIELD_GET(RT9471_DEVID, info)); - - ret = regmap_update_bits(map, RT9471_REG_JEITA, RT9471_JEITA_EN, 0) ?: - regmap_update_bits(map, RT9471_REG_TOP, RT9471_WDT, 0); - if (ret) - return dev_err_probe(dev, ret, "cannot turn off JEITA and the watchdog\n"); - - cfg.dev = dev; - cfg.regmap = map; - cfg.of_node = dev->of_node; - cfg.init_data = of_get_regulator_init_data(dev, dev->of_node, - &rt9471_boost_desc); - rdev = devm_regulator_register(dev, &rt9471_boost_desc, &cfg); - return PTR_ERR_OR_ZERO(rdev); -} - -static const struct of_device_id rt9471_boost_of_match[] = { - { .compatible = "omamobile,tegu-rt9471-boost" }, - { } -}; -MODULE_DEVICE_TABLE(of, rt9471_boost_of_match); - -static struct i2c_driver rt9471_boost_driver = { - .driver = { - .name = "tegu-rt9471-boost", - .of_match_table = rt9471_boost_of_match, - }, - .probe = rt9471_boost_probe, -}; -module_i2c_driver(rt9471_boost_driver); - -MODULE_DESCRIPTION("RT9471 OTG boost for the Pixel 9a's USB-C port"); -MODULE_LICENSE("GPL"); diff --git a/device/tegu/usb-host/usb-host.dtsi b/device/tegu/usb-host/usb-host.dtsi deleted file mode 100644 index 252450a72..000000000 --- a/device/tegu/usb-host/usb-host.dtsi +++ /dev/null @@ -1,51 +0,0 @@ - -/* - * USB-C host mode (ot2): the RT9470's OTG boost on hsi2c10, the MAX77779 - * charger's chgin-otg regulator on top of it (charger to standby, then the - * boost, as Google's ext-otg-only use case), the TCPC sourcing VBUS from - * it as a dual-role port that prefers sink, and the port's data role - * driving the dwc3 role switch. Source PDO from stock (fixed 5 V, 900 mA). - */ -&hsi2c10 { - otg_boost: regulator@5b { - compatible = "omamobile,tegu-rt9471-boost"; - reg = <0x5b>; - regulator-name = "otg-boost"; - }; -}; - -&hsi2c6 { - charger@69 { - compatible = "maxim,max77779-charger"; - reg = <0x69>; - otg-boost-supply = <&otg_boost>; - - chgin_otg: chgin-otg-regulator { - regulator-name = "chgin-otg"; - }; - }; -}; - -&usb_tcpc { - vbus-supply = <&chgin_otg>; - - connector { - power-role = "dual"; - try-power-role = "sink"; - source-pdos = ; - - port { - typec_hs: endpoint { - remote-endpoint = <&usb_hs>; - }; - }; - }; -}; - -&usb { - port { - usb_hs: endpoint { - remote-endpoint = <&typec_hs>; - }; - }; -}; From becf004c1b89e01edf775102122573b320730be0 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:13:09 -0647 Subject: [PATCH 3/9] device/tegu USB-HOST-PLAN: install the early read, publish the H4 and H5 scripts, the meter rule and rollbacks The maintainer's review of the runbook: H2 now copies and enables the early read (and H6 removes it), H1 checks the I2C device nodes and that the DTB dead-man is unarmed and disables it, the meter rule covers any reset with the drive attached, and H4 and H5 have rollback lines and a word on pstore. H5 says plainly that no SSH is guaranteed after the drive-for-laptop swap, what can bring the link back, and the forced restart that boots like H3. The scripts that run while the laptop is out are published next to the early read and started detached with systemd-run: H4's unbinds the charger 20 s after the drive enumerates and logs VBUS and CHG_CNFG_00; H5's resets without a shutdown, and only when the early read is armed and a drive has enumerated. The early read loads i2c-dev itself, since it runs before systemd-modules-load, and waits for the root to be read-write. The DTB paragraph records the gn3 build's sha256 and that it isn't #127 byte for byte; the node comparison against a #127 build is the open step. "settled on #125" is "being settled". --- device/tegu/USB-HOST-PLAN.md | 204 +++++++++++++----- device/tegu/usb-host/tegu-rt9470-early-read | 5 + .../usb-host/tegu-rt9470-early-read.service | 2 +- device/tegu/usb-host/tegu-usb-host-h4-unbind | 60 ++++++ device/tegu/usb-host/tegu-usb-host-h5-reset | 56 +++++ 5 files changed, 274 insertions(+), 53 deletions(-) mode change 100644 => 100755 device/tegu/usb-host/tegu-rt9470-early-read create mode 100755 device/tegu/usb-host/tegu-usb-host-h4-unbind create mode 100755 device/tegu/usb-host/tegu-usb-host-h5-reset diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index eca9cf933..938718544 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -22,13 +22,33 @@ for merge). The two boot helpers are in `device/tegu/usb-host/`. | eUSB2 repeater, PHY | #118, the integration tree | | Kernel the palmtop runs | `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty` (integration tree) | -The palmtop already boots a DTB with this setup (the "gn3" round), so the next -run boots no new DTB and needs no DTB dead-man. The `tegu-dtb-deadman` used -on 10-28 was a one-boot unit: if the gadget wasn't configured 180 s into an -armed boot, it wrote a known-good `vendor_kernel_boot` image (checked against -a stored sha256 first, and read back after) into `vendor_kernel_boot_b` from -the palmtop and rebooted. It is a second path writing slot B next to `bin/omamobile -push`. It stays unarmed, and it won't be used again unless that's agreed first. +The palmtop already boots a DTB with this setup: the "gn3" build of +`zumapro-tegu.dtb`, sha256 +`cde78d026e45da119fbcdcfb5eedb9900b636db5c027889a9e96fe66c2eac049` (the +`dtb_sha256` of its build record). gn3 is the ot6 round's USB-C device tree +plus the GNSS `gnss-type` change, so it isn't #127 byte for byte. The push +kit ships it with the kit's overlays applied (status flips and the GPU OPP +table), and that image's hash changes with the overlay set, so the base +build is the reference. For this run to count as #124's evidence, gn3's +`i2c@108d0000` (hsi2c6: the fuel gauge, `tcpc@25`, `charger@69` with its +`chgin-otg` regulator), `i2c@10ca0000` (hsi2c10, the boost at 0x5b) and +`usb@11210000` nodes are to be compared with a build of #127 at +`5dd15e31c`: build `zumapro-tegu.dtb` from that head, decompile both +(`dtc -I dtb -O dts`) and diff those three nodes. gn3's side is decompiled +and has all three; the #127 build hasn't been made yet, so the diff is +open. The next run boots no new DTB and needs no DTB dead-man. + +The `tegu-dtb-deadman` used on 10-28 was a one-boot unit: if the gadget +wasn't configured 180 s into an armed boot, it wrote a known-good +`vendor_kernel_boot` image (checked against a stored sha256 first, and read +back after) into `vendor_kernel_boot_b` from the palmtop and rebooted. It is +a second path writing slot B next to `bin/omamobile push`. It stays unarmed +(H1 checks that and disables the unit), and it won't be used again unless +that's agreed first. Whether it ever fired: the laptop's logs of the 10-28 +rounds show every armed boot's gadget coming up (the evening run started +with the gadget configured) and no write, but the unit's own log on the +palmtop, `/var/log/omamobile/dtb-deadman.log`, is the record. H1 reads it, +and its answer goes here. **The curated autostart** is the 9a's private bring-up startup (`/usr/local/lib/omamobile-tegu-curated//curated-native-start.py`, @@ -44,67 +64,147 @@ runbook changes none. Forced restart if the palmtop hangs, also in a shutdown under the swap timer: hold Power about 30 s until it is off, then press Power. Stop the run if slot B isn't marked successful: this runbook doesn't mark it (marking is a separate -`devinfo` operation under the rules settled on #125), and nothing here +`devinfo` operation under the rules being settled on #125), and nothing here writes a boot partition. -**H1. Precondition (read-only; risk none).** `tools/phone-ssh 'uname -r; -cat /proc/device-tree/__symbols__/otg_boost; for r in /sys/class/regulator/*; -do grep -H . $r/name; done | grep -E "otg-boost|chgin-otg"'`. -Expect: the release above, the `otg_boost` symbol, and both regulators. -Stop: either regulator missing (an older DTB). - -**H2. Modules for the run (risk low).** Blacklist the boost module, so its -node can't load it before the early read: `echo "blacklist tegu_rt9471_boost" -> /etc/modprobe.d/omamobile-tegu-otg-bringup.conf`. Install the boost module -from #127 (`597a2251…`) and the charger built from #124's head `4970bcdc3820` -(`e5a4c78e…`), both staged in `/var/lib/omamobile-tegu/usb-host/`, over +**The meter rule.** Any reset while the drive is attached is a crash with +host mode on: H5's `echo b`, H4's swap timer firing, or a forced restart +with the drive in. After each one, with the inline USB-C meter between the +palmtop and the drive, expect VBUS to fall to 0 within the reboot. **Stop if +VBUS is still up two minutes after the reset.** Don't plug the laptop in +(two sources on VBUS); unplug the drive and report it. + +**After any unexpected reset** (a forced restart, a crash loop; not the +timer's planned reboot), read pstore on the next boot before anything else. +Ramoops works on the 9a (round ps1): `/sys/fs/pstore/` holds +`dmesg-ramoops-*` for an oops and `console-ramoops-0` for the last console +lines, and systemd-pstore moves them to `/var/lib/systemd/pstore/` soon +after boot. Quote the lines in this plan. H5's reset leaves a console record +too; it is the evidence of what ran last. + +**The detached scripts.** The steps that run with the laptop out use the +scripts in `device/tegu/usb-host/`, installed in H2 and started detached +with `systemd-run --unit=…`, so the swap doesn't kill them. Each logs to +`/var/log/omamobile/` and reads with `i2cget` only; H4's one write is the +unbind, H5's the sysrq. Both wait for the laptop link to go and for a drive +to enumerate, and do nothing if either never happens. + +**H1. Precondition (read-only, plus one unit disabled; risk none).** +`tools/phone-ssh 'uname -r; cat /proc/device-tree/__symbols__/otg_boost; +for r in /sys/class/regulator/*; do grep -H . $r/name; done | grep -E +"otg-boost|chgin-otg"; ls /dev/i2c-*; systemctl is-enabled tegu-dtb-deadman; +ls /var/lib/omamobile-tegu/dtb-deadman/armed; tail -3 +/var/log/omamobile/dtb-deadman.log'`. +Expect: the release above, the `otg_boost` symbol, both regulators, the I2C +device nodes (`i2c-dev` is a module, loaded by then in a session; the early +read loads it itself, since it runs before `systemd-modules-load`), and the +DTB dead-man unarmed: its `armed` marker absent (that `ls` fails), and its +log's last armed boot ending in "gadget configured at Ns: keeping this +DTB", with no "wrote the good DTB image" line. Then `systemctl disable +tegu-dtb-deadman`, so arming it again takes a deliberate step; its files +stay on the palmtop for a DTB round under its own plan. Stop: either +regulator missing (an older DTB), or the marker present (remove it, and say +so here). + +**H2. Modules and helpers for the run (risk low).** Blacklist the boost +module, so its node can't load it before the early read: `echo "blacklist +tegu_rt9471_boost" > /etc/modprobe.d/omamobile-tegu-otg-bringup.conf`. +Install the boost module from #127 (`597a2251…`) and the charger built from +#124's head `4970bcdc3820` (`e5a4c78e…`), both staged in +`/var/lib/omamobile-tegu/usb-host/`, over `/usr/lib/modules/$(uname -r)/updates/otg/`, keeping the old files as `*.before-h2`, then `depmod -a`. These live under one release's `updates/`, so after every `push` of a new kernel they must be rebuilt and reinstalled. -Rollback: put the `*.before-h2` files back and run `depmod -a`. +Then the helpers, streamed from the laptop (`tools/phone-ssh 'cat > /usr/local/sbin/NAME' +< device/tegu/usb-host/NAME`): `tegu-rt9470-early-read`, +`tegu-usb-host-h4-unbind` and `tegu-usb-host-h5-reset` into +`/usr/local/sbin/` (`chmod 0755`), `tegu-rt9470-early-read.service` into +`/etc/systemd/system/`, then `systemctl daemon-reload; systemctl enable +tegu-rt9470-early-read`. Expect: `systemctl is-enabled tegu-rt9470-early-read` +says `enabled`, and the unit does nothing yet (its marker is absent until H5 +arms it). Rollback: put the `*.before-h2` files back, `depmod -a`, and H6's +removal of the helpers. **H3. Boot with the boost module held back (risk low).** Reboot, with kmsg streamed to the laptop. Expect: the gadget comes up as before (it ran before the TCPC node existed), the charger waits for `otg-boost-supply`, and the TCPC waits for the charger. Stop: no SSH 3 minutes after the reboot (forced -restart, then H2's rollback). Then load the boost module by hand (`modprobe -tegu_rt9471_boost`) with kmsg streamed. Expect: `otg-boost` and `chgin-otg` -registered and disabled, and the TCPC probes as a sink with the laptop -attached. +restart with the laptop attached, then H2's rollback). Then load the boost +module by hand (`modprobe tegu_rt9471_boost`) with kmsg streamed. Expect: +`otg-boost` and `chgin-otg` registered and disabled, and the TCPC probes as +a sink with the laptop attached. **H4. Unbind the charger with the drive attached (#124; risk medium).** Arm the swap timer first: `systemd-run --unit=x-deadman --on-active=300 -systemctl reboot`. Swap the laptop for the drive. Expect host mode as on -10-28 (the drive enumerates). Then, from a script started before the swap, -unbind `max77779-charger` 20 s after the drive enumerates and log kmsg, -VBUS (TCPC 0x70/0x71) and `CHG_CNFG_00` (0xbc). Expect a clean kmsg, VBUS -at 0 and `CHG_CNFG_00` reading 0x05. Laptop back in. Over a fresh login -(`tools/phone-ssh --fresh`), stop the timer: `systemctl stop x-deadman.timer`. -Stop: the laptop doesn't come back as a sink before the timer fires. +systemctl reboot`. Start the script detached: `systemd-run +--unit=tegu-usb-host-h4 /usr/local/sbin/tegu-usb-host-h4-unbind`. Swap the +laptop for the drive. Expect host mode as on 10-28 (the drive enumerates). +The script then unbinds the charger 20 s after the drive enumerates (through +the device's `driver/unbind`) and logs kmsg, VBUS as the TCPC measures it +(0x70/0x71) and `CHG_CNFG_00` (0xbc) at 1, 5 and 20 s, to +`/var/log/omamobile/usb-host-h4.log`. Expect a clean kmsg, VBUS at 0 and +`CHG_CNFG_00` reading 0x05. Laptop back in. Over a fresh login +(`tools/phone-ssh --fresh`), stop the timer: `systemctl stop +x-deadman.timer`, and read the log. Stop: the laptop doesn't come back as a +sink before the timer fires, or an oops in kmsg when the drive comes out or +the laptop goes in (TCPM disabling a regulator whose driver is gone); either +goes in this plan. Rollback: the timer's reboot (the meter rule applies if +the drive is still in; it boots like H3 with the laptop attached). Reboot +before H5 in any case: after the unbind TCPM holds a stale handle on +`chgin-otg`, and a rebind gives it nothing new, so H5's host mode needs H3's +boot again, with the `modprobe`. **H5. Reset without shutdown with host mode on (#124, #127; risk -medium-high).** Arm the early read for the next boot (`mkdir -p +medium-high).** From a fresh H3 boot (the boost module loaded by hand, the +laptop in as a sink). Arm the early read for the next boot (`mkdir -p /var/lib/omamobile-tegu/rt9470-early-read; touch -/var/lib/omamobile-tegu/rt9470-early-read/armed`; the script and unit are in -`device/tegu/usb-host/`). With the boost module blacklisted from H2, the read -runs before any RT9470 driver. Arm the swap timer, swap to the drive, and -from a script started before the swap, `echo b > /proc/sysrq-trigger` 20 s -after the drive enumerates. `systemctl reboot` would run the charger's -`.shutdown`, which turns the boost off, so it can't show what a crash leaves. -Then, with an inline USB-C meter between the palmtop and the drive: -- Expect: VBUS falls to 0 within the reboot. -- **Stop if VBUS is still up two minutes after the reset.** Don't plug the - laptop in (two sources on VBUS). Unplug the drive and report it. -- Otherwise put the laptop back in. The log `/var/log/omamobile/rt9470-early-read.log` - has the OTG bit (FUNCTION 0x02 bit 1) and ICSTAT before any driver, and - again at 60 s. If the boost had survived, a read at 60 s also shows - whether the regulator core's unused-regulator cleanup turned it off (only - if the module had loaded by then, which H2's blacklist prevents; a second - run without the blacklist would show it). - -**H6. Afterwards (risk low).** Remove `omamobile-tegu-otg-bringup.conf`, run -`depmod -a`, and reboot. The modules stay as installed in H2, unless H2's -rollback is wanted. +/var/lib/omamobile-tegu/rt9470-early-read/armed`; H2 installed and enabled +its script and unit). With the boost module blacklisted from H2, the read +runs before any RT9470 driver. Arm the swap timer, start the script detached +(`systemd-run --unit=tegu-usb-host-h5 /usr/local/sbin/tegu-usb-host-h5-reset`), +and swap to the drive. The script refuses to reset unless the early read is +armed and enabled and a drive has enumerated; 20 s after the drive +enumerates it logs the boost's state to `/var/log/omamobile/usb-host-h5.log`, +syncs, and runs `echo b > /proc/sysrq-trigger`. `systemctl reboot` would run +the charger's `.shutdown`, which turns the boost off, so it can't show what +a crash leaves. Then, with the inline USB-C meter between the palmtop and +the drive: +- Expect: VBUS falls to 0 within the reboot (the meter rule: stop if it is + still up two minutes after the reset). +- The boot comes up with the drive attached and no laptop. The initramfs + hands over to Arch without waiting for USB (its no-gadget crash is killed + with the other helpers at the switch), and neither the root guard nor the + curated start checks the gadget, so the early read runs (early, and at + 60 s), writes its log and removes its marker. The charger and the TCPC + wait for the blacklisted boost module, so no Type-C driver owns the + MAX77779 in this boot. +- Swap the drive for the laptop. Expect: no SSH is guaranteed after the + swap. The chip opens its USB data switch when the drive comes out (AGENTS, + "USB"), and no Type-C driver closes it. The one thing that can is + `omamobile-tegu-usb-rescue` (started every boot by the audio-up script), + which rewrites `USBSW_CTRL` to 0x09 once VBUS is present and the gadget + has been unconfigured for 4 s, so the link may come back by itself. Give + it two minutes over a fresh login (`tools/phone-ssh --fresh`). If there is + no SSH by then: forced restart with the laptop attached (Power about 30 s, + then Power), which boots like H3. The early-read log is on disk by then, + so nothing is lost. +- Then read `/var/log/omamobile/rt9470-early-read.log`: the OTG bit + (FUNCTION 0x02 bit 1) and ICSTAT before any driver, and again at 60 s. If + the boost had survived, a read at 60 s also shows whether the regulator + core's unused-regulator cleanup turned it off (only if the module had + loaded by then, which H2's blacklist prevents; a second run without the + blacklist would show it). Quote both reads, H5's log and the console + record from pstore here. +Rollback: the forced restart with the laptop attached, then H6. + +**H6. Afterwards (risk low).** Remove `omamobile-tegu-otg-bringup.conf` and +run `depmod -a`. Take the helpers out: `systemctl disable +tegu-rt9470-early-read`, then remove +`/etc/systemd/system/tegu-rt9470-early-read.service`, the three scripts from +`/usr/local/sbin/` and `/var/lib/omamobile-tegu/rt9470-early-read/` (its +marker is already gone), and `systemctl daemon-reload`. Keep the logs under +`/var/log/omamobile/` and quote them here. Then reboot. The modules stay as +installed in H2, unless H2's rollback is wanted. ## Not known yet diff --git a/device/tegu/usb-host/tegu-rt9470-early-read b/device/tegu/usb-host/tegu-rt9470-early-read old mode 100644 new mode 100755 index 5936cc53e..cec73258d --- a/device/tegu/usb-host/tegu-rt9470-early-read +++ b/device/tegu/usb-host/tegu-rt9470-early-read @@ -18,6 +18,11 @@ for _ in $(seq 1 300); do sleep 0.1 done [[ -n $bus ]] || { log "no hsi2c10 bus"; exit 1; } +# i2c-dev is a module, and this runs before systemd-modules-load: load it +# here (it is not an RT9470 driver), then wait for the bus's device node. +modprobe i2c-dev 2>/dev/null +for _ in $(seq 1 100); do [[ -e /dev/i2c-$bus ]] && break; sleep 0.1; done +[[ -e /dev/i2c-$bus ]] || { log "no /dev/i2c-$bus"; exit 1; } read_all() { local r out= for r in 0x01 0x02 0x0c 0x0f 0x10 0x11 0x12 0x13; do diff --git a/device/tegu/usb-host/tegu-rt9470-early-read.service b/device/tegu/usb-host/tegu-rt9470-early-read.service index 9aaf8a26a..2850d5b47 100644 --- a/device/tegu/usb-host/tegu-rt9470-early-read.service +++ b/device/tegu/usb-host/tegu-rt9470-early-read.service @@ -3,7 +3,7 @@ Description=Pixel 9a: read the RT9470's boost state before its driver loads (one boot) ConditionPathExists=/var/lib/omamobile-tegu/rt9470-early-read/armed DefaultDependencies=no -After=systemd-udevd.service +After=systemd-udevd.service systemd-remount-fs.service Before=systemd-modules-load.service [Service] diff --git a/device/tegu/usb-host/tegu-usb-host-h4-unbind b/device/tegu/usb-host/tegu-usb-host-h4-unbind new file mode 100755 index 000000000..4e487c441 --- /dev/null +++ b/device/tegu/usb-host/tegu-usb-host-h4-unbind @@ -0,0 +1,60 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# tegu-usb-host-h4-unbind: USB-HOST-PLAN step H4, the published form of the +# script that runs while the laptop is out. Start it detached before the +# swap (systemd-run --unit=tegu-usb-host-h4 /usr/local/sbin/tegu-usb-host-h4-unbind). +# It waits for the laptop link to go and for a USB drive to enumerate in host +# mode, then 20 s later unbinds the MAX77779 charger (the chgin-otg provider) +# and logs what that leaves: kmsg, VBUS as the TCPC measures it (0x70/0x71) +# and CHG_CNFG_00 (0xbc) at 1, 5 and 20 s. Reads are i2cget only; the one +# write is the unbind. The swap timer the runbook arms (x-deadman) is the +# way back if the laptop link doesn't return. +set -u +L=/var/log/omamobile/usb-host-h4.log; mkdir -p /var/log/omamobile +log() { echo "$(date -Is) $*" >> "$L"; } +bus_of() { local d; for d in /sys/bus/i2c/devices/i2c-*; do readlink -f "$d" | grep -c "$1" >/dev/null && { echo "${d##*-}"; return; }; done; } +CB=$(bus_of 108d0000.i2c) # hsi2c6: the TCPC at 0x25, the charger at 0x69 +RB=$(bus_of 10ca0000.i2c) # hsi2c10: the RT9470 at 0x5b +[[ -n $CB && -n $RB ]] || { log "no hsi2c6 or hsi2c10 bus: nothing done"; exit 1; } +dev=$CB-0069 +vbus_mv() { # TCPCI VBUS_VOLTAGE: bits 9:0 in 25 mV steps, bits 11:10 the scale + local lo hi + lo=$(i2cget -f -y "$CB" 0x25 0x70 2>/dev/null) && hi=$(i2cget -f -y "$CB" 0x25 0x71 2>/dev/null) || { echo "?"; return; } + echo "$(( (((hi & 0x03) << 8 | lo) * 25) << ((hi >> 2) & 0x03) )) (0x71/0x70 $hi/$lo)" +} +snap() { + log "$1 vbus_mV=$(vbus_mv) chg_cnfg_00=$(i2cget -f -y "$CB" 0x69 0xbc 2>/dev/null || echo ?) rt function=$(i2cget -f -y "$RB" 0x5b 0x02 2>/dev/null || echo ?) icstat=$(i2cget -f -y "$RB" 0x5b 0x0f 2>/dev/null || echo ?)" + log "$1 typec: pr=$(cat /sys/class/typec/port0/power_role 2>/dev/null) dr=$(cat /sys/class/typec/port0/data_role 2>/dev/null) role=$(cat /sys/class/usb_role/*/role 2>/dev/null) udc=$(cat /sys/class/udc/*/state 2>/dev/null) regulators: $(for r in /sys/class/regulator/regulator.*; do n=$(cat "$r/name"); case $n in otg-boost|chgin-otg) printf '%s=%s ' "$n" "$(cat "$r/state")";; esac; done)charger=$(basename "$(readlink -f "/sys/bus/i2c/devices/$dev/driver")" 2>/dev/null)" + log "$1 usb: $(cat /sys/bus/usb/devices/*/product 2>/dev/null | tr '\n' '|') disks: $(lsblk -dno NAME,SIZE,TRAN 2>/dev/null | grep usb | tr '\n' '|')" +} +log "start"; snap pre +[[ -e /sys/bus/i2c/devices/$dev/driver ]] || { log "no driver bound at $dev: nothing to unbind"; exit 1; } +# the laptop goes out +for _ in $(seq 1 600); do [[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] && break; sleep 1; done +[[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] || { log "laptop never left in 10 min: nothing done"; exit 0; } +log "laptop link gone" +# the drive enumerates in host mode +drive= +for _ in $(seq 1 180); do + drive=$(lsblk -dno NAME,TRAN 2>/dev/null | awk '$2 == "usb" { print $1; exit }') + [[ -n $drive ]] && break + sleep 1 +done +[[ -n $drive ]] || { snap no-drive; log "no USB drive in 3 min: nothing unbound"; exit 1; } +log "drive $drive enumerated"; snap attached +sleep 20; snap t+20 +if echo "$dev" > "/sys/bus/i2c/devices/$dev/driver/unbind"; then + log "unbound the charger at $dev" +else + log "unbind of $dev failed"; exit 1 +fi +sleep 1; snap unbound+1s +sleep 4; snap unbound+5s +sleep 15; snap unbound+20s +dmesg | grep -iE "max77779|regulator|otg|tcpm|tcpci|vbus|usb [0-9]|sd[a-z]|oops|bug|call trace" | tail -40 >> "$L" +cat /sys/kernel/debug/usb/tcpm-*/log 2>/dev/null | tail -40 >> "$L" +# the laptop goes back in; the swap timer reboots if it doesn't +for _ in $(seq 1 600); do [[ $(cat /sys/class/udc/*/state 2>/dev/null) == configured ]] && break; sleep 1; done +snap laptop-back +dmesg | grep -iE "max77779|regulator|otg|tcpm|vbus|oops|bug|call trace" | tail -20 >> "$L" +log "done" diff --git a/device/tegu/usb-host/tegu-usb-host-h5-reset b/device/tegu/usb-host/tegu-usb-host-h5-reset new file mode 100755 index 000000000..a96492772 --- /dev/null +++ b/device/tegu/usb-host/tegu-usb-host-h5-reset @@ -0,0 +1,56 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# tegu-usb-host-h5-reset: USB-HOST-PLAN step H5, the published form of the +# script that runs while the laptop is out. Start it detached before the +# swap (systemd-run --unit=tegu-usb-host-h5 /usr/local/sbin/tegu-usb-host-h5-reset). +# It waits for the laptop link to go and for a USB drive to enumerate in host +# mode, logs the boost's state 20 s later, syncs, and resets the palmtop +# without a shutdown (echo b > /proc/sysrq-trigger), so that the next boot's +# tegu-rt9470-early-read shows what a reset leaves with host mode on. It +# refuses to reset unless that read is armed and its unit enabled, and +# unless a drive has enumerated: without them the reset would show nothing. +# Reads are i2cget only; the one write is the sysrq. +set -u +L=/var/log/omamobile/usb-host-h5.log; mkdir -p /var/log/omamobile +A=/var/lib/omamobile-tegu/rt9470-early-read/armed +log() { echo "$(date -Is) $*" >> "$L"; } +bus_of() { local d; for d in /sys/bus/i2c/devices/i2c-*; do readlink -f "$d" | grep -c "$1" >/dev/null && { echo "${d##*-}"; return; }; done; } +CB=$(bus_of 108d0000.i2c) # hsi2c6: the TCPC at 0x25, the charger at 0x69 +RB=$(bus_of 10ca0000.i2c) # hsi2c10: the RT9470 at 0x5b +[[ -n $CB && -n $RB ]] || { log "no hsi2c6 or hsi2c10 bus: nothing done"; exit 1; } +vbus_mv() { # TCPCI VBUS_VOLTAGE: bits 9:0 in 25 mV steps, bits 11:10 the scale + local lo hi + lo=$(i2cget -f -y "$CB" 0x25 0x70 2>/dev/null) && hi=$(i2cget -f -y "$CB" 0x25 0x71 2>/dev/null) || { echo "?"; return; } + echo "$(( (((hi & 0x03) << 8 | lo) * 25) << ((hi >> 2) & 0x03) )) (0x71/0x70 $hi/$lo)" +} +snap() { + log "$1 vbus_mV=$(vbus_mv) chg_cnfg_00=$(i2cget -f -y "$CB" 0x69 0xbc 2>/dev/null || echo ?) rt function=$(i2cget -f -y "$RB" 0x5b 0x02 2>/dev/null || echo ?) icstat=$(i2cget -f -y "$RB" 0x5b 0x0f 2>/dev/null || echo ?) stat0-3=$(for r in 0x10 0x11 0x12 0x13; do i2cget -f -y "$RB" 0x5b $r 2>/dev/null || echo ?; done | tr '\n' '/')" + log "$1 typec: pr=$(cat /sys/class/typec/port0/power_role 2>/dev/null) dr=$(cat /sys/class/typec/port0/data_role 2>/dev/null) role=$(cat /sys/class/usb_role/*/role 2>/dev/null) udc=$(cat /sys/class/udc/*/state 2>/dev/null) regulators: $(for r in /sys/class/regulator/regulator.*; do n=$(cat "$r/name"); case $n in otg-boost|chgin-otg) printf '%s=%s ' "$n" "$(cat "$r/state")";; esac; done)" + log "$1 usb: $(cat /sys/bus/usb/devices/*/product 2>/dev/null | tr '\n' '|') disks: $(lsblk -dno NAME,SIZE,TRAN 2>/dev/null | grep usb | tr '\n' '|')" +} +log "start" +if [[ ! -e $A || $(systemctl is-enabled tegu-rt9470-early-read 2>/dev/null) != enabled ]]; then + log "early read not armed and enabled ($A, $(systemctl is-enabled tegu-rt9470-early-read 2>&1)): no reset"; exit 1 +fi +snap pre +# the laptop goes out +for _ in $(seq 1 600); do [[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] && break; sleep 1; done +[[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] || { log "laptop never left in 10 min: no reset"; exit 0; } +log "laptop link gone" +# the drive enumerates in host mode +drive= +for _ in $(seq 1 180); do + drive=$(lsblk -dno NAME,TRAN 2>/dev/null | awk '$2 == "usb" { print $1; exit }') + [[ -n $drive ]] && break + sleep 1 +done +[[ -n $drive ]] || { snap no-drive; log "no USB drive in 3 min: no reset"; exit 1; } +log "drive $drive enumerated"; snap attached +sleep 20; snap t+20 +dmesg | grep -iE "max77779|rt9471|regulator|otg|tcpm|vbus|usb [0-9]|sd[a-z]" | tail -30 >> "$L" +log "resetting now: echo b > /proc/sysrq-trigger (the early read is armed for the next boot)" +sync; sleep 1 +echo b > /proc/sysrq-trigger +sleep 10 +log "still running 10 s after the sysrq: the reset did not happen" +exit 1 From c908bbf01503f2a7426f194af9555c575df696e8 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:47:27 -0647 Subject: [PATCH 4/9] device/tegu USB-HOST-PLAN: the DTB comparison, the peripheral role on warm reboots, stock's PDO and the RT9470's lines The open step from the review is done: #127's DTB matches the palmtop's running tree on the three nodes. Four warm reboots today came up as peripheral on the otg node. Stock's source PDO and the RT9470's interrupt and enable lines are traced to Google's tegu and zuma trees. --- device/tegu/USB-HOST-PLAN.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index 938718544..e69c8fb6d 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -59,6 +59,24 @@ udev from their DT nodes. Re-pinning (recomputing the manifest's sha256 values after a deliberate change) only matters when a pinned module changes. This runbook changes none. +**The three nodes against #127 (2026-10-29).** #127 at `5dd15e31c` built on +maclab (`dtbs` only, the palmtop's config) and compared with the palmtop's +running tree (`/sys/firmware/fdt`), both decompiled with `dtc`: the +`i2c@108d0000` (gauge, TCPC with `try-power-role = "sink"`, charger with +`chgin-otg`), `usi@10ca00c0`/`i2c@10ca0000` (hsi2c10, the boost at 0x5b) +and `usb@11210000` nodes have the same properties and values; only phandle +numbers, the clock-controller phandle inside `clocks` and the order of +sub-nodes differ. So the run counts as #127's for those nodes. + +**The peripheral role on warm reboots (2026-10-29).** The running +`usb@11210000` has `dr_mode = "otg"` with `usb-role-switch` and +`role-switch-default-mode`, and in four warm reboots today (09:15, 09:19, +09:55 and 10:19 local, `reboot-to omamobile` with the laptop attached) the +gadget came up as peripheral every time (`/sys/class/udc/11210000.usb/state` +`configured`, `tools/phone-smoke` "USB gadget ok, bound to 11210000.usb"). +Cold boot and a replug with no host attached are still to be shown (#127's +point 7); they need a hand on the cable. + ## Runbook (attended, on the charger, W4HO at the palmtop) Forced restart if the palmtop hangs, also in a shutdown under the swap timer: @@ -212,9 +230,18 @@ installed in H2, unless H2's rollback is wanted. - Why JEITA tripped. "Read hot" is an inference: the TS pin may have no thermistor on it. - Whether the RT9470 charges under our kernel. Its CE comes from the - MAX77779's sGPIO 7, which hasn't been read. On the charger with the + MAX77779's sGPIO 7 (stock's `rt,ceb_gpio`). On the charger with the battery full, FUNCTION read 0x41 (`CHG_EN` set) and ICSTAT 0xf1 (VBUS ready, not charging). Since #127 turns JEITA off only while the boost is on, this matters only in host mode. -- Where stock's source PDO (5 V, 900 mA in the run) comes from. It isn't - traced to a stock file yet. +- ~~Where stock's source PDO (5 V, 900 mA in the run) comes from.~~ Traced + (10-29): Google's zuma `dts/max777x9-tcpc.dtsi`, included by tegu's + `zuma-tegu-typec.dtsi`, sets `PDO_FIXED(5000, 900, SUSPEND | USB_COMM | + DATA_SWAP | DUAL_ROLE)` ("Extboost can only do ~1A"). The run advertised + USB_COMM and DATA_SWAP only; the mergeable board takes stock's set. +- The RT9470's lines in stock's DT (10-29, `zumapro-buck-charge-rt9471.dtsi` + and `zuma-tegu-charging.dtsi` in Google's tegu tree): interrupt on the + MAX77779's sGPIO 6 (`PLC_INT_L`), chip enable on sGPIO 7, and stock's + driver services the 40 s watchdog from that interrupt. Our kernel has no + MAX77779 sGPIO driver yet, which is why the bring-up node has no + interrupt and the boost runs with the watchdog off. From 2e47c1531aa0242162c39721f97ccdac388dd843 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 11:57:19 -0647 Subject: [PATCH 5/9] device/tegu USB-HOST-PLAN: H2b, the PMIC block and the boost's lines The RT9470's interrupt and enable are MAX77779 SGPIOs, and stock services the boost's watchdog from that interrupt. The block's driver (kernel #139), the board node and the reworked boost (#127) get one attended boot before H3, with Expect, Stop and Rollback, and the PMIC's register readout from today as the before. --- device/tegu/USB-HOST-PLAN.md | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index e69c8fb6d..68f89a735 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -143,6 +143,47 @@ says `enabled`, and the unit does nothing yet (its marker is absent until H5 arms it). Rollback: put the `*.before-h2` files back, `depmod -a`, and H6's removal of the helpers. +**H2b. The PMIC block and the boost's lines (risk low; attended, on the +charger).** New since the 10-29 review: the RT9470's interrupt and chip +enable are the MAX77779's SGPIO6 and SGPIO7, and stock services the boost's +40 s watchdog from that interrupt. #127 now carries the PMIC block on the +board (`5ada9ab0f`, with its gpa8-0 line pinned as stock's `if_pmic_irq`) +and the boost reworked to keep the watchdog and kick it from the interrupt +(`6c5d97e18`); the block's driver is linux-omarchy-mobile#139 (`a6e10f2ba`). +One boot before H3, with the boost module still blacklisted from H2: + +1. Stage the modules built against the running kernel from + `logs/tegu-review-20261029/max77779/` (`gpio-max77779.ko` and the new + `tegu-rt9471-boost.ko`, W=1 clean) over `updates/gpio/` and + `updates/otg/`, keeping the old boost module as `*.before-h2b`, then + `depmod -a`. +2. Push the DTB built from #127 at `5ada9ab0f` (sha256 `c8b3ea8b…`, the + same build that answered the node comparison above plus the PMIC node), + the way the 10-28 ot7 DTB went on: the kit's `omamobile images` with + that DTB as the base and `omamobile push`. Slot B stays marked; the push + writes only the `_b` images. +3. Reboot with kmsg streamed. Expect: `max77779-pmic 24-0066: MAX77779 PMIC + revision 0x02` with no "no interrupt line" message, the line in + `/proc/interrupts` (`24-0066` on gpa8-0) at a count that stays put, the + gadget as before, smoke 19 of 19. Then `modprobe tegu_rt9471_boost` by + hand with kmsg streamed. Expect: `JEITA off, watchdog on (0x1)` as stock + leaves it, `watchdog serviced from interrupt N`, and the regmap readout + of the PMIC (`/sys/kernel/debug/regmap/24-0066/registers`) with SGPIO6 + now an input with `PU` set and `PD` clear and its DATA high, SGPIO7 an + output driving low (CEB asserted). Stop: an interrupt count on gpa8-0 + or on the SGPIO line that climbs by more than 100 a second (a pull + wrong; `rmmod tegu_rt9471_boost` and read the PMIC's `e9`/`ea`), the + boost probing without the interrupt, or no SSH 3 minutes after the + reboot (forced restart with the laptop attached). Rollback: the previous + DTB pushed back and the `*.before-h2b` module restored, `depmod -a`. + +Read-only before the step, for the record: the PMIC's registers as the +driver found them on 10-29 without the node (ID 0x79, revision 0x02, OTP +0x21; `INTB_MASK` 0xff; `SGPIO_PU` 0x00, `SGPIO_PD` 0x5e; CNFG0-7 `00 04 +05 04 05 00 04 00`: SGPIO6 an input with the OTP pull-down, SGPIO7 off, so +nothing drives the boost's enable in the current bring-up and the chip runs +on its own default). + **H3. Boot with the boost module held back (risk low).** Reboot, with kmsg streamed to the laptop. Expect: the gadget comes up as before (it ran before the TCPC node existed), the charger waits for `otg-boost-supply`, and the From 0daf676641c9d34685c07d0f5cfbc458bff0773c Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 12:24:32 -0647 Subject: [PATCH 6/9] device/tegu USB-HOST-PLAN: the H5 script disarms the early read when it doesn't reset, the #127 pin, H4's rollback with the drive in The maintainer's second round. The DTB paragraph no longer calls the node comparison open, since the paragraph below records it, and the status line says #127 is at 5ada9ab0f now, with what the commits after the compared 5dd15e31c changed. The H5 script removes the early read's armed marker on every exit without a reset, so a fallback reboot can't leave a log that looks like H5's; H5 says the read counts only when the script's log ends with the "resetting now" line, and gives the swap timer's command in full. H4's rollback with the drive still in points at H5's swap text, since a boot like H3's needs the laptop back in first. --- device/tegu/USB-HOST-PLAN.md | 55 +++++++++++++-------- device/tegu/usb-host/tegu-usb-host-h5-reset | 16 ++++-- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index 68f89a735..65227e2d6 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -7,8 +7,11 @@ runbook for the next one, which adds two measurements for derekross/linux-omarchy-mobile#124: unbinding the charger with a drive attached, and a reset without shutdown with host mode on. The device tree and the RT9470 module are on the kernel bring-up branch -derekross/linux-omarchy-mobile#127 (`tegu-usb-host-bringup` at `5dd15e31c`, not -for merge). The two boot helpers are in `device/tegu/usb-host/`. +derekross/linux-omarchy-mobile#127 (`tegu-usb-host-bringup`, now at +`5ada9ab0f`, not for merge: after the `5dd15e31c` the DTB comparison below +used, `0caff021a` only changed a comment, `6c5d97e18` reworks the boost +driver and `5ada9ab0f` adds the PMIC node and the boost's lines; H2b boots +that build). The boot helpers are in `device/tegu/usb-host/`. ## What it builds on @@ -32,11 +35,10 @@ table), and that image's hash changes with the overlay set, so the base build is the reference. For this run to count as #124's evidence, gn3's `i2c@108d0000` (hsi2c6: the fuel gauge, `tcpc@25`, `charger@69` with its `chgin-otg` regulator), `i2c@10ca0000` (hsi2c10, the boost at 0x5b) and -`usb@11210000` nodes are to be compared with a build of #127 at -`5dd15e31c`: build `zumapro-tegu.dtb` from that head, decompile both -(`dtc -I dtb -O dts`) and diff those three nodes. gn3's side is decompiled -and has all three; the #127 build hasn't been made yet, so the diff is -open. The next run boots no new DTB and needs no DTB dead-man. +`usb@11210000` nodes were compared with a build of #127 at `5dd15e31c` +(both decompiled with `dtc -I dtb -O dts`; the result is below, "The three +nodes against #127"). The next run boots no new DTB until H2b, and needs +no DTB dead-man. The `tegu-dtb-deadman` used on 10-28 was a one-boot unit: if the gadget wasn't configured 180 s into an armed boot, it wrote a known-good @@ -104,8 +106,9 @@ too; it is the evidence of what ran last. scripts in `device/tegu/usb-host/`, installed in H2 and started detached with `systemd-run --unit=…`, so the swap doesn't kill them. Each logs to `/var/log/omamobile/` and reads with `i2cget` only; H4's one write is the -unbind, H5's the sysrq. Both wait for the laptop link to go and for a drive -to enumerate, and do nothing if either never happens. +unbind, H5's the sysrq (and the removal of the early read's marker when it +doesn't reset). Both wait for the laptop link to go and for a drive to +enumerate, and do nothing if either never happens. **H1. Precondition (read-only, plus one unit disabled; risk none).** `tools/phone-ssh 'uname -r; cat /proc/device-tree/__symbols__/otg_boost; @@ -207,9 +210,12 @@ the device's `driver/unbind`) and logs kmsg, VBUS as the TCPC measures it x-deadman.timer`, and read the log. Stop: the laptop doesn't come back as a sink before the timer fires, or an oops in kmsg when the drive comes out or the laptop goes in (TCPM disabling a regulator whose driver is gone); either -goes in this plan. Rollback: the timer's reboot (the meter rule applies if -the drive is still in; it boots like H3 with the laptop attached). Reboot -before H5 in any case: after the unbind TCPM holds a stale handle on +goes in this plan. Rollback: the timer's reboot. If the laptop went back in +first, that boot is H3's. If the drive is still in, the meter rule applies +and the boot is in H5's position (the boost module blacklisted, no Type-C +driver on the MAX77779), so follow H5's swap text: wait for the rescue +unit, then the forced restart with the laptop attached. Reboot before H5 in +any case: after the unbind TCPM holds a stale handle on `chgin-otg`, and a rebind gives it nothing new, so H5's host mode needs H3's boot again, with the `modprobe`. @@ -219,15 +225,22 @@ laptop in as a sink). Arm the early read for the next boot (`mkdir -p /var/lib/omamobile-tegu/rt9470-early-read; touch /var/lib/omamobile-tegu/rt9470-early-read/armed`; H2 installed and enabled its script and unit). With the boost module blacklisted from H2, the read -runs before any RT9470 driver. Arm the swap timer, start the script detached -(`systemd-run --unit=tegu-usb-host-h5 /usr/local/sbin/tegu-usb-host-h5-reset`), -and swap to the drive. The script refuses to reset unless the early read is -armed and enabled and a drive has enumerated; 20 s after the drive -enumerates it logs the boost's state to `/var/log/omamobile/usb-host-h5.log`, -syncs, and runs `echo b > /proc/sysrq-trigger`. `systemctl reboot` would run -the charger's `.shutdown`, which turns the boost off, so it can't show what -a crash leaves. Then, with the inline USB-C meter between the palmtop and -the drive: +runs before any RT9470 driver. Arm the swap timer (`systemd-run +--unit=x-deadman --on-active=300 systemctl reboot`), start the script +detached (`systemd-run --unit=tegu-usb-host-h5 +/usr/local/sbin/tegu-usb-host-h5-reset`), and swap to the drive. The script +refuses to reset unless the early read is armed and enabled and a drive has +enumerated; 20 s after the drive enumerates it logs the boost's state to +`/var/log/omamobile/usb-host-h5.log`, syncs, and runs `echo b > +/proc/sysrq-trigger`. On every exit without a reset (no drive in 3 minutes, +the laptop never leaving, the sysrq not taking) it removes the `armed` +marker, so a fallback reboot (the swap timer firing first, a `systemctl +reboot` with the charger's `.shutdown`) doesn't produce an early-read log +under the same name. **The early read counts only when `usb-host-h5.log` +ends with the "resetting now" line.** `systemctl reboot` would run the +charger's `.shutdown`, which turns the boost off, so it can't show what a +crash leaves. Then, with the inline USB-C meter between the palmtop and the +drive: - Expect: VBUS falls to 0 within the reboot (the meter rule: stop if it is still up two minutes after the reset). - The boot comes up with the drive attached and no laptop. The initramfs diff --git a/device/tegu/usb-host/tegu-usb-host-h5-reset b/device/tegu/usb-host/tegu-usb-host-h5-reset index a96492772..ba9e6dc53 100755 --- a/device/tegu/usb-host/tegu-usb-host-h5-reset +++ b/device/tegu/usb-host/tegu-usb-host-h5-reset @@ -9,15 +9,20 @@ # tegu-rt9470-early-read shows what a reset leaves with host mode on. It # refuses to reset unless that read is armed and its unit enabled, and # unless a drive has enumerated: without them the reset would show nothing. -# Reads are i2cget only; the one write is the sysrq. +# On every exit without a reset it removes the armed marker, so a fallback +# reboot (the swap timer, a systemctl reboot) doesn't produce an early-read +# log that looks like this step's. The early read counts only when this +# script's log ends with the "resetting now" line. +# Reads are i2cget only; the writes are the marker's removal and the sysrq. set -u L=/var/log/omamobile/usb-host-h5.log; mkdir -p /var/log/omamobile A=/var/lib/omamobile-tegu/rt9470-early-read/armed log() { echo "$(date -Is) $*" >> "$L"; } +disarm() { rm -f "$A"; sync; log "no reset: early read disarmed ($A removed)"; } bus_of() { local d; for d in /sys/bus/i2c/devices/i2c-*; do readlink -f "$d" | grep -c "$1" >/dev/null && { echo "${d##*-}"; return; }; done; } CB=$(bus_of 108d0000.i2c) # hsi2c6: the TCPC at 0x25, the charger at 0x69 RB=$(bus_of 10ca0000.i2c) # hsi2c10: the RT9470 at 0x5b -[[ -n $CB && -n $RB ]] || { log "no hsi2c6 or hsi2c10 bus: nothing done"; exit 1; } +[[ -n $CB && -n $RB ]] || { log "no hsi2c6 or hsi2c10 bus: nothing done"; disarm; exit 1; } vbus_mv() { # TCPCI VBUS_VOLTAGE: bits 9:0 in 25 mV steps, bits 11:10 the scale local lo hi lo=$(i2cget -f -y "$CB" 0x25 0x70 2>/dev/null) && hi=$(i2cget -f -y "$CB" 0x25 0x71 2>/dev/null) || { echo "?"; return; } @@ -30,12 +35,12 @@ snap() { } log "start" if [[ ! -e $A || $(systemctl is-enabled tegu-rt9470-early-read 2>/dev/null) != enabled ]]; then - log "early read not armed and enabled ($A, $(systemctl is-enabled tegu-rt9470-early-read 2>&1)): no reset"; exit 1 + log "early read not armed and enabled ($A, $(systemctl is-enabled tegu-rt9470-early-read 2>&1)): no reset"; disarm; exit 1 fi snap pre # the laptop goes out for _ in $(seq 1 600); do [[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] && break; sleep 1; done -[[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] || { log "laptop never left in 10 min: no reset"; exit 0; } +[[ $(cat /sys/class/udc/*/state 2>/dev/null) != configured ]] || { log "laptop never left in 10 min: no reset"; disarm; exit 0; } log "laptop link gone" # the drive enumerates in host mode drive= @@ -44,7 +49,7 @@ for _ in $(seq 1 180); do [[ -n $drive ]] && break sleep 1 done -[[ -n $drive ]] || { snap no-drive; log "no USB drive in 3 min: no reset"; exit 1; } +[[ -n $drive ]] || { snap no-drive; log "no USB drive in 3 min: no reset"; disarm; exit 1; } log "drive $drive enumerated"; snap attached sleep 20; snap t+20 dmesg | grep -iE "max77779|rt9471|regulator|otg|tcpm|vbus|usb [0-9]|sd[a-z]" | tail -30 >> "$L" @@ -53,4 +58,5 @@ sync; sleep 1 echo b > /proc/sysrq-trigger sleep 10 log "still running 10 s after the sysrq: the reset did not happen" +disarm exit 1 From 4eb33feddaef135a50e3010312ea5f6573cf6c10 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:22:18 -0647 Subject: [PATCH 7/9] device/tegu USB-HOST-PLAN: H1 and H2 ran The read-only precondition and the installs need no hands, so they ran over SSH: the dead-man never fired on 10-28 (its log), it is disabled now, and the charger, the reworked boost, the PMIC driver and the helpers are in place for H2b and H3. --- device/tegu/USB-HOST-PLAN.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index 65227e2d6..0cdabd387 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -127,6 +127,25 @@ stay on the palmtop for a DTB round under its own plan. Stop: either regulator missing (an older DTB), or the marker present (remove it, and say so here). +**H1 ran (2026-10-29 14:30 local, over SSH, no hands).** Release +`7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, the `otg_boost` +symbol at `/soc/usi@10ca00c0/i2c@10ca0000/regulator@5b`, both regulators +(`otg-boost`, `chgin-otg`), `/dev/i2c-19` to `-21`. The DTB dead-man: unit +`masked-runtime`, marker absent, and its log's last armed boot (10-28 +13:48) ends "gadget configured at 1s: keeping this DTB", no "wrote the good +DTB image" line: it never fired on 10-28. Disabled now (`systemctl disable +tegu-dtb-deadman`; the files stay). + +**H2 ran (the same session).** `omamobile-tegu-otg-bringup.conf` blacklists +the boost module; `updates/otg/` holds the #124 charger (`e5a4c78e`) and, +instead of the plan's `597a2251` boost, the reworked boost of #127 at +`6c5d97e18` (the watchdog kept and serviced; without the PMIC lines in the +running DTB it falls back to its kernel timer), the old files kept as +`*.before-h2`; `updates/gpio/` holds #139's `gpio-max77779.ko` for H2b; +`depmod -a` run; the three helpers and the unit installed and the unit +enabled, its marker absent. The modules are per release: after the next +kernel push they are reinstalled. + **H2. Modules and helpers for the run (risk low).** Blacklist the boost module, so its node can't load it before the early read: `echo "blacklist tegu_rt9471_boost" > /etc/modprobe.d/omamobile-tegu-otg-bringup.conf`. From 2198e47a3ef45c49781d57bbfe07d8bbf091acbc Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:28:12 -0647 Subject: [PATCH 8/9] device/tegu: the H2b overlay, and H2b as an overlay round The #127 DTB can't take the kit's other overlays (a dry pack failed on the first of them), so H2b's delta, the MAX77779 PMIC node with its pin and the boost's two lines, goes on gn3 as a bring-up overlay, where bring-up overlays live. A dry pack applied it and the overlaid tree has all three pieces. --- device/tegu/USB-HOST-PLAN.md | 13 +++++--- device/tegu/overlays/usb-host-pmic.dtso | 44 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 device/tegu/overlays/usb-host-pmic.dtso diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index 0cdabd387..74bfa85f0 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -179,11 +179,14 @@ One boot before H3, with the boost module still blacklisted from H2: `tegu-rt9471-boost.ko`, W=1 clean) over `updates/gpio/` and `updates/otg/`, keeping the old boost module as `*.before-h2b`, then `depmod -a`. -2. Push the DTB built from #127 at `5ada9ab0f` (sha256 `c8b3ea8b…`, the - same build that answered the node comparison above plus the PMIC node), - the way the 10-28 ot7 DTB went on: the kit's `omamobile images` with - that DTB as the base and `omamobile push`. Slot B stays marked; the push - writes only the `_b` images. +2. Push gn3 plus `device/tegu/overlays/usb-host-pmic.dtso` (the PMIC node on + hsi2c6 with gpa8-0 pinned as stock's `if_pmic_irq`, and the boost's + `int-gpios`/`enable-gpios`: the same nodes as #127 at `5ada9ab0f`, as an + overlay, because the #127 DTB itself can't take the kit's other overlays; + a dry pack on 10-29 applied it and the overlaid tree carries all three + pieces). Added to the kit's `DTB_OVERLAYS` after `package-startup`, then + `omamobile images` twice and `omamobile push`. Slot B stays marked; the + push writes only the `_b` images. 3. Reboot with kmsg streamed. Expect: `max77779-pmic 24-0066: MAX77779 PMIC revision 0x02` with no "no interrupt line" message, the line in `/proc/interrupts` (`24-0066` on gpa8-0) at a count that stays put, the diff --git a/device/tegu/overlays/usb-host-pmic.dtso b/device/tegu/overlays/usb-host-pmic.dtso new file mode 100644 index 000000000..57bf9dd40 --- /dev/null +++ b/device/tegu/overlays/usb-host-pmic.dtso @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-only +/dts-v1/; +/plugin/; + +/* + * Pixel 9a bring-up, not for merge (USB-HOST-PLAN H2b): the MAX77779 PMIC + * block at 0x66 on hsi2c6 (maxim,max77779-pmic, linux-omarchy-mobile#139) + * with the chip's interrupt line on gpa8-0, pinned as stock's if_pmic_irq + * (EINT, pull-up), and the RT9470 boost's two lines on it as stock's + * zumapro-buck-charge-rt9471.dtsi has them: the interrupt on SGPIO6 with a + * pull-up (rt,intr_gpio), the chip enable on SGPIO7 (rt,ceb_gpio). The + * same nodes as linux-omarchy-mobile#127 at 5ada9ab0f, as an overlay on + * the palmtop's gn3 DTB (which has the hsi2c6, pinctrl_alive, gpa8 and + * otg_boost labels). Numbers: IRQ_TYPE_LEVEL_LOW 8, GPIO_ACTIVE_LOW 1, + * GPIO_PULL_UP 16. + */ +&hsi2c6 { + max77779_pmic: pmic@66 { + compatible = "maxim,max77779-pmic"; + reg = <0x66>; + interrupt-parent = <&gpa8>; + interrupts = <0 8>; + pinctrl-names = "default"; + pinctrl-0 = <&if_pmic_irq>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; +}; + +&pinctrl_alive { + if_pmic_irq: if-pmic-irq-pins { + samsung,pins = "gpa8-0"; + samsung,pin-function = <0x0f>; + samsung,pin-pud = <0x03>; + samsung,pin-drv = <0>; + }; +}; + +&otg_boost { + int-gpios = <&max77779_pmic 6 17>; + enable-gpios = <&max77779_pmic 7 1>; +}; From 35689d424f01973a062913f726816a94833a4f88 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 20:15:55 -0647 Subject: [PATCH 9/9] device/tegu USB-HOST-PLAN: H2b tests the PMIC block and the boost's interrupt only, with its way back From Derek's review of 2198e47. The H2b overlay no longer gives the boost its enable line: SGPIO7 is the RT9470's charge enable, and driving it with nothing managing the charger could start it charging beside the MAX77779; that line stays with kernel #127, which must clear CHG_EN before taking it. H2b now reads the boost's FUNCTION and ICSTAT after the modprobe, as the H4 script does, and stops if ICSTAT shows charging. Its rollback says what to do when SSH doesn't come back after a forced restart: fastboot by the buttons and stop, no flash without Derek (#125), so the step is risk medium; the header and the DTB paragraph say that H2b's push writes slot B's images through the normal path. The status line says H2b boots gn3 plus the overlay, step 1 is marked done by H2, the H5 script traps TERM so the swap timer's reboot disarms the early read too, the overlay's header says bring-up only, and the watchdog sentences record the reworked boost driver (6c5d97e18) as the follow-up asked for on #131. --- device/tegu/USB-HOST-PLAN.md | 88 ++++++++++++++------- device/tegu/overlays/usb-host-pmic.dtso | 22 +++--- device/tegu/usb-host/tegu-usb-host-h5-reset | 8 +- 3 files changed, 75 insertions(+), 43 deletions(-) diff --git a/device/tegu/USB-HOST-PLAN.md b/device/tegu/USB-HOST-PLAN.md index 74bfa85f0..9bee84ec9 100644 --- a/device/tegu/USB-HOST-PLAN.md +++ b/device/tegu/USB-HOST-PLAN.md @@ -11,7 +11,8 @@ derekross/linux-omarchy-mobile#127 (`tegu-usb-host-bringup`, now at `5ada9ab0f`, not for merge: after the `5dd15e31c` the DTB comparison below used, `0caff021a` only changed a comment, `6c5d97e18` reworks the boost driver and `5ada9ab0f` adds the PMIC node and the boost's lines; H2b boots -that build). The boot helpers are in `device/tegu/usb-host/`. +gn3 plus the overlay below, `usb-host-pmic.dtso`, not #127's DTB). The boot +helpers are in `device/tegu/usb-host/`. ## What it builds on @@ -19,7 +20,7 @@ that build). The boot helpers are in `device/tegu/usb-host/`. | --- | --- | | Board DT: fuel gauge, TCPC node | derekross/linux-omarchy-mobile#119 | | `usi10`/`hsi2c10`, its pins, the RT9470 node, the TCPC as dual-role with `vbus-supply`, the graph to dwc3 | #127 (USI10 clocks: #102, merged) | -| RT9470 OTG boost module (`tegu-rt9471-boost`) | #127. JEITA and the watchdog are off only while the boost is enabled | +| RT9470 OTG boost module (`tegu-rt9471-boost`) | #127. Since `6c5d97e18` (the #131 follow-up) the driver keeps the RT9470's 40 s watchdog and services it from the PMIC interrupt, or from a 20 s kernel timer without it, as stock does, instead of clearing it; JEITA is off only while the boost is enabled | | MAX77779 charger and its `chgin-otg` regulator | #92, #124 (head `4970bcdc3820`) | | MAX77779 TCPC in `tcpci_maxim` | #97 (merged) | | eUSB2 repeater, PHY | #118, the integration tree | @@ -37,8 +38,9 @@ build is the reference. For this run to count as #124's evidence, gn3's `chgin-otg` regulator), `i2c@10ca0000` (hsi2c10, the boost at 0x5b) and `usb@11210000` nodes were compared with a build of #127 at `5dd15e31c` (both decompiled with `dtc -I dtb -O dts`; the result is below, "The three -nodes against #127"). The next run boots no new DTB until H2b, and needs -no DTB dead-man. +nodes against #127"). The next run boots no new DTB until H2b. H2b pushes +gn3 plus one overlay to slot B through the normal `push` path, without a +DTB dead-man; its way back when SSH doesn't return is written into H2b. The `tegu-dtb-deadman` used on 10-28 was a one-boot unit: if the gadget wasn't configured 180 s into an armed boot, it wrote a known-good @@ -84,8 +86,9 @@ point 7); they need a hand on the cable. Forced restart if the palmtop hangs, also in a shutdown under the swap timer: hold Power about 30 s until it is off, then press Power. Stop the run if slot B isn't marked successful: this runbook doesn't mark it (marking is a separate -`devinfo` operation under the rules being settled on #125), and nothing here -writes a boot partition. +`devinfo` operation under the rules being settled on #125). The one +boot-partition write here is H2b's `omamobile push` of gn3 plus the overlay +to slot B's images, through the normal path; nothing else writes one. **The meter rule.** Any reset while the drive is attached is a crash with host mode on: H5's `echo b`, H4's swap timer firing, or a forced restart @@ -165,8 +168,8 @@ says `enabled`, and the unit does nothing yet (its marker is absent until H5 arms it). Rollback: put the `*.before-h2` files back, `depmod -a`, and H6's removal of the helpers. -**H2b. The PMIC block and the boost's lines (risk low; attended, on the -charger).** New since the 10-29 review: the RT9470's interrupt and chip +**H2b. The PMIC block and the boost's interrupt line (risk medium: its +rollback can end in fastboot; attended, on the charger).** New since the 10-29 review: the RT9470's interrupt and chip enable are the MAX77779's SGPIO6 and SGPIO7, and stock services the boost's 40 s watchdog from that interrupt. #127 now carries the PMIC block on the board (`5ada9ab0f`, with its gpa8-0 line pinned as stock's `if_pmic_irq`) @@ -174,19 +177,27 @@ and the boost reworked to keep the watchdog and kick it from the interrupt (`6c5d97e18`); the block's driver is linux-omarchy-mobile#139 (`a6e10f2ba`). One boot before H3, with the boost module still blacklisted from H2: -1. Stage the modules built against the running kernel from - `logs/tegu-review-20261029/max77779/` (`gpio-max77779.ko` and the new - `tegu-rt9471-boost.ko`, W=1 clean) over `updates/gpio/` and - `updates/otg/`, keeping the old boost module as `*.before-h2b`, then - `depmod -a`. +1. Modules: already done by H2, which installed #139's driver + (`gpio-max77779.ko`) and the boost built from `6c5d97e18` + (`tegu-rt9471-boost.ko`, W=1 clean) over `updates/gpio/` and + `updates/otg/`; `5ada9ab0f` only changes the device tree, so nothing is + staged for this step. After a kernel push they are rebuilt and + reinstalled as H2 says. 2. Push gn3 plus `device/tegu/overlays/usb-host-pmic.dtso` (the PMIC node on hsi2c6 with gpa8-0 pinned as stock's `if_pmic_irq`, and the boost's - `int-gpios`/`enable-gpios`: the same nodes as #127 at `5ada9ab0f`, as an - overlay, because the #127 DTB itself can't take the kit's other overlays; - a dry pack on 10-29 applied it and the overlaid tree carries all three - pieces). Added to the kit's `DTB_OVERLAYS` after `package-startup`, then - `omamobile images` twice and `omamobile push`. Slot B stays marked; the - push writes only the `_b` images. + `int-gpios` on SGPIO6: the PMIC node and the pin of #127 at `5ada9ab0f`, + as an overlay, because the #127 DTB itself can't take the kit's other + overlays; a dry pack on 10-29 applied it). The overlay does not give the + boost its `enable-gpios`: SGPIO7 is the RT9470's charge enable (mainline's + `richtek,rt9471.yaml`: the GPIO that turns charging on and off), and + with the pin driven low the chip could start charging the battery at its + power-on defaults beside the MAX77779, with nothing managing it (the + 10-29 readout had `FUNCTION` 0x41, `CHG_EN` set, with the pin undriven). + That line stays with #127, which must clear `CHG_EN` before taking it, + or not take it; this boot tests one thing, the PMIC block and the boost's + interrupt. Added to the kit's `DTB_OVERLAYS` after `package-startup`, + then `omamobile images` twice and `omamobile push`. Slot B stays marked; + the push writes only the `_b` images. 3. Reboot with kmsg streamed. Expect: `max77779-pmic 24-0066: MAX77779 PMIC revision 0x02` with no "no interrupt line" message, the line in `/proc/interrupts` (`24-0066` on gpa8-0) at a count that stays put, the @@ -194,13 +205,25 @@ One boot before H3, with the boost module still blacklisted from H2: hand with kmsg streamed. Expect: `JEITA off, watchdog on (0x1)` as stock leaves it, `watchdog serviced from interrupt N`, and the regmap readout of the PMIC (`/sys/kernel/debug/regmap/24-0066/registers`) with SGPIO6 - now an input with `PU` set and `PD` clear and its DATA high, SGPIO7 an - output driving low (CEB asserted). Stop: an interrupt count on gpa8-0 - or on the SGPIO line that climbs by more than 100 a second (a pull - wrong; `rmmod tegu_rt9471_boost` and read the PMIC's `e9`/`ea`), the - boost probing without the interrupt, or no SSH 3 minutes after the - reboot (forced restart with the laptop attached). Rollback: the previous - DTB pushed back and the `*.before-h2b` module restored, `depmod -a`. + now an input with `PU` set and `PD` clear and its DATA high, SGPIO7 + still off (CNFG7 0x00: nothing drives the enable). Then read the boost + as the H4 script does, `i2cget -f -y 0x5b 0x02` + (`FUNCTION`) and `0x0f` (ICSTAT): expect `FUNCTION` 0x41 as on 10-29 + and ICSTAT 0xf1, VBUS ready and not charging. Stop: ICSTAT showing + charging (anything but the not-charging value): `rmmod + tegu_rt9471_boost`, read both again, and record them; an interrupt + count on gpa8-0 or on the SGPIO line that climbs by more than 100 a + second (a pull wrong; `rmmod tegu_rt9471_boost` and read the PMIC's + `e9`/`ea`); the boost probing without the interrupt; or no SSH 3 minutes + after the reboot. On that last one: a forced restart with the laptop + attached (slot B is marked, so ABL boots the same DTB again). If SSH + doesn't come back after the forced restart either, go to fastboot by the + buttons (Volume Down + Power held about 20 s) and stop there: pushing + the previous DTB back needs the SSH that is missing, and the way back + from fastboot is `omamobile flash`, which unmarks slot B (#125), so ask + Derek before any `flash`. Rollback while SSH works: the previous DTB + pushed back (the kit restored, `omamobile images` twice, `omamobile + push`); the modules stay as H2 left them. Read-only before the step, for the record: the PMIC's registers as the driver found them on 10-29 without the node (ID 0x79, revision 0x02, OTP @@ -256,7 +279,8 @@ enumerated; 20 s after the drive enumerates it logs the boost's state to `/var/log/omamobile/usb-host-h5.log`, syncs, and runs `echo b > /proc/sysrq-trigger`. On every exit without a reset (no drive in 3 minutes, the laptop never leaving, the sysrq not taking) it removes the `armed` -marker, so a fallback reboot (the swap timer firing first, a `systemctl +marker, and it traps `TERM` to do the same, so a fallback reboot (the swap +timer firing while it still waits, which stops the unit; a `systemctl reboot` with the charger's `.shutdown`) doesn't produce an early-read log under the same name. **The early read counts only when `usb-host-h5.log` ends with the "resetting now" line.** `systemctl reboot` would run the @@ -318,6 +342,10 @@ installed in H2, unless H2's rollback is wanted. - The RT9470's lines in stock's DT (10-29, `zumapro-buck-charge-rt9471.dtsi` and `zuma-tegu-charging.dtsi` in Google's tegu tree): interrupt on the MAX77779's sGPIO 6 (`PLC_INT_L`), chip enable on sGPIO 7, and stock's - driver services the 40 s watchdog from that interrupt. Our kernel has no - MAX77779 sGPIO driver yet, which is why the bring-up node has no - interrupt and the boost runs with the watchdog off. + driver services the 40 s watchdog from that interrupt. Until 10-29 our + kernel had no MAX77779 sGPIO driver, so the bring-up node had no + interrupt and the boost ran with the watchdog off. Now the reworked boost + driver on derekross/linux-omarchy-mobile#127 (`6c5d97e18`) keeps the + RT9470's watchdog and services it from the interrupt, or from a 20 s + timer when the node has none, as stock does, instead of clearing it + (the follow-up Derek asked for on #131); the sGPIO driver is #139. diff --git a/device/tegu/overlays/usb-host-pmic.dtso b/device/tegu/overlays/usb-host-pmic.dtso index 57bf9dd40..ecc8263d4 100644 --- a/device/tegu/overlays/usb-host-pmic.dtso +++ b/device/tegu/overlays/usb-host-pmic.dtso @@ -3,15 +3,18 @@ /plugin/; /* - * Pixel 9a bring-up, not for merge (USB-HOST-PLAN H2b): the MAX77779 PMIC - * block at 0x66 on hsi2c6 (maxim,max77779-pmic, linux-omarchy-mobile#139) - * with the chip's interrupt line on gpa8-0, pinned as stock's if_pmic_irq - * (EINT, pull-up), and the RT9470 boost's two lines on it as stock's - * zumapro-buck-charge-rt9471.dtsi has them: the interrupt on SGPIO6 with a - * pull-up (rt,intr_gpio), the chip enable on SGPIO7 (rt,ceb_gpio). The - * same nodes as linux-omarchy-mobile#127 at 5ada9ab0f, as an overlay on - * the palmtop's gn3 DTB (which has the hsi2c6, pinctrl_alive, gpa8 and - * otg_boost labels). Numbers: IRQ_TYPE_LEVEL_LOW 8, GPIO_ACTIVE_LOW 1, + * Pixel 9a bring-up only; in no device's default DTB_OVERLAYS + * (USB-HOST-PLAN H2b): the MAX77779 PMIC block at 0x66 on hsi2c6 + * (maxim,max77779-pmic, linux-omarchy-mobile#139) with the chip's + * interrupt line on gpa8-0, pinned as stock's if_pmic_irq (EINT, pull-up), + * and the RT9470 boost's interrupt on its SGPIO6 with a pull-up, as stock's + * zumapro-buck-charge-rt9471.dtsi has it (rt,intr_gpio). The PMIC node and + * the pin are those of linux-omarchy-mobile#127 at 5ada9ab0f, as an overlay + * on the palmtop's gn3 DTB (which has the hsi2c6, pinctrl_alive, gpa8 and + * otg_boost labels). Not the boost's enable-gpios (stock's rt,ceb_gpio on + * SGPIO7): that pin is the RT9470's charge enable, and driving it with + * nothing managing the charger could start it charging; the line stays + * with #127. Numbers: IRQ_TYPE_LEVEL_LOW 8, GPIO_ACTIVE_LOW 1, * GPIO_PULL_UP 16. */ &hsi2c6 { @@ -40,5 +43,4 @@ &otg_boost { int-gpios = <&max77779_pmic 6 17>; - enable-gpios = <&max77779_pmic 7 1>; }; diff --git a/device/tegu/usb-host/tegu-usb-host-h5-reset b/device/tegu/usb-host/tegu-usb-host-h5-reset index ba9e6dc53..4fa01446b 100755 --- a/device/tegu/usb-host/tegu-usb-host-h5-reset +++ b/device/tegu/usb-host/tegu-usb-host-h5-reset @@ -9,9 +9,10 @@ # tegu-rt9470-early-read shows what a reset leaves with host mode on. It # refuses to reset unless that read is armed and its unit enabled, and # unless a drive has enumerated: without them the reset would show nothing. -# On every exit without a reset it removes the armed marker, so a fallback -# reboot (the swap timer, a systemctl reboot) doesn't produce an early-read -# log that looks like this step's. The early read counts only when this +# On every exit without a reset it removes the armed marker, and it traps +# TERM to do the same (the swap timer's reboot stops this unit first), so a +# fallback reboot (the swap timer, a systemctl reboot) doesn't produce an +# early-read log that looks like this step's. The early read counts only when this # script's log ends with the "resetting now" line. # Reads are i2cget only; the writes are the marker's removal and the sysrq. set -u @@ -19,6 +20,7 @@ L=/var/log/omamobile/usb-host-h5.log; mkdir -p /var/log/omamobile A=/var/lib/omamobile-tegu/rt9470-early-read/armed log() { echo "$(date -Is) $*" >> "$L"; } disarm() { rm -f "$A"; sync; log "no reset: early read disarmed ($A removed)"; } +trap 'disarm; exit 1' TERM bus_of() { local d; for d in /sys/bus/i2c/devices/i2c-*; do readlink -f "$d" | grep -c "$1" >/dev/null && { echo "${d##*-}"; return; }; done; } CB=$(bus_of 108d0000.i2c) # hsi2c6: the TCPC at 0x25, the charger at 0x69 RB=$(bus_of 10ca0000.i2c) # hsi2c10: the RT9470 at 0x5b