1d2e32724c005f11f21c20c7799aaf34c0f4d4c3
[kernel-power] / kernel-power-2.6.28 / debian / patches / resume_use_rtc_clock.diff
1 From 76fc6d798113bb5d3c8499f8d61a9f74df10bdb0 Mon Sep 17 00:00:00 2001
2 From: David Fries <David@Fries.net>
3 Date: Sat, 25 Aug 2012 13:48:08 -0500
4 Subject: [PATCH] update system time after N900 resumes
5
6 enable with,
7 CONFIG_RTC_HCTOSYS=m
8 CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
9
10 Currently nothing updates the system clock after a suspend to memory
11 operation, and date shows that almost no time elapsed.
12 As ARM doesn't have a specific read_persistent_clock the default
13 returns 0.  The RTC rtc_suspend/rtc_resume will set the clock after
14 resume, but requires CONFIG_RTC_HCTOSYS_DEVICE to be set, but that
15 requires RTC to be compiled into the kernel.
16
17 This splits up the configuration for setting the system time on bootup
18 from setting the time on resume.  This allows RTC_CLASS to be compiled
19 as a module if the system needs the RTC for resume, but not for boot,
20 which is the case for the N900.
21
22 Note, v3.0-rc1 removed the support for compiling RTC_CLASS as a
23 module, so this change isn't releavant upstream.  One option is to
24 compile RTC into the kernel and enable RTC_HCTOSYS, I just see this as
25 the smaller change.
26
27 Signed-off-by: David Fries <David@Fries.net>
28 ---
29  arch/arm/configs/rx51_defconfig |    2 ++
30  drivers/rtc/Kconfig             |   39 ++++++++++++++++++++++++---------------
31  drivers/rtc/Makefile            |    2 +-
32  3 files changed, 27 insertions(+), 16 deletions(-)
33
34 diff --git a/arch/arm/configs/rx51_defconfig b/arch/arm/configs/rx51_defconfig
35 index d09af85..b61769b 100644
36 --- a/arch/arm/configs/rx51_defconfig
37 +++ b/arch/arm/configs/rx51_defconfig
38 @@ -1885,6 +1885,8 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
39  CONFIG_LEDS_TRIGGER_KEYB=y
40  CONFIG_RTC_LIB=y
41  CONFIG_RTC_CLASS=m
42 +CONFIG_RTC_HCTOSYS=m
43 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
44  
45  #
46  # RTC interfaces
47 diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
48 index 123092d..738ae0a 100644
49 --- a/drivers/rtc/Kconfig
50 +++ b/drivers/rtc/Kconfig
51 @@ -21,27 +21,24 @@ menuconfig RTC_CLASS
52  if RTC_CLASS
53  
54  config RTC_HCTOSYS
55 -       bool "Set system time from RTC on startup and resume"
56 -       depends on RTC_CLASS = y
57 -       default y
58 +       tristate "Enable setting system time from RTC"
59 +       depends on RTC_CLASS
60 +       default RTC_CLASS
61         help
62 -         If you say yes here, the system time (wall clock) will be set using
63 -         the value read from a specified RTC device. This is useful to avoid
64 -         unnecessary fsck runs at boot time, and to network better.
65 +         This enables RTC_HCTOSYS_DEVICE to set the RTC device used for
66 +         resume and optionally RTC_HCTOSYS_BOOT to also set the time on boot.
67  
68  config RTC_HCTOSYS_DEVICE
69 -       string "RTC used to set the system time"
70 -       depends on RTC_HCTOSYS = y
71 +       string "RTC used to set the system time on startup or resume"
72 +       depends on RTC_HCTOSYS
73         default "rtc0"
74         help
75           The RTC device that will be used to (re)initialize the system
76           clock, usually rtc0.  Initialization is done when the system
77 -         starts up, and when it resumes from a low power state.  This
78 -         device should record time in UTC, since the kernel won't do
79 -         timezone correction.
80 -
81 -         The driver for this RTC device must be loaded before late_initcall
82 -         functions run, so it must usually be statically linked.
83 +         starts up (if RTC_HCTOSYS is selected), and when it resumes from a
84 +         low power state.  This device should record time in UTC, since the
85 +         kernel won't do timezone correction.  The system clock is only
86 +         modified if the driver is loaded in resume (if compiled as a module).
87  
88           This clock should be battery-backed, so that it reads the correct
89           time when the system boots from a power-off state.  Otherwise, your
90 @@ -49,9 +46,21 @@ config RTC_HCTOSYS_DEVICE
91  
92           If the clock you specify here is not battery backed, it may still
93           be useful to reinitialize system time when resuming from system
94 -         sleep states. Do not specify an RTC here unless it stays powered
95 +         sleep states.  Do not specify an RTC here unless it stays powered
96           during all this system's supported sleep states.
97  
98 +config RTC_HCTOSYS_BOOT
99 +       bool "Set system time from RTC on startup"
100 +       depends on RTC_HCTOSYS = y
101 +       default y
102 +       help
103 +         If you say yes here, the system time (wall clock) will be set using
104 +         the value read from a specified RTC device.  This is useful to avoid
105 +         unnecessary fsck runs at boot time, and to network better.
106 +
107 +         The driver for the RTC_HCTOSYS_DEVICE must be loaded before
108 +         late_initcall functions run, so it must usually be statically linked.
109 +
110  config RTC_DEBUG
111         bool "RTC debug support"
112         depends on RTC_CLASS = y
113 diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
114 index 6e79c91..0a8ed8b 100644
115 --- a/drivers/rtc/Makefile
116 +++ b/drivers/rtc/Makefile
117 @@ -7,7 +7,7 @@ ifeq ($(CONFIG_RTC_DEBUG),y)
118  endif
119  
120  obj-$(CONFIG_RTC_LIB)          += rtc-lib.o
121 -obj-$(CONFIG_RTC_HCTOSYS)      += hctosys.o
122 +obj-$(CONFIG_RTC_HCTOSYS_BOOT) += hctosys.o
123  obj-$(CONFIG_RTC_CLASS)                += rtc-core.o
124  rtc-core-y                     := class.o interface.o
125  
126 -- 
127 1.7.10.4
128