[PATCH 0/2] rtc: mt6397: expose the RTC's spare bytes as nvmem

From: Ryan Brue

Date: Fri Sep 18 2026 - 00:58:06 EST


Four of the MT6397 RTC's alarm registers use only their low bits. Each alarm
field lives in the low byte of its own register and the driver masks its
writes accordingly, so the high byte of four of them is storage the clock and
the alarm never touch. MediaTek's documentation names them RTC_NEW_SPARE0 to
RTC_NEW_SPARE3 and assigns the first to a fuel gauge, which is how its PMIC
battery drivers carry a state of charge across a reboot.

These patches describe that layout in the binding and expose all four bytes
from the RTC driver as a battery-backed nvmem provider. Doing it here rather
than in the consumer is the point: a write then lands under the same lock the
alarm paths take, so it can neither be lost inside mtk_rtc_set_alarm()'s
read-modify-write nor fire the write trigger in the middle of one.

There is no in-tree consumer yet. The one this is for is an MT6397 fuel gauge
that is not ready to post; its other dependency, the MT6397 PMIC AUXADC, is
on the list now [1]. Offering the provider ahead of the consumer follows what
the subsystem already does -- 32 drivers under drivers/rtc register nvmem --
and it is the part that has to exist before a battery driver can stop reaching
into this block behind the RTC's back.

Tested on an MT6397, in an Amazon Fire HD 10 (2017). MediaTek's spare map for
the mt6323 matches, and the alarm field masks are common to every compatible
this driver binds.

[1] https://lore.kernel.org/all/20260917-rbrue-suez-upstreaming-mt6397-auxadc-v2-0-db35882a6080@xxxxxxxxx/

Signed-off-by: Ryan Brue <ryanbrue.dev@xxxxxxxxx>
---
Ryan Brue (2):
dt-bindings: mfd: mediatek: mt6397: describe the RTC's nvmem layout
rtc: mt6397: expose the spare bytes of the alarm registers as nvmem

.../devicetree/bindings/mfd/mediatek,mt6397.yaml | 9 +++
drivers/rtc/rtc-mt6397.c | 91 +++++++++++++++++++++-
include/linux/mfd/mt6397/rtc.h | 7 ++
3 files changed, 106 insertions(+), 1 deletion(-)
---
base-commit: fd73f4a6659897191fa0d40695fe370925dd3780
change-id: 20260917-rbrue-suez-upstreaming-mt6397-rtc-nvmem-ee2a326ad7f2

Best regards,
--
Ryan Brue <ryanbrue.dev@xxxxxxxxx>