Skip to content

rtc: s5m: disarm the S2MPG12's WTSR and SMPL restarts at power off - #233

Merged
derekross merged 1 commit into
derekross:omamobilefrom
ikegam:omamobile-poweroff
Nov 12, 2026
Merged

derekross merged 1 commit into
derekross:omamobilefrom
ikegam:omamobile-poweroff

Conversation

@ikegam

@ikegam ikegam commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

On the Pixel 7 Pro (gs201, S2MPG12), power off restarted the phone, and holding Volume Down + Power for fastboot also ended in a normal boot. The PMIC's RTC block, read on a running phone through the ACPM regmap (one register per read), had the warm-reset restart armed: 0x02 (SMPL) 0x0e, SMPL_EN 0; 0x03 (WTSR) 0x0f, WTSR_EN 1. Google's rtc-s2mpg12.c clears SMPL_EN, WTSR_EN and COLDRST_EN in its shutdown callback before every power off; rtc-s5m didn't. This does the same for power off and halt on the S2MPG12; restarts are left alone.

Tested on a Pixel 7 Pro, this commit on the release kernel (7.3.0-rc6-omamobile-g2219cc6cda77 → -push1-g0e3da55c9e9f), 2026-11-09. The power-off behaviour follows the kernel that shuts down:

kernel at shutdown cable next
release in a normal boot at once
this commit in off, then the bootloader's charger boot (androidboot.mode = "charger")
this commit out stayed off for 3 minutes, until Power

Rebased here onto omamobile at 1a9d1d4e9289, a clean pick; tools/kernel-pr-check passes (sign-off, prefixes, checkpatch --strict 0/0, identifiers). Not done: a W=1 build of the touched object (the full build was clean at the default warning level). The userspace side of the charger boot is omarchy-mobile's device-cheetah 0.1.48.

🤖 Generated with Claude Code

@derekross

Copy link
Copy Markdown
Owner

Thank you, and welcome! Tracking power off's restart down to the PMIC's
WTSR, and checking it against Google's rtc-s2mpg12.c, is a really useful
find: power off from Linux has never been tested on my 7 Pro, and this
explains what I'd have hit. The change matches Google's shutdown callback
bit for bit (SMPL_EN bit 0, WTSR_EN bit 0, COLDRST bit 4), it's gated on
the S2MPG12 and on power off or halt only, and leaving restarts alone is
the careful choice. I ran our gate merged onto today's omamobile: it
merges cleanly, checkpatch is clean, and the W=1 build of rtc-s5m.c is
clean too, so that box is ticked.

Two things before merging:

  1. The Volume Down + Power sentence. The message says holding Volume
    Down + Power to reach fastboot also ended in a normal boot. This change
    runs only when the kernel powers off or halts; the keys' path is the
    PMIC's own reset and never reaches it. Could you either check whether
    the keys reach fastboot with this kernel, or take that sentence out of
    this commit? It's an important finding in its own right, because our
    recovery instructions rely on those keys, and I've asked about it on
    #554.
  2. A run on my phone. This changes every gs201 board's power off (the
    7 Pro, and also the 7a and 7, whose PMIC node is enabled), so I'll run
    it on my 7 Pro before merging: a power off on the release kernel first,
    then with your commit, with the cable in and out, and a read after the
    next cold boot to see that the bootloader arms WTSR again (our kernel
    never writes it, and the value you read, 0x0f, is neither what stock's
    driver writes at probe nor at restart, so I think ABL sets it each
    boot). Could you share the exact command you used for the
    one-register reads, so I run the same thing?

Small ones: the branch's coding-assistants.rst gives Assisted-by: LLM [TOOLS] as the format; and a line naming the boards that change (cheetah,
lynx, panther) would help their owners.

@derekross

derekross commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

