From f7e2edc4a27b7faf21bd9b90ff04b240dd8e22fc Mon Sep 17 00:00:00 2001 From: Colin Lundholm <265166644+gitColinX@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:21:11 -0700 Subject: [PATCH 1/2] mfd: sec: s2mpg14: Let the RTC regmap write SMPL and WTSR 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> --- drivers/mfd/sec-acpm.c | 8 ++++---- drivers/mfd/sec-common.c | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/sec-acpm.c b/drivers/mfd/sec-acpm.c index c644530c44..1e1274c964 100644 --- a/drivers/mfd/sec-acpm.c +++ b/drivers/mfd/sec-acpm.c @@ -644,9 +644,9 @@ static const struct regmap_config s2mpg14_regmap_config_pmic = { /* * The RTC: everything up to the oscillator control may be read. Writes - * only where 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) stay read-only. + * only where rtc-s5m writes: CTRL, UPDATE, the time and alarm 0, and SMPL + * and WTSR, where it clears SMPL_EN, WTSR_EN and COLDRST_EN at power off. + * CAP_SEL and OSC_CTRL (the oscillator tuning) stay read-only. */ static const struct regmap_range s2mpg14_rtc_rd_registers[] = { regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_OSC_CTRL), @@ -658,7 +658,7 @@ static const struct regmap_access_table s2mpg14_rtc_rd_table = { }; static const struct regmap_range s2mpg14_rtc_wr_registers[] = { - regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_UPDATE), + regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_WTSR), regmap_reg_range(S2MPG10_RTC_SEC, S2MPG10_RTC_A0YEAR), }; diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c index 6a40169c4f..03cdc22065 100644 --- a/drivers/mfd/sec-common.c +++ b/drivers/mfd/sec-common.c @@ -79,7 +79,10 @@ static const struct resource s2mpg14_rtc_resources[] = { DEFINE_RES_IRQ_NAMED(S2MPG14_IRQ_RTCA0, "alarm"), }; -/* The qualified LDOs and the RTC with its alarm; no GPIO or protection writes. */ +/* + * 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. + */ static const struct mfd_cell s2mpg14_devs[] = { MFD_CELL_NAME("s2mpg14-regulator"), MFD_CELL_RES("s2mpg14-rtc", s2mpg14_rtc_resources), From 5161d3b8368fb7638ceca558d7a5b80bce3d1161 Mon Sep 17 00:00:00 2001 From: Colin Lundholm <265166644+gitColinX@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:21:11 -0700 Subject: [PATCH 2/2] rtc: s5m: disarm the S2MPG14's WTSR and SMPL restarts at power off too On the Pixel 8 Pro (zuma, S2MPG14), power off restarts the phone, as it did on the Pixel 7 Pro before 2db2bc35b ("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: https://github.com/derekross/omarchy-mobile/issues/578 Assisted-by: LLM Signed-off-by: Colin Lundholm <265166644+gitColinX@users.noreply.github.com> --- drivers/rtc/rtc-s5m.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index 1e997bf8ca..aab5f8a73d 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c @@ -716,17 +716,19 @@ static int s5m_rtc_restart_s2mpg10(struct sys_off_data *data) * The PMIC's warm-reset (WTSR, with its cold-reset follow-up) and sudden * power loss (SMPL) restarts stay armed in the always-on RTC block across * boots. Left on, the PMIC answers the AP's power-off by powering it back - * up, so power off turns into a restart. Google's S2MPG12 RTC driver turns - * all three off in its shutdown callback before every power off, and arms - * them again only for a restart (rtc-s2mpg12.c, s2m_rtc_shutdown()). - * Restarts are left alone here: they never needed it on gs201. + * up, so power off turns into a restart. Google's S2MPG12 and S2MPG14 RTC + * drivers turn all three off in their shutdown callbacks before every power + * off, and arm them again only for a restart (rtc-s2mpg12.c and + * rtc-s2mpg14.c, s2m_rtc_shutdown()). The S2MPG14's RTC has the same + * registers and bits. Restarts are left alone here: they never needed it + * on gs201. */ static void s5m_rtc_shutdown(struct platform_device *pdev) { struct s5m_rtc_info *info = platform_get_drvdata(pdev); int ret; - if (info->device_type != S2MPG12) + if (info->device_type != S2MPG12 && info->device_type != S2MPG14) return; if (system_state != SYSTEM_POWER_OFF && system_state != SYSTEM_HALT)