2 * tick internal variable and functions used by low/high res code
4 #include <linux/hrtimer.h>
5 #include <linux/tick.h>
7 extern seqlock_t jiffies_lock;
9 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD
11 #define TICK_DO_TIMER_NONE -1
12 #define TICK_DO_TIMER_BOOT -2
14 DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
15 extern ktime_t tick_next_period;
16 extern ktime_t tick_period;
17 extern int tick_do_timer_cpu __read_mostly;
19 extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
20 extern void tick_handle_periodic(struct clock_event_device *dev);
21 extern void tick_check_new_device(struct clock_event_device *dev);
22 extern void tick_handover_do_timer(int *cpup);
23 extern void tick_shutdown(unsigned int *cpup);
24 extern void tick_suspend(void);
25 extern void tick_resume(void);
27 extern void clockevents_shutdown(struct clock_event_device *dev);
30 * NO_HZ / high resolution timer shared code
32 #ifdef CONFIG_TICK_ONESHOT
33 extern void tick_setup_oneshot(struct clock_event_device *newdev,
34 void (*handler)(struct clock_event_device *),
36 extern int tick_program_event(ktime_t expires, int force);
37 extern void tick_oneshot_notify(void);
38 extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
39 extern void tick_resume_oneshot(void);
40 # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
41 extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
42 extern int tick_broadcast_oneshot_control(unsigned long reason);
43 extern void tick_broadcast_switch_to_oneshot(void);
44 extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
45 extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
46 extern int tick_broadcast_oneshot_active(void);
47 extern void tick_check_oneshot_broadcast(int cpu);
48 bool tick_broadcast_oneshot_available(void);
49 # else /* BROADCAST */
50 static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
54 static inline int tick_broadcast_oneshot_control(unsigned long reason) { return 0; }
55 static inline void tick_broadcast_switch_to_oneshot(void) { }
56 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
57 static inline int tick_broadcast_oneshot_active(void) { return 0; }
58 static inline void tick_check_oneshot_broadcast(int cpu) { }
59 static inline bool tick_broadcast_oneshot_available(void) { return true; }
60 # endif /* !BROADCAST */
64 void tick_setup_oneshot(struct clock_event_device *newdev,
65 void (*handler)(struct clock_event_device *),
70 static inline void tick_resume_oneshot(void)
74 static inline int tick_program_event(ktime_t expires, int force)
78 static inline void tick_oneshot_notify(void) { }
79 static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
83 static inline int tick_broadcast_oneshot_control(unsigned long reason) { return 0; }
84 static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
85 static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
89 static inline int tick_broadcast_oneshot_active(void) { return 0; }
90 static inline bool tick_broadcast_oneshot_available(void) { return false; }
91 #endif /* !TICK_ONESHOT */
94 * Broadcasting support
96 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
97 extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
98 extern void tick_install_broadcast_device(struct clock_event_device *dev);
99 extern int tick_is_broadcast_device(struct clock_event_device *dev);
100 extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
101 extern void tick_shutdown_broadcast(unsigned int *cpup);
102 extern void tick_suspend_broadcast(void);
103 extern int tick_resume_broadcast(void);
104 extern void tick_broadcast_init(void);
106 tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
108 #else /* !BROADCAST */
110 static inline void tick_install_broadcast_device(struct clock_event_device *dev)
114 static inline int tick_is_broadcast_device(struct clock_event_device *dev)
118 static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
123 static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
124 static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
125 static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
126 static inline void tick_suspend_broadcast(void) { }
127 static inline int tick_resume_broadcast(void) { return 0; }
128 static inline void tick_broadcast_init(void) { }
131 * Set the periodic handler in non broadcast mode
133 static inline void tick_set_periodic_handler(struct clock_event_device *dev,
136 dev->event_handler = tick_handle_periodic;
138 #endif /* !BROADCAST */
141 * Check, if the device is functional or a dummy for broadcast
143 static inline int tick_device_is_functional(struct clock_event_device *dev)
145 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
148 int __clockevents_update_freq(struct clock_event_device *dev, u32 freq);
152 extern void do_timer(unsigned long ticks);