aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2007-10-11 18:46:08 -0400
committerRalf Baechle <ralf@linux-mips.org>2007-10-11 18:46:08 -0400
commit4b550488f894c899aa54dc935c8fee47bca2b7df (patch)
treef7ee1d0ff80542124b5fa864a30022277d703c49 /arch/mips
parentf5ff0a280201c9cbfb6e9eb4bafdb465c2269ed3 (diff)
[MIPS] Deforest the function pointer jungle in the time code.
Hard to follow who is pointing what to where and why so it's simply getting in the way of the time code renovation. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/au1000/common/setup.c2
-rw-r--r--arch/mips/au1000/common/time.c4
-rw-r--r--arch/mips/basler/excite/excite_setup.c5
-rw-r--r--arch/mips/bcm47xx/setup.c1
-rw-r--r--arch/mips/bcm47xx/time.c3
-rw-r--r--arch/mips/dec/setup.c4
-rw-r--r--arch/mips/dec/time.c12
-rw-r--r--arch/mips/emma2rh/markeins/setup.c4
-rw-r--r--arch/mips/gt64120/wrppmc/setup.c4
-rw-r--r--arch/mips/gt64120/wrppmc/time.c2
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c4
-rw-r--r--arch/mips/kernel/time.c45
-rw-r--r--arch/mips/lasat/ds1603.c6
-rw-r--r--arch/mips/lasat/ds1603.h2
-rw-r--r--arch/mips/lasat/setup.c6
-rw-r--r--arch/mips/lasat/sysctl.c10
-rw-r--r--arch/mips/lemote/lm2e/setup.c7
-rw-r--r--arch/mips/mips-boards/atlas/atlas_setup.c5
-rw-r--r--arch/mips/mips-boards/generic/time.c4
-rw-r--r--arch/mips/mips-boards/malta/malta_setup.c4
-rw-r--r--arch/mips/mips-boards/sead/sead_setup.c3
-rw-r--r--arch/mips/mipssim/sim_setup.c2
-rw-r--r--arch/mips/mipssim/sim_time.c2
-rw-r--r--arch/mips/philips/pnx8550/common/setup.c3
-rw-r--r--arch/mips/philips/pnx8550/common/time.c7
-rw-r--r--arch/mips/pmc-sierra/msp71xx/msp_setup.c3
-rw-r--r--arch/mips/pmc-sierra/msp71xx/msp_time.c3
-rw-r--r--arch/mips/pmc-sierra/yosemite/setup.c18
-rw-r--r--arch/mips/sgi-ip22/ip22-setup.c2
-rw-r--r--arch/mips/sgi-ip22/ip22-time.c15
-rw-r--r--arch/mips/sgi-ip27/ip27-init.c3
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c6
-rw-r--r--arch/mips/sgi-ip32/ip32-setup.c12
-rw-r--r--arch/mips/sibyte/swarm/setup.c56
-rw-r--r--arch/mips/sni/pcimt.c1
-rw-r--r--arch/mips/sni/pcit.c1
-rw-r--r--arch/mips/sni/rm200.c1
-rw-r--r--arch/mips/sni/time.c8
-rw-r--r--arch/mips/tx4927/common/tx4927_setup.c9
-rw-r--r--arch/mips/tx4938/common/setup.c9
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/setup.c3
-rw-r--r--arch/mips/vr41xx/common/init.c8
42 files changed, 110 insertions, 199 deletions
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
index a95b37773196..b212c0726125 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/au1000/common/setup.c
@@ -50,7 +50,6 @@ extern void au1000_halt(void);
50extern void au1000_power_off(void); 50extern void au1000_power_off(void);
51extern void au1x_time_init(void); 51extern void au1x_time_init(void);
52extern void au1x_timer_setup(struct irqaction *irq); 52extern void au1x_timer_setup(struct irqaction *irq);
53extern void au1xxx_time_init(void);
54extern void set_cpuspec(void); 53extern void set_cpuspec(void);
55 54
56void __init plat_mem_setup(void) 55void __init plat_mem_setup(void)
@@ -112,7 +111,6 @@ void __init plat_mem_setup(void)
112 _machine_restart = au1000_restart; 111 _machine_restart = au1000_restart;
113 _machine_halt = au1000_halt; 112 _machine_halt = au1000_halt;
114 pm_power_off = au1000_power_off; 113 pm_power_off = au1000_power_off;
115 board_time_init = au1xxx_time_init;
116 114
117 /* IO/MEM resources. */ 115 /* IO/MEM resources. */
118 set_io_port_base(0); 116 set_io_port_base(0);
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
index 8fc29982d700..fb1fd50f19a6 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/au1000/common/time.c
@@ -329,7 +329,3 @@ void __init plat_timer_setup(struct irqaction *irq)
329 329
330#endif 330#endif
331} 331}
332
333void __init au1xxx_time_init(void)
334{
335}
diff --git a/arch/mips/basler/excite/excite_setup.c b/arch/mips/basler/excite/excite_setup.c
index 56003188f17c..68be19d1802e 100644
--- a/arch/mips/basler/excite/excite_setup.c
+++ b/arch/mips/basler/excite/excite_setup.c
@@ -68,7 +68,7 @@ DEFINE_SPINLOCK(titan_lock);
68int titan_irqflags; 68int titan_irqflags;
69 69
70 70
71static void excite_timer_init(void) 71void __init plat_time_init(void)
72{ 72{
73 const u32 modebit5 = ocd_readl(0x00e4); 73 const u32 modebit5 = ocd_readl(0x00e4);
74 unsigned int 74 unsigned int
@@ -261,9 +261,6 @@ void __init plat_mem_setup(void)
261 /* Announce RAM to system */ 261 /* Announce RAM to system */
262 add_memory_region(0x00000000, memsize, BOOT_MEM_RAM); 262 add_memory_region(0x00000000, memsize, BOOT_MEM_RAM);
263 263
264 /* Set up timer initialization hooks */
265 board_time_init = excite_timer_init;
266
267 /* Set up the peripheral address map */ 264 /* Set up the peripheral address map */
268 *(boot_ocd_base + (LKB9 / sizeof (u32))) = 0; 265 *(boot_ocd_base + (LKB9 / sizeof (u32))) = 0;
269 *(boot_ocd_base + (LKB10 / sizeof (u32))) = 0; 266 *(boot_ocd_base + (LKB10 / sizeof (u32))) = 0;
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index f48aa5aa9bf0..1b6b0fa5028f 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -119,6 +119,5 @@ void __init plat_mem_setup(void)
119 _machine_restart = bcm47xx_machine_restart; 119 _machine_restart = bcm47xx_machine_restart;
120 _machine_halt = bcm47xx_machine_halt; 120 _machine_halt = bcm47xx_machine_halt;
121 pm_power_off = bcm47xx_machine_halt; 121 pm_power_off = bcm47xx_machine_halt;
122 board_time_init = bcm47xx_time_init;
123} 122}
124 123
diff --git a/arch/mips/bcm47xx/time.c b/arch/mips/bcm47xx/time.c
index b27d07f29059..0ab4676c8bd3 100644
--- a/arch/mips/bcm47xx/time.c
+++ b/arch/mips/bcm47xx/time.c
@@ -28,8 +28,7 @@
28#include <asm/time.h> 28#include <asm/time.h>
29#include <bcm47xx.h> 29#include <bcm47xx.h>
30 30
31void __init 31void __init plat_time_init(void)
32bcm47xx_time_init(void)
33{ 32{
34 unsigned long hz; 33 unsigned long hz;
35 34
diff --git a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c
index 3e634f2f5443..bd5431e1f408 100644
--- a/arch/mips/dec/setup.c
+++ b/arch/mips/dec/setup.c
@@ -145,13 +145,9 @@ static void __init dec_be_init(void)
145 } 145 }
146} 146}
147 147
148
149extern void dec_time_init(void);
150
151void __init plat_mem_setup(void) 148void __init plat_mem_setup(void)
152{ 149{
153 board_be_init = dec_be_init; 150 board_be_init = dec_be_init;
154 board_time_init = dec_time_init;
155 151
156 wbflush_setup(); 152 wbflush_setup();
157 153
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index e2973a432b92..820e5331205f 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -35,7 +35,7 @@
35#include <asm/dec/ioasic_addrs.h> 35#include <asm/dec/ioasic_addrs.h>
36#include <asm/dec/machtype.h> 36#include <asm/dec/machtype.h>
37 37
38static unsigned long dec_rtc_get_time(void) 38unsigned long read_persistent_clock(void)
39{ 39{
40 unsigned int year, mon, day, hour, min, sec, real_year; 40 unsigned int year, mon, day, hour, min, sec, real_year;
41 unsigned long flags; 41 unsigned long flags;
@@ -74,13 +74,13 @@ static unsigned long dec_rtc_get_time(void)
74} 74}
75 75
76/* 76/*
77 * In order to set the CMOS clock precisely, dec_rtc_set_mmss has to 77 * In order to set the CMOS clock precisely, rtc_mips_set_mmss has to
78 * be called 500 ms after the second nowtime has started, because when 78 * be called 500 ms after the second nowtime has started, because when
79 * nowtime is written into the registers of the CMOS clock, it will 79 * nowtime is written into the registers of the CMOS clock, it will
80 * jump to the next second precisely 500 ms later. Check the Dallas 80 * jump to the next second precisely 500 ms later. Check the Dallas
81 * DS1287 data sheet for details. 81 * DS1287 data sheet for details.
82 */ 82 */
83static int dec_rtc_set_mmss(unsigned long nowtime) 83int rtc_mips_set_mmss(unsigned long nowtime)
84{ 84{
85 int retval = 0; 85 int retval = 0;
86 int real_seconds, real_minutes, cmos_minutes; 86 int real_seconds, real_minutes, cmos_minutes;
@@ -139,7 +139,6 @@ static int dec_rtc_set_mmss(unsigned long nowtime)
139 return retval; 139 return retval;
140} 140}
141 141
142
143static int dec_timer_state(void) 142static int dec_timer_state(void)
144{ 143{
145 return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0; 144 return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0;
@@ -160,11 +159,8 @@ static cycle_t dec_ioasic_hpt_read(void)
160} 159}
161 160
162 161
163void __init dec_time_init(void) 162void __init plat_time_init(void)
164{ 163{
165 rtc_mips_get_time = dec_rtc_get_time;
166 rtc_mips_set_mmss = dec_rtc_set_mmss;
167
168 mips_timer_state = dec_timer_state; 164 mips_timer_state = dec_timer_state;
169 mips_timer_ack = dec_timer_ack; 165 mips_timer_ack = dec_timer_ack;
170 166
diff --git a/arch/mips/emma2rh/markeins/setup.c b/arch/mips/emma2rh/markeins/setup.c
index 2f060e1ed36c..5e1da53b04a7 100644
--- a/arch/mips/emma2rh/markeins/setup.c
+++ b/arch/mips/emma2rh/markeins/setup.c
@@ -88,7 +88,7 @@ static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
88 return clock[reg]; 88 return clock[reg];
89} 89}
90 90
91static void __init emma2rh_time_init(void) 91void __init plat_time_init(void)
92{ 92{
93 u32 reg; 93 u32 reg;
94 if (bus_frequency == 0) 94 if (bus_frequency == 0)
@@ -124,8 +124,6 @@ void __init plat_mem_setup(void)
124 124
125 set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE)); 125 set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE));
126 126
127 board_time_init = emma2rh_time_init;
128
129 _machine_restart = markeins_machine_restart; 127 _machine_restart = markeins_machine_restart;
130 _machine_halt = markeins_machine_halt; 128 _machine_halt = markeins_machine_halt;
131 pm_power_off = markeins_machine_power_off; 129 pm_power_off = markeins_machine_power_off;
diff --git a/arch/mips/gt64120/wrppmc/setup.c b/arch/mips/gt64120/wrppmc/setup.c
index 238b5087fbb3..f2ccf101e6d9 100644
--- a/arch/mips/gt64120/wrppmc/setup.c
+++ b/arch/mips/gt64120/wrppmc/setup.c
@@ -126,7 +126,6 @@ static void wrppmc_setup_serial(void)
126 126
127void __init plat_mem_setup(void) 127void __init plat_mem_setup(void)
128{ 128{
129 extern void wrppmc_time_init(void);
130 extern void wrppmc_machine_restart(char *command); 129 extern void wrppmc_machine_restart(char *command);
131 extern void wrppmc_machine_halt(void); 130 extern void wrppmc_machine_halt(void);
132 extern void wrppmc_machine_power_off(void); 131 extern void wrppmc_machine_power_off(void);
@@ -135,9 +134,6 @@ void __init plat_mem_setup(void)
135 _machine_halt = wrppmc_machine_halt; 134 _machine_halt = wrppmc_machine_halt;
136 pm_power_off = wrppmc_machine_power_off; 135 pm_power_off = wrppmc_machine_power_off;
137 136
138 /* Use MIPS Count/Compare Timer */
139 board_time_init = wrppmc_time_init;
140
141 /* This makes the operations of 'in/out[bwl]' to the 137 /* This makes the operations of 'in/out[bwl]' to the
142 * physical address ( < KSEG0) can work via KSEG1 138 * physical address ( < KSEG0) can work via KSEG1
143 */ 139 */
diff --git a/arch/mips/gt64120/wrppmc/time.c b/arch/mips/gt64120/wrppmc/time.c
index 5b440859bcee..faf164e7e0df 100644
--- a/arch/mips/gt64120/wrppmc/time.c
+++ b/arch/mips/gt64120/wrppmc/time.c
@@ -38,7 +38,7 @@ void __init plat_timer_setup(struct irqaction *irq)
38 * NOTE: We disable all GT64120 timers, and use MIPS processor internal 38 * NOTE: We disable all GT64120 timers, and use MIPS processor internal
39 * timer as the source of kernel clock tick. 39 * timer as the source of kernel clock tick.
40 */ 40 */
41void __init wrppmc_time_init(void) 41void __init plat_time_init(void)
42{ 42{
43 /* Disable GT64120 timers */ 43 /* Disable GT64120 timers */
44 GT_WRITE(GT_TC_CONTROL_OFS, 0x00); 44 GT_WRITE(GT_TC_CONTROL_OFS, 0x00);
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index fde56e86c2ab..7f14f70a1b88 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -109,7 +109,7 @@ static void jmr3927_timer_ack(void)
109 jmr3927_tmrptr->tisr = 0; /* ack interrupt */ 109 jmr3927_tmrptr->tisr = 0; /* ack interrupt */
110} 110}
111 111
112static void __init jmr3927_time_init(void) 112void __init plat_time_init(void)
113{ 113{
114 clocksource_mips.read = jmr3927_hpt_read; 114 clocksource_mips.read = jmr3927_hpt_read;
115 mips_timer_ack = jmr3927_timer_ack; 115 mips_timer_ack = jmr3927_timer_ack;
@@ -141,8 +141,6 @@ void __init plat_mem_setup(void)
141 141
142 set_io_port_base(JMR3927_PORT_BASE + JMR3927_PCIIO); 142 set_io_port_base(JMR3927_PORT_BASE + JMR3927_PCIIO);
143 143
144 board_time_init = jmr3927_time_init;
145
146 _machine_restart = jmr3927_machine_restart; 144 _machine_restart = jmr3927_machine_restart;
147 _machine_halt = jmr3927_machine_halt; 145 _machine_halt = jmr3927_machine_halt;
148 pm_power_off = jmr3927_machine_power_off; 146 pm_power_off = jmr3927_machine_power_off;
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 628a8ba6da57..9bbbd9b327fc 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -49,24 +49,19 @@
49 * forward reference 49 * forward reference
50 */ 50 */
51DEFINE_SPINLOCK(rtc_lock); 51DEFINE_SPINLOCK(rtc_lock);
52EXPORT_SYMBOL(rtc_lock);
52 53
53/* 54int __weak rtc_mips_set_time(unsigned long sec)
54 * By default we provide the null RTC ops
55 */
56static unsigned long null_rtc_get_time(void)
57{ 55{
58 return mktime(2000, 1, 1, 0, 0, 0); 56 return 0;
59} 57}
58EXPORT_SYMBOL(rtc_mips_set_time);
60 59
61static int null_rtc_set_time(unsigned long sec) 60int __weak rtc_mips_set_mmss(unsigned long nowtime)
62{ 61{
63 return 0; 62 return rtc_mips_set_time(nowtime);
64} 63}
65 64
66unsigned long (*rtc_mips_get_time)(void) = null_rtc_get_time;
67int (*rtc_mips_set_time)(unsigned long) = null_rtc_set_time;
68int (*rtc_mips_set_mmss)(unsigned long);
69
70int update_persistent_clock(struct timespec now) 65int update_persistent_clock(struct timespec now)
71{ 66{
72 return rtc_mips_set_mmss(now.tv_sec); 67 return rtc_mips_set_mmss(now.tv_sec);
@@ -247,21 +242,18 @@ asmlinkage void ll_local_timer_interrupt(int irq)
247/* 242/*
248 * time_init() - it does the following things. 243 * time_init() - it does the following things.
249 * 244 *
250 * 1) board_time_init() - 245 * 1) plat_time_init() -
251 * a) (optional) set up RTC routines, 246 * a) (optional) set up RTC routines,
252 * b) (optional) calibrate and set the mips_hpt_frequency 247 * b) (optional) calibrate and set the mips_hpt_frequency
253 * (only needed if you intended to use cpu counter as timer interrupt 248 * (only needed if you intended to use cpu counter as timer interrupt
254 * source) 249 * source)
255 * 2) setup xtime based on rtc_mips_get_time(). 250 * 2) calculate a couple of cached variables for later usage
256 * 3) calculate a couple of cached variables for later usage 251 * 3) plat_timer_setup() -
257 * 4) plat_timer_setup() -
258 * a) (optional) over-write any choices made above by time_init(). 252 * a) (optional) over-write any choices made above by time_init().
259 * b) machine specific code should setup the timer irqaction. 253 * b) machine specific code should setup the timer irqaction.
260 * c) enable the timer interrupt 254 * c) enable the timer interrupt
261 */ 255 */
262 256
263void (*board_time_init)(void);
264
265unsigned int mips_hpt_frequency; 257unsigned int mips_hpt_frequency;
266 258
267static struct irqaction timer_irqaction = { 259static struct irqaction timer_irqaction = {
@@ -341,19 +333,13 @@ static void __init init_mips_clocksource(void)
341 clocksource_register(&clocksource_mips); 333 clocksource_register(&clocksource_mips);
342} 334}
343 335
344void __init time_init(void) 336void __init __weak plat_time_init(void)
345{ 337{
346 if (board_time_init) 338}
347 board_time_init();
348
349 if (!rtc_mips_set_mmss)
350 rtc_mips_set_mmss = rtc_mips_set_time;
351
352 xtime.tv_sec = rtc_mips_get_time();
353 xtime.tv_nsec = 0;
354 339
355 set_normalized_timespec(&wall_to_monotonic, 340void __init time_init(void)
356 -xtime.tv_sec, -xtime.tv_nsec); 341{
342 plat_time_init();
357 343
358 /* Choose appropriate high precision timer routines. */ 344 /* Choose appropriate high precision timer routines. */
359 if (!cpu_has_counter && !clocksource_mips.read) 345 if (!cpu_has_counter && !clocksource_mips.read)
@@ -459,7 +445,4 @@ void to_tm(unsigned long tim, struct rtc_time *tm)
459 tm->tm_wday = (gday + 4) % 7; /* 1970/1/1 was Thursday */ 445 tm->tm_wday = (gday + 4) % 7; /* 1970/1/1 was Thursday */
460} 446}
461 447
462EXPORT_SYMBOL(rtc_lock);
463EXPORT_SYMBOL(to_tm); 448EXPORT_SYMBOL(to_tm);
464EXPORT_SYMBOL(rtc_mips_set_time);
465EXPORT_SYMBOL(rtc_mips_get_time);
diff --git a/arch/mips/lasat/ds1603.c b/arch/mips/lasat/ds1603.c
index 0b315f51d62c..52cb1436a12a 100644
--- a/arch/mips/lasat/ds1603.c
+++ b/arch/mips/lasat/ds1603.c
@@ -135,8 +135,7 @@ static void rtc_end_op(void)
135 lasat_ndelay(1000); 135 lasat_ndelay(1000);
136} 136}
137 137
138/* interface */ 138unsigned long read_persistent_clock(void)
139unsigned long ds1603_read(void)
140{ 139{
141 unsigned long word; 140 unsigned long word;
142 unsigned long flags; 141 unsigned long flags;
@@ -147,10 +146,11 @@ unsigned long ds1603_read(void)
147 word = rtc_read_word(); 146 word = rtc_read_word();
148 rtc_end_op(); 147 rtc_end_op();
149 spin_unlock_irqrestore(&rtc_lock, flags); 148 spin_unlock_irqrestore(&rtc_lock, flags);
149
150 return word; 150 return word;
151} 151}
152 152
153int ds1603_set(unsigned long time) 153int rtc_mips_set_mmss(unsigned long time)
154{ 154{
155 unsigned long flags; 155 unsigned long flags;
156 156
diff --git a/arch/mips/lasat/ds1603.h b/arch/mips/lasat/ds1603.h
index c2e5c76a379d..2da3704044fd 100644
--- a/arch/mips/lasat/ds1603.h
+++ b/arch/mips/lasat/ds1603.h
@@ -20,8 +20,6 @@ struct ds_defs {
20 20
21extern struct ds_defs *ds1603; 21extern struct ds_defs *ds1603;
22 22
23unsigned long ds1603_read(void);
24int ds1603_set(unsigned long);
25void ds1603_set_trimmer(unsigned int); 23void ds1603_set_trimmer(unsigned int);
26void ds1603_enable(void); 24void ds1603_enable(void);
27void ds1603_disable(void); 25void ds1603_disable(void);
diff --git a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
index 187e37821d93..54827d0174bf 100644
--- a/arch/mips/lasat/setup.c
+++ b/arch/mips/lasat/setup.c
@@ -117,7 +117,7 @@ static struct notifier_block lasat_panic_block[] =
117 } 117 }
118}; 118};
119 119
120static void lasat_time_init(void) 120void plat_time_init(void)
121{ 121{
122 mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2; 122 mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2;
123} 123}
@@ -142,12 +142,8 @@ void __init plat_mem_setup(void)
142 142
143 lasat_reboot_setup(); 143 lasat_reboot_setup();
144 144
145 board_time_init = lasat_time_init;
146
147#ifdef CONFIG_DS1603 145#ifdef CONFIG_DS1603
148 ds1603 = &ds_defs[mips_machtype]; 146 ds1603 = &ds_defs[mips_machtype];
149 rtc_mips_get_time = ds1603_read;
150 rtc_mips_set_time = ds1603_set;
151#endif 147#endif
152 148
153#ifdef DYNAMIC_SERIAL_INIT 149#ifdef DYNAMIC_SERIAL_INIT
diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c
index 4575a829766d..389336c4ecc5 100644
--- a/arch/mips/lasat/sysctl.c
+++ b/arch/mips/lasat/sysctl.c
@@ -32,6 +32,8 @@
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34 34
35#include <asm/time.h>
36
35#include "sysctl.h" 37#include "sysctl.h"
36#include "ds1603.h" 38#include "ds1603.h"
37 39
@@ -106,7 +108,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
106 108
107 mutex_lock(&lasat_info_mutex); 109 mutex_lock(&lasat_info_mutex);
108 if (!write) { 110 if (!write) {
109 rtctmp = ds1603_read(); 111 rtctmp = read_persistent_clock();
110 /* check for time < 0 and set to 0 */ 112 /* check for time < 0 and set to 0 */
111 if (rtctmp < 0) 113 if (rtctmp < 0)
112 rtctmp = 0; 114 rtctmp = 0;
@@ -116,7 +118,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
116 mutex_unlock(&lasat_info_mutex); 118 mutex_unlock(&lasat_info_mutex);
117 return r; 119 return r;
118 } 120 }
119 ds1603_set(rtctmp); 121 rtc_mips_set_mmss(rtctmp);
120 mutex_unlock(&lasat_info_mutex); 122 mutex_unlock(&lasat_info_mutex);
121 123
122 return 0; 124 return 0;
@@ -152,7 +154,7 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
152 int r; 154 int r;
153 155
154 mutex_lock(&lasat_info_mutex); 156 mutex_lock(&lasat_info_mutex);
155 rtctmp = ds1603_read(); 157 rtctmp = read_persistent_clock();
156 if (rtctmp < 0) 158 if (rtctmp < 0)
157 rtctmp = 0; 159 rtctmp = 0;
158 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen); 160 r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen);
@@ -161,7 +163,7 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
161 return r; 163 return r;
162 } 164 }
163 if (newval && newlen) 165 if (newval && newlen)
164 ds1603_set(rtctmp); 166 rtc_mips_set_mmss(rtctmp);
165 mutex_unlock(&lasat_info_mutex); 167 mutex_unlock(&lasat_info_mutex);
166 168
167 return 1; 169 return 1;
diff --git a/arch/mips/lemote/lm2e/setup.c b/arch/mips/lemote/lm2e/setup.c
index f34350a4f271..09314a20f9fb 100644
--- a/arch/mips/lemote/lm2e/setup.c
+++ b/arch/mips/lemote/lm2e/setup.c
@@ -58,13 +58,13 @@ void __init plat_timer_setup(struct irqaction *irq)
58 setup_irq(MIPS_CPU_IRQ_BASE + 7, irq); 58 setup_irq(MIPS_CPU_IRQ_BASE + 7, irq);
59} 59}
60 60
61static void __init loongson2e_time_init(void) 61void __init plat_time_init(void)
62{ 62{
63 /* setup mips r4k timer */ 63 /* setup mips r4k timer */
64 mips_hpt_frequency = cpu_clock_freq / 2; 64 mips_hpt_frequency = cpu_clock_freq / 2;
65} 65}
66 66
67static unsigned long __init mips_rtc_get_time(void) 67unsigned long read_persistent_clock(void)
68{ 68{
69 return mc146818_get_cmos_time(); 69 return mc146818_get_cmos_time();
70} 70}
@@ -89,9 +89,6 @@ void __init plat_mem_setup(void)
89 89
90 mips_reboot_setup(); 90 mips_reboot_setup();
91 91
92 board_time_init = loongson2e_time_init;
93 rtc_mips_get_time = mips_rtc_get_time;
94
95 __wbflush = wbflush_loongson2e; 92 __wbflush = wbflush_loongson2e;
96 93
97 add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); 94 add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
diff --git a/arch/mips/mips-boards/atlas/atlas_setup.c b/arch/mips/mips-boards/atlas/atlas_setup.c
index c68358a476dd..86bfc0548164 100644
--- a/arch/mips/mips-boards/atlas/atlas_setup.c
+++ b/arch/mips/mips-boards/atlas/atlas_setup.c
@@ -35,8 +35,6 @@
35#include <asm/traps.h> 35#include <asm/traps.h>
36 36
37extern void mips_reboot_setup(void); 37extern void mips_reboot_setup(void);
38extern void mips_time_init(void);
39extern unsigned long mips_rtc_get_time(void);
40 38
41#ifdef CONFIG_KGDB 39#ifdef CONFIG_KGDB
42extern void kgdb_config(void); 40extern void kgdb_config(void);
@@ -63,9 +61,6 @@ void __init plat_mem_setup(void)
63 kgdb_config(); 61 kgdb_config();
64#endif 62#endif
65 mips_reboot_setup(); 63 mips_reboot_setup();
66
67 board_time_init = mips_time_init;
68 rtc_mips_get_time = mips_rtc_get_time;
69} 64}
70 65
71static void __init serial_init(void) 66static void __init serial_init(void)
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index d7bff9ca5356..075f9d46f40e 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -224,12 +224,12 @@ static unsigned int __init estimate_cpu_frequency(void)
224 return count; 224 return count;
225} 225}
226 226
227unsigned long __init mips_rtc_get_time(void) 227unsigned long read_persistent_clock(void)
228{ 228{
229 return mc146818_get_cmos_time(); 229 return mc146818_get_cmos_time();
230} 230}
231 231
232void __init mips_time_init(void) 232void __init plat_time_init(void)
233{ 233{
234 unsigned int est_freq; 234 unsigned int est_freq;
235 235
diff --git a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mips-boards/malta/malta_setup.c
index 8f1b78dfd89f..a5a5a43a1984 100644
--- a/arch/mips/mips-boards/malta/malta_setup.c
+++ b/arch/mips/mips-boards/malta/malta_setup.c
@@ -36,7 +36,6 @@
36#endif 36#endif
37 37
38extern void mips_reboot_setup(void); 38extern void mips_reboot_setup(void);
39extern void mips_time_init(void);
40extern unsigned long mips_rtc_get_time(void); 39extern unsigned long mips_rtc_get_time(void);
41 40
42#ifdef CONFIG_KGDB 41#ifdef CONFIG_KGDB
@@ -185,7 +184,4 @@ void __init plat_mem_setup(void)
185#endif 184#endif
186#endif 185#endif
187 mips_reboot_setup(); 186 mips_reboot_setup();
188
189 board_time_init = mips_time_init;
190 rtc_mips_get_time = mips_rtc_get_time;
191} 187}
diff --git a/arch/mips/mips-boards/sead/sead_setup.c b/arch/mips/mips-boards/sead/sead_setup.c
index 5f70eaf01fab..fad58972f3ac 100644
--- a/arch/mips/mips-boards/sead/sead_setup.c
+++ b/arch/mips/mips-boards/sead/sead_setup.c
@@ -35,7 +35,6 @@
35#include <asm/time.h> 35#include <asm/time.h>
36 36
37extern void mips_reboot_setup(void); 37extern void mips_reboot_setup(void);
38extern void mips_time_init(void);
39 38
40static void __init serial_init(void); 39static void __init serial_init(void);
41 40
@@ -52,8 +51,6 @@ void __init plat_mem_setup(void)
52 51
53 serial_init (); 52 serial_init ();
54 53
55 board_time_init = mips_time_init;
56
57 mips_reboot_setup(); 54 mips_reboot_setup();
58} 55}
59 56
diff --git a/arch/mips/mipssim/sim_setup.c b/arch/mips/mipssim/sim_setup.c
index d012719c4d24..452c129d02c1 100644
--- a/arch/mips/mipssim/sim_setup.c
+++ b/arch/mips/mipssim/sim_setup.c
@@ -36,7 +36,6 @@
36#include <asm/mips-boards/simint.h> 36#include <asm/mips-boards/simint.h>
37 37
38 38
39extern void sim_time_init(void);
40static void __init serial_init(void); 39static void __init serial_init(void);
41unsigned int _isbonito = 0; 40unsigned int _isbonito = 0;
42 41
@@ -54,7 +53,6 @@ void __init plat_mem_setup(void)
54 53
55 serial_init(); 54 serial_init();
56 55
57 board_time_init = sim_time_init;
58 pr_info("Linux started...\n"); 56 pr_info("Linux started...\n");
59 57
60#ifdef CONFIG_MIPS_MT_SMP 58#ifdef CONFIG_MIPS_MT_SMP
diff --git a/arch/mips/mipssim/sim_time.c b/arch/mips/mipssim/sim_time.c
index a0f5a5dca1b2..9a355e77952f 100644
--- a/arch/mips/mipssim/sim_time.c
+++ b/arch/mips/mipssim/sim_time.c
@@ -146,7 +146,7 @@ static unsigned int __init estimate_cpu_frequency(void)
146 return count; 146 return count;
147} 147}
148 148
149void __init sim_time_init(void) 149void __init plat_time_init(void)
150{ 150{
151 unsigned int est_freq, flags; 151 unsigned int est_freq, flags;
152 152
diff --git a/arch/mips/philips/pnx8550/common/setup.c b/arch/mips/philips/pnx8550/common/setup.c
index 5bd737477685..2ce298f4d19a 100644
--- a/arch/mips/philips/pnx8550/common/setup.c
+++ b/arch/mips/philips/pnx8550/common/setup.c
@@ -47,7 +47,6 @@ extern void pnx8550_machine_halt(void);
47extern void pnx8550_machine_power_off(void); 47extern void pnx8550_machine_power_off(void);
48extern struct resource ioport_resource; 48extern struct resource ioport_resource;
49extern struct resource iomem_resource; 49extern struct resource iomem_resource;
50extern void pnx8550_time_init(void);
51extern void rs_kgdb_hook(int tty_no); 50extern void rs_kgdb_hook(int tty_no);
52extern char *prom_getcmdline(void); 51extern char *prom_getcmdline(void);
53 52
@@ -104,8 +103,6 @@ void __init plat_mem_setup(void)
104 _machine_halt = pnx8550_machine_halt; 103 _machine_halt = pnx8550_machine_halt;
105 pm_power_off = pnx8550_machine_power_off; 104 pm_power_off = pnx8550_machine_power_off;
106 105
107 board_time_init = pnx8550_time_init;
108
109 /* Clear the Global 2 Register, PCI Inta Output Enable Registers 106 /* Clear the Global 2 Register, PCI Inta Output Enable Registers
110 Bit 1:Enable DAC Powerdown 107 Bit 1:Enable DAC Powerdown
111 -> 0:DACs are enabled and are working normally 108 -> 0:DACs are enabled and are working normally
diff --git a/arch/mips/philips/pnx8550/common/time.c b/arch/mips/philips/pnx8550/common/time.c
index 68def3880a1c..e818fd0f1584 100644
--- a/arch/mips/philips/pnx8550/common/time.c
+++ b/arch/mips/philips/pnx8550/common/time.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright 2001, 2002, 2003 MontaVista Software Inc. 2 * Copyright 2001, 2002, 2003 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net 3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
4 * 5 *
5 * Common time service routines for MIPS machines. See 6 * Common time service routines for MIPS machines. See
6 * Documents/MIPS/README.txt. 7 * Documents/MIPS/README.txt.
@@ -46,16 +47,16 @@ static void timer_ack(void)
46} 47}
47 48
48/* 49/*
49 * pnx8550_time_init() - it does the following things: 50 * plat_time_init() - it does the following things:
50 * 51 *
51 * 1) board_time_init() - 52 * 1) plat_time_init() -
52 * a) (optional) set up RTC routines, 53 * a) (optional) set up RTC routines,
53 * b) (optional) calibrate and set the mips_hpt_frequency 54 * b) (optional) calibrate and set the mips_hpt_frequency
54 * (only needed if you intended to use cpu counter as timer interrupt 55 * (only needed if you intended to use cpu counter as timer interrupt
55 * source) 56 * source)
56 */ 57 */
57 58
58void pnx8550_time_init(void) 59__init void plat_time_init(void)
59{ 60{
60 unsigned int n; 61 unsigned int n;
61 unsigned int m; 62 unsigned int m;
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_setup.c b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
index e4cc54824475..c93675615f5d 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_setup.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
@@ -25,7 +25,6 @@
25#define MSP_BOARD_RESET_GPIO 9 25#define MSP_BOARD_RESET_GPIO 9
26#endif 26#endif
27 27
28extern void msp_timer_init(void);
29extern void msp_serial_setup(void); 28extern void msp_serial_setup(void);
30extern void pmctwiled_setup(void); 29extern void pmctwiled_setup(void);
31 30
@@ -149,8 +148,6 @@ void __init plat_mem_setup(void)
149 _machine_restart = msp_restart; 148 _machine_restart = msp_restart;
150 _machine_halt = msp_halt; 149 _machine_halt = msp_halt;
151 pm_power_off = msp_power_off; 150 pm_power_off = msp_power_off;
152
153 board_time_init = msp_timer_init;
154} 151}
155 152
156void __init prom_init(void) 153void __init prom_init(void)
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_time.c b/arch/mips/pmc-sierra/msp71xx/msp_time.c
index 2a2beac5a4f8..f221d4763625 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_time.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_time.c
@@ -36,7 +36,7 @@
36#include <msp_int.h> 36#include <msp_int.h>
37#include <msp_regs.h> 37#include <msp_regs.h>
38 38
39void __init msp_timer_init(void) 39void __init plat_time_init(void)
40{ 40{
41 char *endp, *s; 41 char *endp, *s;
42 unsigned long cpu_rate = 0; 42 unsigned long cpu_rate = 0;
@@ -81,7 +81,6 @@ void __init msp_timer_init(void)
81 mips_hpt_frequency = cpu_rate/2; 81 mips_hpt_frequency = cpu_rate/2;
82} 82}
83 83
84
85void __init plat_timer_setup(struct irqaction *irq) 84void __init plat_timer_setup(struct irqaction *irq)
86{ 85{
87#ifdef CONFIG_IRQ_MSP_CIC 86#ifdef CONFIG_IRQ_MSP_CIC
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c
index 58862c8d1d00..56bf69595da8 100644
--- a/arch/mips/pmc-sierra/yosemite/setup.c
+++ b/arch/mips/pmc-sierra/yosemite/setup.c
@@ -70,7 +70,7 @@ void __init bus_error_init(void)
70} 70}
71 71
72 72
73unsigned long m48t37y_get_time(void) 73unsigned long read_persistent_clock(void)
74{ 74{
75 unsigned int year, month, day, hour, min, sec; 75 unsigned int year, month, day, hour, min, sec;
76 unsigned long flags; 76 unsigned long flags;
@@ -95,7 +95,7 @@ unsigned long m48t37y_get_time(void)
95 return mktime(year, month, day, hour, min, sec); 95 return mktime(year, month, day, hour, min, sec);
96} 96}
97 97
98int m48t37y_set_time(unsigned long sec) 98int rtc_mips_set_time(unsigned long tim)
99{ 99{
100 struct rtc_time tm; 100 struct rtc_time tm;
101 unsigned long flags; 101 unsigned long flags;
@@ -138,7 +138,7 @@ void __init plat_timer_setup(struct irqaction *irq)
138 setup_irq(7, irq); 138 setup_irq(7, irq);
139} 139}
140 140
141void yosemite_time_init(void) 141void __init plat_time_init(void)
142{ 142{
143 mips_hpt_frequency = cpu_clock_freq / 2; 143 mips_hpt_frequency = cpu_clock_freq / 2;
144mips_hpt_frequency = 33000000 * 3 * 5; 144mips_hpt_frequency = 33000000 * 3 * 5;
@@ -198,17 +198,6 @@ static void __init py_rtc_setup(void)
198 m48t37_base = ioremap(YOSEMITE_RTC_BASE, YOSEMITE_RTC_SIZE); 198 m48t37_base = ioremap(YOSEMITE_RTC_BASE, YOSEMITE_RTC_SIZE);
199 if (!m48t37_base) 199 if (!m48t37_base)
200 printk(KERN_ERR "Mapping the RTC failed\n"); 200 printk(KERN_ERR "Mapping the RTC failed\n");
201
202 rtc_mips_get_time = m48t37y_get_time;
203 rtc_mips_set_time = m48t37y_set_time;
204
205 write_seqlock(&xtime_lock);
206 xtime.tv_sec = m48t37y_get_time();
207 xtime.tv_nsec = 0;
208
209 set_normalized_timespec(&wall_to_monotonic,
210 -xtime.tv_sec, -xtime.tv_nsec);
211 write_sequnlock(&xtime_lock);
212} 201}
213 202
214/* Not only time init but that's what the hook it's called through is named */ 203/* Not only time init but that's what the hook it's called through is named */
@@ -221,7 +210,6 @@ static void __init py_late_time_init(void)
221 210
222void __init plat_mem_setup(void) 211void __init plat_mem_setup(void)
223{ 212{
224 board_time_init = yosemite_time_init;
225 late_time_init = py_late_time_init; 213 late_time_init = py_late_time_init;
226 214
227 /* Add memory regions */ 215 /* Add memory regions */
diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
index e7ce7982db72..174f09e42f6b 100644
--- a/arch/mips/sgi-ip22/ip22-setup.c
+++ b/arch/mips/sgi-ip22/ip22-setup.c
@@ -51,7 +51,6 @@ void ip22_do_break(void)
51EXPORT_SYMBOL(ip22_do_break); 51EXPORT_SYMBOL(ip22_do_break);
52 52
53extern void ip22_be_init(void) __init; 53extern void ip22_be_init(void) __init;
54extern void ip22_time_init(void) __init;
55 54
56void __init plat_mem_setup(void) 55void __init plat_mem_setup(void)
57{ 56{
@@ -59,7 +58,6 @@ void __init plat_mem_setup(void)
59 char *cserial; 58 char *cserial;
60 59
61 board_be_init = ip22_be_init; 60 board_be_init = ip22_be_init;
62 ip22_time_init();
63 61
64 /* Init the INDY HPC I/O controller. Need to call this before 62 /* Init the INDY HPC I/O controller. Need to call this before
65 * fucking with the memory controller because it needs to know the 63 * fucking with the memory controller because it needs to know the
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index de3d01823ad5..0387c385b4b2 100644
--- a/arch/mips/sgi-ip22/ip22-time.c
+++ b/arch/mips/sgi-ip22/ip22-time.c
@@ -32,7 +32,7 @@
32 * note that mktime uses month from 1 to 12 while to_tm 32 * note that mktime uses month from 1 to 12 while to_tm
33 * uses 0 to 11. 33 * uses 0 to 11.
34 */ 34 */
35static unsigned long indy_rtc_get_time(void) 35unsigned long read_persistent_clock(void)
36{ 36{
37 unsigned int yrs, mon, day, hrs, min, sec; 37 unsigned int yrs, mon, day, hrs, min, sec;
38 unsigned int save_control; 38 unsigned int save_control;
@@ -60,7 +60,7 @@ static unsigned long indy_rtc_get_time(void)
60 return mktime(yrs + 1900, mon, day, hrs, min, sec); 60 return mktime(yrs + 1900, mon, day, hrs, min, sec);
61} 61}
62 62
63static int indy_rtc_set_time(unsigned long tim) 63int rtc_mips_set_time(unsigned long tim)
64{ 64{
65 struct rtc_time tm; 65 struct rtc_time tm;
66 unsigned int save_control; 66 unsigned int save_control;
@@ -128,7 +128,7 @@ static unsigned long dosample(void)
128/* 128/*
129 * Here we need to calibrate the cycle counter to at least be close. 129 * Here we need to calibrate the cycle counter to at least be close.
130 */ 130 */
131static __init void indy_time_init(void) 131__init void plat_time_init(void)
132{ 132{
133 unsigned long r4k_ticks[3]; 133 unsigned long r4k_ticks[3];
134 unsigned long r4k_tick; 134 unsigned long r4k_tick;
@@ -207,12 +207,3 @@ void __init plat_timer_setup(struct irqaction *irq)
207 /* setup irqaction */ 207 /* setup irqaction */
208 setup_irq(SGI_TIMER_IRQ, irq); 208 setup_irq(SGI_TIMER_IRQ, irq);
209} 209}
210
211void __init ip22_time_init(void)
212{
213 /* setup hookup functions */
214 rtc_mips_get_time = indy_rtc_get_time;
215 rtc_mips_set_time = indy_rtc_set_time;
216
217 board_time_init = indy_time_init;
218}
diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c
index af08c41d6aa8..681b593071cb 100644
--- a/arch/mips/sgi-ip27/ip27-init.c
+++ b/arch/mips/sgi-ip27/ip27-init.c
@@ -194,7 +194,6 @@ static inline void ioc3_eth_init(void)
194 ioc3->eier = 0; 194 ioc3->eier = 0;
195} 195}
196 196
197extern void ip27_time_init(void);
198extern void ip27_reboot_setup(void); 197extern void ip27_reboot_setup(void);
199 198
200void __init plat_mem_setup(void) 199void __init plat_mem_setup(void)
@@ -241,6 +240,4 @@ void __init plat_mem_setup(void)
241 per_cpu_init(); 240 per_cpu_init();
242 241
243 set_io_port_base(IO_BASE); 242 set_io_port_base(IO_BASE);
244
245 board_time_init = ip27_time_init;
246} 243}
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 31346162e9fa..9c1700e85be0 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -123,7 +123,7 @@ again:
123#include <asm/sn/sn0/hubio.h> 123#include <asm/sn/sn0/hubio.h>
124#include <asm/pci/bridge.h> 124#include <asm/pci/bridge.h>
125 125
126static __init unsigned long get_m48t35_time(void) 126unsigned long read_persistent_clock(void)
127{ 127{
128 unsigned int year, month, date, hour, min, sec; 128 unsigned int year, month, date, hour, min, sec;
129 struct m48t35_rtc *rtc; 129 struct m48t35_rtc *rtc;
@@ -205,12 +205,10 @@ static cycle_t ip27_hpt_read(void)
205 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT); 205 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
206} 206}
207 207
208void __init ip27_time_init(void) 208void __init plat_time_init(void)
209{ 209{
210 clocksource_mips.read = ip27_hpt_read; 210 clocksource_mips.read = ip27_hpt_read;
211 mips_hpt_frequency = CYCLES_PER_SEC; 211 mips_hpt_frequency = CYCLES_PER_SEC;
212 xtime.tv_sec = get_m48t35_time();
213 xtime.tv_nsec = 0;
214} 212}
215 213
216void __init cpu_time_init(void) 214void __init cpu_time_init(void)
diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
index bbba066cb405..4125a5ba119e 100644
--- a/arch/mips/sgi-ip32/ip32-setup.c
+++ b/arch/mips/sgi-ip32/ip32-setup.c
@@ -62,10 +62,15 @@ static inline void str2eaddr(unsigned char *ea, unsigned char *str)
62} 62}
63#endif 63#endif
64 64
65unsigned long read_persistent_clock(void)
66{
67 return mc146818_get_cmos_time();
68}
69
65/* An arbitrary time; this can be decreased if reliability looks good */ 70/* An arbitrary time; this can be decreased if reliability looks good */
66#define WAIT_MS 10 71#define WAIT_MS 10
67 72
68void __init ip32_time_init(void) 73void __init plat_time_init(void)
69{ 74{
70 printk(KERN_INFO "Calibrating system timer... "); 75 printk(KERN_INFO "Calibrating system timer... ");
71 write_c0_count(0); 76 write_c0_count(0);
@@ -85,11 +90,6 @@ void __init plat_mem_setup(void)
85{ 90{
86 board_be_init = ip32_be_init; 91 board_be_init = ip32_be_init;
87 92
88 rtc_mips_get_time = mc146818_get_cmos_time;
89 rtc_mips_set_mmss = mc146818_set_rtc_mmss;
90
91 board_time_init = ip32_time_init;
92
93#ifdef CONFIG_SGI_O2MACE_ETH 93#ifdef CONFIG_SGI_O2MACE_ETH
94 { 94 {
95 char *mac = ArcGetEnvironmentVariable("eaddr"); 95 char *mac = ArcGetEnvironmentVariable("eaddr");
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index 83572d8f3e14..8b3ef0e4cd55 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -69,7 +69,7 @@ const char *get_system_type(void)
69 return "SiByte " SIBYTE_BOARD_NAME; 69 return "SiByte " SIBYTE_BOARD_NAME;
70} 70}
71 71
72void __init swarm_time_init(void) 72void __init plat_time_init(void)
73{ 73{
74#if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) 74#if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
75 /* Setup HPT */ 75 /* Setup HPT */
@@ -104,6 +104,44 @@ int swarm_be_handler(struct pt_regs *regs, int is_fixup)
104 return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL); 104 return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
105} 105}
106 106
107enum swarm_rtc_type {
108 RTC_NONE,
109 RTC_XICOR,
110 RTC_M4LT81
111};
112
113enum swarm_rtc_type swarm_rtc_type;
114
115unsigned long read_persistent_clock(void)
116{
117 switch (swarm_rtc_type) {
118 case RTC_XICOR:
119 return xicor_get_time();
120
121 case RTC_M4LT81:
122 return m41t81_get_time();
123
124 case RTC_NONE:
125 default:
126 return mktime(2000, 1, 1, 0, 0, 0);
127 }
128}
129
130int rtc_mips_set_time(unsigned long sec)
131{
132 switch (swarm_rtc_type) {
133 case RTC_XICOR:
134 return xicor_set_time(sec);
135
136 case RTC_M4LT81:
137 return m41t81_set_time(sec);
138
139 case RTC_NONE:
140 default:
141 return -1;
142 }
143}
144
107void __init plat_mem_setup(void) 145void __init plat_mem_setup(void)
108{ 146{
109#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) 147#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
@@ -116,20 +154,12 @@ void __init plat_mem_setup(void)
116 154
117 panic_timeout = 5; /* For debug. */ 155 panic_timeout = 5; /* For debug. */
118 156
119 board_time_init = swarm_time_init;
120 board_be_handler = swarm_be_handler; 157 board_be_handler = swarm_be_handler;
121 158
122 if (xicor_probe()) { 159 if (xicor_probe())
123 printk("swarm setup: Xicor 1241 RTC detected.\n"); 160 swarm_rtc_type = RTC_XICOR;
124 rtc_mips_get_time = xicor_get_time; 161 if (m41t81_probe())
125 rtc_mips_set_time = xicor_set_time; 162 swarm_rtc_type = RTC_M4LT81;
126 }
127
128 if (m41t81_probe()) {
129 printk("swarm setup: M41T81 RTC detected.\n");
130 rtc_mips_get_time = m41t81_get_time;
131 rtc_mips_set_time = m41t81_set_time;
132 }
133 163
134 printk("This kernel optimized for " 164 printk("This kernel optimized for "
135#ifdef CONFIG_SIMULATION 165#ifdef CONFIG_SIMULATION
diff --git a/arch/mips/sni/pcimt.c b/arch/mips/sni/pcimt.c
index 44b1ae62aa4a..25cf646329ae 100644
--- a/arch/mips/sni/pcimt.c
+++ b/arch/mips/sni/pcimt.c
@@ -313,7 +313,6 @@ void __init sni_pcimt_init(void)
313{ 313{
314 sni_pcimt_detect(); 314 sni_pcimt_detect();
315 sni_pcimt_sc_init(); 315 sni_pcimt_sc_init();
316 board_time_init = sni_cpu_time_init;
317 ioport_resource.end = sni_io_resource.end; 316 ioport_resource.end = sni_io_resource.end;
318#ifdef CONFIG_PCI 317#ifdef CONFIG_PCI
319 PCIBIOS_MIN_IO = 0x9000; 318 PCIBIOS_MIN_IO = 0x9000;
diff --git a/arch/mips/sni/pcit.c b/arch/mips/sni/pcit.c
index 2480c478dcbd..3361bdd240e6 100644
--- a/arch/mips/sni/pcit.c
+++ b/arch/mips/sni/pcit.c
@@ -263,7 +263,6 @@ void __init sni_pcit_cplus_irq_init(void)
263 263
264void __init sni_pcit_init(void) 264void __init sni_pcit_init(void)
265{ 265{
266 board_time_init = sni_cpu_time_init;
267 ioport_resource.end = sni_io_resource.end; 266 ioport_resource.end = sni_io_resource.end;
268#ifdef CONFIG_PCI 267#ifdef CONFIG_PCI
269 PCIBIOS_MIN_IO = 0x9000; 268 PCIBIOS_MIN_IO = 0x9000;
diff --git a/arch/mips/sni/rm200.c b/arch/mips/sni/rm200.c
index 28a11d8605ce..94f115c6b2e0 100644
--- a/arch/mips/sni/rm200.c
+++ b/arch/mips/sni/rm200.c
@@ -194,5 +194,4 @@ void __init sni_rm200_init(void)
194{ 194{
195 set_io_port_base(SNI_PORT_BASE + 0x02000000); 195 set_io_port_base(SNI_PORT_BASE + 0x02000000);
196 ioport_resource.end += 0x02000000; 196 ioport_resource.end += 0x02000000;
197 board_time_init = sni_cpu_time_init;
198} 197}
diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c
index 20028fc7757e..92452d677d8f 100644
--- a/arch/mips/sni/time.c
+++ b/arch/mips/sni/time.c
@@ -4,6 +4,7 @@
4 4
5#include <asm/sni.h> 5#include <asm/sni.h>
6#include <asm/time.h> 6#include <asm/time.h>
7#include <asm-generic/rtc.h>
7 8
8#define SNI_CLOCK_TICK_RATE 3686400 9#define SNI_CLOCK_TICK_RATE 3686400
9#define SNI_COUNTER2_DIV 64 10#define SNI_COUNTER2_DIV 64
@@ -71,7 +72,7 @@ static __init unsigned long dosample(void)
71/* 72/*
72 * Here we need to calibrate the cycle counter to at least be close. 73 * Here we need to calibrate the cycle counter to at least be close.
73 */ 74 */
74__init void sni_cpu_time_init(void) 75void __init plat_time_init(void)
75{ 76{
76 unsigned long r4k_ticks[3]; 77 unsigned long r4k_ticks[3];
77 unsigned long r4k_tick; 78 unsigned long r4k_tick;
@@ -146,3 +147,8 @@ void __init plat_timer_setup(struct irqaction *irq)
146 break; 147 break;
147 } 148 }
148} 149}
150
151unsigned long read_persistent_clock(void)
152{
153 return -1;
154}
diff --git a/arch/mips/tx4927/common/tx4927_setup.c b/arch/mips/tx4927/common/tx4927_setup.c
index b18ed58f88a9..8ce0989671d8 100644
--- a/arch/mips/tx4927/common/tx4927_setup.c
+++ b/arch/mips/tx4927/common/tx4927_setup.c
@@ -49,14 +49,11 @@
49 49
50#undef DEBUG 50#undef DEBUG
51 51
52void __init tx4927_time_init(void);
53void dump_cp0(char *key); 52void dump_cp0(char *key);
54 53
55 54
56void __init plat_mem_setup(void) 55void __init plat_mem_setup(void)
57{ 56{
58 board_time_init = tx4927_time_init;
59
60#ifdef CONFIG_TOSHIBA_RBTX4927 57#ifdef CONFIG_TOSHIBA_RBTX4927
61 { 58 {
62 extern void toshiba_rbtx4927_setup(void); 59 extern void toshiba_rbtx4927_setup(void);
@@ -65,20 +62,16 @@ void __init plat_mem_setup(void)
65#endif 62#endif
66} 63}
67 64
68void __init tx4927_time_init(void) 65void __init plat_time_init(void)
69{ 66{
70
71#ifdef CONFIG_TOSHIBA_RBTX4927 67#ifdef CONFIG_TOSHIBA_RBTX4927
72 { 68 {
73 extern void toshiba_rbtx4927_time_init(void); 69 extern void toshiba_rbtx4927_time_init(void);
74 toshiba_rbtx4927_time_init(); 70 toshiba_rbtx4927_time_init();
75 } 71 }
76#endif 72#endif
77
78 return;
79} 73}
80 74
81
82void __init plat_timer_setup(struct irqaction *irq) 75void __init plat_timer_setup(struct irqaction *irq)
83{ 76{
84 setup_irq(TX4927_IRQ_CPU_TIMER, irq); 77 setup_irq(TX4927_IRQ_CPU_TIMER, irq);
diff --git a/arch/mips/tx4938/common/setup.c b/arch/mips/tx4938/common/setup.c
index 142abf453e40..ab4082267553 100644
--- a/arch/mips/tx4938/common/setup.c
+++ b/arch/mips/tx4938/common/setup.c
@@ -34,25 +34,16 @@
34#include <asm/tx4938/rbtx4938.h> 34#include <asm/tx4938/rbtx4938.h>
35 35
36extern void toshiba_rbtx4938_setup(void); 36extern void toshiba_rbtx4938_setup(void);
37extern void rbtx4938_time_init(void);
38 37
39void __init tx4938_setup(void); 38void __init tx4938_setup(void);
40void __init tx4938_time_init(void);
41void dump_cp0(char *key); 39void dump_cp0(char *key);
42 40
43void __init 41void __init
44plat_mem_setup(void) 42plat_mem_setup(void)
45{ 43{
46 board_time_init = tx4938_time_init;
47 toshiba_rbtx4938_setup(); 44 toshiba_rbtx4938_setup();
48} 45}
49 46
50void __init
51tx4938_time_init(void)
52{
53 rbtx4938_time_init();
54}
55
56void __init plat_timer_setup(struct irqaction *irq) 47void __init plat_timer_setup(struct irqaction *irq)
57{ 48{
58 setup_irq(TX4938_IRQ_CPU_TIMER, irq); 49 setup_irq(TX4938_IRQ_CPU_TIMER, irq);
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
index f236b1ff8923..304b406fcb9d 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
@@ -39,7 +39,6 @@
39#include <asm/tx4938/spi.h> 39#include <asm/tx4938/spi.h>
40#include <asm/gpio.h> 40#include <asm/gpio.h>
41 41
42extern void rbtx4938_time_init(void) __init;
43extern char * __init prom_getcmdline(void); 42extern char * __init prom_getcmdline(void);
44static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr); 43static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr);
45 44
@@ -856,7 +855,7 @@ void tx4938_report_pcic_status(void)
856/* We use onchip r4k counter or TMR timer as our system wide timer 855/* We use onchip r4k counter or TMR timer as our system wide timer
857 * interrupt running at 100HZ. */ 856 * interrupt running at 100HZ. */
858 857
859void __init rbtx4938_time_init(void) 858void __init plat_time_init(void)
860{ 859{
861 mips_hpt_frequency = txx9_cpu_clock / 2; 860 mips_hpt_frequency = txx9_cpu_clock / 2;
862} 861}
diff --git a/arch/mips/vr41xx/common/init.c b/arch/mips/vr41xx/common/init.c
index 4f97e0ba9e24..407cec203b29 100644
--- a/arch/mips/vr41xx/common/init.c
+++ b/arch/mips/vr41xx/common/init.c
@@ -36,7 +36,7 @@ static void __init iomem_resource_init(void)
36 iomem_resource.end = IO_MEM_RESOURCE_END; 36 iomem_resource.end = IO_MEM_RESOURCE_END;
37} 37}
38 38
39static void __init setup_timer_frequency(void) 39void __init plat_time_init(void)
40{ 40{
41 unsigned long tclock; 41 unsigned long tclock;
42 42
@@ -53,16 +53,10 @@ void __init plat_timer_setup(struct irqaction *irq)
53 setup_irq(TIMER_IRQ, irq); 53 setup_irq(TIMER_IRQ, irq);
54} 54}
55 55
56static void __init timer_init(void)
57{
58 board_time_init = setup_timer_frequency;
59}
60
61void __init plat_mem_setup(void) 56void __init plat_mem_setup(void)
62{ 57{
63 vr41xx_calculate_clock_frequency(); 58 vr41xx_calculate_clock_frequency();
64 59
65 timer_init();
66 iomem_resource_init(); 60 iomem_resource_init();
67} 61}
68 62