update system time after N900 resumes
authorDavid Fries <David@Fries.net>
Tue, 11 Sep 2012 02:44:52 +0000 (21:44 -0500)
committerPali Rohár <pali.rohar@gmail.com>
Fri, 25 Oct 2013 19:59:09 +0000 (21:59 +0200)
Currently nothing updates the system clock after a suspend to memory
operation, and date shows that almost no time elapsed.
As ARM doesn't have a specific read_persistent_clock the default
returns 0.  The RTC rtc_suspend/rtc_resume will set the clock after
resume, but requires CONFIG_RTC_HCTOSYS_DEVICE to be set, but that
requires RTC to be compiled into the kernel.

This splits up the configuration for setting the system time on bootup
from setting the time on resume.  This allows RTC_CLASS to be compiled
as a module if the system needs the RTC for resume, but not for boot,
which is the case for the N900.

kernel-power-2.6.28/debian/patches/resume_use_rtc_clock.diff [new file with mode: 0644]
kernel-power-2.6.28/debian/patches/series

diff --git a/kernel-power-2.6.28/debian/patches/resume_use_rtc_clock.diff b/kernel-power-2.6.28/debian/patches/resume_use_rtc_clock.diff
new file mode 100644 (file)
index 0000000..1d2e327
--- /dev/null
@@ -0,0 +1,128 @@
+From 76fc6d798113bb5d3c8499f8d61a9f74df10bdb0 Mon Sep 17 00:00:00 2001
+From: David Fries <David@Fries.net>
+Date: Sat, 25 Aug 2012 13:48:08 -0500
+Subject: [PATCH] update system time after N900 resumes
+
+enable with,
+CONFIG_RTC_HCTOSYS=m
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+
+Currently nothing updates the system clock after a suspend to memory
+operation, and date shows that almost no time elapsed.
+As ARM doesn't have a specific read_persistent_clock the default
+returns 0.  The RTC rtc_suspend/rtc_resume will set the clock after
+resume, but requires CONFIG_RTC_HCTOSYS_DEVICE to be set, but that
+requires RTC to be compiled into the kernel.
+
+This splits up the configuration for setting the system time on bootup
+from setting the time on resume.  This allows RTC_CLASS to be compiled
+as a module if the system needs the RTC for resume, but not for boot,
+which is the case for the N900.
+
+Note, v3.0-rc1 removed the support for compiling RTC_CLASS as a
+module, so this change isn't releavant upstream.  One option is to
+compile RTC into the kernel and enable RTC_HCTOSYS, I just see this as
+the smaller change.
+
+Signed-off-by: David Fries <David@Fries.net>
+---
+ arch/arm/configs/rx51_defconfig |    2 ++
+ drivers/rtc/Kconfig             |   39 ++++++++++++++++++++++++---------------
+ drivers/rtc/Makefile            |    2 +-
+ 3 files changed, 27 insertions(+), 16 deletions(-)
+
+diff --git a/arch/arm/configs/rx51_defconfig b/arch/arm/configs/rx51_defconfig
+index d09af85..b61769b 100644
+--- a/arch/arm/configs/rx51_defconfig
++++ b/arch/arm/configs/rx51_defconfig
+@@ -1885,6 +1885,8 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+ CONFIG_LEDS_TRIGGER_KEYB=y
+ CONFIG_RTC_LIB=y
+ CONFIG_RTC_CLASS=m
++CONFIG_RTC_HCTOSYS=m
++CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+ #
+ # RTC interfaces
+diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
+index 123092d..738ae0a 100644
+--- a/drivers/rtc/Kconfig
++++ b/drivers/rtc/Kconfig
+@@ -21,27 +21,24 @@ menuconfig RTC_CLASS
+ if RTC_CLASS
+ config RTC_HCTOSYS
+-      bool "Set system time from RTC on startup and resume"
+-      depends on RTC_CLASS = y
+-      default y
++      tristate "Enable setting system time from RTC"
++      depends on RTC_CLASS
++      default RTC_CLASS
+       help
+-        If you say yes here, the system time (wall clock) will be set using
+-        the value read from a specified RTC device. This is useful to avoid
+-        unnecessary fsck runs at boot time, and to network better.
++        This enables RTC_HCTOSYS_DEVICE to set the RTC device used for
++        resume and optionally RTC_HCTOSYS_BOOT to also set the time on boot.
+ config RTC_HCTOSYS_DEVICE
+-      string "RTC used to set the system time"
+-      depends on RTC_HCTOSYS = y
++      string "RTC used to set the system time on startup or resume"
++      depends on RTC_HCTOSYS
+       default "rtc0"
+       help
+         The RTC device that will be used to (re)initialize the system
+         clock, usually rtc0.  Initialization is done when the system
+-        starts up, and when it resumes from a low power state.  This
+-        device should record time in UTC, since the kernel won't do
+-        timezone correction.
+-
+-        The driver for this RTC device must be loaded before late_initcall
+-        functions run, so it must usually be statically linked.
++        starts up (if RTC_HCTOSYS is selected), and when it resumes from a
++        low power state.  This device should record time in UTC, since the
++        kernel won't do timezone correction.  The system clock is only
++        modified if the driver is loaded in resume (if compiled as a module).
+         This clock should be battery-backed, so that it reads the correct
+         time when the system boots from a power-off state.  Otherwise, your
+@@ -49,9 +46,21 @@ config RTC_HCTOSYS_DEVICE
+         If the clock you specify here is not battery backed, it may still
+         be useful to reinitialize system time when resuming from system
+-        sleep states. Do not specify an RTC here unless it stays powered
++        sleep states.  Do not specify an RTC here unless it stays powered
+         during all this system's supported sleep states.
++config RTC_HCTOSYS_BOOT
++      bool "Set system time from RTC on startup"
++      depends on RTC_HCTOSYS = y
++      default y
++      help
++        If you say yes here, the system time (wall clock) will be set using
++        the value read from a specified RTC device.  This is useful to avoid
++        unnecessary fsck runs at boot time, and to network better.
++
++        The driver for the RTC_HCTOSYS_DEVICE must be loaded before
++        late_initcall functions run, so it must usually be statically linked.
++
+ config RTC_DEBUG
+       bool "RTC debug support"
+       depends on RTC_CLASS = y
+diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
+index 6e79c91..0a8ed8b 100644
+--- a/drivers/rtc/Makefile
++++ b/drivers/rtc/Makefile
+@@ -7,7 +7,7 @@ ifeq ($(CONFIG_RTC_DEBUG),y)
+ endif
+ obj-$(CONFIG_RTC_LIB)         += rtc-lib.o
+-obj-$(CONFIG_RTC_HCTOSYS)     += hctosys.o
++obj-$(CONFIG_RTC_HCTOSYS_BOOT)        += hctosys.o
+ obj-$(CONFIG_RTC_CLASS)               += rtc-core.o
+ rtc-core-y                    := class.o interface.o
+-- 
+1.7.10.4
+
index aee481c..5fa66ab 100644 (file)
@@ -89,3 +89,4 @@ tif_restore_sigmask-syscalls-arm.patch
 dm9601-ethernet.patch
 asix-ethernet.patch
 nokia-av_key.patch
+resume_use_rtc_clock.diff