* [PATCH 1/2] Add powerpc get/set_rtc_time interface to new generic rtc class
@ 2006-09-26 22:46 Kim Phillips
2006-09-27 15:59 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Kim Phillips @ 2006-09-26 22:46 UTC (permalink / raw)
To: linuxppc-dev
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>
---
arch/powerpc/kernel/time.c | 42 ++++++++++++++++++++++++++++++++++++++++++
include/asm-powerpc/time.h | 6 +++++-
2 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 7a3c3f7..b4ed362 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -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
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index 5785ac4..b051d4c 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -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 @@ #define snapshot_timebases() do { } wh
#endif
#endif /* __KERNEL__ */
-#endif /* __PPC64_TIME_H */
+#endif /* __POWERPC_TIME_H */
--
1.4.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] Add powerpc get/set_rtc_time interface to new generic rtc class
2006-09-26 22:46 [PATCH 1/2] Add powerpc get/set_rtc_time interface to new generic rtc class Kim Phillips
@ 2006-09-27 15:59 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2006-09-27 15:59 UTC (permalink / raw)
To: Kim Phillips; +Cc: linuxppc-dev
On Tue, Sep 26, 2006 at 05:46:37PM -0500, Kim Phillips wrote:
[snip]
> --- a/include/asm-powerpc/time.h
> +++ b/include/asm-powerpc/time.h
> @@ -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
Conditional code doesn't usually get externs ifdef'd, unless I'm
mistaken.
--
Tom Rini
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-09-27 15:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 22:46 [PATCH 1/2] Add powerpc get/set_rtc_time interface to new generic rtc class Kim Phillips
2006-09-27 15:59 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).