blob: 75890efd24ff315245562b8ca0c9aef796bc6628 [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;
8
9extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
10extern void tick_handle_periodic(struct clock_event_device *dev);
11
12/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080013 * NO_HZ / high resolution timer shared code
14 */
15#ifdef CONFIG_TICK_ONESHOT
16extern void tick_setup_oneshot(struct clock_event_device *newdev,
17 void (*handler)(struct clock_event_device *),
18 ktime_t nextevt);
19extern int tick_program_event(ktime_t expires, int force);
20extern void tick_oneshot_notify(void);
21extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
22
23# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
24extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
25extern void tick_broadcast_oneshot_control(unsigned long reason);
26extern void tick_broadcast_switch_to_oneshot(void);
27extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
28# else /* BROADCAST */
29static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
30{
31 BUG();
32}
33static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
34static inline void tick_broadcast_switch_to_oneshot(void) { }
35static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
36# endif /* !BROADCAST */
37
38#else /* !ONESHOT */
39static inline
40void tick_setup_oneshot(struct clock_event_device *newdev,
41 void (*handler)(struct clock_event_device *),
42 ktime_t nextevt)
43{
44 BUG();
45}
46static inline int tick_program_event(ktime_t expires, int force)
47{
48 return 0;
49}
50static inline void tick_oneshot_notify(void) { }
51static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
52{
53 BUG();
54}
55static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
56static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
57#endif /* !TICK_ONESHOT */
58
59/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080060 * Broadcasting support
61 */
62#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
63extern int tick_do_broadcast(cpumask_t mask);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080064
65extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
66extern int tick_check_broadcast_device(struct clock_event_device *dev);
67extern int tick_is_broadcast_device(struct clock_event_device *dev);
68extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
69extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010070extern void tick_suspend_broadcast(void);
71extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080072
73extern void
74tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
75
76#else /* !BROADCAST */
77
78static inline int tick_check_broadcast_device(struct clock_event_device *dev)
79{
80 return 0;
81}
82
83static inline int tick_is_broadcast_device(struct clock_event_device *dev)
84{
85 return 0;
86}
87static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
88 int cpu)
89{
90 return 0;
91}
92static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
93static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
94static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +010095static inline void tick_suspend_broadcast(void) { }
96static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080097
98/*
99 * Set the periodic handler in non broadcast mode
100 */
101static inline void tick_set_periodic_handler(struct clock_event_device *dev,
102 int broadcast)
103{
104 dev->event_handler = tick_handle_periodic;
105}
106#endif /* !BROADCAST */
107
108/*
109 * Check, if the device is functional or a dummy for broadcast
110 */
111static inline int tick_device_is_functional(struct clock_event_device *dev)
112{
113 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
114}