blob: 6e9db9734aa6213d866aaf93c1ec82ecf2ed9b18 [file] [log] [blame]
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08001/*
2 * tick internal variable and functions used by low/high res code
3 */
4DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
5extern spinlock_t tick_device_lock;
6extern ktime_t tick_next_period;
7extern ktime_t tick_period;
Thomas Gleixnerd3ed7822007-05-08 00:30:03 -07008extern int tick_do_timer_cpu __read_mostly;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08009
10extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
11extern void tick_handle_periodic(struct clock_event_device *dev);
12
Thomas Gleixner2344abb2008-09-16 11:32:50 -070013extern void clockevents_shutdown(struct clock_event_device *dev);
14
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080015/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080016 * NO_HZ / high resolution timer shared code
17 */
18#ifdef CONFIG_TICK_ONESHOT
19extern void tick_setup_oneshot(struct clock_event_device *newdev,
20 void (*handler)(struct clock_event_device *),
21 ktime_t nextevt);
Thomas Gleixner1fb9b7d2008-09-03 21:37:14 +000022extern int tick_dev_program_event(struct clock_event_device *dev,
23 ktime_t expires, int force);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080024extern int tick_program_event(ktime_t expires, int force);
25extern void tick_oneshot_notify(void);
26extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010027extern void tick_resume_oneshot(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080028# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
29extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
30extern void tick_broadcast_oneshot_control(unsigned long reason);
31extern void tick_broadcast_switch_to_oneshot(void);
32extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010033extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080034# else /* BROADCAST */
35static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
36{
37 BUG();
38}
39static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
40static inline void tick_broadcast_switch_to_oneshot(void) { }
41static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
42# endif /* !BROADCAST */
43
44#else /* !ONESHOT */
45static inline
46void tick_setup_oneshot(struct clock_event_device *newdev,
47 void (*handler)(struct clock_event_device *),
48 ktime_t nextevt)
49{
50 BUG();
51}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010052static inline void tick_resume_oneshot(void)
53{
54 BUG();
55}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080056static inline int tick_program_event(ktime_t expires, int force)
57{
58 return 0;
59}
60static inline void tick_oneshot_notify(void) { }
61static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
62{
63 BUG();
64}
65static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
66static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010067static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
68{
69 return 0;
70}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080071#endif /* !TICK_ONESHOT */
72
73/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080074 * Broadcasting support
75 */
76#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080077extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
78extern int tick_check_broadcast_device(struct clock_event_device *dev);
79extern int tick_is_broadcast_device(struct clock_event_device *dev);
80extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
81extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010082extern void tick_suspend_broadcast(void);
83extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080084
85extern void
86tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
87
88#else /* !BROADCAST */
89
90static inline int tick_check_broadcast_device(struct clock_event_device *dev)
91{
92 return 0;
93}
94
95static inline int tick_is_broadcast_device(struct clock_event_device *dev)
96{
97 return 0;
98}
99static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
100 int cpu)
101{
102 return 0;
103}
104static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
105static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
106static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100107static inline void tick_suspend_broadcast(void) { }
108static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800109
110/*
111 * Set the periodic handler in non broadcast mode
112 */
113static inline void tick_set_periodic_handler(struct clock_event_device *dev,
114 int broadcast)
115{
116 dev->event_handler = tick_handle_periodic;
117}
118#endif /* !BROADCAST */
119
120/*
121 * Check, if the device is functional or a dummy for broadcast
122 */
123static inline int tick_device_is_functional(struct clock_event_device *dev)
124{
125 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
126}