* [PATCH v4 1/5] rtc: zynqmp: correct frequency value
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
@ 2026-01-22 13:53 ` Tomas Melin
2026-01-22 13:53 ` [PATCH v4 2/5] rtc: zynqmp: check calibration max value Tomas Melin
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Melin @ 2026-01-22 13:53 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
Fix calibration value in case a clock reference is provided.
The actual calibration value written into register is
frequency - 1.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 3baa2b481d9f2008750046005283b98a0d546c5c..856bc1678e7d31144f320ae9f75fc58c742a2a64 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -345,7 +345,10 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
&xrtcdev->freq);
if (ret)
xrtcdev->freq = RTC_CALIB_DEF;
+ } else {
+ xrtcdev->freq--;
}
+
ret = readl(xrtcdev->reg_base + RTC_CALIB_RD);
if (!ret)
writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR));
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v4 2/5] rtc: zynqmp: check calibration max value
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
2026-01-22 13:53 ` [PATCH v4 1/5] rtc: zynqmp: correct frequency value Tomas Melin
@ 2026-01-22 13:53 ` Tomas Melin
2026-01-22 13:53 ` [PATCH v4 3/5] rtc: zynqmp: rework read_offset Tomas Melin
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Melin @ 2026-01-22 13:53 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
Enable check to not overflow the calibration
max value.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 856bc1678e7d31144f320ae9f75fc58c742a2a64..caacce3725e2ef3803ea42d40e77ceaeb7d7b914 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -349,6 +349,11 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
xrtcdev->freq--;
}
+ if (xrtcdev->freq > RTC_TICK_MASK) {
+ dev_err(&pdev->dev, "Invalid RTC calibration value\n");
+ return -EINVAL;
+ }
+
ret = readl(xrtcdev->reg_base + RTC_CALIB_RD);
if (!ret)
writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR));
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v4 3/5] rtc: zynqmp: rework read_offset
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
2026-01-22 13:53 ` [PATCH v4 1/5] rtc: zynqmp: correct frequency value Tomas Melin
2026-01-22 13:53 ` [PATCH v4 2/5] rtc: zynqmp: check calibration max value Tomas Melin
@ 2026-01-22 13:53 ` Tomas Melin
2026-01-22 13:53 ` [PATCH v4 4/5] rtc: zynqmp: rework set_offset Tomas Melin
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Melin @ 2026-01-22 13:53 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
read_offset() was using static frequency for determining
the tick offset. It was also using remainder from do_div()
operation as tick_mult value which caused the offset to be
incorrect.
At the same time, rework function to improve readability.
It is worth noting, that due to rounding errors, the offset
readback will differ slightly for positive and negative
calibration values.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index caacce3725e2ef3803ea42d40e77ceaeb7d7b914..c82f4d490fc7ebb5876b820182f5e79a99e496a8 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -43,7 +43,7 @@
#define RTC_MSEC 1000
#define RTC_FR_MASK 0xF0000
#define RTC_FR_MAX_TICKS 16
-#define RTC_PPB 1000000000LL
+#define RTC_PPB 1000000000
#define RTC_MIN_OFFSET -32768000
#define RTC_MAX_OFFSET 32767000
@@ -178,21 +178,28 @@ static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev)
static int xlnx_rtc_read_offset(struct device *dev, long *offset)
{
struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
- unsigned long long rtc_ppb = RTC_PPB;
- unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
- unsigned int calibval;
+ unsigned int calibval, fract_data, fract_part;
+ int freq = xrtcdev->freq;
+ int max_tick, tick_mult;
long offset_val;
+ /* Tick to offset multiplier */
+ tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, freq);
+
calibval = readl(xrtcdev->reg_base + RTC_CALIB_RD);
/* Offset with seconds ticks */
- offset_val = calibval & RTC_TICK_MASK;
- offset_val = offset_val - RTC_CALIB_DEF;
- offset_val = offset_val * tick_mult;
+ max_tick = calibval & RTC_TICK_MASK;
+ offset_val = max_tick - freq;
+ /* Convert to ppb */
+ offset_val *= tick_mult;
/* Offset with fractional ticks */
- if (calibval & RTC_FR_EN)
- offset_val += ((calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT)
- * (tick_mult / RTC_FR_MAX_TICKS);
+ if (calibval & RTC_FR_EN) {
+ fract_data = (calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT;
+ fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
+ offset_val += (fract_part * fract_data);
+ }
+
*offset = offset_val;
return 0;
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v4 4/5] rtc: zynqmp: rework set_offset
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (2 preceding siblings ...)
2026-01-22 13:53 ` [PATCH v4 3/5] rtc: zynqmp: rework read_offset Tomas Melin
@ 2026-01-22 13:53 ` Tomas Melin
2026-01-29 9:33 ` T, Harini
2026-01-22 13:53 ` [PATCH v4 5/5] rtc: zynqmp: use dynamic max and min offset ranges Tomas Melin
` (3 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Tomas Melin @ 2026-01-22 13:53 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
set_offset was using remainder of do_div as tick_mult which resulted in
wrong offset. Calibration value also assumed builtin calibration default.
Update fract_offset to correctly calculate the value for
negative offset and replace the for loop with division.
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index c82f4d490fc7ebb5876b820182f5e79a99e496a8..f0f5dc63e254799ed99927c259c767b30ee877a4 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -208,13 +208,13 @@ static int xlnx_rtc_read_offset(struct device *dev, long *offset)
static int xlnx_rtc_set_offset(struct device *dev, long offset)
{
struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
- unsigned long long rtc_ppb = RTC_PPB;
- unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
- unsigned char fract_tick = 0;
+ int max_tick, tick_mult, fract_offset, fract_part;
+ int freq = xrtcdev->freq;
unsigned int calibval;
- short int max_tick;
- int fract_offset;
+ int fract_data = 0;
+ /* Tick to offset multiplier */
+ tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, freq);
if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
return -ERANGE;
@@ -223,29 +223,22 @@ static int xlnx_rtc_set_offset(struct device *dev, long offset)
/* Number fractional ticks for given offset */
if (fract_offset) {
- if (fract_offset < 0) {
- fract_offset = fract_offset + tick_mult;
+ fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
+ fract_data = fract_offset / fract_part;
+ /* Subtract one from max_tick while adding fract_offset */
+ if (fract_offset < 0 && fract_data) {
max_tick--;
- }
- if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
- for (fract_tick = 1; fract_tick < 16; fract_tick++) {
- if (fract_offset <=
- (fract_tick *
- (tick_mult / RTC_FR_MAX_TICKS)))
- break;
- }
+ fract_data += RTC_FR_MAX_TICKS;
}
}
/* Zynqmp RTC uses second and fractional tick
* counters for compensation
*/
- calibval = max_tick + RTC_CALIB_DEF;
-
- if (fract_tick)
- calibval |= RTC_FR_EN;
+ calibval = max_tick + freq;
- calibval |= (fract_tick << RTC_FR_DATSHIFT);
+ if (fract_data)
+ calibval |= (RTC_FR_EN | (fract_data << RTC_FR_DATSHIFT));
writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* RE: [PATCH v4 4/5] rtc: zynqmp: rework set_offset
2026-01-22 13:53 ` [PATCH v4 4/5] rtc: zynqmp: rework set_offset Tomas Melin
@ 2026-01-29 9:33 ` T, Harini
0 siblings, 0 replies; 10+ messages in thread
From: T, Harini @ 2026-01-29 9:33 UTC (permalink / raw)
To: Tomas Melin, Alexandre Belloni, Simek, Michal
Cc: linux-rtc, linux-arm-kernel, linux-kernel
[Public]
Reviewed-by: Harini T <harini.t@amd.com>
> -----Original Message-----
> From: Tomas Melin <tomas.melin@vaisala.com>
> Sent: Thursday, January 22, 2026 7:24 PM
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Simek, Michal
> <michal.simek@amd.com>
> Cc: linux-rtc@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; Tomas Melin <tomas.melin@vaisala.com>; T, Harini
> <Harini.T@amd.com>
> Subject: [PATCH v4 4/5] rtc: zynqmp: rework set_offset
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> set_offset was using remainder of do_div as tick_mult which resulted in
> wrong offset. Calibration value also assumed builtin calibration default.
> Update fract_offset to correctly calculate the value for negative offset and
> replace the for loop with division.
>
> Tested-by: Harini T <harini.t@amd.com>
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> ---
> drivers/rtc/rtc-zynqmp.c | 33 +++++++++++++--------------------
> 1 file changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c index
> c82f4d490fc7ebb5876b820182f5e79a99e496a8..f0f5dc63e254799ed99927c25
> 9c767b30ee877a4 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -208,13 +208,13 @@ static int xlnx_rtc_read_offset(struct device *dev,
> long *offset) static int xlnx_rtc_set_offset(struct device *dev, long offset) {
> struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
> - unsigned long long rtc_ppb = RTC_PPB;
> - unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
> - unsigned char fract_tick = 0;
> + int max_tick, tick_mult, fract_offset, fract_part;
> + int freq = xrtcdev->freq;
> unsigned int calibval;
> - short int max_tick;
> - int fract_offset;
> + int fract_data = 0;
>
> + /* Tick to offset multiplier */
> + tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, freq);
> if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
> return -ERANGE;
>
> @@ -223,29 +223,22 @@ static int xlnx_rtc_set_offset(struct device *dev,
> long offset)
>
> /* Number fractional ticks for given offset */
> if (fract_offset) {
> - if (fract_offset < 0) {
> - fract_offset = fract_offset + tick_mult;
> + fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
> + fract_data = fract_offset / fract_part;
> + /* Subtract one from max_tick while adding fract_offset */
> + if (fract_offset < 0 && fract_data) {
> max_tick--;
> - }
> - if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
> - for (fract_tick = 1; fract_tick < 16; fract_tick++) {
> - if (fract_offset <=
> - (fract_tick *
> - (tick_mult / RTC_FR_MAX_TICKS)))
> - break;
> - }
> + fract_data += RTC_FR_MAX_TICKS;
> }
> }
>
> /* Zynqmp RTC uses second and fractional tick
> * counters for compensation
> */
> - calibval = max_tick + RTC_CALIB_DEF;
> -
> - if (fract_tick)
> - calibval |= RTC_FR_EN;
> + calibval = max_tick + freq;
>
> - calibval |= (fract_tick << RTC_FR_DATSHIFT);
> + if (fract_data)
> + calibval |= (RTC_FR_EN | (fract_data <<
> + RTC_FR_DATSHIFT));
>
> writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
>
>
> --
> 2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 5/5] rtc: zynqmp: use dynamic max and min offset ranges
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (3 preceding siblings ...)
2026-01-22 13:53 ` [PATCH v4 4/5] rtc: zynqmp: rework set_offset Tomas Melin
@ 2026-01-22 13:53 ` Tomas Melin
2026-01-29 9:36 ` [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset T, Harini
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Melin @ 2026-01-22 13:53 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
Maximum and minimum offsets in ppb that can be handled are dependent on
the rtc clock frequency and what can fit in the 16-bit register field.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index f0f5dc63e254799ed99927c259c767b30ee877a4..2ae54804b87a47642d118789dc33191c53b36932 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -44,8 +44,6 @@
#define RTC_FR_MASK 0xF0000
#define RTC_FR_MAX_TICKS 16
#define RTC_PPB 1000000000
-#define RTC_MIN_OFFSET -32768000
-#define RTC_MAX_OFFSET 32767000
struct xlnx_rtc_dev {
struct rtc_device *rtc;
@@ -215,12 +213,13 @@ static int xlnx_rtc_set_offset(struct device *dev, long offset)
/* Tick to offset multiplier */
tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, freq);
- if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
- return -ERANGE;
/* Number ticks for given offset */
max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
+ if (freq + max_tick > RTC_TICK_MASK || (freq + max_tick < 1))
+ return -ERANGE;
+
/* Number fractional ticks for given offset */
if (fract_offset) {
fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* RE: [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (4 preceding siblings ...)
2026-01-22 13:53 ` [PATCH v4 5/5] rtc: zynqmp: use dynamic max and min offset ranges Tomas Melin
@ 2026-01-29 9:36 ` T, Harini
2026-01-29 10:11 ` Michal Simek
2026-01-30 22:59 ` Alexandre Belloni
7 siblings, 0 replies; 10+ messages in thread
From: T, Harini @ 2026-01-29 9:36 UTC (permalink / raw)
To: Tomas Melin, Alexandre Belloni, Simek, Michal
Cc: linux-rtc, linux-arm-kernel, linux-kernel
[Public]
The patch series looks fine to me.
Thanks,
Harini T
> -----Original Message-----
> From: Tomas Melin <tomas.melin@vaisala.com>
> Sent: Thursday, January 22, 2026 7:24 PM
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Simek, Michal
> <michal.simek@amd.com>
> Cc: linux-rtc@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; Tomas Melin <tomas.melin@vaisala.com>; T, Harini
> <Harini.T@amd.com>
> Subject: [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> 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 v4:
> - Do not limit building to zynqmp arch as building on other platforms
> might be needed. Implies dropping commit.
> - No need for RTC_PPB to be 64 bit value, use 32 bit instead
> - Link to v3: https://lore.kernel.org/r/20260119-zynqmp-rtc-updates-v3-0-
> acd902fdeab1@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 (5):
> 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/rtc-zynqmp.c | 75 ++++++++++++++++++++++++++---------------------
> -
> 1 file changed, 41 insertions(+), 34 deletions(-)
> ---
> base-commit: cd635e33b0113287c94021be53d2a7c61a1614e9
> change-id: 20251201-zynqmp-rtc-updates-d260364cc01b
>
> Best regards,
> --
> Tomas Melin <tomas.melin@vaisala.com>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (5 preceding siblings ...)
2026-01-29 9:36 ` [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset T, Harini
@ 2026-01-29 10:11 ` Michal Simek
2026-01-30 22:59 ` Alexandre Belloni
7 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2026-01-29 10:11 UTC (permalink / raw)
To: Tomas Melin, Alexandre Belloni
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Harini T
On 1/22/26 14:53, Tomas Melin wrote:
> 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 v4:
> - Do not limit building to zynqmp arch as building on other platforms
> might be needed. Implies dropping commit.
> - No need for RTC_PPB to be 64 bit value, use 32 bit instead
> - Link to v3: https://lore.kernel.org/r/20260119-zynqmp-rtc-updates-v3-0-acd902fdeab1@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 (5):
> 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/rtc-zynqmp.c | 75 ++++++++++++++++++++++++++----------------------
> 1 file changed, 41 insertions(+), 34 deletions(-)
> ---
> base-commit: cd635e33b0113287c94021be53d2a7c61a1614e9
> change-id: 20251201-zynqmp-rtc-updates-d260364cc01b
>
> Best regards,
Acked-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset
2026-01-22 13:53 [PATCH v4 0/5] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (6 preceding siblings ...)
2026-01-29 10:11 ` Michal Simek
@ 2026-01-30 22:59 ` Alexandre Belloni
7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Belloni @ 2026-01-30 22:59 UTC (permalink / raw)
To: Michal Simek, Tomas Melin
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Harini T
On Thu, 22 Jan 2026 13:53:44 +0000, Tomas Melin wrote:
> 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.
>
> [...]
Applied, thanks!
[1/5] rtc: zynqmp: correct frequency value
https://git.kernel.org/abelloni/c/2724fb4d429c
[2/5] rtc: zynqmp: check calibration max value
https://git.kernel.org/abelloni/c/83b9e5eb0437
[3/5] rtc: zynqmp: rework read_offset
https://git.kernel.org/abelloni/c/0f9989443fae
[4/5] rtc: zynqmp: rework set_offset
https://git.kernel.org/abelloni/c/9f5af70268d6
[5/5] rtc: zynqmp: use dynamic max and min offset ranges
https://git.kernel.org/abelloni/c/2254383176fc
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 10+ messages in thread