public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset
@ 2026-01-19  9:51 Tomas Melin
  2026-01-19  9:51 ` [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch Tomas Melin
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19  9:51 UTC (permalink / raw)
  To: Alexandre Belloni, Michal Simek
  Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin,
	kernel test robot, Harini T

Add improvements for read and set offset functions.
The basic functionality is still the same, but offset correction values
are now updated to match with expected.

The RTC calibration value operates with full ticks,
and fractional ticks which are a 1/16 of a full tick.
The 16 lowest bits in the calibration registers are for the full ticks
and value matches the external oscillator in Hz. Through that,
the maximum and minimum offset values can be calculated dynamically,
as they depend on the input frequency used.

For docs on the calibration register, see
https://docs.amd.com/r/en-US/ug1087-zynq-ultrascale-registers/CALIB_READ-RTC-Register

Due to rounding errors (different number of fract ticks),
offset readback will differ slightly depending on
if the offset is negative or positive. This is however well below the granularity
provided by the hardware.

For example
$ echo 34335 > offset 
$ cat offset 
34335
$ echo -34335 > offset 
$ cat offset 
-34326

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
Changes in v3:
- Add commit for limiting building of driver to zynqmp arch.
- Reorder variable declarations in set_offset
- Link to v2: https://lore.kernel.org/r/20260108-zynqmp-rtc-updates-v2-0-864c161fa83d@vaisala.com

Changes in v2:
- Add commit introducing check for calibration value overflow
- Update comments
- Align data types across set and read
- Rename fract_tick as fract_data conforming to data sheet
- Further improve on set offset calculation logic
- Link to v1: https://lore.kernel.org/r/20251201-zynqmp-rtc-updates-v1-0-33875c1e385b@vaisala.com

---
Tomas Melin (6):
      rtc: zynqmp: declare dependency on arch
      rtc: zynqmp: correct frequency value
      rtc: zynqmp: check calibration max value
      rtc: zynqmp: rework read_offset
      rtc: zynqmp: rework set_offset
      rtc: zynqmp: use dynamic max and min offset ranges

 drivers/rtc/Kconfig      |  2 +-
 drivers/rtc/rtc-zynqmp.c | 74 ++++++++++++++++++++++++++----------------------
 2 files changed, 41 insertions(+), 35 deletions(-)
---
base-commit: cd635e33b0113287c94021be53d2a7c61a1614e9
change-id: 20251201-zynqmp-rtc-updates-d260364cc01b

Best regards,
-- 
Tomas Melin <tomas.melin@vaisala.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-01-22 12:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19  9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
2026-01-19  9:51 ` [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch Tomas Melin
2026-01-21 12:11   ` Michal Simek
2026-01-21 12:16   ` Michal Simek
2026-01-22 12:25     ` Tomas Melin
2026-01-22 12:38       ` Michal Simek
2026-01-19  9:51 ` [PATCH v3 2/6] rtc: zynqmp: correct frequency value Tomas Melin
2026-01-19  9:51 ` [PATCH v3 3/6] rtc: zynqmp: check calibration max value Tomas Melin
2026-01-19  9:51 ` [PATCH v3 4/6] rtc: zynqmp: rework read_offset Tomas Melin
2026-01-19  9:51 ` [PATCH v3 5/6] rtc: zynqmp: rework set_offset Tomas Melin
2026-01-19  9:51 ` [PATCH v3 6/6] rtc: zynqmp: use dynamic max and min offset ranges Tomas Melin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox