aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/time.c
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/kernel/time.c
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/kernel/time.c')
-rw-r--r--arch/mips/kernel/time.c45
1 files changed, 14 insertions, 31 deletions
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);