From 1cbd4151f4699b247be1932e1a2073416bf70600 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Mon, 26 Oct 2026 09:22:04 -0647 Subject: [PATCH 1/2] mfd: sec: s2mpg14: Add the RTC regmap and cell 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> --- drivers/mfd/sec-acpm.c | 37 +++++++++++++++++++++++++++++ drivers/mfd/sec-common.c | 6 ++++- include/linux/mfd/samsung/s2mpg14.h | 12 ++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/sec-acpm.c b/drivers/mfd/sec-acpm.c index 05efc8cf5d..8e842d67b1 100644 --- a/drivers/mfd/sec-acpm.c +++ b/drivers/mfd/sec-acpm.c @@ -592,6 +592,7 @@ static const struct regmap_config s2mpg14_regmap_config_common = { }; static const struct regmap_range s2mpg14_pmic_rd_registers[] = { + regmap_reg_range(S2MPG14_PMIC_STATUS2, S2MPG14_PMIC_STATUS2), /* RTC alarm flag */ regmap_reg_range(S2MPG14_PMIC_L4M_CTRL, S2MPG14_PMIC_L4M_CTRL), regmap_reg_range(S2MPG14_PMIC_L8M_CTRL, S2MPG14_PMIC_L9M_CTRL), regmap_reg_range(S2MPG14_PMIC_L19M_CTRL, S2MPG14_PMIC_L19M_CTRL), @@ -624,6 +625,41 @@ static const struct regmap_config s2mpg14_regmap_config_pmic = { .wr_table = &s2mpg14_pmic_wr_table, }; +/* + * 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. + */ +static const struct regmap_range s2mpg14_rtc_rd_registers[] = { + regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_OSC_CTRL), +}; + +static const struct regmap_access_table s2mpg14_rtc_rd_table = { + .yes_ranges = s2mpg14_rtc_rd_registers, + .n_yes_ranges = ARRAY_SIZE(s2mpg14_rtc_rd_registers), +}; + +static const struct regmap_range s2mpg14_rtc_wr_registers[] = { + regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_UPDATE), + regmap_reg_range(S2MPG10_RTC_SEC, S2MPG10_RTC_A0YEAR), +}; + +static const struct regmap_access_table s2mpg14_rtc_wr_table = { + .yes_ranges = s2mpg14_rtc_wr_registers, + .n_yes_ranges = ARRAY_SIZE(s2mpg14_rtc_wr_registers), +}; + +static const struct regmap_config s2mpg14_regmap_config_rtc = { + .name = "rtc", + .reg_bits = ACPM_ADDR_BITS, + .val_bits = 8, + .max_register = S2MPG10_RTC_OSC_CTRL, + .rd_table = &s2mpg14_rtc_rd_table, + .wr_table = &s2mpg14_rtc_wr_table, + .cache_type = REGCACHE_NONE, +}; + struct sec_pmic_acpm_shared_bus_context { struct acpm_handle *acpm; unsigned int acpm_chan_id; @@ -858,6 +894,7 @@ static const struct sec_pmic_acpm_platform_data s2mpg14_data = { .speedy_channel = 0, .regmap_cfg_common = &s2mpg14_regmap_config_common, .regmap_cfg_pmic = &s2mpg14_regmap_config_pmic, + .regmap_cfg_rtc = &s2mpg14_regmap_config_rtc, .no_irq = true, }; diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c index a81ed6cb00..efb7273869 100644 --- a/drivers/mfd/sec-common.c +++ b/drivers/mfd/sec-common.c @@ -75,9 +75,13 @@ static const struct mfd_cell s2mpg13_devs[] = { MFD_CELL_OF("s2mpg13-gpio", NULL, NULL, 0, 0, "samsung,s2mpg13-gpio"), }; -/* Only the qualified LDOs; no RTC, interrupt, GPIO or protection writes. */ +/* + * The qualified LDOs and the RTC. No interrupt line is described yet, so + * the RTC keeps time without an alarm; no GPIO or protection writes. + */ static const struct mfd_cell s2mpg14_devs[] = { MFD_CELL_NAME("s2mpg14-regulator"), + MFD_CELL_NAME("s2mpg14-rtc"), }; static const struct resource s2mps11_rtc_resources[] = { diff --git a/include/linux/mfd/samsung/s2mpg14.h b/include/linux/mfd/samsung/s2mpg14.h index f553fac55d..b09785f0d9 100644 --- a/include/linux/mfd/samsung/s2mpg14.h +++ b/include/linux/mfd/samsung/s2mpg14.h @@ -6,7 +6,10 @@ #ifndef __LINUX_MFD_S2MPG14_H #define __LINUX_MFD_S2MPG14_H +#include + #define S2MPG14_COMMON_CHIPID 0x0b +#define S2MPG14_PMIC_STATUS2 0x0b #define S2MPG14_PMIC_L4M_CTRL 0x2e #define S2MPG14_PMIC_L8M_CTRL 0x32 #define S2MPG14_PMIC_L9M_CTRL 0x33 @@ -14,4 +17,13 @@ #define S2MPG14_PMIC_L25M_CTRL 0x43 #define S2MPG14_PMIC_LDO_CTRL1 0x44 +/* S2MPG14_PMIC_STATUS2: the alarm flag sits where it does on S2MPG12 */ +#define S2MPG14_STATUS2_RTCA0E BIT(2) + +/* + * The RTC block has S2MPG10's register layout (S2MPG10_RTC_* in rtc.h): + * CTRL at 0x00 through OSC_CTRL at 0x1b, then two nonces to 0x2b and + * five scratch registers to 0x30. + */ + #endif /* __LINUX_MFD_S2MPG14_H */ From 6a999334466c265811f793d107c5d3dd1fb73abe Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Mon, 26 Oct 2026 09:22:04 -0647 Subject: [PATCH 2/2] rtc: s5m: Add S2MPG14 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> --- drivers/rtc/rtc-s5m.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index 27faa7f6a0..63bdc74191 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* @@ -259,6 +260,11 @@ static int s5m_check_pending_alarm_interrupt(struct s5m_rtc_info *info, &val); val &= S2MPG12_STATUS2_RTCA0E; break; + case S2MPG14: + ret = regmap_read(info->s5m87xx->regmap_pmic, S2MPG14_PMIC_STATUS2, + &val); + val &= S2MPG14_STATUS2_RTCA0E; + break; case S2MPG10: case S2MPS15X: case S2MPS14X: @@ -309,6 +315,7 @@ static int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info) break; case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -361,6 +368,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm) case S5M8767X: case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -386,6 +394,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm) case S5M8767X: case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -425,6 +434,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) case S5M8767X: case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -465,6 +475,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info) case S5M8767X: case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -505,6 +516,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info) case S5M8767X: case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -544,6 +556,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) case S5M8767X: case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -626,6 +639,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info) case S2MPG10: case S2MPG12: + case S2MPG14: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -726,8 +740,9 @@ static int s5m_rtc_probe(struct platform_device *pdev) if (IS_ERR(info->regmap)) return dev_err_probe(&pdev->dev, PTR_ERR(info->regmap), "Failed to allocate regmap\n"); - } else if (device_type == S2MPG10 || device_type == S2MPG12) { - /* S2MPG12's RTC has the same registers as S2MPG10's */ + } else if (device_type == S2MPG10 || device_type == S2MPG12 || + device_type == S2MPG14) { + /* S2MPG12's and S2MPG14's RTCs have S2MPG10's registers */ info->regs = &s2mpg10_rtc_regs; } else { return dev_err_probe(&pdev->dev, -ENODEV, @@ -825,6 +840,7 @@ static const struct platform_device_id s5m_rtc_id[] = { { .name = "s5m-rtc", .driver_data = S5M8767X }, { .name = "s2mpg10-rtc", .driver_data = S2MPG10 }, { .name = "s2mpg12-rtc", .driver_data = S2MPG12 }, + { .name = "s2mpg14-rtc", .driver_data = S2MPG14 }, { .name = "s2mps13-rtc", .driver_data = S2MPS13X }, { .name = "s2mps14-rtc", .driver_data = S2MPS14X }, { .name = "s2mps15-rtc", .driver_data = S2MPS15X },