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; 8f8381cbaSThomas Gleixner 9f8381cbaSThomas Gleixner extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); 10f8381cbaSThomas Gleixner extern void tick_handle_periodic(struct clock_event_device *dev); 11f8381cbaSThomas Gleixner 12f8381cbaSThomas Gleixner /* 1379bf2bb3SThomas Gleixner * NO_HZ / high resolution timer shared code 1479bf2bb3SThomas Gleixner */ 1579bf2bb3SThomas Gleixner #ifdef CONFIG_TICK_ONESHOT 1679bf2bb3SThomas Gleixner extern void tick_setup_oneshot(struct clock_event_device *newdev, 1779bf2bb3SThomas Gleixner void (*handler)(struct clock_event_device *), 1879bf2bb3SThomas Gleixner ktime_t nextevt); 1979bf2bb3SThomas Gleixner extern int tick_program_event(ktime_t expires, int force); 2079bf2bb3SThomas Gleixner extern void tick_oneshot_notify(void); 2179bf2bb3SThomas Gleixner extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); 2279bf2bb3SThomas Gleixner 2379bf2bb3SThomas Gleixner # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 2479bf2bb3SThomas Gleixner extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); 2579bf2bb3SThomas Gleixner extern void tick_broadcast_oneshot_control(unsigned long reason); 2679bf2bb3SThomas Gleixner extern void tick_broadcast_switch_to_oneshot(void); 2779bf2bb3SThomas Gleixner extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); 2879bf2bb3SThomas Gleixner # else /* BROADCAST */ 2979bf2bb3SThomas Gleixner static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 3079bf2bb3SThomas Gleixner { 3179bf2bb3SThomas Gleixner BUG(); 3279bf2bb3SThomas Gleixner } 3379bf2bb3SThomas Gleixner static inline void tick_broadcast_oneshot_control(unsigned long reason) { } 3479bf2bb3SThomas Gleixner static inline void tick_broadcast_switch_to_oneshot(void) { } 3579bf2bb3SThomas Gleixner static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 3679bf2bb3SThomas Gleixner # endif /* !BROADCAST */ 3779bf2bb3SThomas Gleixner 3879bf2bb3SThomas Gleixner #else /* !ONESHOT */ 3979bf2bb3SThomas Gleixner static inline 4079bf2bb3SThomas Gleixner void tick_setup_oneshot(struct clock_event_device *newdev, 4179bf2bb3SThomas Gleixner void (*handler)(struct clock_event_device *), 4279bf2bb3SThomas Gleixner ktime_t nextevt) 4379bf2bb3SThomas Gleixner { 4479bf2bb3SThomas Gleixner BUG(); 4579bf2bb3SThomas Gleixner } 4679bf2bb3SThomas Gleixner static inline int tick_program_event(ktime_t expires, int force) 4779bf2bb3SThomas Gleixner { 4879bf2bb3SThomas Gleixner return 0; 4979bf2bb3SThomas Gleixner } 5079bf2bb3SThomas Gleixner static inline void tick_oneshot_notify(void) { } 5179bf2bb3SThomas Gleixner static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 5279bf2bb3SThomas Gleixner { 5379bf2bb3SThomas Gleixner BUG(); 5479bf2bb3SThomas Gleixner } 5579bf2bb3SThomas Gleixner static inline void tick_broadcast_oneshot_control(unsigned long reason) { } 5679bf2bb3SThomas Gleixner static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 5779bf2bb3SThomas Gleixner #endif /* !TICK_ONESHOT */ 5879bf2bb3SThomas Gleixner 5979bf2bb3SThomas Gleixner /* 60f8381cbaSThomas Gleixner * Broadcasting support 61f8381cbaSThomas Gleixner */ 62f8381cbaSThomas Gleixner #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 63f8381cbaSThomas Gleixner extern int tick_do_broadcast(cpumask_t mask); 64f8381cbaSThomas Gleixner 65f8381cbaSThomas Gleixner extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); 66f8381cbaSThomas Gleixner extern int tick_check_broadcast_device(struct clock_event_device *dev); 67f8381cbaSThomas Gleixner extern int tick_is_broadcast_device(struct clock_event_device *dev); 68f8381cbaSThomas Gleixner extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); 69f8381cbaSThomas Gleixner extern void tick_shutdown_broadcast(unsigned int *cpup); 706321dd60SThomas Gleixner extern void tick_suspend_broadcast(void); 716321dd60SThomas Gleixner extern int tick_resume_broadcast(void); 72f8381cbaSThomas Gleixner 73f8381cbaSThomas Gleixner extern void 74f8381cbaSThomas Gleixner tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); 75f8381cbaSThomas Gleixner 76f8381cbaSThomas Gleixner #else /* !BROADCAST */ 77f8381cbaSThomas Gleixner 78f8381cbaSThomas Gleixner static inline int tick_check_broadcast_device(struct clock_event_device *dev) 79f8381cbaSThomas Gleixner { 80f8381cbaSThomas Gleixner return 0; 81f8381cbaSThomas Gleixner } 82f8381cbaSThomas Gleixner 83f8381cbaSThomas Gleixner static inline int tick_is_broadcast_device(struct clock_event_device *dev) 84f8381cbaSThomas Gleixner { 85f8381cbaSThomas Gleixner return 0; 86f8381cbaSThomas Gleixner } 87f8381cbaSThomas Gleixner static inline int tick_device_uses_broadcast(struct clock_event_device *dev, 88f8381cbaSThomas Gleixner int cpu) 89f8381cbaSThomas Gleixner { 90f8381cbaSThomas Gleixner return 0; 91f8381cbaSThomas Gleixner } 92f8381cbaSThomas Gleixner static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } 93f8381cbaSThomas Gleixner static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } 94f8381cbaSThomas Gleixner static inline void tick_shutdown_broadcast(unsigned int *cpup) { } 956321dd60SThomas Gleixner static inline void tick_suspend_broadcast(void) { } 966321dd60SThomas Gleixner static inline int tick_resume_broadcast(void) { return 0; } 97f8381cbaSThomas Gleixner 98f8381cbaSThomas Gleixner /* 99f8381cbaSThomas Gleixner * Set the periodic handler in non broadcast mode 100f8381cbaSThomas Gleixner */ 101f8381cbaSThomas Gleixner static inline void tick_set_periodic_handler(struct clock_event_device *dev, 102f8381cbaSThomas Gleixner int broadcast) 103f8381cbaSThomas Gleixner { 104f8381cbaSThomas Gleixner dev->event_handler = tick_handle_periodic; 105f8381cbaSThomas Gleixner } 106f8381cbaSThomas Gleixner #endif /* !BROADCAST */ 107f8381cbaSThomas Gleixner 108f8381cbaSThomas Gleixner /* 109f8381cbaSThomas Gleixner * Check, if the device is functional or a dummy for broadcast 110f8381cbaSThomas Gleixner */ 111f8381cbaSThomas Gleixner static inline int tick_device_is_functional(struct clock_event_device *dev) 112f8381cbaSThomas Gleixner { 113f8381cbaSThomas Gleixner return !(dev->features & CLOCK_EVT_FEAT_DUMMY); 114f8381cbaSThomas Gleixner } 115