From af8471ca5584a171c13e6b3e9398a31e59b1cff9 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 23 Sep 2017 19:27:37 +0100 Subject: rtc: armada38x: provide set_offset_nsec Armada 388 resets the prescaler when the time register is written, so it requires the current second as close to the start of that second as possible. The data sheet is a bit unclear, so this has been confirmed on real hardware. Verified on Armada 388 based Clearfog. Signed-off-by: Russell King --- drivers/rtc/rtc-armada38x.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c index cc542e6b1d5b..05997ea8fa48 100644 --- a/drivers/rtc/rtc-armada38x.c +++ b/drivers/rtc/rtc-armada38x.c @@ -448,6 +448,15 @@ static int armada38x_rtc_set_offset(struct device *dev, long offset) return 0; } +static void armada38x_rtc_pre_register(struct rtc_device *rtc) +{ + /* + * The Armada 388 resets the prescaler when we write the time. + * Validated on clearfog. + */ + rtc->set_offset_nsec = 0; +} + static const struct rtc_class_ops armada38x_rtc_ops = { .read_time = armada38x_rtc_read_time, .set_time = armada38x_rtc_set_time, @@ -456,6 +465,7 @@ static const struct rtc_class_ops armada38x_rtc_ops = { .alarm_irq_enable = armada38x_rtc_alarm_irq_enable, .read_offset = armada38x_rtc_read_offset, .set_offset = armada38x_rtc_set_offset, + .pre_register = armada38x_rtc_pre_register, }; static const struct armada38x_rtc_data armada38x_data = { -- cgit