blob: 28c578568c9dc8736fa0fcb63e00b101a6e9c940 [file] [log] [blame]
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08001/*
2 * tick internal variable and functions used by low/high res code
3 */
Torben Hohne2830b52011-01-27 16:00:32 +01004#include <linux/hrtimer.h>
5#include <linux/tick.h>
Thomas Gleixner64414022008-09-22 18:46:37 +02006
7#define TICK_DO_TIMER_NONE -1
8#define TICK_DO_TIMER_BOOT -2
9
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080010DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080011extern ktime_t tick_next_period;
12extern ktime_t tick_period;
Thomas Gleixnerd3ed7822007-05-08 00:30:03 -070013extern int tick_do_timer_cpu __read_mostly;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080014
15extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
16extern void tick_handle_periodic(struct clock_event_device *dev);
17
Thomas Gleixner2344abb2008-09-16 11:32:50 -070018extern void clockevents_shutdown(struct clock_event_device *dev);
19
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080020/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080021 * NO_HZ / high resolution timer shared code
22 */
23#ifdef CONFIG_TICK_ONESHOT
24extern void tick_setup_oneshot(struct clock_event_device *newdev,
25 void (*handler)(struct clock_event_device *),
26 ktime_t nextevt);
Thomas Gleixner1fb9b7d2008-09-03 21:37:14 +000027extern int tick_dev_program_event(struct clock_event_device *dev,
28 ktime_t expires, int force);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080029extern int tick_program_event(ktime_t expires, int force);
30extern void tick_oneshot_notify(void);
31extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010032extern void tick_resume_oneshot(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080033# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
34extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
35extern void tick_broadcast_oneshot_control(unsigned long reason);
36extern void tick_broadcast_switch_to_oneshot(void);
37extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010038extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020039extern int tick_broadcast_oneshot_active(void);
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020040extern void tick_check_oneshot_broadcast(int cpu);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080041# else /* BROADCAST */
42static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
43{
44 BUG();
45}
46static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
47static inline void tick_broadcast_switch_to_oneshot(void) { }
48static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020049static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020050static inline void tick_check_oneshot_broadcast(int cpu) { }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080051# endif /* !BROADCAST */
52
53#else /* !ONESHOT */
54static inline
55void tick_setup_oneshot(struct clock_event_device *newdev,
56 void (*handler)(struct clock_event_device *),
57 ktime_t nextevt)
58{
59 BUG();
60}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010061static inline void tick_resume_oneshot(void)
62{
63 BUG();
64}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080065static inline int tick_program_event(ktime_t expires, int force)
66{
67 return 0;
68}
69static inline void tick_oneshot_notify(void) { }
70static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
71{
72 BUG();
73}
74static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
75static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010076static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
77{
78 return 0;
79}
Ingo Molnarf8e256c2008-09-23 13:00:57 +020080static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080081#endif /* !TICK_ONESHOT */
82
83/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080084 * Broadcasting support
85 */
86#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080087extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
88extern int tick_check_broadcast_device(struct clock_event_device *dev);
89extern int tick_is_broadcast_device(struct clock_event_device *dev);
90extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
91extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010092extern void tick_suspend_broadcast(void);
93extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080094
95extern void
96tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
97
98#else /* !BROADCAST */
99
100static inline int tick_check_broadcast_device(struct clock_event_device *dev)
101{
102 return 0;
103}
104
105static inline int tick_is_broadcast_device(struct clock_event_device *dev)
106{
107 return 0;
108}
109static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
110 int cpu)
111{
112 return 0;
113}
114static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
115static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
116static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100117static inline void tick_suspend_broadcast(void) { }
118static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800119
120/*
121 * Set the periodic handler in non broadcast mode
122 */
123static inline void tick_set_periodic_handler(struct clock_event_device *dev,
124 int broadcast)
125{
126 dev->event_handler = tick_handle_periodic;
127}
128#endif /* !BROADCAST */
129
130/*
131 * Check, if the device is functional or a dummy for broadcast
132 */
133static inline int tick_device_is_functional(struct clock_event_device *dev)
134{
135 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
136}
Torben Hohne2830b52011-01-27 16:00:32 +0100137
138extern void do_timer(unsigned long ticks);
139extern seqlock_t xtime_lock;