From c59065d8ba824d2bb559adea2d99cd381ee89b6e Mon Sep 17 00:00:00 2001 From: Gr-linkk <280405187+Gr-linkk@users.noreply.github.com> Date: Fri, 30 Oct 2026 18:07:39 -0700 Subject: [PATCH] rtc: s5m: read S2MPG10 alarm pending bit from STATUS2 The S2MPG10 alarm callback reads S2MPS14_REG_ST2 at offset 0x08. On S2MPG10 that offset is an interrupt mask register; alarm 0's pending bit is bit 2 of STATUS2 at offset 0x0d. The callback can therefore report the mask bit as the pending alarm state. Read S2MPG10_PMIC_STATUS2 for S2MPG10 and check the read result before using the value. Leave the other PMIC paths unchanged. Fixes: e64180846e7e ("rtc: s5m: add support for S2MPG10 RTC") Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/drivers/rtc/rtc-s2mpg10.c Link: https://android.googlesource.com/kernel/google-modules/soc/gs/+/204078758737776959ecc85c527a00fd2cabb62f/include/linux/mfd/samsung/rtc-s2mpg10.h Assisted-by: LLM Signed-off-by: Gr-linkk <280405187+Gr-linkk@users.noreply.github.com> --- drivers/rtc/rtc-s5m.c | 7 +++++++ include/linux/mfd/samsung/s2mpg10.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index c70384de63..a7c95ab3e8 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -260,6 +261,12 @@ static int s5m_check_pending_alarm_interrupt(struct s5m_rtc_info *info, val &= S2MPG12_STATUS2_RTCA0E; break; case S2MPG10: + ret = regmap_read(info->s5m87xx->regmap_pmic, S2MPG10_PMIC_STATUS2, + &val); + if (ret < 0) + return ret; + val &= S2MPG10_STATUS2_RTCA0E; + break; case S2MPS15X: case S2MPS14X: case S2MPS13X: diff --git a/include/linux/mfd/samsung/s2mpg10.h b/include/linux/mfd/samsung/s2mpg10.h index 8e5cf21cbd..50dcb77d5f 100644 --- a/include/linux/mfd/samsung/s2mpg10.h +++ b/include/linux/mfd/samsung/s2mpg10.h @@ -290,6 +290,9 @@ enum s2mpg10_pmic_reg { S2MPG10_PMIC_LDO_SENSE4, }; +/* Alarm0 pending flag in S2MPG10_PMIC_STATUS2. */ +#define S2MPG10_STATUS2_RTCA0E BIT(2) + /* Rail controlled externally, based on PCTRLSELx */ #define S2MPG10_PMIC_CTRL_ENABLE_EXT BIT(0)