From: Kim Phillips <kim.phillips@freescale.com>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class
Date: Mon, 25 Sep 2006 21:55:31 -0500 [thread overview]
Message-ID: <20060925215531.3e43be36.kim.phillips@freescale.com> (raw)
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.
Currently, the only default config in powerpc arch is the 8349 itx.
Other platforms wanting to consolidate code may also use this.
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
arch/powerpc/kernel/time.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 7a3c3f7..a231b6d 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1048,6 +1048,50 @@ void __init time_init(void)
set_dec(tb_ticks_per_jiffy);
}
+#ifdef CONFIG_RTC_CLASS
+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;
+}
+
+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;
+}
+
+static 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;
+}
+
+late_initcall(rtc_class_hookup);
+#endif /* CONFIG_RTC_CLASS */
+
#define FEBRUARY 2
#define STARTOFTIME 1970
--
1.4.2.1
next reply other threads:[~2006-09-26 2:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-26 2:55 Kim Phillips [this message]
2006-09-26 3:13 ` [PATCH] Add powerpc get/set_rtc_time interface to new generic rtc class Benjamin Herrenschmidt
2006-09-26 14:14 ` Kumar Gala
2006-09-26 22:01 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060925215531.3e43be36.kim.phillips@freescale.com \
--to=kim.phillips@freescale.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).