Skip to contentSkip to conversation

enable genrtc for MIPS

PATCH In review Jun Sun 5 participants 6 messages Jan 30, 2004 – Feb 3, 2004 MIPS

lore
Share & tools
lore

Jun Sun

author
#0 lore raw

PATCH 1/1 enable genrtc for MIPS

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

arch/mips/kernel/Makefile renamed from arch/mips/kernel/Makefile.orig +2 -0
diff -Nru linux/arch/mips/kernel/Makefile.orig linux/arch/mips/kernel/Makefile
@@ -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)
arch/mips/kernel/genrtc.c renamed from arch/mips/kernel/genrtc.c.orig +65 -0

65 lines not on this page · raw message

include/asm-mips/rtc.h renamed from include/asm-mips/rtc.h.orig +32 -5
diff -Nru linux/include/asm-mips/rtc.h.orig linux/include/asm-mips/rtc.h
@@ -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, [email protected] or [email protected]
+ *
+ * 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
#1 lore raw
Quoted 2 lines · Jun Sun

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. :)

s/old/full-featured/

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#2 lore raw
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Maciej W. Rozycki

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. :)

macro> s/old/full-featured/

No, I suppose s/rtc/mips-rtc/ is what the original patch means.

By the way, with this patch, individual board can not implement it's own genrtc routines. How about making gen_rtc_time, etc. pointer to functions to allow overrides?

I think implementing rtc_get_time (mips specific) with get_rtc_time (genrtc) is more efficient than implementing get_rtc_time with rtc_get_time for most RTC chips.

---
Atsushi Nemoto

#3 lore raw
Quoted 3 lines · Atsushi Nemoto

I think implementing rtc_get_time (mips specific) with get_rtc_time (genrtc) is more efficient than implementing get_rtc_time with rtc_get_time for most RTC chips.

Indeed, that's what I noticed a while ago, too.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#4 lore raw
In reply to Atsushi Nemoto
Quoted 5 lines · Atsushi Nemoto

By the way, with this patch, individual board can not implement it's own genrtc routines. How about making gen_rtc_time, etc. pointer to functions to allow overrides?

Is this necessary? How about letting us wait until there is a sensible need?

Quoted 4 lines

I think implementing rtc_get_time (mips specific) with get_rtc_time (genrtc) is more efficient than implementing get_rtc_time with rtc_get_time for most RTC chips.

If I understand you correctly, you like to have board rtc read routines to return a rtc structure instead of the unsigned long integer.

There are actually boards which makes the current implementation more efficient. See vr4181.

In general, however, this is not a bad idea, just involving a lot more board level changes. I think it deserves another patch or even debate.

Jun

#5 lore raw
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jun Sun

By the way, with this patch, individual board can not implement it's own genrtc routines. How about making gen_rtc_time, etc. pointer to functions to allow overrides?

jsun> Is this necessary? How about letting us wait until there is a jsun> sensible need?

OK, we can wait. But still I suppose gen_rtc_time will become a pointer sooner or later....

Anyway, I think using genrtc instead of mips-rtc is very good idea. Thank you.

jsun> If I understand you correctly, you like to have board rtc read jsun> routines to return a rtc structure instead of the unsigned long jsun> integer.

jsun> There are actually boards which makes the current implementation jsun> more efficient. See vr4181.

I see.

jsun> In general, however, this is not a bad idea, just involving a jsun> lot more board level changes. I think it deserves another patch jsun> or even debate.

Though I'm not have a real code yet, how about this idea?

1. Provide std_rtc_get_time (returns ulong) implemented with get_rtc_time (returns rtc struct) pointer.
2. Provide std_get_rtc_time (returns rtc struct) implemented with rtc_get_time returns ulong) pointer.
3. Each board implement its own rtc_get_time or get_rtc_time.
4. In generic time_init(), initialize rtc_get_time pointer or get_rtc_time pointer with std_rtc_get_time or std_get_rtc_time if they were NULL.

---
Atsushi Nemoto