Skip to content

rtc: s5m: disarm the S2MPG14's WTSR and SMPL restarts at power off too - #262

Open
gitColinX wants to merge 2 commits into
derekross:omamobilefrom
gitColinX:omamobile-s2mpg14-poweroff
Open

gitColinX wants to merge 2 commits into
derekross:omamobilefrom
gitColinX:omamobile-s2mpg14-poweroff

Conversation

@gitColinX

@gitColinX gitColinX commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

On the Pixel 8 Pro, systemctl poweroff restarts the phone, and every restart spends a slot B retry (derekross/omarchy-mobile#578). This extends #233's power-off disarm, written for the S2MPG12 (gs201), to the S2MPG14 (zuma, zumapro).

Why: the RTC block of a running 8 Pro, read through the RTC regmap in debugfs on two units (mine and @Somnius's, published omamobile at 82f31d3a7), shows the same values the 7 Pro had before #233:

02: 0e    SMPL: SMPL_EN 0
03: 0f    WTSR: WTSR_EN 1, WTSRT 7, COLDRST_EN 0

With WTSR armed, the PMIC answers the AP's power-off by powering it up again. Google's S2MPG14 driver clears SMPL_EN, WTSR_EN and COLDRST_EN before every power off (android-gs-shusky-6.1-android16, drivers/rtc/rtc-s2mpg14.c: s2m_rtc_shutdown() and s2m_rtc_disable_wtsr_smpl()), and its rtc-s2mpg14.h has SMPL at 0x2 and WTSR at 0x3 with the bits that are S2MPG10's here.

The change: s5m_rtc_shutdown() returns early unless the device is S2MPG12 or S2MPG14, plus the comment. Restarts are left alone. Because the check is by chip, it changes power off on all three S2MPG14 boards: husky, akita and tegu.

A first commit (mfd: sec: s2mpg14) adds SMPL and WTSR to the S2MPG14 RTC regmap's write table and updates its comment, so the write no longer depends on regmap skipping the table. The rtc-s5m code is unchanged from 4a2d34d69.

Tested on husky (@Somnius's unit, published 82f31d3a7 plus this change; his reports on #578):

  • cable out, systemctl poweroff: stayed off for about 15 minutes, no answer to ping for 200 s, started only by the power key;
  • cable in, systemctl poweroff: stayed off for about 7 minutes, nothing on the screen or the USB bus, started by the power key;
  • systemctl reboot still restarts. The boot reason reads reboot after it, and reboot,uvlo,pmic,if after a power-key start from off.

Not covered:

  • No log of the clear itself: journald is gone by the time the shutdown hook runs, and the registers read 0e/0f again after each boot.
  • akita and tegu are untested.
  • Not yet run on my own unit; I can if wanted.

tools/kernel-pr-check: sign-off, prefix, checkpatch --strict and policy all ok. Built for husky on 82f31d3a7 (7.3.0-rc6-omamobile-push1-gaea6b8a082bb) and rebased unchanged onto today's omamobile.

@Somnius

Somnius commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@gitColinX thanks for opening it. I built this exact head (4a2d34d, on omamobile d49d68c) with the usual husky config and ran it on my 8 Pro last night, release 7.3.0-rc6-omamobile-push1-g4a2d34d69208. Booted fine, Wi-Fi and USB up, no failed units, s5m-rtc s2mpg14-rtc: registered as rtc0.

Cable in: systemctl poweroff at 22:53, journal ends with "Journal stopped" at 22:53:32, then nothing. I watched the phone's USB port on the desktop and it never came back; it stayed off about 40 min until I brought it up from the bootloader myself.

Cable out: poweroff at 23:38, ping and ssh to it every 20 s for 16 min, 42 tries and no answer. journalctl --list-boots shows the next boot at 23:57 when I pressed power, nothing in between.

I also left it off overnight on the same build, cable out: shut down at 00:02, next boot this morning at 07:19 when I pressed power, nothing in between.

So the same result as my local copy of the change on #578. I didn't run the tip without the commit as a control on this build, the before case is the one from #578.

@gitColinX

Copy link
Copy Markdown
Contributor Author

@Somnius, thank you for building the exact head (4a2d34d69) and running it, the overnight run included.

My unit is still on 82f31d3a7 without this change and hasn't run a power off. The offer in the description stands: if a second unit's result is wanted before merging, I'll run it.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Colin, and thank you @Somnius for building the exact head and running it three times, the overnight one included. I checked the change against Google's rtc-s2mpg14.c and rtc-s2mpg14.h on android-gs-shusky-6.1-android16: SMPL at 0x2 and WTSR at 0x3 with the S2MPG10's bits, and s2m_rtc_shutdown() clearing SMPL_EN, WTSR_EN and COLDRST_EN before a power off and arming WTSR again only for a restart. The same file is on the Pixel 9a's branch. Our gate passes on today's omamobile, CI is green, and nothing under drivers/rtc or drivers/mfd has moved since the base Somnius built on, so his runs describe what would land. The Pixel 7 Pro's path is unchanged.

One thing before I merge. On the S2MPG14 the RTC regmap has a write table, and it doesn't list these two registers. drivers/mfd/sec-acpm.c says, above s2mpg14_rtc_wr_registers[]: "SMPL, WTSR, CAP_SEL and OSC_CTRL ... stay read-only". Your write still reaches the PMIC, because regmap sends an update_bits on an uncached register straight to the bus's reg_update_bits and never looks at the write table, and Somnius's runs show it lands. But I don't want the fix to depend on that, or the tree to say both things. Could you add a small commit in front of this one (mfd: sec: s2mpg14: ...) that:

  • makes the first write range regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_WTSR);
  • changes the comment to say that rtc-s5m clears SMPL_EN, WTSR_EN and COLDRST_EN at power off, and that CAP_SEL and OSC_CTRL stay read-only.

It doesn't change anything the husky runs exercised, so no new run is needed. A Link: to derekross/omarchy-mobile#578 in the RTC commit would be welcome too.

For the Pixel 8a and Pixel 9a owners reading along: this changes power off on your phones as well, and it hasn't run there. When a kernel with it reaches you, please do the first systemctl poweroff with the phone in front of you (on the charger for the 9a), and after the next boot read 0x02 and 0x03 of the RTC block the way Colin did. 0e/0f there means the bootloader armed WTSR again, as on the 8 Pro.

Colin, a run on your own unit isn't needed for this.

@gitColinX
gitColinX force-pushed the omamobile-s2mpg14-poweroff branch from 4a2d34d to 488283b Compare November 18, 2026 08:14
@gitColinX

Copy link
Copy Markdown
Contributor Author

@derekross, done, as two commits on the same base (d49d68c76):

tools/kernel-pr-check --build passes on the pair (checkpatch --strict, W=1 on both files).

One thing I left alone: sec-common.c still says of s2mpg14_devs "no GPIO or protection writes". If you read SMPL and WTSR as protections there, I can reword it in the mfd commit.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Colin. The mfd commit is what I asked for: the write range now ends at WTSR, the comment says what rtc-s5m does there, and its message explains why the write got through before. rtc-s5m.c is the same blob as in 4a2d34d69, so Somnius's three power-offs stand for this head. Our gate passes on today's omamobile and CI is green.

On your question about sec-common.c: yes, please reword it. That line ("no GPIO or protection writes") came in with the same commit that called SMPL and WTSR "the power-loss and watchdog-reset protections", so it means these two registers, and it is no longer true. Something like "no GPIO; the RTC's only protection writes clear SMPL_EN, WTSR_EN and COLDRST_EN at power off" in the mfd commit is enough. It is a comment, so nothing needs to run again, and I'll merge once CI is green on that push.

rtc-s5m is about to clear SMPL_EN, WTSR_EN and COLDRST_EN on the
S2MPG14 at power off, as it does on the S2MPG12, so that a power off
does not restart the phone. The bits are in the RTC block's SMPL
(0x02) and WTSR (0x03) registers, and the S2MPG14's write table leaves
both out.

The write would reach the PMIC anyway: this regmap has no cache, so
every register it can read is volatile, and _regmap_update_bits()
hands an update of a volatile register straight to the bus's
reg_update_bits() without looking at the write table. The fix should
not depend on that, and the table and its comment should say what the
drivers do. So extend the first write range to WTSR, and say in the
comment why. CAP_SEL and OSC_CTRL stay read-only.

sec-common.c said of the S2MPG14's cells "no GPIO or protection
writes". SMPL and WTSR are those protections, so say what the RTC
writes there now.

Assisted-by: LLM
Signed-off-by: Colin Lundholm <265166644+gitColinX@users.noreply.github.com>
On the Pixel 8 Pro (zuma, S2MPG14), power off restarts the phone, as it
did on the Pixel 7 Pro before 2db2bc3 ("rtc: s5m: disarm the
S2MPG12's WTSR and SMPL restarts at power off"). The RTC block read on
a running Pixel 8 Pro shows the same values the 7 Pro had:

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

Google's S2MPG14 RTC driver clears SMPL_EN, WTSR_EN and COLDRST_EN in
its shutdown callback before every power off, as its S2MPG12 driver
does (rtc-s2mpg14.c, s2m_rtc_shutdown() and
s2m_rtc_disable_wtsr_smpl()), and its rtc-s2mpg14.h puts SMPL at 0x2
and WTSR at 0x3 with the same bits, which are S2MPG10's here. So take
the S2MPG14 into the same power-off path. Restarts are left as they are.

This changes power off on the S2MPG14 boards: husky, akita and tegu.
Only husky has been tested with it.

Link: derekross/omarchy-mobile#578
Assisted-by: LLM
Signed-off-by: Colin Lundholm <265166644+gitColinX@users.noreply.github.com>
@gitColinX
gitColinX force-pushed the omamobile-s2mpg14-poweroff branch from 488283b to 5161d3b Compare November 19, 2026 00:43
@gitColinX

Copy link
Copy Markdown
Contributor Author

@derekross, reworded in the mfd commit as you suggested:

/*
 * The qualified LDOs and the RTC with its alarm; no GPIO. The RTC's only
 * protection writes clear SMPL_EN, WTSR_EN and COLDRST_EN at power off.
 */

Nothing else changed, and rtc-s5m.c is still the same blob. tools/kernel-pr-check --build passes on the pair.

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.

3 participants