aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/cris/Kconfig3
-rw-r--r--arch/cris/arch-v10/kernel/time.c37
-rw-r--r--arch/cris/arch-v32/kernel/time.c40
-rw-r--r--arch/cris/kernel/time.c20
4 files changed, 18 insertions, 82 deletions
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 059eac6abda1..e25bf4440b51 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -23,6 +23,9 @@ config RWSEM_XCHGADD_ALGORITHM
23config GENERIC_TIME 23config GENERIC_TIME
24 def_bool y 24 def_bool y
25 25
26config GENERIC_CMOS_UPDATE
27 def_bool y
28
26config ARCH_USES_GETTIMEOFFSET 29config ARCH_USES_GETTIMEOFFSET
27 def_bool y 30 def_bool y
28 31
diff --git a/arch/cris/arch-v10/kernel/time.c b/arch/cris/arch-v10/kernel/time.c
index 31ca1418d5a7..30adae594aef 100644
--- a/arch/cris/arch-v10/kernel/time.c
+++ b/arch/cris/arch-v10/kernel/time.c
@@ -26,7 +26,6 @@
26/* it will make jiffies at 96 hz instead of 100 hz though */ 26/* it will make jiffies at 96 hz instead of 100 hz though */
27#undef USE_CASCADE_TIMERS 27#undef USE_CASCADE_TIMERS
28 28
29extern void update_xtime_from_cmos(void);
30extern int set_rtc_mmss(unsigned long nowtime); 29extern int set_rtc_mmss(unsigned long nowtime);
31extern int have_rtc; 30extern int have_rtc;
32 31
@@ -188,8 +187,6 @@ stop_watchdog(void)
188#endif 187#endif
189} 188}
190 189
191/* last time the cmos clock got updated */
192static long last_rtc_update = 0;
193 190
194/* 191/*
195 * timer_interrupt() needs to keep up the real-time clock, 192 * timer_interrupt() needs to keep up the real-time clock,
@@ -232,24 +229,6 @@ timer_interrupt(int irq, void *dev_id)
232 do_timer(1); 229 do_timer(1);
233 230
234 cris_do_profile(regs); /* Save profiling information */ 231 cris_do_profile(regs); /* Save profiling information */
235
236 /*
237 * If we have an externally synchronized Linux clock, then update
238 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
239 * called as close as possible to 500 ms before the new second starts.
240 *
241 * The division here is not time critical since it will run once in
242 * 11 minutes
243 */
244 if (ntp_synced() &&
245 xtime.tv_sec > last_rtc_update + 660 &&
246 (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
247 (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
248 if (set_rtc_mmss(xtime.tv_sec) == 0)
249 last_rtc_update = xtime.tv_sec;
250 else
251 last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
252 }
253 return IRQ_HANDLED; 232 return IRQ_HANDLED;
254} 233}
255 234
@@ -274,22 +253,10 @@ time_init(void)
274 */ 253 */
275 loops_per_usec = 50; 254 loops_per_usec = 50;
276 255
277 if(RTC_INIT() < 0) { 256 if(RTC_INIT() < 0)
278 /* no RTC, start at 1980 */
279 xtime.tv_sec = 0;
280 xtime.tv_nsec = 0;
281 have_rtc = 0; 257 have_rtc = 0;
282 } else { 258 else
283 /* get the current time */
284 have_rtc = 1; 259 have_rtc = 1;
285 update_xtime_from_cmos();
286 }
287
288 /*
289 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
290 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
291 */
292 set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
293 260
294 /* Setup the etrax timers 261 /* Setup the etrax timers
295 * Base frequency is 25000 hz, divider 250 -> 100 HZ 262 * Base frequency is 25000 hz, divider 250 -> 100 HZ
diff --git a/arch/cris/arch-v32/kernel/time.c b/arch/cris/arch-v32/kernel/time.c
index b1920d8de403..1ee0e1010228 100644
--- a/arch/cris/arch-v32/kernel/time.c
+++ b/arch/cris/arch-v32/kernel/time.c
@@ -44,7 +44,6 @@ unsigned long timer_regs[NR_CPUS] =
44#endif 44#endif
45}; 45};
46 46
47extern void update_xtime_from_cmos(void);
48extern int set_rtc_mmss(unsigned long nowtime); 47extern int set_rtc_mmss(unsigned long nowtime);
49extern int have_rtc; 48extern int have_rtc;
50 49
@@ -198,9 +197,6 @@ handle_watchdog_bite(struct pt_regs* regs)
198#endif 197#endif
199} 198}
200 199
201/* Last time the cmos clock got updated. */
202static long last_rtc_update = 0;
203
204/* 200/*
205 * timer_interrupt() needs to keep up the real-time clock, 201 * timer_interrupt() needs to keep up the real-time clock,
206 * as well as call the "do_timer()" routine every clocktick. 202 * as well as call the "do_timer()" routine every clocktick.
@@ -238,25 +234,6 @@ timer_interrupt(int irq, void *dev_id)
238 234
239 /* Call the real timer interrupt handler */ 235 /* Call the real timer interrupt handler */
240 do_timer(1); 236 do_timer(1);
241
242 /*
243 * If we have an externally synchronized Linux clock, then update
244 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
245 * called as close as possible to 500 ms before the new second starts.
246 *
247 * The division here is not time critical since it will run once in
248 * 11 minutes
249 */
250 if ((time_status & STA_UNSYNC) == 0 &&
251 xtime.tv_sec > last_rtc_update + 660 &&
252 (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
253 (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
254 if (set_rtc_mmss(xtime.tv_sec) == 0)
255 last_rtc_update = xtime.tv_sec;
256 else
257 /* Do it again in 60 s */
258 last_rtc_update = xtime.tv_sec - 600;
259 }
260 return IRQ_HANDLED; 237 return IRQ_HANDLED;
261} 238}
262 239
@@ -309,23 +286,10 @@ time_init(void)
309 */ 286 */
310 loops_per_usec = 50; 287 loops_per_usec = 50;
311 288
312 if(RTC_INIT() < 0) { 289 if(RTC_INIT() < 0)
313 /* No RTC, start at 1980 */
314 xtime.tv_sec = 0;
315 xtime.tv_nsec = 0;
316 have_rtc = 0; 290 have_rtc = 0;
317 } else { 291 else
318 /* Get the current time */
319 have_rtc = 1; 292 have_rtc = 1;
320 update_xtime_from_cmos();
321 }
322
323 /*
324 * Initialize wall_to_monotonic such that adding it to
325 * xtime will yield zero, the tv_nsec field must be normalized
326 * (i.e., 0 <= nsec < NSEC_PER_SEC).
327 */
328 set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
329 293
330 /* Start CPU local timer. */ 294 /* Start CPU local timer. */
331 cris_timer_init(); 295 cris_timer_init();
diff --git a/arch/cris/kernel/time.c b/arch/cris/kernel/time.c
index a05dd31f3efb..c72730d20ef6 100644
--- a/arch/cris/kernel/time.c
+++ b/arch/cris/kernel/time.c
@@ -98,6 +98,8 @@ unsigned long
98get_cmos_time(void) 98get_cmos_time(void)
99{ 99{
100 unsigned int year, mon, day, hour, min, sec; 100 unsigned int year, mon, day, hour, min, sec;
101 if(!have_rtc)
102 return 0;
101 103
102 sec = CMOS_READ(RTC_SECONDS); 104 sec = CMOS_READ(RTC_SECONDS);
103 min = CMOS_READ(RTC_MINUTES); 105 min = CMOS_READ(RTC_MINUTES);
@@ -119,19 +121,19 @@ get_cmos_time(void)
119 return mktime(year, mon, day, hour, min, sec); 121 return mktime(year, mon, day, hour, min, sec);
120} 122}
121 123
122/* update xtime from the CMOS settings. used when /dev/rtc gets a SET_TIME.
123 * TODO: this doesn't reset the fancy NTP phase stuff as do_settimeofday does.
124 */
125 124
126void 125int update_persistent_clock(struct timespec now)
127update_xtime_from_cmos(void)
128{ 126{
129 if(have_rtc) { 127 return set_rtc_mmss(now.tv_sec);
130 xtime.tv_sec = get_cmos_time();
131 xtime.tv_nsec = 0;
132 }
133} 128}
134 129
130void read_persistent_clock(struct timespec *ts)
131{
132 ts->tv_sec = get_cmos_time();
133 ts->tv_nsec = 0;
134}
135
136
135extern void cris_profile_sample(struct pt_regs* regs); 137extern void cris_profile_sample(struct pt_regs* regs);
136 138
137void 139void