Skip to content

rtc: s5m: Add the S2MPG14 (Pixel 9a) RTC - #54

Closed
W4HO-ham wants to merge 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-s2mpg14-rtc
Closed

W4HO-ham wants to merge 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-s2mpg14-rtc

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

The Pixel 9a's main PMIC, the S2MPG14, keeps its RTC in the S2MPG10 register layout behind ACPM access type 0x02. Two commits:

  • mfd: sec: s2mpg14: Add the RTC regmap and cell: an uncached "rtc" regmap over the ACPM bus (0x00-0x2b), STATUS2 readable in the PMIC regmap for the alarm flag, and the s2mpg14-rtc cell. No interrupt line is described yet, so no alarm resource.
  • rtc: s5m: Add S2MPG14: takes the S2MPG10 register table, STATUS2 bit 2 for the pending alarm as on the S2MPG12, and comes up time-only until the PMIC interrupt lands.

Tested on the Pixel 9a on top of today's omamobile: rtc0 registers at boot and sets the system clock (s5m-rtc s2mpg14-rtc: registered as rtc0, setting system clock to 2026-10-26T13:28:26 UTC), hwclock reads and sets it, systemd-timesyncd writes the synchronized time back, and the time holds across reboots and a power-key reset.

tools/kernel-pr-check b495db69c: sign-offs, prefixes and policy pass; checkpatch --strict reports no errors and one pre-existing warning (the undocumented samsung,s2mpg15-pmic string in the context of sec-acpm.c, not introduced here).

Source for the register layout: Google's GPL rtc-s2mpg14.h (linked in the first commit).

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Reworked: the first push carried unrelated S2MPG15 hunks from my working tree (that's where the W=1 failures in sec-acpm.c and sec-common.c and the undocumented-compatible warning came from). The branch is now the RTC change only, 58 lines across the four files, rebased on b495db6. Both touched drivers and rtc-s5m build with W=1 against defconfig + omamobile.config, checkpatch --strict is clean, and the phone test stands.

@derekross

Copy link
Copy Markdown
Owner

Thanks for this, and for cleaning the branch up so quickly. The RTC change
on its own is easy to review. I checked the layout against Google's
rtc-s2mpg14.h and s2mpg14-register.h on the tegu android16 branch.
CTRL through OSC_CTRL match S2MPG10's table, the UPDATE bits (RUDR 0,
WUDR 1, AUDR 4) match s2mpg10_rtc_regs, and STATUS2 is 0x0b in the PM
block with RTCA0E at bit 2, which is what Google's driver reads. I also
built sec-acpm.o, sec-common.o and rtc-s5m.o before and after and
compared them function by function. Nothing changes for the S2MPG10 or
S2MPG12 paths: only the device-type masks gain S2MPG14. The gate passes on
the merge with the current omamobile.

Two things before I merge:

  1. Please narrow the RTC write table to what rtc-s5m writes. Right now
    s2mpg14_rtc_table is both the read and the write table for 0x00-0x2b,
    so the regmap would accept writes to SMPL (0x02), WTSR (0x03), CAPSEL
    (0x04), OSC_CTRL (0x1b) and the nonces. Nothing writes them today, but
    they are the power-loss and watchdog-reset protections and the
    oscillator tuning. The other S2MPG14 tables here allow only what the
    driver uses. rtc-s5m writes CTRL (0x00), UPDATE (0x01), the time
    (0x06-0x0c) and alarm 0 (0x0d-0x13), so a write table of
    {0x00-0x01, 0x06-0x13} covers it. The read table can stay as it is, or
    stop at OSC_CTRL like S2MPG10's. Please update the comment above the
    table to match too.
  2. One boot of the final head on the 9a. The test in the description
    ran before the force-push, on a tree that also had the S2MPG15 hunks and
    the bus-level range check. The RTC code is the same, so I'm not doubting
    the result. But after the table change I'd like to see it on the commit
    we merge: uname -r, dmesg | grep -i rtc, hwclock -r, one
    hwclock -w with a read-back, and the tools/phone-smoke report. Please
    also say which board DT you booted, since the 9a's DTS isn't public yet.

A small one while you're in there: commit 1's message quotes
registered as rtc0, but that line only appears once commit 2 adds the
id. Could you move the log lines to the second commit?

By the way, the range check you dropped is a good idea in its own right.
It covers update_bits on volatile registers, which regmap sends straight
to the bus without checking the write table. It would change the S2MPG10
and S2MPG12 regmaps too, though, so I'd want it as a separate PR with a
Pixel 7 Pro boot.

Thanks again. This is a tidy, well-sourced change.

