1f8381cbaSThomas Gleixner /* 2f8381cbaSThomas Gleixner * tick internal variable and functions used by low/high res code 3f8381cbaSThomas Gleixner */ 4e2830b5cSTorben Hohn #include <linux/hrtimer.h> 5e2830b5cSTorben Hohn #include <linux/tick.h> 66441402bSThomas Gleixner 7eb93e4d9SThomas Gleixner extern seqlock_t jiffies_lock; 8eb93e4d9SThomas Gleixner 97cf37e87SThomas Gleixner #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD 106441402bSThomas Gleixner 116441402bSThomas Gleixner #define TICK_DO_TIMER_NONE -1 126441402bSThomas Gleixner #define TICK_DO_TIMER_BOOT -2 136441402bSThomas Gleixner 14f8381cbaSThomas Gleixner DECLARE_PER_CPU(struct tick_device, tick_cpu_device); 15f8381cbaSThomas Gleixner extern ktime_t tick_next_period; 16f8381cbaSThomas Gleixner extern ktime_t tick_period; 17d3ed7824SThomas Gleixner extern int tick_do_timer_cpu __read_mostly; 18f8381cbaSThomas Gleixner 19f8381cbaSThomas Gleixner extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); 20f8381cbaSThomas Gleixner extern void tick_handle_periodic(struct clock_event_device *dev); 217172a286SThomas Gleixner extern void tick_notify(unsigned long reason, void *dev); 227172a286SThomas Gleixner extern void tick_check_new_device(struct clock_event_device *dev); 23f8381cbaSThomas Gleixner 242344abbcSThomas Gleixner extern void clockevents_shutdown(struct clock_event_device *dev); 252344abbcSThomas Gleixner 26f8381cbaSThomas Gleixner /* 2779bf2bb3SThomas Gleixner * NO_HZ / high resolution timer shared code 2879bf2bb3SThomas Gleixner */ 2979bf2bb3SThomas Gleixner #ifdef CONFIG_TICK_ONESHOT 3079bf2bb3SThomas Gleixner extern void tick_setup_oneshot(struct clock_event_device *newdev, 3179bf2bb3SThomas Gleixner void (*handler)(struct clock_event_device *), 3279bf2bb3SThomas Gleixner ktime_t nextevt); 3379bf2bb3SThomas Gleixner extern int tick_program_event(ktime_t expires, int force); 3479bf2bb3SThomas Gleixner extern void tick_oneshot_notify(void); 3579bf2bb3SThomas Gleixner extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); 36cd05a1f8SThomas Gleixner extern void tick_resume_oneshot(void); 3779bf2bb3SThomas Gleixner # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 3879bf2bb3SThomas Gleixner extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); 3979bf2bb3SThomas Gleixner extern void tick_broadcast_oneshot_control(unsigned long reason); 4079bf2bb3SThomas Gleixner extern void tick_broadcast_switch_to_oneshot(void); 4179bf2bb3SThomas Gleixner extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); 42cd05a1f8SThomas Gleixner extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); 4327ce4cb4SThomas Gleixner extern int tick_broadcast_oneshot_active(void); 44fb02fbc1SThomas Gleixner extern void tick_check_oneshot_broadcast(int cpu); 453a142a06SThomas Gleixner bool tick_broadcast_oneshot_available(void); 4679bf2bb3SThomas Gleixner # else /* BROADCAST */ 4779bf2bb3SThomas Gleixner static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 4879bf2bb3SThomas Gleixner { 4979bf2bb3SThomas Gleixner BUG(); 5079bf2bb3SThomas Gleixner } 5179bf2bb3SThomas Gleixner static inline void tick_broadcast_oneshot_control(unsigned long reason) { } 5279bf2bb3SThomas Gleixner static inline void tick_broadcast_switch_to_oneshot(void) { } 5379bf2bb3SThomas Gleixner static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 5427ce4cb4SThomas Gleixner static inline int tick_broadcast_oneshot_active(void) { return 0; } 55fb02fbc1SThomas Gleixner static inline void tick_check_oneshot_broadcast(int cpu) { } 563a142a06SThomas Gleixner static inline bool tick_broadcast_oneshot_available(void) { return true; } 5779bf2bb3SThomas Gleixner # endif /* !BROADCAST */ 5879bf2bb3SThomas Gleixner 5979bf2bb3SThomas Gleixner #else /* !ONESHOT */ 6079bf2bb3SThomas Gleixner static inline 6179bf2bb3SThomas Gleixner void tick_setup_oneshot(struct clock_event_device *newdev, 6279bf2bb3SThomas Gleixner void (*handler)(struct clock_event_device *), 6379bf2bb3SThomas Gleixner ktime_t nextevt) 6479bf2bb3SThomas Gleixner { 6579bf2bb3SThomas Gleixner BUG(); 6679bf2bb3SThomas Gleixner } 67cd05a1f8SThomas Gleixner static inline void tick_resume_oneshot(void) 68cd05a1f8SThomas Gleixner { 69cd05a1f8SThomas Gleixner BUG(); 70cd05a1f8SThomas Gleixner } 7179bf2bb3SThomas Gleixner static inline int tick_program_event(ktime_t expires, int force) 7279bf2bb3SThomas Gleixner { 7379bf2bb3SThomas Gleixner return 0; 7479bf2bb3SThomas Gleixner } 7579bf2bb3SThomas Gleixner static inline void tick_oneshot_notify(void) { } 7679bf2bb3SThomas Gleixner static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 7779bf2bb3SThomas Gleixner { 7879bf2bb3SThomas Gleixner BUG(); 7979bf2bb3SThomas Gleixner } 8079bf2bb3SThomas Gleixner static inline void tick_broadcast_oneshot_control(unsigned long reason) { } 8179bf2bb3SThomas Gleixner static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 82cd05a1f8SThomas Gleixner static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc) 83cd05a1f8SThomas Gleixner { 84cd05a1f8SThomas Gleixner return 0; 85cd05a1f8SThomas Gleixner } 86f8e256c6SIngo Molnar static inline int tick_broadcast_oneshot_active(void) { return 0; } 873a142a06SThomas Gleixner static inline bool tick_broadcast_oneshot_available(void) { return false; } 8879bf2bb3SThomas Gleixner #endif /* !TICK_ONESHOT */ 8979bf2bb3SThomas Gleixner 9079bf2bb3SThomas Gleixner /* 91f8381cbaSThomas Gleixner * Broadcasting support 92f8381cbaSThomas Gleixner */ 93f8381cbaSThomas Gleixner #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 94f8381cbaSThomas Gleixner extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); 957172a286SThomas Gleixner extern void tick_install_broadcast_device(struct clock_event_device *dev); 96f8381cbaSThomas Gleixner extern int tick_is_broadcast_device(struct clock_event_device *dev); 97f8381cbaSThomas Gleixner extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); 98f8381cbaSThomas Gleixner extern void tick_shutdown_broadcast(unsigned int *cpup); 996321dd60SThomas Gleixner extern void tick_suspend_broadcast(void); 1006321dd60SThomas Gleixner extern int tick_resume_broadcast(void); 101b352bc1cSThomas Gleixner extern void tick_broadcast_init(void); 102f8381cbaSThomas Gleixner extern void 103f8381cbaSThomas Gleixner tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); 104f8381cbaSThomas Gleixner 105f8381cbaSThomas Gleixner #else /* !BROADCAST */ 106f8381cbaSThomas Gleixner 1077172a286SThomas Gleixner static inline void tick_install_broadcast_device(struct clock_event_device *dev) 108f8381cbaSThomas Gleixner { 109f8381cbaSThomas Gleixner } 110f8381cbaSThomas Gleixner 111f8381cbaSThomas Gleixner static inline int tick_is_broadcast_device(struct clock_event_device *dev) 112f8381cbaSThomas Gleixner { 113f8381cbaSThomas Gleixner return 0; 114f8381cbaSThomas Gleixner } 115f8381cbaSThomas Gleixner static inline int tick_device_uses_broadcast(struct clock_event_device *dev, 116f8381cbaSThomas Gleixner int cpu) 117f8381cbaSThomas Gleixner { 118f8381cbaSThomas Gleixner return 0; 119f8381cbaSThomas Gleixner } 120f8381cbaSThomas Gleixner static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } 121f8381cbaSThomas Gleixner static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } 122f8381cbaSThomas Gleixner static inline void tick_shutdown_broadcast(unsigned int *cpup) { } 1236321dd60SThomas Gleixner static inline void tick_suspend_broadcast(void) { } 1246321dd60SThomas Gleixner static inline int tick_resume_broadcast(void) { return 0; } 125b352bc1cSThomas Gleixner static inline void tick_broadcast_init(void) { } 126f8381cbaSThomas Gleixner 127f8381cbaSThomas Gleixner /* 128f8381cbaSThomas Gleixner * Set the periodic handler in non broadcast mode 129f8381cbaSThomas Gleixner */ 130f8381cbaSThomas Gleixner static inline void tick_set_periodic_handler(struct clock_event_device *dev, 131f8381cbaSThomas Gleixner int broadcast) 132f8381cbaSThomas Gleixner { 133f8381cbaSThomas Gleixner dev->event_handler = tick_handle_periodic; 134f8381cbaSThomas Gleixner } 135f8381cbaSThomas Gleixner #endif /* !BROADCAST */ 136f8381cbaSThomas Gleixner 137f8381cbaSThomas Gleixner /* 138f8381cbaSThomas Gleixner * Check, if the device is functional or a dummy for broadcast 139f8381cbaSThomas Gleixner */ 140f8381cbaSThomas Gleixner static inline int tick_device_is_functional(struct clock_event_device *dev) 141f8381cbaSThomas Gleixner { 142f8381cbaSThomas Gleixner return !(dev->features & CLOCK_EVT_FEAT_DUMMY); 143f8381cbaSThomas Gleixner } 144e2830b5cSTorben Hohn 1457cf37e87SThomas Gleixner #endif 1467cf37e87SThomas Gleixner 147e2830b5cSTorben Hohn extern void do_timer(unsigned long ticks); 148