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); 70f8381cbaSThomas Gleixner 71f8381cbaSThomas Gleixner extern void 72f8381cbaSThomas Gleixner tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); 73f8381cbaSThomas Gleixner 74f8381cbaSThomas Gleixner #else /* !BROADCAST */ 75f8381cbaSThomas Gleixner 76f8381cbaSThomas Gleixner static inline int tick_check_broadcast_device(struct clock_event_device *dev) 77f8381cbaSThomas Gleixner { 78f8381cbaSThomas Gleixner return 0; 79f8381cbaSThomas Gleixner } 80f8381cbaSThomas Gleixner 81f8381cbaSThomas Gleixner static inline int tick_is_broadcast_device(struct clock_event_device *dev) 82f8381cbaSThomas Gleixner { 83f8381cbaSThomas Gleixner return 0; 84f8381cbaSThomas Gleixner } 85f8381cbaSThomas Gleixner static inline int tick_device_uses_broadcast(struct clock_event_device *dev, 86f8381cbaSThomas Gleixner int cpu) 87f8381cbaSThomas Gleixner { 88f8381cbaSThomas Gleixner return 0; 89f8381cbaSThomas Gleixner } 90f8381cbaSThomas Gleixner static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } 91f8381cbaSThomas Gleixner static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } 92f8381cbaSThomas Gleixner static inline void tick_shutdown_broadcast(unsigned int *cpup) { } 93f8381cbaSThomas Gleixner 94f8381cbaSThomas Gleixner /* 95f8381cbaSThomas Gleixner * Set the periodic handler in non broadcast mode 96f8381cbaSThomas Gleixner */ 97f8381cbaSThomas Gleixner static inline void tick_set_periodic_handler(struct clock_event_device *dev, 98f8381cbaSThomas Gleixner int broadcast) 99f8381cbaSThomas Gleixner { 100f8381cbaSThomas Gleixner dev->event_handler = tick_handle_periodic; 101f8381cbaSThomas Gleixner } 102f8381cbaSThomas Gleixner #endif /* !BROADCAST */ 103f8381cbaSThomas Gleixner 104f8381cbaSThomas Gleixner /* 105f8381cbaSThomas Gleixner * Check, if the device is functional or a dummy for broadcast 106f8381cbaSThomas Gleixner */ 107f8381cbaSThomas Gleixner static inline int tick_device_is_functional(struct clock_event_device *dev) 108f8381cbaSThomas Gleixner { 109f8381cbaSThomas Gleixner return !(dev->features & CLOCK_EVT_FEAT_DUMMY); 110f8381cbaSThomas Gleixner } 111