]> err.no Git - linux-2.6/commitdiff
[POWERPC] Add powerpc get/set_rtc_time interface to new generic rtc class
authorKim Phillips <kim.phillips@freescale.com>
Tue, 26 Sep 2006 22:46:37 +0000 (17:46 -0500)
committerPaul Mackerras <paulus@samba.org>
Mon, 2 Oct 2006 07:48:47 +0000 (17:48 +1000)
Add powerpc get/set_rtc_time interface to new generic rtc class. This
abstracts rtc chip specific code from the platform code for rtc-over-i2c
platforms.  Specific RTC chip support is now configured under
Device Drivers -> Real Time Clock. Setting time of day from the RTC
on startup is also configurable.

this time without the potentially platform breaking initcall.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/time.c
include/asm-powerpc/time.h

index 7a3c3f791ade2aaac30bbadc0994da40ea12e80a..b4ed362c457acd75ea80fc490f0fd4518eb7bf46 100644 (file)
@@ -1048,6 +1048,48 @@ void __init time_init(void)
        set_dec(tb_ticks_per_jiffy);
 }
 
+#ifdef CONFIG_RTC_CLASS
+static int set_rtc_class_time(struct rtc_time *tm)
+{
+       int err;
+       struct class_device *class_dev =
+               rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+
+       if (class_dev == NULL)
+               return -ENODEV;
+
+       err = rtc_set_time(class_dev, tm);
+
+       rtc_class_close(class_dev);
+
+       return 0;
+}
+
+static void get_rtc_class_time(struct rtc_time *tm)
+{
+       int err;
+       struct class_device *class_dev =
+               rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+
+       if (class_dev == NULL)
+               return;
+
+       err = rtc_read_time(class_dev, tm);
+
+       rtc_class_close(class_dev);
+
+       return;
+}
+
+int __init rtc_class_hookup(void)
+{
+       ppc_md.get_rtc_time = get_rtc_class_time;
+       ppc_md.set_rtc_time = set_rtc_class_time;
+
+       return 0;
+}
+#endif /* CONFIG_RTC_CLASS */
+
 
 #define FEBRUARY       2
 #define        STARTOFTIME     1970
index 5785ac4737b5ee7575837b2d8e8d9c05b752f8cd..b051d4c88c3b46a19b40ba11d2e951010be502d6 100644 (file)
@@ -39,6 +39,10 @@ extern void generic_calibrate_decr(void);
 extern void wakeup_decrementer(void);
 extern void snapshot_timebase(void);
 
+#ifdef CONFIG_RTC_CLASS
+extern int __init rtc_class_hookup(void);
+#endif
+
 /* Some sane defaults: 125 MHz timebase, 1GHz processor */
 extern unsigned long ppc_proc_freq;
 #define DEFAULT_PROC_FREQ      (DEFAULT_TB_FREQ * 8)
@@ -234,4 +238,4 @@ extern void snapshot_timebases(void);
 #endif
 
 #endif /* __KERNEL__ */
-#endif /* __PPC64_TIME_H */
+#endif /* __POWERPC_TIME_H */