aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/sgi-ip22
diff options
context:
space:
mode:
authorThomas Bogendoerfer <tsbogend@alpha.franken.de>2008-10-14 11:16:55 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-10-15 07:46:51 -0400
commit7d81a5e03ddbb44d05a32cad4a46a23577216497 (patch)
treead785aafe0b7877bcb65ea8c5d6e0571d6a183f6 /arch/mips/sgi-ip22
parent540799e32eb146c9363445d1118b2bfdebd3da0b (diff)
MIPS: IP22/28: Switch over to RTC class driver
This patchset removes some dead code and creates a platform device for the RTC class driver. Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/sgi-ip22')
-rw-r--r--arch/mips/sgi-ip22/ip22-platform.c15
-rw-r--r--arch/mips/sgi-ip22/ip22-setup.c1
-rw-r--r--arch/mips/sgi-ip22/ip22-time.c64
3 files changed, 15 insertions, 65 deletions
diff --git a/arch/mips/sgi-ip22/ip22-platform.c b/arch/mips/sgi-ip22/ip22-platform.c
index 52486c4d2b0..deddbf0ebe5 100644
--- a/arch/mips/sgi-ip22/ip22-platform.c
+++ b/arch/mips/sgi-ip22/ip22-platform.c
@@ -192,3 +192,18 @@ static int __init sgi_button_devinit(void)
192} 192}
193 193
194device_initcall(sgi_button_devinit); 194device_initcall(sgi_button_devinit);
195
196static int __init sgi_ds1286_devinit(void)
197{
198 struct resource res;
199
200 memset(&res, 0, sizeof(res));
201 res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs);
202 res.end = res.start + sizeof(hpc3c0->rtcregs) - 1;
203 res.flags = IORESOURCE_MEM;
204
205 return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,
206 &res, 1));
207}
208
209device_initcall(sgi_ds1286_devinit);
diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
index 896a1ef8482..b9a931358e2 100644
--- a/arch/mips/sgi-ip22/ip22-setup.c
+++ b/arch/mips/sgi-ip22/ip22-setup.c
@@ -4,7 +4,6 @@
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) 4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
5 * Copyright (C) 1997, 1998 Ralf Baechle (ralf@gnu.org) 5 * Copyright (C) 1997, 1998 Ralf Baechle (ralf@gnu.org)
6 */ 6 */
7#include <linux/ds1286.h>
8#include <linux/init.h> 7#include <linux/init.h>
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/kdev_t.h> 9#include <linux/kdev_t.h>
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index 10e50549165..3dcb27ec0c5 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;