diff options
author | Thomas Bogendoerfer <tsbogend@alpha.franken.de> | 2008-10-14 11:17:28 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-10-15 07:46:51 -0400 |
commit | 3ec066cdb75fb0ece5d4cc1ddfa93392f0f6498a (patch) | |
tree | 28323975f8e22b23d84e84626c264bc1dcf559be | |
parent | 5f119f29063c9a9bf1ab40112c02710c2db84f29 (diff) |
MIPS: IP27: 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>
-rw-r--r-- | arch/mips/sgi-ip27/ip27-timer.c | 99 |
1 files changed, 22 insertions, 77 deletions
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c index 8b4e854af925..1327c2746fb7 100644 --- a/arch/mips/sgi-ip27/ip27-timer.c +++ b/arch/mips/sgi-ip27/ip27-timer.c | |||
@@ -13,12 +13,12 @@ | |||
13 | #include <linux/time.h> | 13 | #include <linux/time.h> |
14 | #include <linux/timex.h> | 14 | #include <linux/timex.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/platform_device.h> | ||
16 | 17 | ||
17 | #include <asm/time.h> | 18 | #include <asm/time.h> |
18 | #include <asm/pgtable.h> | 19 | #include <asm/pgtable.h> |
19 | #include <asm/sgialib.h> | 20 | #include <asm/sgialib.h> |
20 | #include <asm/sn/ioc3.h> | 21 | #include <asm/sn/ioc3.h> |
21 | #include <asm/m48t35.h> | ||
22 | #include <asm/sn/klconfig.h> | 22 | #include <asm/sn/klconfig.h> |
23 | #include <asm/sn/arch.h> | 23 | #include <asm/sn/arch.h> |
24 | #include <asm/sn/addrs.h> | 24 | #include <asm/sn/addrs.h> |
@@ -28,51 +28,6 @@ | |||
28 | 28 | ||
29 | #define TICK_SIZE (tick_nsec / 1000) | 29 | #define TICK_SIZE (tick_nsec / 1000) |
30 | 30 | ||
31 | #if 0 | ||
32 | static int set_rtc_mmss(unsigned long nowtime) | ||
33 | { | ||
34 | int retval = 0; | ||
35 | int real_seconds, real_minutes, cmos_minutes; | ||
36 | struct m48t35_rtc *rtc; | ||
37 | nasid_t nid; | ||
38 | |||
39 | nid = get_nasid(); | ||
40 | rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base + | ||
41 | IOC3_BYTEBUS_DEV0); | ||
42 | |||
43 | rtc->control |= M48T35_RTC_READ; | ||
44 | cmos_minutes = BCD2BIN(rtc->min); | ||
45 | rtc->control &= ~M48T35_RTC_READ; | ||
46 | |||
47 | /* | ||
48 | * Since we're only adjusting minutes and seconds, don't interfere with | ||
49 | * hour overflow. This avoids messing with unknown time zones but | ||
50 | * requires your RTC not to be off by more than 15 minutes | ||
51 | */ | ||
52 | real_seconds = nowtime % 60; | ||
53 | real_minutes = nowtime / 60; | ||
54 | if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) | ||
55 | real_minutes += 30; /* correct for half hour time zone */ | ||
56 | real_minutes %= 60; | ||
57 | |||
58 | if (abs(real_minutes - cmos_minutes) < 30) { | ||
59 | real_seconds = BIN2BCD(real_seconds); | ||
60 | real_minutes = BIN2BCD(real_minutes); | ||
61 | rtc->control |= M48T35_RTC_SET; | ||
62 | rtc->sec = real_seconds; | ||
63 | rtc->min = real_minutes; | ||
64 | rtc->control &= ~M48T35_RTC_SET; | ||
65 | } else { | ||
66 | printk(KERN_WARNING | ||
67 | "set_rtc_mmss: can't update from %d to %d\n", | ||
68 | cmos_minutes, real_minutes); | ||
69 | retval = -1; | ||
70 | } | ||
71 | |||
72 | return retval; | ||
73 | } | ||
74 | #endif | ||
75 | |||
76 | /* Includes for ioc3_init(). */ | 31 | /* Includes for ioc3_init(). */ |
77 | #include <asm/sn/types.h> | 32 | #include <asm/sn/types.h> |
78 | #include <asm/sn/sn0/addrs.h> | 33 | #include <asm/sn/sn0/addrs.h> |
@@ -80,37 +35,6 @@ static int set_rtc_mmss(unsigned long nowtime) | |||
80 | #include <asm/sn/sn0/hubio.h> | 35 | #include <asm/sn/sn0/hubio.h> |
81 | #include <asm/pci/bridge.h> | 36 | #include <asm/pci/bridge.h> |
82 | 37 | ||
83 | unsigned long read_persistent_clock(void) | ||
84 | { | ||
85 | unsigned int year, month, date, hour, min, sec; | ||
86 | struct m48t35_rtc *rtc; | ||
87 | nasid_t nid; | ||
88 | |||
89 | nid = get_nasid(); | ||
90 | rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base + | ||
91 | IOC3_BYTEBUS_DEV0); | ||
92 | |||
93 | rtc->control |= M48T35_RTC_READ; | ||
94 | sec = rtc->sec; | ||
95 | min = rtc->min; | ||
96 | hour = rtc->hour; | ||
97 | date = rtc->date; | ||
98 | month = rtc->month; | ||
99 | year = rtc->year; | ||
100 | rtc->control &= ~M48T35_RTC_READ; | ||
101 | |||
102 | sec = BCD2BIN(sec); | ||
103 | min = BCD2BIN(min); | ||
104 | hour = BCD2BIN(hour); | ||
105 | date = BCD2BIN(date); | ||
106 | month = BCD2BIN(month); | ||
107 | year = BCD2BIN(year); | ||
108 | |||
109 | year += 1970; | ||
110 | |||
111 | return mktime(year, month, date, hour, min, sec); | ||
112 | } | ||
113 | |||
114 | static void enable_rt_irq(unsigned int irq) | 38 | static void enable_rt_irq(unsigned int irq) |
115 | { | 39 | { |
116 | } | 40 | } |
@@ -286,6 +210,7 @@ void __cpuinit cpu_time_init(void) | |||
286 | 210 | ||
287 | void __cpuinit hub_rtc_init(cnodeid_t cnode) | 211 | void __cpuinit hub_rtc_init(cnodeid_t cnode) |
288 | { | 212 | { |
213 | |||
289 | /* | 214 | /* |
290 | * We only need to initialize the current node. | 215 | * We only need to initialize the current node. |
291 | * If this is not the current node then it is a cpuless | 216 | * If this is not the current node then it is a cpuless |
@@ -301,3 +226,23 @@ void __cpuinit hub_rtc_init(cnodeid_t cnode) | |||
301 | LOCAL_HUB_S(PI_RT_PEND_B, 0); | 226 | LOCAL_HUB_S(PI_RT_PEND_B, 0); |
302 | } | 227 | } |
303 | } | 228 | } |
229 | |||
230 | static int __init sgi_ip27_rtc_devinit(void) | ||
231 | { | ||
232 | struct resource res; | ||
233 | |||
234 | memset(&res, 0, sizeof(res)); | ||
235 | res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base + | ||
236 | IOC3_BYTEBUS_DEV0); | ||
237 | res.end = res.start + 32767; | ||
238 | res.flags = IORESOURCE_MEM; | ||
239 | |||
240 | return IS_ERR(platform_device_register_simple("rtc-m48t35", -1, | ||
241 | &res, 1)); | ||
242 | } | ||
243 | |||
244 | /* | ||
245 | * kludge make this a device_initcall after ioc3 resource conflicts | ||
246 | * are resolved | ||
247 | */ | ||
248 | late_initcall(sgi_ip27_rtc_devinit); | ||