Merge branch 'gpio/merge' of git://git.secretlab.ca/git/linux-2.6 into grant
[linux-2.6-block.git] / arch / cris / kernel / time.c
CommitLineData
daa00b9c 1/*
1da177e4
LT
2 * linux/arch/cris/kernel/time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * Copyright (C) 1999, 2000, 2001 Axis Communications AB
6 *
7 * 1994-07-02 Alan Modra
8 * fixed set_rtc_mmss, fixed time.year for >= 2000, new mktime
9 * 1995-03-26 Markus Kuhn
10 * fixed 500 ms bug at call to set_rtc_mmss, fixed DS12887
11 * precision CMOS clock update
12 * 1996-05-03 Ingo Molnar
13 * fixed time warps in do_[slow|fast]_gettimeoffset()
14 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
15 * "A Kernel Model for Precision Timekeeping" by Dave Mills
16 *
17 * Linux/CRIS specific code:
18 *
19 * Authors: Bjorn Wesen
daa00b9c 20 * Johan Adolfsson
1da177e4
LT
21 *
22 */
23
1da177e4
LT
24#include <linux/errno.h>
25#include <linux/module.h>
26#include <linux/param.h>
27#include <linux/jiffies.h>
28#include <linux/bcd.h>
29#include <linux/timex.h>
30#include <linux/init.h>
21783c97 31#include <linux/profile.h>
4e57b681 32#include <linux/sched.h> /* just for sched_clock() - funny that */
1da177e4 33
9c75fc8c
JN
34
35#define D(x)
1da177e4
LT
36
37#define TICK_SIZE tick
38
1da177e4
LT
39extern unsigned long loops_per_jiffy; /* init/main.c */
40unsigned long loops_per_usec;
41
60dbd663
JN
42
43#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
1da177e4
LT
44extern unsigned long do_slow_gettimeoffset(void);
45static unsigned long (*do_gettimeoffset)(void) = do_slow_gettimeoffset;
46
ba875ba6 47u32 arch_gettimeoffset(void)
1da177e4 48{
60dbd663 49 return do_gettimeoffset() * 1000;
1da177e4 50}
60dbd663 51#endif
1da177e4 52
1da177e4
LT
53int set_rtc_mmss(unsigned long nowtime)
54{
9c75fc8c
JN
55 D(printk(KERN_DEBUG "set_rtc_mmss(%lu)\n", nowtime));
56 return 0;
1da177e4
LT
57}
58
59/* grab the time from the RTC chip */
9c75fc8c 60unsigned long get_cmos_time(void)
1da177e4 61{
9c75fc8c 62 return 0;
1da177e4
LT
63}
64
1da177e4 65
8eff8a5c 66int update_persistent_clock(struct timespec now)
1da177e4 67{
8eff8a5c 68 return set_rtc_mmss(now.tv_sec);
1da177e4
LT
69}
70
8eff8a5c
JS
71void read_persistent_clock(struct timespec *ts)
72{
9c75fc8c 73 ts->tv_sec = 0;
8eff8a5c
JS
74 ts->tv_nsec = 0;
75}
76
77
21783c97
MS
78extern void cris_profile_sample(struct pt_regs* regs);
79
80void
81cris_do_profile(struct pt_regs* regs)
82{
83
0188e603 84#ifdef CONFIG_SYSTEM_PROFILER
21783c97
MS
85 cris_profile_sample(regs);
86#endif
87
0188e603 88#ifdef CONFIG_PROFILING
c2610381 89 profile_tick(CPU_PROFILING);
21783c97
MS
90#endif
91}
92
daa00b9c
JN
93unsigned long long sched_clock(void)
94{
60dbd663 95 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ) +
daa00b9c
JN
96 get_ns_in_jiffie();
97}
98
1da177e4
LT
99static int
100__init init_udelay(void)
101{
102 loops_per_usec = (loops_per_jiffy * HZ) / 1000000;
103 return 0;
104}
105
106__initcall(init_udelay);