clockevents: Split out selection logic
[deliverable/linux.git] / kernel / time / tick-internal.h
CommitLineData
f8381cba
TG
1/*
2 * tick internal variable and functions used by low/high res code
3 */
e2830b5c
TH
4#include <linux/hrtimer.h>
5#include <linux/tick.h>
6441402b 6
eb93e4d9
TG
7extern seqlock_t jiffies_lock;
8
7cf37e87 9#ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD
6441402b
TG
10
11#define TICK_DO_TIMER_NONE -1
12#define TICK_DO_TIMER_BOOT -2
13
f8381cba 14DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
f8381cba
TG
15extern ktime_t tick_next_period;
16extern ktime_t tick_period;
d3ed7824 17extern int tick_do_timer_cpu __read_mostly;
f8381cba
TG
18
19extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
20extern void tick_handle_periodic(struct clock_event_device *dev);
7172a286 21extern void tick_check_new_device(struct clock_event_device *dev);
8c53daf6
TG
22extern void tick_handover_do_timer(int *cpup);
23extern void tick_shutdown(unsigned int *cpup);
24extern void tick_suspend(void);
25extern void tick_resume(void);
f8381cba 26
2344abbc
TG
27extern void clockevents_shutdown(struct clock_event_device *dev);
28
79bf2bb3
TG
29/*
30 * NO_HZ / high resolution timer shared code
31 */
32#ifdef CONFIG_TICK_ONESHOT
33extern void tick_setup_oneshot(struct clock_event_device *newdev,
34 void (*handler)(struct clock_event_device *),
35 ktime_t nextevt);
36extern int tick_program_event(ktime_t expires, int force);
37extern void tick_oneshot_notify(void);
38extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
cd05a1f8 39extern void tick_resume_oneshot(void);
79bf2bb3
TG
40# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
41extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
42extern void tick_broadcast_oneshot_control(unsigned long reason);
43extern void tick_broadcast_switch_to_oneshot(void);
44extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
cd05a1f8 45extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
27ce4cb4 46extern int tick_broadcast_oneshot_active(void);
fb02fbc1 47extern void tick_check_oneshot_broadcast(int cpu);
3a142a06 48bool tick_broadcast_oneshot_available(void);
79bf2bb3
TG
49# else /* BROADCAST */
50static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
51{
52 BUG();
53}
54static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
55static inline void tick_broadcast_switch_to_oneshot(void) { }
56static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
27ce4cb4 57static inline int tick_broadcast_oneshot_active(void) { return 0; }
fb02fbc1 58static inline void tick_check_oneshot_broadcast(int cpu) { }
3a142a06 59static inline bool tick_broadcast_oneshot_available(void) { return true; }
79bf2bb3
TG
60# endif /* !BROADCAST */
61
62#else /* !ONESHOT */
63static inline
64void tick_setup_oneshot(struct clock_event_device *newdev,
65 void (*handler)(struct clock_event_device *),
66 ktime_t nextevt)
67{
68 BUG();
69}
cd05a1f8
TG
70static inline void tick_resume_oneshot(void)
71{
72 BUG();
73}
79bf2bb3
TG
74static inline int tick_program_event(ktime_t expires, int force)
75{
76 return 0;
77}
78static inline void tick_oneshot_notify(void) { }
79static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
80{
81 BUG();
82}
83static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
84static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
cd05a1f8
TG
85static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
86{
87 return 0;
88}
f8e256c6 89static inline int tick_broadcast_oneshot_active(void) { return 0; }
3a142a06 90static inline bool tick_broadcast_oneshot_available(void) { return false; }
79bf2bb3
TG
91#endif /* !TICK_ONESHOT */
92
f8381cba
TG
93/*
94 * Broadcasting support
95 */
96#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
f8381cba 97extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
7172a286 98extern void tick_install_broadcast_device(struct clock_event_device *dev);
f8381cba
TG
99extern int tick_is_broadcast_device(struct clock_event_device *dev);
100extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
101extern void tick_shutdown_broadcast(unsigned int *cpup);
6321dd60
TG
102extern void tick_suspend_broadcast(void);
103extern int tick_resume_broadcast(void);
b352bc1c 104extern void tick_broadcast_init(void);
f8381cba
TG
105extern void
106tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
107
108#else /* !BROADCAST */
109
7172a286 110static inline void tick_install_broadcast_device(struct clock_event_device *dev)
f8381cba 111{
f8381cba
TG
112}
113
114static inline int tick_is_broadcast_device(struct clock_event_device *dev)
115{
116 return 0;
117}
118static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
119 int cpu)
120{
121 return 0;
122}
123static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
124static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
125static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
6321dd60
TG
126static inline void tick_suspend_broadcast(void) { }
127static inline int tick_resume_broadcast(void) { return 0; }
b352bc1c 128static inline void tick_broadcast_init(void) { }
f8381cba
TG
129
130/*
131 * Set the periodic handler in non broadcast mode
132 */
133static inline void tick_set_periodic_handler(struct clock_event_device *dev,
134 int broadcast)
135{
136 dev->event_handler = tick_handle_periodic;
137}
138#endif /* !BROADCAST */
139
140/*
141 * Check, if the device is functional or a dummy for broadcast
142 */
143static inline int tick_device_is_functional(struct clock_event_device *dev)
144{
145 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
146}
e2830b5c 147
7cf37e87
TG
148#endif
149
e2830b5c 150extern void do_timer(unsigned long ticks);
This page took 0.465095 seconds and 5 git commands to generate.