blob: 17b5e76a4c3131471599b52bb3aea12ce78aad43 [file] [log] [blame]
Paul Mundtaa016662006-01-16 22:14:18 -08001#ifndef __ASM_SH_TIMER_H
2#define __ASM_SH_TIMER_H
3
4#include <linux/sysdev.h>
5#include <asm/cpu/timer.h>
6
7struct sys_timer_ops {
8 int (*init)(void);
Andriy Skulysh3aa770e2006-09-27 16:20:22 +09009 int (*start)(void);
10 int (*stop)(void);
Paul Mundt45882142006-10-04 13:21:45 +090011#ifndef CONFIG_GENERIC_TIME
Paul Mundtaa016662006-01-16 22:14:18 -080012 unsigned long (*get_offset)(void);
Paul Mundt45882142006-10-04 13:21:45 +090013#endif
Paul Mundtaa016662006-01-16 22:14:18 -080014};
15
16struct sys_timer {
17 const char *name;
18
19 struct sys_device dev;
20 struct sys_timer_ops *ops;
Paul Mundtbd156142006-12-01 13:23:47 +090021
22#ifdef CONFIG_NO_IDLE_HZ
23 struct dyn_tick_timer *dyn_tick;
24#endif
Paul Mundtaa016662006-01-16 22:14:18 -080025};
26
Paul Mundtbd156142006-12-01 13:23:47 +090027#ifdef CONFIG_NO_IDLE_HZ
28#define DYN_TICK_ENABLED (1 << 1)
29
30struct dyn_tick_timer {
31 spinlock_t lock;
32 unsigned int state; /* Current state */
33 int (*enable)(void); /* Enables dynamic tick */
34 int (*disable)(void); /* Disables dynamic tick */
35 void (*reprogram)(unsigned long); /* Reprograms the timer */
36 int (*handler)(int, void *);
37};
38
39void timer_dyn_reprogram(void);
40#else
41#define timer_dyn_reprogram() do { } while (0)
42#endif
43
Paul Mundtaa016662006-01-16 22:14:18 -080044#define TICK_SIZE (tick_nsec / 1000)
45
Paul Mundt710ee0c2006-11-05 16:48:42 +090046extern struct sys_timer tmu_timer, cmt_timer, mtu2_timer;
Paul Mundtaa016662006-01-16 22:14:18 -080047extern struct sys_timer *sys_timer;
48
Paul Mundt45882142006-10-04 13:21:45 +090049#ifndef CONFIG_GENERIC_TIME
Paul Mundtaa016662006-01-16 22:14:18 -080050static inline unsigned long get_timer_offset(void)
51{
52 return sys_timer->ops->get_offset();
53}
Paul Mundt45882142006-10-04 13:21:45 +090054#endif
Paul Mundtaa016662006-01-16 22:14:18 -080055
Paul Mundtaa016662006-01-16 22:14:18 -080056/* arch/sh/kernel/timers/timer.c */
57struct sys_timer *get_sys_timer(void);
58
59/* arch/sh/kernel/time.c */
Paul Mundt35f3c512006-10-06 15:31:16 +090060void handle_timer_tick(void);
Paul Mundtaa016662006-01-16 22:14:18 -080061
62#endif /* __ASM_SH_TIMER_H */