From 3b6cdc36553b1fe627f782a7f5efe5ffc806faa1 Mon Sep 17 00:00:00 2001 From: Imre Kaloz Date: Tue, 13 Oct 2026 14:02:08 +0200 Subject: [PATCH] rtc: ds1685: keep setting PAB until power is removed A kickstart or wake-up flag set while its interrupt is enabled (KF with KSE, WF with WIE) clears PAB, and the system stays powered. Clear the event flags together with setting PAB, and repeat the write until power is gone. Signed-off-by: Imre Kaloz Acked-by: Joshua Kinard Link: https://patch.msgid.link/20261013120208.11268-4-kaloz@kernel.org Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ds1685.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c index 1c84c5debca1..220a8b15d15f 100644 --- a/drivers/rtc/rtc-ds1685.c +++ b/drivers/rtc/rtc-ds1685.c @@ -1423,15 +1423,21 @@ ds1685_rtc_poweroff(struct platform_device *pdev) rtc->write(rtc, RTC_EXT_CTRL_4B, ctrl4b); } - /* Set PAB to 1 in Control 4A to power the system down. */ + /* + * Set PAB to 1 in Control 4A to power the system down. PAB + * is cleared again while KF and KSE, or WF and WIE, are set, + * so keep clearing the flags and setting PAB until power is + * gone. We do not switch back to bank0. + */ dev_warn(&pdev->dev, "Powerdown.\n"); mdelay(20); - rtc->write(rtc, RTC_EXT_CTRL_4A, - (ctrl4a | RTC_CTRL_4A_PAB)); - - /* Spin ... we do not switch back to bank0. */ - while(1); - unreachable(); + while (1) { + ctrl4a = rtc->read(rtc, RTC_EXT_CTRL_4A); + rtc->write(rtc, RTC_EXT_CTRL_4A, + (ctrl4a & ~RTC_CTRL_4A_RWK_MASK) | + RTC_CTRL_4A_PAB); + mdelay(100); + } } } EXPORT_SYMBOL_GPL(ds1685_rtc_poweroff);