diff options
| author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
| commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
| tree | 5e32586114534ed3f2165614cba3d578f5d87307 /arch/sh/kernel/time.c | |
| parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
| parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) | |
Merge branch 'master' into gfs2
Diffstat (limited to 'arch/sh/kernel/time.c')
| -rw-r--r-- | arch/sh/kernel/time.c | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index a1589f85499d..149d9713eddf 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c | |||
| @@ -3,13 +3,12 @@ | |||
| 3 | * | 3 | * |
| 4 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | 4 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka |
| 5 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | 5 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> |
| 6 | * Copyright (C) 2002, 2003, 2004, 2005 Paul Mundt | 6 | * Copyright (C) 2002 - 2006 Paul Mundt |
| 7 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> | 7 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> |
| 8 | * | 8 | * |
| 9 | * Some code taken from i386 version. | 9 | * Some code taken from i386 version. |
| 10 | * Copyright (C) 1991, 1992, 1995 Linus Torvalds | 10 | * Copyright (C) 1991, 1992, 1995 Linus Torvalds |
| 11 | */ | 11 | */ |
| 12 | |||
| 13 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 15 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| @@ -26,15 +25,20 @@ struct sys_timer *sys_timer; | |||
| 26 | DEFINE_SPINLOCK(rtc_lock); | 25 | DEFINE_SPINLOCK(rtc_lock); |
| 27 | EXPORT_SYMBOL(rtc_lock); | 26 | EXPORT_SYMBOL(rtc_lock); |
| 28 | 27 | ||
| 29 | /* XXX: Can we initialize this in a routine somewhere? Dreamcast doesn't want | 28 | /* Dummy RTC ops */ |
| 30 | * these routines anywhere... */ | 29 | static void null_rtc_get_time(struct timespec *tv) |
| 31 | #ifdef CONFIG_SH_RTC | 30 | { |
| 32 | void (*rtc_get_time)(struct timespec *) = sh_rtc_gettimeofday; | 31 | tv->tv_sec = mktime(2000, 1, 1, 0, 0, 0); |
| 33 | int (*rtc_set_time)(const time_t) = sh_rtc_settimeofday; | 32 | tv->tv_nsec = 0; |
| 34 | #else | 33 | } |
| 35 | void (*rtc_get_time)(struct timespec *); | 34 | |
| 36 | int (*rtc_set_time)(const time_t); | 35 | static int null_rtc_set_time(const time_t secs) |
| 37 | #endif | 36 | { |
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 40 | void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time; | ||
| 41 | int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time; | ||
| 38 | 42 | ||
| 39 | /* | 43 | /* |
| 40 | * Scheduler clock - returns current time in nanosec units. | 44 | * Scheduler clock - returns current time in nanosec units. |
| @@ -70,7 +74,6 @@ void do_gettimeofday(struct timeval *tv) | |||
| 70 | tv->tv_sec = sec; | 74 | tv->tv_sec = sec; |
| 71 | tv->tv_usec = usec; | 75 | tv->tv_usec = usec; |
| 72 | } | 76 | } |
| 73 | |||
| 74 | EXPORT_SYMBOL(do_gettimeofday); | 77 | EXPORT_SYMBOL(do_gettimeofday); |
| 75 | 78 | ||
| 76 | int do_settimeofday(struct timespec *tv) | 79 | int do_settimeofday(struct timespec *tv) |
| @@ -103,7 +106,6 @@ int do_settimeofday(struct timespec *tv) | |||
| 103 | 106 | ||
| 104 | return 0; | 107 | return 0; |
| 105 | } | 108 | } |
| 106 | |||
| 107 | EXPORT_SYMBOL(do_settimeofday); | 109 | EXPORT_SYMBOL(do_settimeofday); |
| 108 | 110 | ||
| 109 | /* last time the RTC clock got updated */ | 111 | /* last time the RTC clock got updated */ |
| @@ -135,7 +137,7 @@ void handle_timer_tick(struct pt_regs *regs) | |||
| 135 | xtime.tv_sec > last_rtc_update + 660 && | 137 | xtime.tv_sec > last_rtc_update + 660 && |
| 136 | (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && | 138 | (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && |
| 137 | (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) { | 139 | (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) { |
| 138 | if (rtc_set_time(xtime.tv_sec) == 0) | 140 | if (rtc_sh_set_time(xtime.tv_sec) == 0) |
| 139 | last_rtc_update = xtime.tv_sec; | 141 | last_rtc_update = xtime.tv_sec; |
| 140 | else | 142 | else |
| 141 | /* do it again in 60s */ | 143 | /* do it again in 60s */ |
| @@ -143,8 +145,33 @@ void handle_timer_tick(struct pt_regs *regs) | |||
| 143 | } | 145 | } |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 148 | #ifdef CONFIG_PM | ||
| 149 | int timer_suspend(struct sys_device *dev, pm_message_t state) | ||
| 150 | { | ||
| 151 | struct sys_timer *sys_timer = container_of(dev, struct sys_timer, dev); | ||
| 152 | |||
| 153 | sys_timer->ops->stop(); | ||
| 154 | |||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | |||
| 158 | int timer_resume(struct sys_device *dev) | ||
| 159 | { | ||
| 160 | struct sys_timer *sys_timer = container_of(dev, struct sys_timer, dev); | ||
| 161 | |||
| 162 | sys_timer->ops->start(); | ||
| 163 | |||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | #else | ||
| 167 | #define timer_suspend NULL | ||
| 168 | #define timer_resume NULL | ||
| 169 | #endif | ||
| 170 | |||
| 146 | static struct sysdev_class timer_sysclass = { | 171 | static struct sysdev_class timer_sysclass = { |
| 147 | set_kset_name("timer"), | 172 | set_kset_name("timer"), |
| 173 | .suspend = timer_suspend, | ||
| 174 | .resume = timer_resume, | ||
| 148 | }; | 175 | }; |
| 149 | 176 | ||
| 150 | static int __init timer_init_sysfs(void) | 177 | static int __init timer_init_sysfs(void) |
| @@ -156,7 +183,6 @@ static int __init timer_init_sysfs(void) | |||
| 156 | sys_timer->dev.cls = &timer_sysclass; | 183 | sys_timer->dev.cls = &timer_sysclass; |
| 157 | return sysdev_register(&sys_timer->dev); | 184 | return sysdev_register(&sys_timer->dev); |
| 158 | } | 185 | } |
| 159 | |||
| 160 | device_initcall(timer_init_sysfs); | 186 | device_initcall(timer_init_sysfs); |
| 161 | 187 | ||
| 162 | void (*board_time_init)(void); | 188 | void (*board_time_init)(void); |
| @@ -168,15 +194,9 @@ void __init time_init(void) | |||
| 168 | 194 | ||
| 169 | clk_init(); | 195 | clk_init(); |
| 170 | 196 | ||
| 171 | if (rtc_get_time) { | 197 | rtc_sh_get_time(&xtime); |
| 172 | rtc_get_time(&xtime); | 198 | set_normalized_timespec(&wall_to_monotonic, |
| 173 | } else { | 199 | -xtime.tv_sec, -xtime.tv_nsec); |
| 174 | xtime.tv_sec = mktime(2000, 1, 1, 0, 0, 0); | ||
| 175 | xtime.tv_nsec = 0; | ||
| 176 | } | ||
| 177 | |||
| 178 | set_normalized_timespec(&wall_to_monotonic, | ||
| 179 | -xtime.tv_sec, -xtime.tv_nsec); | ||
| 180 | 200 | ||
| 181 | /* | 201 | /* |
| 182 | * Find the timer to use as the system timer, it will be | 202 | * Find the timer to use as the system timer, it will be |
