Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: NTP: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization

Currently, CONFIG_RTC_SYSTOHC uses CONFIG_RTC_HCTOSYS_DEVICE which
is originally used by CONFIG_RTC_HCTOSYS, but this rtc device has
some limiations, for example, it must be battery-backed, be able
to work with irq off and through system suspension, etc.

So add CONFIG_RTC_SYSTOHC_DEVICE used exclusively for CONFIG_RTC_SYSTOHC,
it is more lenient compared to CONFIG_RTC_HCTOSYS_DEVICE, and could
be assigned any available RTC in the system.

Default value is CONFIG_RTC_HCTOSYS_DEVICE which is "rtc0" by default.
After this patch, NTP will sync up "rtc0" by default.

Cc: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Xunlei Pang and committed by
Alexandre Belloni
9c5150b3 9033fd8b

+21 -10
+20 -9
drivers/rtc/Kconfig
··· 25 25 the value read from a specified RTC device. This is useful to avoid 26 26 unnecessary fsck runs at boot time, and to network better. 27 27 28 - config RTC_SYSTOHC 29 - bool "Set the RTC time based on NTP synchronization" 30 - default y 31 - help 32 - If you say yes here, the system time (wall clock) will be stored 33 - in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 34 - minutes if userspace reports synchronized NTP status. 35 - 36 28 config RTC_HCTOSYS_DEVICE 37 29 string "RTC used to set the system time" 38 - depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y 30 + depends on RTC_HCTOSYS 39 31 default "rtc0" 40 32 help 41 33 The RTC device that will be used to (re)initialize the system ··· 47 55 be useful to reinitialize system time when resuming from system 48 56 sleep states. Do not specify an RTC here unless it stays powered 49 57 during all this system's supported sleep states. 58 + 59 + config RTC_SYSTOHC 60 + bool "Set the RTC time based on NTP synchronization" 61 + default y 62 + help 63 + If you say yes here, the system time (wall clock) will be stored 64 + in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 65 + minutes if userspace reports synchronized NTP status. 66 + 67 + config RTC_SYSTOHC_DEVICE 68 + string "RTC used to synchronize NTP adjustment" 69 + depends on RTC_SYSTOHC 70 + default RTC_HCTOSYS_DEVICE if RTC_HCTOSYS 71 + default "rtc0" 72 + help 73 + The RTC device used for NTP synchronization. The main difference 74 + between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this 75 + one can sleep when setting time, because it runs in the workqueue 76 + context. 50 77 51 78 config RTC_DEBUG 52 79 bool "RTC debug support"
+1 -1
drivers/rtc/systohc.c
··· 31 31 else 32 32 rtc_time64_to_tm(now.tv_sec + 1, &tm); 33 33 34 - rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); 34 + rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); 35 35 if (rtc) { 36 36 /* rtc_hctosys exclusively uses UTC, so we call set_time here, 37 37 * not set_mmss. */