From: Shiv Prakash Gupta <shivprakash.gupta@nxp.com>
To: linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-watchdog@vger.kernel.org,
devicetree@vger.kernel.org, alexandre.belloni@bootlin.com,
krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org,
linux@roeck-us.net, wim@linux-watchdog.org
Cc: vikash.bansal@nxp.com, priyanka.jain@nxp.com,
lakshay.piplani@nxp.com,
Shiv Prakash Gupta <shivprakash.gupta@nxp.com>
Subject: [PATCH v5 0/4] rtc: Add NXP PCF8525 RTC support
Date: Thu, 26 Nov 2026 12:41:20 +0530 [thread overview]
Message-ID: <20261126071124.2383368-1-shivprakash.gupta@nxp.com> (raw)
The PCF8525 is an NXP I2C real-time clock using an external
32.768-kHz crystal. It provides alarms, external timestamp capture,
recording of the last calendar write, backup battery switch-over,
a hardware watchdog timer, and an on-chip temperature sensor.
This series introduces DT bindings, the core RTC driver, watchdog
support, and optional hardware-monitoring (temperature readout) via
the hwmon subsystem.
Changes in v5:
- Remove the reset-source property and its example entry from the
binding; watchdog expiry is reported through INTB as an alarm-only
watchdog.
- Remove the quartz-load-femtofarads property, as the crystal load
capacitance is fixed and Control_5 bit 1 is reserved. Allow a single
named inta or intb interrupt, or both in the order inta, intb, and
use level-low interrupts in the example.
- Reject wakeup-source in the binding when only the intb interrupt is
described, as the wakeup line is INTA.
- Program and read back the month and year alarm fields using the
Rev. 3.0 alarm enable bit positions, and keep the alarm interrupt
disabled while the alarm is rewritten.
- Use one helper for the CTRL2 write-0-to-clear flags.
- Mask the unused INTA sources and drain stale TSF/AF/MSF flags before
unmasking INTA, failing probe if the drain fails. The runtime
handler uses the same bounded drain and no longer claims an event
whose acknowledge failed.
- Propagate I2C errors from the Timestamp1 read; only an invalid or
empty timestamp is acknowledged so INTA cannot stay stuck low.
- Refresh the OTP after setting the time clears the oscillator-stop
flag, even if clearing STOP fails.
- When interrupt-names is present, do not take INTA from the first
interrupt if only INTB is named.
- Use RTC_FEATURE_ALARM_WAKEUP_ONLY when only wakeup is wired, and do
not repeat the wakeup setup the I2C core already did.
- Set up wakeup before registering the RTC so that wakealarm is exposed
without a wakeup-source property.
- Apply the start-year offset to the sysfs timestamps, make timestamp1
read-only, and clear just TSF on a timestamp0 write instead of
issuing the CTS command.
- Rate-limit the VLF and interrupt warnings, and use devm_mutex_init(),
guard(mutex) and the regmap bit helpers.
- Register the watchdog only when the INTB interrupt is described,
advertise WDIOF_ALARMONLY and clear WDTF in the handler.
- Mask all INTB sources before touching watchdog state, start from a
stopped counter with the 1/4 Hz source, clear a stale WDTF and
switch the nINTB pin last; on start, load the counter before
enabling WD_CD and unmasking INTB, undoing it on error.
- Keep the watchdog counter and WD_CD across suspend and only mask the
INTB route, re-arming on resume. On teardown leave the INTB route
intact if the watchdog is still running (nowayout).
- Clear TEMP_RD_EN to enable the digital temperature readout, and drop
the cleanup action since the bit only gates the readout register.
- Select the closest supported update_interval instead of failing with
-EINVAL.
Changes in v4:
- Rework timestamp handling to serialize sysfs clear and IRQ
processing, read Timestamp1 before clearing TSF, and restore TSM
after the CTS command.
- Correct Timestamp2 handling to report the last calendar write
instead of treating it as a second external timestamp capture.
- Rework the INTA threaded IRQ handler to drain pending AF/MSF/TSF
events and re-read status registers, avoiding missed events on an
edge-triggered IRQ.
- Preserve all CTRL2 Write-0-to-Clear status flags, including WDTF,
across register read-modify-write operations.
- Rework watchdog support to use nINTB as the watchdog output without
a Linux watchdog IRQ or pretimeout notification; remove unsupported
pretimeout handling and write-only watchdog-value read.
- Establish a known watchdog state at probe, clear stale WDTF before
enabling the watchdog output, and report the hardware-achieved
timeout.
- Fix RTC feature and time-setting handling, including
update-interrupt capability reporting and writing the
hundredths-of-a-second register when setting the calendar.
- Improve interrupt/wakeup and device-managed cleanup ordering so
hardware interrupt sources are safely masked on probe failure and
driver removal.
- Rework hwmon registration and power-management handling so the
temperature readout is enabled before exposure to userspace and
cleanly disabled on failure, suspend, and removal.
Changes in v3:
- patch 2: protect the Write-0-to-Clear (W0C) status flags in the
CTRL2/CTRL3 read-modify-write cycles so concurrently asserted
interrupt events are not silently cleared
- patch 2: replace the timestamp spinlock with a mutex and re-read
CTRL4 under it, closing the TOCTOU race between the threaded IRQ
handler and the sysfs timestamp store
- patch 3: configure the nINTB/CLKOUT pin (CLKOE=0) before requesting
the watchdog IRQ to avoid a spurious interrupt storm
- patch 3: add suspend/resume PM ops to stop and re-ping the watchdog
across system sleep
- patch 3: add WDIOF_PRETIMEOUT so the watchdog core attaches a
pretimeout governor
- patch 3: re-mask INTA/INTB interrupts on driver unbind via devm
cleanup actions
- patch 4: enable TEMP_RD_EN before registering the hwmon device and
add a devm cleanup to disable it on unbind
Changes in v2:
- Fix include: use <linux/pm_wakeirq.h> instead of <pm_wakeup.h>
- Add spinlock_t ts_lock to protect ts[]/ts_valid[] from IRQ/sysfs race
- Fix W0C ordering: clear AF/TSF flags before acting on alarm/timestamp
events
- Use dev_pm_set_wake_irq() for suspend wakeup wiring
- Clear stale WDTF before unmasking watchdog interrupt on INTB to prevent
boot loop when battery-backed flag persists across resets
- Add watchdog_notify_pretimeout() call in INTB IRQ handler
- Set WDOG_HW_RUNNING if bootloader left watchdog running at probe time
- Register hwmon device first, then enable PCF8525_CTRL5_TEMP_RD_EN only
after successful registration
Shiv Prakash Gupta (4):
dt-bindings: rtc: Add NXP PCF8525 RTC
rtc: pcf8525: Add NXP PCF8525 RTC driver
rtc: pcf8525: Add watchdog support
rtc: pcf8525: Add temperature sensor support via hwmon
.../devicetree/bindings/rtc/nxp,pcf8525.yaml | 88 ++
MAINTAINERS | 8 +
drivers/rtc/Kconfig | 24 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-pcf8525.c | 1404 +++++++++++++++++
5 files changed, 1525 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/nxp,pcf8525.yaml
create mode 100644 drivers/rtc/rtc-pcf8525.c
--
2.34.1
next reply other threads:[~2026-11-26 7:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 7:11 Shiv Prakash Gupta [this message]
2026-11-26 7:11 ` [PATCH v5 1/4] dt-bindings: rtc: Add NXP PCF8525 RTC Shiv Prakash Gupta
2026-11-26 7:11 ` [PATCH v5 2/4] rtc: pcf8525: Add NXP PCF8525 RTC driver Shiv Prakash Gupta
2026-11-26 7:11 ` [PATCH v5 3/4] rtc: pcf8525: Add watchdog support Shiv Prakash Gupta
2026-11-26 7:11 ` [PATCH v5 4/4] rtc: pcf8525: Add temperature sensor support via hwmon Shiv Prakash Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126071124.2383368-1-shivprakash.gupta@nxp.com \
--to=shivprakash.gupta@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lakshay.piplani@nxp.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=priyanka.jain@nxp.com \
--cc=robh@kernel.org \
--cc=vikash.bansal@nxp.com \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®