aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/sgi-ip22/ip22-time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/sgi-ip22/ip22-time.c')
-rw-r--r--arch/mips/sgi-ip22/ip22-time.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index 10e505491655..3dcb27ec0c53 100644
--- a/arch/mips/sgi-ip22/ip22-time.c
+++ b/arch/mips/sgi-ip22/ip22-time.c
@@ -10,7 +10,6 @@
10 * Copyright (C) 2003, 06 Ralf Baechle (ralf@linux-mips.org) 10 * Copyright (C) 2003, 06 Ralf Baechle (ralf@linux-mips.org)
11 */ 11 */
12#include <linux/bcd.h> 12#include <linux/bcd.h>
13#include <linux/ds1286.h>
14#include <linux/init.h> 13#include <linux/init.h>
15#include <linux/irq.h> 14#include <linux/irq.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
@@ -29,69 +28,6 @@
29#include <asm/sgi/hpc3.h> 28#include <asm/sgi/hpc3.h>
30#include <asm/sgi/ip22.h> 29#include <asm/sgi/ip22.h>
31 30
32/*
33 * Note that mktime uses month from 1 to 12 while rtc_time_to_tm
34 * uses 0 to 11.
35 */
36unsigned long read_persistent_clock(void)
37{
38 unsigned int yrs, mon, day, hrs, min, sec;
39 unsigned int save_control;
40 unsigned long flags;
41
42 spin_lock_irqsave(&rtc_lock, flags);
43 save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff;
44 hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE;
45
46 sec = BCD2BIN(hpc3c0->rtcregs[RTC_SECONDS] & 0xff);
47 min = BCD2BIN(hpc3c0->rtcregs[RTC_MINUTES] & 0xff);
48 hrs = BCD2BIN(hpc3c0->rtcregs[RTC_HOURS] & 0x3f);
49 day = BCD2BIN(hpc3c0->rtcregs[RTC_DATE] & 0xff);
50 mon = BCD2BIN(hpc3c0->rtcregs[RTC_MONTH] & 0x1f);
51 yrs = BCD2BIN(hpc3c0->rtcregs[RTC_YEAR] & 0xff);
52
53 hpc3c0->rtcregs[RTC_CMD] = save_control;
54 spin_unlock_irqrestore(&rtc_lock, flags);
55
56 if (yrs < 45)
57 yrs += 30;
58 if ((yrs += 40) < 70)
59 yrs += 100;
60
61 return mktime(yrs + 1900, mon, day, hrs, min, sec);
62}
63
64int rtc_mips_set_time(unsigned long tim)
65{
66 struct rtc_time tm;
67 unsigned int save_control;
68 unsigned long flags;
69
70 rtc_time_to_tm(tim, &tm);
71
72 tm.tm_mon += 1; /* tm_mon starts at zero */
73 tm.tm_year -= 40;
74 if (tm.tm_year >= 100)
75 tm.tm_year -= 100;
76
77 spin_lock_irqsave(&rtc_lock, flags);
78 save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff;
79 hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE;
80
81 hpc3c0->rtcregs[RTC_YEAR] = BIN2BCD(tm.tm_year);
82 hpc3c0->rtcregs[RTC_MONTH] = BIN2BCD(tm.tm_mon);
83 hpc3c0->rtcregs[RTC_DATE] = BIN2BCD(tm.tm_mday);
84 hpc3c0->rtcregs[RTC_HOURS] = BIN2BCD(tm.tm_hour);
85 hpc3c0->rtcregs[RTC_MINUTES] = BIN2BCD(tm.tm_min);
86 hpc3c0->rtcregs[RTC_SECONDS] = BIN2BCD(tm.tm_sec);
87 hpc3c0->rtcregs[RTC_HUNDREDTH_SECOND] = 0;
88
89 hpc3c0->rtcregs[RTC_CMD] = save_control;
90 spin_unlock_irqrestore(&rtc_lock, flags);
91
92 return 0;
93}
94
95static unsigned long dosample(void) 31static unsigned long dosample(void)
96{ 32{
97 u32 ct0, ct1; 33 u32 ct0, ct1;