]> git.hungrycats.org Git - linux/commitdiff
[PATCH] M68k generic RTC driver updates
authorGeert Uytterhoeven <geert@linux-m68k.org>
Thu, 16 Jan 2003 00:10:58 +0000 (16:10 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 16 Jan 2003 00:10:58 +0000 (16:10 -0800)
M68k generic RTC driver updates:
  - Revive help text for CONFIG_GEN_RTC
  - Re-add lost config option for CONFIG_GEN_RTC_X
  - Re-add lost mach_get_ss()
  - Export mach_[gs]et_rtc_pll()
  - Add implementation of mach_get_ss() and mach_[gs]et_rtc_pll() for Q40/Q60
  - Add missing include
  - Add implementation of get_rtc_ss()

arch/m68k/Kconfig
arch/m68k/kernel/m68k_ksyms.c
arch/m68k/kernel/setup.c
arch/m68k/q40/config.c
include/asm-m68k/machdep.h
include/asm-m68k/rtc.h

index 657e5f9afb9443b11cd66b8e127169aadda588f0..cabe93920be2a1d6735078a4c77b015feb7670c5 100644 (file)
@@ -1720,6 +1720,31 @@ config GEN_RTC
        tristate "Generic /dev/rtc emulation" if !SUN3
        depends on !ATARI
        default y if SUN3
+       ---help---
+         If you say Y here and create a character special file /dev/rtc with
+         major number 10 and minor number 135 using mknod ("man mknod"), you
+         will get access to the real time clock (or hardware clock) built
+         into your computer.
+
+         It reports status information via the file /proc/driver/rtc and its
+         behaviour is set by various ioctls on /dev/rtc. If you enable the
+         "extended RTC operation" below it will also provide an emulation
+         for RTC_UIE which is required by some programs and may improve
+         precision in some cases.
+
+         This driver is also available as a module ( = code which can be
+         inserted in and removed from the running kernel whenever you want).
+         The module is called genrtc.o. If you want to compile it as a module,
+         say M here and read <file:Documentation/modules.txt>. To load the
+         module automatically add 'alias char-major-10-135 genrtc' to your
+         /etc/modules.conf
+
+config GEN_RTC_X
+       bool "Extended RTC operation"
+       depends on GEN_RTC
+       help
+         Provides an emulation for RTC_UIE which is required by some programs
+         and may improve precision of the generic RTC support in some cases.
 
 config UNIX98_PTYS
        bool "Unix98 PTY support"
index ad8aebdfd0e54125958f63eda5e0b2ccdab66423..533efcc46185ca3d435544dc9b4d5edbb7a567b7 100644 (file)
@@ -50,6 +50,9 @@ EXPORT_SYMBOL(kernel_set_cachemode);
 #endif /* !CONFIG_SUN3 */
 EXPORT_SYMBOL(m68k_debug_device);
 EXPORT_SYMBOL(mach_hwclk);
+EXPORT_SYMBOL(mach_get_ss);
+EXPORT_SYMBOL(mach_get_rtc_pll);
+EXPORT_SYMBOL(mach_set_rtc_pll);
 EXPORT_SYMBOL(dump_fpu);
 EXPORT_SYMBOL(dump_thread);
 EXPORT_SYMBOL(strnlen);
index ba0ea7d6361cd44d780098d074eab0396dab877a..c8f2f7211eb51fc85663eba5d260250157237876 100644 (file)
@@ -82,6 +82,7 @@ void (*mach_process_int) (int, struct pt_regs *) = NULL;
 unsigned long (*mach_gettimeoffset) (void);
 int (*mach_hwclk) (int, struct rtc_time*) = NULL;
 int (*mach_set_clock_mmss) (unsigned long) = NULL;
+unsigned int (*mach_get_ss)(void) = NULL;
 int (*mach_get_rtc_pll)(struct rtc_pll_info *) = NULL;
 int (*mach_set_rtc_pll)(struct rtc_pll_info *) = NULL;
 void (*mach_reset)( void );
index eed9bed584f7acec61b083e6f52156c23d7de606..9e5ca227cf4952e61832162063b21f7232e66fd7 100644 (file)
@@ -53,7 +53,10 @@ extern void q40_sched_init(void (*handler)(int, void *, struct pt_regs *));
 
 extern unsigned long q40_gettimeoffset (void);
 extern int q40_hwclk (int, struct rtc_time *);
+extern unsigned int q40_get_ss (void);
 extern int q40_set_clock_mmss (unsigned long);
+static int q40_get_rtc_pll(struct rtc_pll_info *pll);
+static int q40_set_rtc_pll(struct rtc_pll_info *pll);
 extern void q40_reset (void);
 void q40_halt(void);
 extern void q40_waitbut(void);
@@ -170,6 +173,9 @@ void __init config_q40(void)
     mach_init_IRQ        = q40_init_IRQ;   
     mach_gettimeoffset   = q40_gettimeoffset; 
     mach_hwclk           = q40_hwclk; 
+    mach_get_ss          = q40_get_ss;
+    mach_get_rtc_pll     = q40_get_rtc_pll;
+    mach_set_rtc_pll     = q40_set_rtc_pll;
     mach_set_clock_mmss         = q40_set_clock_mmss;
 
     mach_reset          = q40_reset;
@@ -290,6 +296,11 @@ int q40_hwclk(int op, struct rtc_time *t)
        return 0;
 }
 
