[PATCH v3 0/4] rtc: mt6397: Enhance RTC driver with BBPU alarm status handling

From: Dhatrisri Anumula

Date: Tue May 26 2026 - 03:43:03 EST


From: Shunxi Zhang <ot_shunxi.zhang@xxxxxxxxxxxx>

This patch series enhances the MediaTek MT6397 RTC driver to properly
handle BBPU (Battery-Backed Power Unit) alarm status, addressing critical
power management issues where:

1. The RTC BBPU alarm state remains active after an alarm event occurs,
causing the IRQ handler to be triggered repeatedly
2. Systems unexpectedly power on after shutdown because the RTC alarm
state was not cleared during the shutdown sequence

The series adds necessary bit definitions to the RTC header, implements
alarm status reset functionality in the interrupt handler, and adds a
shutdown handler to ensure clean power-down behavior.

Changes in v3:
- Removed standalone cosmetic formatting patch per maintainer feedback
- Removed devicetree property "mediatek,alarm-sta-supported" approach
- Removed alarm_sta_supported flag and conditional checks
- Execute mtk_rtc_reset_bbpu_alarm_status() unconditionally (PMIC-driven)
- Fixed commit messages to use imperative mood throughout
- Validated all patches with checkpatch.pl --strict
- Validated DTS changes with 'make dtbs_check W=1'
- Addressed all review comments from Krzysztof Kozlowski,
AngeloGioacchino Del Regno, and Alexandre Belloni

Changes in v2:
- Initial public submission to LKML
- Added DT property for alarm status support (approach rejected)
- Added cosmetic formatting changes (rejected)

Testing:
- Tested on MT6359 PMIC with MT8189 platform (ChromeOS)
- Verified RTC alarm triggering and proper status clearing
- Verified system shutdown behavior with pending alarm
- Validated against mainline v6.16-rc1
- Passed dtbs_check and dt_binding_check

Background:
The MT6397 family of PMICs (including MT6358, MT6359) share the same
RTC IP block. The BBPU register contains an alarm status bit (bit 3)
that must be explicitly cleared after an alarm event. Without this
handling, systems can experience spurious wakeups or fail to power
down cleanly.

Shunxi Zhang (4):
dt-bindings: rtc: mediatek: Document MT6397 RTC alarm handling
mfd: mt6397: Add BBPU bit definitions for alarm status control
rtc: mt6397: Add BBPU alarm status reset and shutdown handling
arm64: dts: mediatek: mt6359: Enable RTC alarm status reset

.../bindings/rtc/mediatek,mt6397-rtc.yaml | 12 ++++++++
arch/arm64/boot/dts/mediatek/mt6359.dtsi | 1 +
drivers/rtc/rtc-mt6397.c | 30 +++++++++++++++++++
include/linux/mfd/mt6397/rtc.h | 2 ++
4 files changed, 45 insertions(+)

---
Maintainers CC list (use scripts/get_maintainer.pl):
- Alessandro Zummo <a.zummo@xxxxxxxxxxxx> (RTC maintainer)
- Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx> (RTC maintainer)
- Lee Jones <lee@xxxxxxxxxx> (MFD maintainer)
- Matthias Brugger <matthias.bgg@xxxxxxxxx> (MediaTek maintainer)
- AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx> (MediaTek reviewer)
- linux-rtc@xxxxxxxxxxxxxxx
- linux-mediatek@xxxxxxxxxxxxxxxxxxx
- linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
- linux-kernel@xxxxxxxxxxxxxxx

base-commit: <your-base-commit-hash>
--
2.45.2