From: Jun Sun <jsun@mvista.com>
To: linux-mips@linux-mips.org
Cc: jsun@mvista.com
Subject: [PATCH 2.6] enable genrtc for MIPS
Date: Fri, 30 Jan 2004 10:39:13 -0800 [thread overview]
Message-ID: <20040130103913.E31937@mvista.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
genrtc.c is like mips-rtc.c we have in 2.4, except it is shared by
other arches and has more capabilities (such as emulated alarms)
This patch implements the arch-specific code for genrtc based on
MIPS's rtc_get_time() and rtc_set_time(), which are now implemented
by every MIPS board. This essentially means with this patch
every MIPS machine now has a working genrtc for free.
Of course, individual board is still free to choose the old rtc.c
or implement some peculiar ones of its own - although I can't see why. :)
Jun
[-- Attachment #2: mips-genrtc.patch --]
[-- Type: text/plain, Size: 3543 bytes --]
diff -Nru linux/arch/mips/kernel/Makefile.orig linux/arch/mips/kernel/Makefile
--- linux/arch/mips/kernel/Makefile.orig Mon Jan 5 10:33:35 2004
+++ linux/arch/mips/kernel/Makefile Fri Jan 30 10:29:07 2004
@@ -51,6 +51,8 @@
obj-$(CONFIG_MIPS64) += cpu-bugs64.o
+obj-$(CONFIG_GEN_RTC) += genrtc.o
+
CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
EXTRA_AFLAGS := $(CFLAGS)
diff -Nru linux/arch/mips/kernel/genrtc.c.orig linux/arch/mips/kernel/genrtc.c
--- linux/arch/mips/kernel/genrtc.c.orig Thu Jan 29 16:35:28 2004
+++ linux/arch/mips/kernel/genrtc.c Thu Jan 29 17:22:56 2004
@@ -0,0 +1,65 @@
+/*
+ * A glue layer that provides RTC read/write to drivers/char/genrtc.c driver
+ * based on MIPS internal RTC routines. It does take care locking
+ * issues so that we are SMP/Preemption safe.
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * Please read the COPYING file for all license details.
+ */
+
+#include <linux/config.h>
+#include <linux/spinlock.h>
+
+#include <asm/rtc.h>
+#include <asm/time.h>
+
+static spinlock_t mips_rtc_lock = SPIN_LOCK_UNLOCKED;
+
+unsigned int get_rtc_time(struct rtc_time *time)
+{
+ unsigned long nowtime;
+
+ spin_lock(&mips_rtc_lock);
+ nowtime = rtc_get_time();
+ to_tm(nowtime, time);
+ time->tm_year -= 1900;
+ spin_unlock(&mips_rtc_lock);
+
+ return RTC_24H;
+}
+
+int set_rtc_time(struct rtc_time *time)
+{
+ unsigned long nowtime;
+ int ret;
+
+ spin_lock(&mips_rtc_lock);
+ nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
+ time->tm_mday, time->tm_hour, time->tm_min,
+ time->tm_sec);
+ ret = rtc_set_time(nowtime);
+ spin_unlock(&mips_rtc_lock);
+
+ return ret;
+}
+
+unsigned int get_rtc_ss(void)
+{
+ struct rtc_time h;
+
+ get_rtc_time(&h);
+ return h.tm_sec;
+}
+
+int get_rtc_pll(struct rtc_pll_info *pll)
+{
+ return -EINVAL;
+}
+
+int set_rtc_pll(struct rtc_pll_info *pll)
+{
+ return -EINVAL;
+}
+
diff -Nru linux/include/asm-mips/rtc.h.orig linux/include/asm-mips/rtc.h
--- linux/include/asm-mips/rtc.h.orig Thu Oct 31 08:35:52 2002
+++ linux/include/asm-mips/rtc.h Thu Jan 29 16:35:14 2004
@@ -1,10 +1,37 @@
-#ifndef _I386_RTC_H
-#define _I386_RTC_H
-
/*
- * x86 uses the default access methods for the RTC.
+ * include/asm-mips/rtc.h
+ *
+ * (Really an interface for drivers/char/genrtc.c)
+ *
+ * Copyright (C) 2004 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * Please read the COPYING file for all license details.
*/
-#include <asm-generic/rtc.h>
+#ifndef _MIPS_RTC_H
+#define _MIPS_RTC_H
+
+#ifdef __KERNEL__
+
+#include <linux/rtc.h>
+
+#define RTC_PIE 0x40 /* periodic interrupt enable */
+#define RTC_AIE 0x20 /* alarm interrupt enable */
+#define RTC_UIE 0x10 /* update-finished interrupt enable */
+/* some dummy definitions */
+#define RTC_BATT_BAD 0x100 /* battery bad */
+#define RTC_SQWE 0x08 /* enable square-wave output */
+#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
+#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
+#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
+
+unsigned int get_rtc_time(struct rtc_time *time);
+int set_rtc_time(struct rtc_time *time);
+unsigned int get_rtc_ss(void);
+int get_rtc_pll(struct rtc_pll_info *pll);
+int set_rtc_pll(struct rtc_pll_info *pll);
+
+#endif
#endif
next reply other threads:[~2004-01-30 18:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-30 18:39 Jun Sun [this message]
2004-01-30 19:13 ` [PATCH 2.6] enable genrtc for MIPS Maciej W. Rozycki
2004-02-01 11:30 ` Atsushi Nemoto
2004-02-01 12:04 ` Geert Uytterhoeven
2004-02-02 21:19 ` Jun Sun
2004-02-03 1:30 ` Atsushi Nemoto
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=20040130103913.E31937@mvista.com \
--to=jsun@mvista.com \
--cc=linux-mips@linux-mips.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