| Message ID | 20251121121137.3043764-2-lakshay.piplani@nxp.com |
|---|---|
| State | Superseded |
| Delegated to: | Alexandre Belloni |
| Headers | show |
| Series | [v4,1/5] dt-bindings: rtc: nxp,pcf85363: add timestamp mode config | expand |
> -----Original Message----- > From: Lakshay Piplani <lakshay.piplani@nxp.com> > Sent: Friday, November 21, 2025 5:42 PM > To: alexandre.belloni@bootlin.com; linux-rtc@vger.kernel.org; linux- > kernel@vger.kernel.org; robh@kernel.org; krzk+dt@kernel.org; > conor+dt@kernel.org; devicetree@vger.kernel.org; wim@linux-watchdog.org; > linux@roeck-us.net; linux-watchdog@vger.kernel.org > Cc: Vikash Bansal <vikash.bansal@nxp.com>; Priyanka Jain > <priyanka.jain@nxp.com>; Shashank Rebbapragada > <shashank.rebbapragada@nxp.com>; Lakshay Piplani > <lakshay.piplani@nxp.com> > Subject: [PATCH v4 2/5] rtc: pcf85363: support reporting battery switch-over > via RTC_VL > > Add battery switch-over reporting for PCF85263/PCF85363 using the standard > RTC_VL_* ioctl interface. When the backup supply takes over, the BSF flag is > exposed to userspace through RTC_VL_READ and can be cleared using > RTC_VL_CLR. > > This allows applications to detect loss of main power without relying on non- > standard interfaces. > > Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com> > --- > V3 -> V4: > - No changes in v4. > V2 -> V3: > - Split into separate patches as suggested: > - Battery switch-over detection. > - Timestamp recording for TS pin and battery switch-over events. > - Offset calibration. > - Watchdog timer (to be reviewed by watchdog maintainers). > - Dropped Alarm2 support > - Switched to rtc_add_group() for sysfs attributes > V1 -> V2: > - Watchdog related changes due to removal of vendor specific properties > from device tree > * remove vendor DT knobs (enable/timeout/stepsize/repeat) > * use watchdog_init_timeout (with 10s default) > * derive clock_sel from final timeout > * default, repeat=true (repeat mode) > - Fixed uninitalised warning on 'ret' (reported by kernel test robot) > - Use dev_dbg instead of dev_info for debug related print messages > - Minor cleanup and comments. > > drivers/rtc/rtc-pcf85363.c | 49 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 47 insertions(+), 2 deletions(-) > Hi, I'm sending a gentle reminder regarding the patches that I submitted in November. I haven't received any review comments yet, so I'd really appreciate it if you could have a look whenever you have some time. Best Regards Lakshay Piplani
> > Hi, > > I'm sending a gentle reminder regarding the patches that I submitted in > November. > I haven't received any review comments yet, so I'd really appreciate it if you > could have a look whenever you have some time. > > Best Regards > Lakshay Piplani Hi, I hope you're doing well. This is a gentle follow-up regarding the v4 patch series for the PCF85363 RTC driver that I submitted in November 2025. I understand things can get busy, but I haven't seen any feedback on the series yet, so I wanted to check if you've had a chance to review it. I'd be happy to make any updates if needed. Please let me know if there's anything required from my side to move this forward. Thanks in advance for your time and feedback. Best regards, Lakshay Piplani
diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c index 540042b9eec8..c03d5a65c5f7 100644 --- a/drivers/rtc/rtc-pcf85363.c +++ b/drivers/rtc/rtc-pcf85363.c @@ -14,6 +14,7 @@ #include <linux/err.h> #include <linux/errno.h> #include <linux/bcd.h> +#include <linux/device.h> #include <linux/of.h> #include <linux/regmap.h> @@ -295,23 +296,67 @@ static int pcf85363_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) static irqreturn_t pcf85363_rtc_handle_irq(int irq, void *dev_id) { struct pcf85363 *pcf85363 = i2c_get_clientdata(dev_id); + bool handled = false; unsigned int flags; int err; err = regmap_read(pcf85363->regmap, CTRL_FLAGS, &flags); + if (err) return IRQ_NONE; + if (flags) { + dev_dbg(&pcf85363->rtc->dev, "IRQ flags: 0x%02x%s%s\n", + flags, (flags & FLAGS_A1F) ? " [A1F]" : "", + (flags & FLAGS_BSF) ? " [BSF]" : ""); + } + if (flags & FLAGS_A1F) { rtc_update_irq(pcf85363->rtc, 1, RTC_IRQF | RTC_AF); regmap_update_bits(pcf85363->regmap, CTRL_FLAGS, FLAGS_A1F, 0); - return IRQ_HANDLED; + handled = true; } - return IRQ_NONE; + if (flags & FLAGS_BSF) { + regmap_update_bits(pcf85363->regmap, CTRL_FLAGS, FLAGS_BSF, 0); + handled = true; + } + + return handled ? IRQ_HANDLED : IRQ_NONE; +} + +static int pcf85363_rtc_ioctl(struct device *dev, + unsigned int cmd, unsigned long arg) +{ + struct pcf85363 *pcf85363 = dev_get_drvdata(dev); + unsigned int val; + int ret; + + switch (cmd) { + case RTC_VL_READ: { + u32 status = 0; + + ret = regmap_read(pcf85363->regmap, CTRL_FLAGS, &val); + + if (ret) + return ret; + + if (val & FLAGS_BSF) + status |= RTC_VL_BACKUP_SWITCH; + + return put_user(status, (u32 __user *)arg); + } + + case RTC_VL_CLR: + return regmap_update_bits(pcf85363->regmap, CTRL_FLAGS, FLAGS_BSF, 0); + + default: + return -ENOIOCTLCMD; + } } static const struct rtc_class_ops rtc_ops = { + .ioctl = pcf85363_rtc_ioctl, .read_time = pcf85363_rtc_read_time, .set_time = pcf85363_rtc_set_time, .read_alarm = pcf85363_rtc_read_alarm,
Add battery switch-over reporting for PCF85263/PCF85363 using the standard RTC_VL_* ioctl interface. When the backup supply takes over, the BSF flag is exposed to userspace through RTC_VL_READ and can be cleared using RTC_VL_CLR. This allows applications to detect loss of main power without relying on non-standard interfaces. Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com> --- V3 -> V4: - No changes in v4. V2 -> V3: - Split into separate patches as suggested: - Battery switch-over detection. - Timestamp recording for TS pin and battery switch-over events. - Offset calibration. - Watchdog timer (to be reviewed by watchdog maintainers). - Dropped Alarm2 support - Switched to rtc_add_group() for sysfs attributes V1 -> V2: - Watchdog related changes due to removal of vendor specific properties from device tree * remove vendor DT knobs (enable/timeout/stepsize/repeat) * use watchdog_init_timeout (with 10s default) * derive clock_sel from final timeout * default, repeat=true (repeat mode) - Fixed uninitalised warning on 'ret' (reported by kernel test robot) - Use dev_dbg instead of dev_info for debug related print messages - Minor cleanup and comments. drivers/rtc/rtc-pcf85363.c | 49 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)