The S2MPG14's RTC block sits at ACPM access type 0x02 and has the same
register layout as the S2MPG10's (CTRL at 0x00 through OSC_CTRL at 0x1b,
two nonces to 0x2b, five scratch registers to 0x30), per Google's GPL
rtc-s2mpg14.h. Describe it as an uncached "rtc" regmap over the ACPM bus,
let the PMIC regmap read STATUS2 (the alarm flag, bit 2 as on S2MPG12),
and add the s2mpg14-rtc cell. No interrupt line is described yet, so the
cell carries no alarm resource.

The regmap reads up to OSC_CTRL and writes only what rtc-s5m writes:
CTRL, UPDATE, the time and alarm 0. SMPL, WTSR, CAP_SEL and OSC_CTRL
(the power-loss and watchdog-reset protections and the oscillator
tuning) and the nonces stay read-only.

Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/refs/heads/android-gs-tegu-6.1-android16/include/linux/mfd/samsung/rtc-s2mpg14.h
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The S2MPG14 (Pixel 9a main PMIC) keeps its RTC in the S2MPG10 layout,
reached through the "rtc" regmap the sec-acpm driver now provides, so it
takes the S2MPG10 register table. Its alarm flag is STATUS2 bit 2 in the
PMIC regmap, as on the S2MPG12. Without a PMIC interrupt line the device
comes up with the alarm feature cleared, as a time-only clock.

On the Pixel 9a the RTC registers as rtc0 and the system clock is set
from it at boot:

  s5m-rtc s2mpg14-rtc: registered as rtc0
  s5m-rtc s2mpg14-rtc: setting system clock to 2026-10-26T13:28:26 UTC

Tested on the Pixel 9a: rtc0 registers at boot, hwclock reads and sets
the time, systemd-timesyncd writes the synchronized time back, and the
time survives reboots and a power-key reset.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Done, rebased onto omamobile (9afbb1a):

  1. The RTC regmap now has separate tables. Reads go up to OSC_CTRL (max_register too). Writes are only {CTRL-UPDATE, SEC-A0YEAR}, which is 0x00-0x01 and 0x06-0x13, exactly what rtc-s5m writes. The comment above them says why SMPL, WTSR, CAP_SEL and OSC_CTRL stay read-only. S2MPG14_RTC_LAST went with the old table.
  2. The registered as rtc0 lines moved to the second commit's message, and the first commit's message describes the tables instead.

checkpatch --strict is clean on both, and sec-acpm.o, sec-common.o and rtc-s5m.o build with W=1.

The boot of this head on the 9a is still to come. The palmtop is waiting for a power-key restart after an overnight test. When it's back I'll post uname -r, dmesg | grep -i rtc, hwclock -r, a hwclock -w with a read-back, the phone-smoke report and the board DT nodes.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Booted on the palmtop (Pixel 9a). This is our integration kernel with exactly the RTC and interrupt code of this PR's head and #55's (the review diff applied on top), built as 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty.

$ dmesg | grep -i rtc
s5m-rtc s2mpg14-rtc: registered as rtc0
s5m-rtc s2mpg14-rtc: setting system clock to 2026-10-27T14:00:51 UTC (1793109651)
$ hwclock -r
2026-10-27 07:02:24.846365-07:00
$ hwclock -w && hwclock -r
2026-10-27 07:02:24.998913-07:00

phone-smoke passes every required check. Its one non-required line is a failed tegu-curated-bluetooth-prepare.service, a bring-up unit of mine that the bring-up script now replaces, unrelated to the RTC. The board DT is our integration board file, which isn't public. Its PMIC is the samsung,s2mpg14-pmic node under the ACPM firmware node, with the regulators for the touchscreen and eUSB2. The interrupt and syscon nodes are in my #55 comment.

@derekross

Copy link
Copy Markdown
Owner

Thanks, that's both points done. The split tables are exactly what I asked for: reads up to OSC_CTRL, writes only CTRL, UPDATE, the time and alarm 0, which I checked against what rtc-s5m actually writes (regmap_write of CTRL, regmap_update_bits of UPDATE, raw writes of the time and alarm 0; alarm 1 is never touched). The comment says why the protections stay read-only, the log lines sit in the commit that makes them appear, and the gate and CI pass on today's omamobile.

So the only thing left is the boot of this head on the 9a, whenever the palmtop is back: uname -r, dmesg | grep -i rtc, hwclock -r, one hwclock -w with a read-back, the tools/phone-smoke report and the board nodes you booted with. If you run it on the #55 head instead, that covers this PR too, since its first two commits are these. I'll merge as soon as that's posted.

@derekross

Copy link
Copy Markdown
Owner

Landed through #55, which carries this with the interrupt made optional. Thank you, @W4HO-ham.

@derekross derekross closed this Nov 1, 2026
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