diff options
author | John Stultz <johnstul@us.ibm.com> | 2010-03-03 22:57:24 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-03-12 19:14:12 -0500 |
commit | cb0e996378900fa05d5c779d6bfa52d55ebc3407 (patch) | |
tree | 3eda87b69ffd4ef9760ef04975fc633cf985c0e9 | |
parent | 6ffdc5774a9ef80e58db398a8307d5b2db2644ce (diff) |
blackfin: Convert blackfin to use read/update_persistent_clock
This patch converts the blackfin architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.
I have not built or tested this patch, so help from arch maintainers
would be appreciated.
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <1267675049-12337-10-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/blackfin/kernel/time-ts.c | 13 | ||||
-rw-r--r-- | arch/blackfin/kernel/time.c | 39 |
2 files changed, 13 insertions, 39 deletions
diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c index 17c38c5b5b22..08dd3e83c187 100644 --- a/arch/blackfin/kernel/time-ts.c +++ b/arch/blackfin/kernel/time-ts.c | |||
@@ -348,9 +348,15 @@ static int __init bfin_clockevent_init(void) | |||
348 | return 0; | 348 | return 0; |
349 | } | 349 | } |
350 | 350 | ||
351 | void __init time_init(void) | 351 | void read_persistent_clock(struct timespec *ts) |
352 | { | 352 | { |
353 | time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */ | 353 | time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */ |
354 | ts->tv_sec = secs_since_1970; | ||
355 | ts->tv_nsec = 0; | ||
356 | } | ||
357 | |||
358 | void __init time_init(void) | ||
359 | { | ||
354 | 360 | ||
355 | #ifdef CONFIG_RTC_DRV_BFIN | 361 | #ifdef CONFIG_RTC_DRV_BFIN |
356 | /* [#2663] hack to filter junk RTC values that would cause | 362 | /* [#2663] hack to filter junk RTC values that would cause |
@@ -363,11 +369,6 @@ void __init time_init(void) | |||
363 | } | 369 | } |
364 | #endif | 370 | #endif |
365 | 371 | ||
366 | /* Initialize xtime. From now on, xtime is updated with timer interrupts */ | ||
367 | xtime.tv_sec = secs_since_1970; | ||
368 | xtime.tv_nsec = 0; | ||
369 | set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); | ||
370 | |||
371 | bfin_cs_cycles_init(); | 372 | bfin_cs_cycles_init(); |
372 | bfin_cs_gptimer0_init(); | 373 | bfin_cs_gptimer0_init(); |
373 | bfin_clockevent_init(); | 374 | bfin_clockevent_init(); |
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c index 13c1ee3e6408..c9113619029f 100644 --- a/arch/blackfin/kernel/time.c +++ b/arch/blackfin/kernel/time.c | |||
@@ -112,11 +112,6 @@ u32 arch_gettimeoffset(void) | |||
112 | } | 112 | } |
113 | #endif | 113 | #endif |
114 | 114 | ||
115 | static inline int set_rtc_mmss(unsigned long nowtime) | ||
116 | { | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | /* | 115 | /* |
121 | * timer_interrupt() needs to keep up the real-time clock, | 116 | * timer_interrupt() needs to keep up the real-time clock, |
122 | * as well as call the "do_timer()" routine every clocktick | 117 | * as well as call the "do_timer()" routine every clocktick |
@@ -126,29 +121,8 @@ __attribute__((l1_text)) | |||
126 | #endif | 121 | #endif |
127 | irqreturn_t timer_interrupt(int irq, void *dummy) | 122 | irqreturn_t timer_interrupt(int irq, void *dummy) |
128 | { | 123 | { |
129 | /* last time the cmos clock got updated */ | ||
130 | static long last_rtc_update; | ||
131 | |||
132 | write_seqlock(&xtime_lock); | 124 | write_seqlock(&xtime_lock); |
133 | do_timer(1); | 125 | do_timer(1); |
134 | |||
135 | /* | ||
136 | * If we have an externally synchronized Linux clock, then update | ||
137 | * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be | ||
138 | * called as close as possible to 500 ms before the new second starts. | ||
139 | */ | ||
140 | if (ntp_synced() && | ||
141 | xtime.tv_sec > last_rtc_update + 660 && | ||
142 | (xtime.tv_nsec / NSEC_PER_USEC) >= | ||
143 | 500000 - ((unsigned)TICK_SIZE) / 2 | ||
144 | && (xtime.tv_nsec / NSEC_PER_USEC) <= | ||
145 | 500000 + ((unsigned)TICK_SIZE) / 2) { | ||
146 | if (set_rtc_mmss(xtime.tv_sec) == 0) | ||
147 | last_rtc_update = xtime.tv_sec; | ||
148 | else | ||
149 | /* Do it again in 60s. */ | ||
150 | last_rtc_update = xtime.tv_sec - 600; | ||
151 | } | ||
152 | write_sequnlock(&xtime_lock); | 126 | write_sequnlock(&xtime_lock); |
153 | 127 | ||
154 | #ifdef CONFIG_IPIPE | 128 | #ifdef CONFIG_IPIPE |
@@ -161,10 +135,15 @@ irqreturn_t timer_interrupt(int irq, void *dummy) | |||
161 | return IRQ_HANDLED; | 135 | return IRQ_HANDLED; |
162 | } | 136 | } |
163 | 137 | ||
164 | void __init time_init(void) | 138 | void read_persistent_clock(struct timespec *ts) |
165 | { | 139 | { |
166 | time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */ | 140 | time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */ |
141 | ts->tv_sec = secs_since_1970; | ||
142 | ts->tv_nsec = 0; | ||
143 | } | ||
167 | 144 | ||
145 | void __init time_init(void) | ||
146 | { | ||
168 | #ifdef CONFIG_RTC_DRV_BFIN | 147 | #ifdef CONFIG_RTC_DRV_BFIN |
169 | /* [#2663] hack to filter junk RTC values that would cause | 148 | /* [#2663] hack to filter junk RTC values that would cause |
170 | * userspace to have to deal with time values greater than | 149 | * userspace to have to deal with time values greater than |
@@ -176,11 +155,5 @@ void __init time_init(void) | |||
176 | } | 155 | } |
177 | #endif | 156 | #endif |
178 | 157 | ||
179 | /* Initialize xtime. From now on, xtime is updated with timer interrupts */ | ||
180 | xtime.tv_sec = secs_since_1970; | ||
181 | xtime.tv_nsec = 0; | ||
182 | |||
183 | wall_to_monotonic.tv_sec = -xtime.tv_sec; | ||
184 | |||
185 | time_sched_init(timer_interrupt); | 158 | time_sched_init(timer_interrupt); |
186 | } | 159 | } |