+unsigned int q40_get_ss()
+{
+       return bcd2bin(Q40_RTC_SECS);
+}
+
 /*
  * Set the minutes and seconds from seconds value 'nowtime'.  Fail if
  * clock is out by > 30 minutes.  Logic lifted from atari code.
@@ -321,3 +332,36 @@ int q40_set_clock_mmss (unsigned long nowtime)
        return retval;
 }
 
+
+/* get and set PLL calibration of RTC clock */
+#define Q40_RTC_PLL_MASK ((1<<5)-1)
+#define Q40_RTC_PLL_SIGN (1<<5)
+
+static int q40_get_rtc_pll(struct rtc_pll_info *pll)
+{
+       int tmp=Q40_RTC_CTRL;
+       pll->pll_value = tmp & Q40_RTC_PLL_MASK;
+       if (tmp & Q40_RTC_PLL_SIGN)
+               pll->pll_value = -pll->pll_value;
+       pll->pll_max=31;
+       pll->pll_min=-31;
+       pll->pll_posmult=512;
+       pll->pll_negmult=256;
+       pll->pll_clock=125829120;
+       return 0;
+}
+
+static int q40_set_rtc_pll(struct rtc_pll_info *pll)
+{
+       if (!pll->pll_ctrl){
+               /* the docs are a bit unclear so I am doublesetting */
+               /* RTC_WRITE here ... */
+               int tmp = (pll->pll_value & 31) | (pll->pll_value<0 ? 32 : 0) |
+                         Q40_RTC_WRITE;
+               Q40_RTC_CTRL |= Q40_RTC_WRITE;
+               Q40_RTC_CTRL = tmp;
+               Q40_RTC_CTRL &= ~(Q40_RTC_WRITE);
+               return 0;
+       } else
+               return -EINVAL;
+}
index 3aadd7727e1e79b0e65c2d9ef21f32e80aa2d3f0..62ad61c76fa0b915db499fa2254bc3dc685d7934 100644 (file)
@@ -23,6 +23,7 @@ extern void (*mach_process_int) (int irq, struct pt_regs *fp);
 /* machine dependent timer functions */
 extern unsigned long (*mach_gettimeoffset)(void);
 extern int (*mach_hwclk)(int, struct rtc_time*);
+extern unsigned int (*mach_get_ss)(void);
 extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
 extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
 extern int (*mach_set_clock_mmss)(unsigned long);
index 309b12a5d24a45c460dbd90e874589c9f10d9b87..043d5f94761856dce4472091d44c28bc0b7116d0 100644 (file)
@@ -13,6 +13,7 @@
 
 #ifdef __KERNEL__
 
+#include <linux/rtc.h>
 #include <asm/machdep.h>
 
 /* a few implementation details for the emulation : */
@@ -45,6 +46,18 @@ static inline int set_rtc_time(struct rtc_time *time)
        return mach_hwclk(1, time);
 }
 
+static inline unsigned int get_rtc_ss(void)
+{
+       if (mach_get_ss)
+               return mach_get_ss();
+       else{
+               struct rtc_time h;
+
+               get_rtc_time(&h);
+               return h.tm_sec;
+       }
+}
+
 static inline int get_rtc_pll(struct rtc_pll_info *pll)
 {
        if (mach_get_rtc_pll)