aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXunlei Pang <pang.xunlei@linaro.org>2015-06-11 23:10:16 -0400
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-06-24 19:13:42 -0400
commit9c5150b31b49e3d89c52df9b1c1ebcea4e665ec3 (patch)
treebba4dff4be684e676b1a148ea7eca8393cb39efb
parent9033fd8ba7e96821e65fe3afc3f4077a8b66d1c9 (diff)
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>
-rw-r--r--drivers/rtc/Kconfig29
-rw-r--r--drivers/rtc/systohc.c2
2 files changed, 21 insertions, 10 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index c94bb6aded51..efaff368ee94 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -25,17 +25,9 @@ config RTC_HCTOSYS
25 the value read from a specified RTC device. This is useful to avoid 25 the value read from a specified RTC device. This is useful to avoid
26 unnecessary fsck runs at boot time, and to network better. 26 unnecessary fsck runs at boot time, and to network better.
27 27
28config 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
36config RTC_HCTOSYS_DEVICE 28config RTC_HCTOSYS_DEVICE
37 string "RTC used to set the system time" 29 string "RTC used to set the system time"
38 depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y 30 depends on RTC_HCTOSYS
39 default "rtc0" 31 default "rtc0"
40 help 32 help
41 The RTC device that will be used to (re)initialize the system 33 The RTC device that will be used to (re)initialize the system
@@ -56,6 +48,25 @@ config RTC_HCTOSYS_DEVICE
56 sleep states. Do not specify an RTC here unless it stays powered 48 sleep states. Do not specify an RTC here unless it stays powered
57 during all this system's supported sleep states. 49 during all this system's supported sleep states.
58 50
51config RTC_SYSTOHC
52 bool "Set the RTC time based on NTP synchronization"
53 default y
54 help
55 If you say yes here, the system time (wall clock) will be stored
56 in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
57 minutes if userspace reports synchronized NTP status.
58
59config RTC_SYSTOHC_DEVICE
60 string "RTC used to synchronize NTP adjustment"
61 depends on RTC_SYSTOHC
62 default RTC_HCTOSYS_DEVICE if RTC_HCTOSYS
63 default "rtc0"
64 help
65 The RTC device used for NTP synchronization. The main difference
66 between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this
67 one can sleep when setting time, because it runs in the workqueue
68 context.
69
59config RTC_DEBUG 70config RTC_DEBUG
60 bool "RTC debug support" 71 bool "RTC debug support"
61 help 72 help
diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c
index 7728d5e32bf4..b4a68ffcd06b 100644
--- a/drivers/rtc/systohc.c
+++ b/drivers/rtc/systohc.c
@@ -31,7 +31,7 @@ int rtc_set_ntp_time(struct timespec64 now)
31 else 31 else
32 rtc_time64_to_tm(now.tv_sec + 1, &tm); 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 if (rtc) { 35 if (rtc) {
36 /* rtc_hctosys exclusively uses UTC, so we call set_time here, 36 /* rtc_hctosys exclusively uses UTC, so we call set_time here,
37 * not set_mmss. */ 37 * not set_mmss. */