The run on my Pixel 7 Pro is done, 2026-11-10: published omamobile (253208c11b25 plus #116) without and with this commit.

Kernel at shutdown Cable What followed
without this commit (…-g42be9bc424d4) in the next boot started 16 s after the journal stopped
with it (…-gc7fb37460f84) in the next boot started 16 s after the journal stopped, with androidboot.mode = "charger" in /proc/bootconfig: off, then the bootloader's charger start, as you described
with it out off for 3 min 12 s, until I pressed Power; a normal boot, no androidboot.mode

Each was a systemctl poweroff with the modem up; the modem's stop was logged each time and the next boot brought it ONLINE with no refusal. No failed units on any of the boots.

Two limits of my run. On the first row I didn't read /proc/bootconfig, so I can't show from my own boot that the release kernel's restart carries no androidboot.mode; the cable-out row is what shows the difference. And I didn't read the PMIC's RTC registers after the cold boot: I'd still like the exact one-register command you used, so I run the same thing rather than guess at a read on that chip.

Without #554 the charger start brings up the whole phone, modem included, which is what #554 is for.

Still open from my last comment: the Volume Down + Power sentence in the commit message. I'll try those keys on this kernel myself and report here; if they do reach fastboot, the sentence needs to come out or be reworded before I merge, since this change can't affect that path.

@derekross

Copy link
Copy Markdown
Owner

The keys, tried on this kernel (…-gc7fb37460f84, with this commit) on my 7 Pro: holding Volume Down + Power forced a reset, and the phone then booted normally, with androidboot.bootreason = "reboot", "longkey", "master_dc". It reaches fastboot only when Volume Down is still held while the bootloader starts, as on stock. So what you saw with the keys is the bootloader's ordinary behaviour and has nothing to do with WTSR or with this change.

That leaves one thing before I merge: please take the Volume Down + Power sentence out of the commit message, so the commit claims only what it changes (power off and halt). Everything else is done, and the three power-off runs above stand.

@ikegam

ikegam commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I'll fix all of these.

@derekross

Copy link
Copy Markdown
Owner

Thank you! Nothing else is open here: I ran the gate again on today's omamobile and it still merges cleanly, with checkpatch and the W=1 build of rtc-s5m.c clean, and my three power-off runs on the 7 Pro from 2026-11-10 stand.

The one thing left is the commit message. The first paragraph still says that holding Volume Down and Power "also ends in a normal boot". We merge kernel commits by rebase, so the message lands exactly as written, and this change can't affect that path (on my phone the keys force a reset, and fastboot comes up when Volume Down is still held while the bootloader starts). Could you drop that clause, so the paragraph reads:

On the Pixel 7 Pro (gs201, S2MPG12), power off restarts the phone.

and force-push? If it's easier, say so and I'll make that one edit on your branch myself, keeping your authorship and sign-off and noting the change in brackets above mine.

If you touch the message anyway, two small things: a line naming the boards whose power off changes (cheetah, lynx and panther), and the trailer in the form our tree documents, Assisted-by: LLM [TOOLS]. And if you still have it, the one-register read command you used for 0x02 and 0x03: I'd like to read them after a cold boot the same way you did.

On the Pixel 7 Pro (gs201, S2MPG12), power off restarts the phone.
The RTC block read on a running phone shows the PMIC's warm-reset
restart armed:

  0x02 (SMPL) = 0x0e: SMPL_EN 0
  0x03 (WTSR) = 0x0f: WTSR_EN 1, WTSRT 7, COLDRST_EN 0

With WTSR enabled, the PMIC answers the AP dropping power by powering
it up again. Google's S2MPG12 RTC driver clears SMPL_EN, WTSR_EN and
COLDRST_EN in its shutdown callback before every power off, and arms
them again only for a restart (rtc-s2mpg12.c, s2m_rtc_shutdown()).

Do the same for power off and halt. Restarts are left as they are.
This changes power off on the S2MPG12 boards: cheetah, lynx and
panther.

Assisted-by: LLM
Signed-off-by: Hiroyuki Ikegami <ikegam@mixallow.net>
@ikegam
ikegam force-pushed the omamobile-poweroff branch from e635297 to f361fe5 Compare November 12, 2026 01:08
@ikegam

ikegam commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Force-pushed f361fe5: the Volume Down + Power clause is gone, so the first paragraph now reads exactly as you suggested. I also added the line naming cheetah, lynx and panther, and changed the trailer to Assisted-by: LLM. The code is unchanged.

For 0x02 and 0x03 I read the RTC regmap through debugfs as root. Each line of registers is 7 bytes ("RR: VV\n"), so this reads a single register:

d="/sys/kernel/debug/regmap/firmware:power-management:pmic-1-rtc"
dd if="$d/registers" bs=7 skip=2 count=1 status=none   # 02: 0e
dd if="$d/registers" bs=7 skip=3 count=1 status=none   # 03: 0f

@derekross

Copy link
Copy Markdown
Owner

Thank you, that's everything. The first paragraph now reads as I suggested, the message names cheetah, lynx and panther, the trailer is in our tree's form, and the code is the same as before: the patch id of f361fe5 equals the one I ran on my 7 Pro on the 10th. Nothing under the RTC or the PMIC driver has moved on omamobile since that run, so my three power-off results stand for what lands. Our gate passes on the merge with today's omamobile (sign-off, prefix, checkpatch, W=1 build of rtc-s5m.c).

The CI run on this head was waiting for my approval; I've started it and will merge when it's green.

Thanks for the read command too. I read it against the regmap code before using it: a 7-byte read is exactly one register on this map, and each line carries its register number, so it checks itself. I'll read 0x03 after a cold boot on my phone and put the value in the 7 Pro's notes, to see whether the bootloader arms WTSR again. That doesn't hold the merge.

Thank you for the fix, and for your patience with the wording.

@derekross
derekross merged commit 2db2bc3 into derekross:omamobile Nov 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants