xref: /openbmc/linux/kernel/time/tick-internal.h (revision 2344abbc)
1f8381cbaSThomas Gleixner /*
2f8381cbaSThomas Gleixner  * tick internal variable and functions used by low/high res code
3f8381cbaSThomas Gleixner  */
4f8381cbaSThomas Gleixner DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
5f8381cbaSThomas Gleixner extern spinlock_t tick_device_lock;
6f8381cbaSThomas Gleixner extern ktime_t tick_next_period;
7f8381cbaSThomas Gleixner extern ktime_t tick_period;
8d3ed7824SThomas Gleixner extern int tick_do_timer_cpu __read_mostly;
9f8381cbaSThomas Gleixner 
10f8381cbaSThomas Gleixner extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
11f8381cbaSThomas Gleixner extern void tick_handle_periodic(struct clock_event_device *dev);
12f8381cbaSThomas Gleixner 
132344abbcSThomas Gleixner extern void clockevents_shutdown(struct clock_event_device *dev);
142344abbcSThomas Gleixner 
15f8381cbaSThomas Gleixner /*
1679bf2bb3SThomas Gleixner  * NO_HZ / high resolution timer shared code
1779bf2bb3SThomas Gleixner  */
1879bf2bb3SThomas Gleixner #ifdef CONFIG_TICK_ONESHOT
1979bf2bb3SThomas Gleixner extern void tick_setup_oneshot(struct clock_event_device *newdev,
2079bf2bb3SThomas Gleixner 			       void (*handler)(struct clock_event_device *),
2179bf2bb3SThomas Gleixner 			       ktime_t nextevt);
221fb9b7d2SThomas Gleixner extern int tick_dev_program_event(struct clock_event_device *dev,
231fb9b7d2SThomas Gleixner 				  ktime_t expires, int force);
2479bf2bb3SThomas Gleixner extern int tick_program_event(ktime_t expires, int force);
2579bf2bb3SThomas Gleixner extern void tick_oneshot_notify(void);
2679bf2bb3SThomas Gleixner extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
27cd05a1f8SThomas Gleixner extern void tick_resume_oneshot(void);
2879bf2bb3SThomas Gleixner # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
2979bf2bb3SThomas Gleixner extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
3079bf2bb3SThomas Gleixner extern void tick_broadcast_oneshot_control(unsigned long reason);
3179bf2bb3SThomas Gleixner extern void tick_broadcast_switch_to_oneshot(void);
3279bf2bb3SThomas Gleixner extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
33cd05a1f8SThomas Gleixner extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
3479bf2bb3SThomas Gleixner # else /* BROADCAST */
3579bf2bb3SThomas Gleixner static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
3679bf2bb3SThomas Gleixner {
3779bf2bb3SThomas Gleixner 	BUG();
3879bf2bb3SThomas Gleixner }
3979bf2bb3SThomas Gleixner static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
4079bf2bb3SThomas Gleixner static inline void tick_broadcast_switch_to_oneshot(void) { }
4179bf2bb3SThomas Gleixner static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
4279bf2bb3SThomas Gleixner # endif /* !BROADCAST */
4379bf2bb3SThomas Gleixner 
4479bf2bb3SThomas Gleixner #else /* !ONESHOT */
4579bf2bb3SThomas Gleixner static inline
4679bf2bb3SThomas Gleixner void tick_setup_oneshot(struct clock_event_device *newdev,
4779bf2bb3SThomas Gleixner 			void (*handler)(struct clock_event_device *),
4879bf2bb3SThomas Gleixner 			ktime_t nextevt)
4979bf2bb3SThomas Gleixner {
5079bf2bb3SThomas Gleixner 	BUG();
5179bf2bb3SThomas Gleixner }
52cd05a1f8SThomas Gleixner static inline void tick_resume_oneshot(void)
53cd05a1f8SThomas Gleixner {
54cd05a1f8SThomas Gleixner 	BUG();
55cd05a1f8SThomas Gleixner }
5679bf2bb3SThomas Gleixner static inline int tick_program_event(ktime_t expires, int force)
5779bf2bb3SThomas Gleixner {
5879bf2bb3SThomas Gleixner 	return 0;
5979bf2bb3SThomas Gleixner }
6079bf2bb3SThomas Gleixner static inline void tick_oneshot_notify(void) { }
6179bf2bb3SThomas Gleixner static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
6279bf2bb3SThomas Gleixner {
6379bf2bb3SThomas Gleixner 	BUG();
6479bf2bb3SThomas Gleixner }
6579bf2bb3SThomas Gleixner static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
6679bf2bb3SThomas Gleixner static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
67cd05a1f8SThomas Gleixner static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
68cd05a1f8SThomas Gleixner {
69cd05a1f8SThomas Gleixner 	return 0;
70cd05a1f8SThomas Gleixner }
7179bf2bb3SThomas Gleixner #endif /* !TICK_ONESHOT */
7279bf2bb3SThomas Gleixner 
7379bf2bb3SThomas Gleixner /*
74f8381cbaSThomas Gleixner  * Broadcasting support
75f8381cbaSThomas Gleixner  */
76f8381cbaSThomas Gleixner #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
77f8381cbaSThomas Gleixner extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
78f8381cbaSThomas Gleixner extern int tick_check_broadcast_device(struct clock_event_device *dev);
79f8381cbaSThomas Gleixner extern int tick_is_broadcast_device(struct clock_event_device *dev);
80f8381cbaSThomas Gleixner extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
81f8381cbaSThomas Gleixner extern void tick_shutdown_broadcast(unsigned int *cpup);
826321dd60SThomas Gleixner extern void tick_suspend_broadcast(void);
836321dd60SThomas Gleixner extern int tick_resume_broadcast(void);
84f8381cbaSThomas Gleixner 
85f8381cbaSThomas Gleixner extern void
86f8381cbaSThomas Gleixner tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
87f8381cbaSThomas Gleixner 
88f8381cbaSThomas Gleixner #else /* !BROADCAST */
89f8381cbaSThomas Gleixner 
90f8381cbaSThomas Gleixner static inline int tick_check_broadcast_device(struct clock_event_device *dev)
91f8381cbaSThomas Gleixner {
92f8381cbaSThomas Gleixner 	return 0;
93f8381cbaSThomas Gleixner }
94f8381cbaSThomas Gleixner 
95f8381cbaSThomas Gleixner static inline int tick_is_broadcast_device(struct clock_event_device *dev)
96f8381cbaSThomas Gleixner {
97f8381cbaSThomas Gleixner 	return 0;
98f8381cbaSThomas Gleixner }
99f8381cbaSThomas Gleixner static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
100f8381cbaSThomas Gleixner 					     int cpu)
101f8381cbaSThomas Gleixner {
102f8381cbaSThomas Gleixner 	return 0;
103f8381cbaSThomas Gleixner }
104f8381cbaSThomas Gleixner static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
105f8381cbaSThomas Gleixner static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
106f8381cbaSThomas Gleixner static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
1076321dd60SThomas Gleixner static inline void tick_suspend_broadcast(void) { }
1086321dd60SThomas Gleixner static inline int tick_resume_broadcast(void) { return 0; }
109f8381cbaSThomas Gleixner 
110f8381cbaSThomas Gleixner /*
111f8381cbaSThomas Gleixner  * Set the periodic handler in non broadcast mode
112f8381cbaSThomas Gleixner  */
113f8381cbaSThomas Gleixner static inline void tick_set_periodic_handler(struct clock_event_device *dev,
114f8381cbaSThomas Gleixner 					     int broadcast)
115f8381cbaSThomas Gleixner {
116f8381cbaSThomas Gleixner 	dev->event_handler = tick_handle_periodic;
117f8381cbaSThomas Gleixner }
118f8381cbaSThomas Gleixner #endif /* !BROADCAST */
119f8381cbaSThomas Gleixner 
120f8381cbaSThomas Gleixner /*
121f8381cbaSThomas Gleixner  * Check, if the device is functional or a dummy for broadcast
122f8381cbaSThomas Gleixner  */
123f8381cbaSThomas Gleixner static inline int tick_device_is_functional(struct clock_event_device *dev)
124f8381cbaSThomas Gleixner {
125f8381cbaSThomas Gleixner 	return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
126f8381cbaSThomas Gleixner }
127