]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: meson-vrtc: Use ktime_get_real_ts64() to get the current time
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Mon, 20 Mar 2023 21:21:42 +0000 (22:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2023 09:35:51 +0000 (11:35 +0200)
commit2384110d6fbf08e2c8a6c3dacfd24e82cb94bb0e
tree24c95ed593ebc0f32bcabc55b13e5700572fca6f
parentdd2b5649e50f0a50f1d0818b43b1b9d705e38f99
rtc: meson-vrtc: Use ktime_get_real_ts64() to get the current time

[ Upstream commit 0e6255fa3f649170da6bd1a544680589cfae1131 ]

The VRTC alarm register can be programmed with an amount of seconds
after which the SoC will be woken up by the VRTC timer again. We are
already converting the alarm time from meson_vrtc_set_alarm() to
"seconds since 1970". This means we also need to use "seconds since
1970" for the current time.

This fixes a problem where setting the alarm to one minute in the future
results in the firmware (which handles wakeup) to output (on the serial
console) that the system will be woken up in billions of seconds.
ktime_get_raw_ts64() returns the time since boot, not since 1970. Switch
to ktime_get_real_ts64() to fix the calculation of the alarm time and to
make the SoC wake up at the specified date/time. Also the firmware
(which manages suspend) now prints either 59 or 60 seconds until wakeup
(depending on how long it takes for the system to enter suspend).

Fixes: 892ce5cbfefe ("rtc: Add Amlogic Virtual Wake RTC")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Link: https://lore.kernel.org/r/20230320212142.2355062-1-martin.blumenstingl@googlemail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-meson-vrtc.c