Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * tick internal variable and functions used by low/high res code |
| 3 | */ |
Thomas Gleixner | 6441402 | 2008-09-22 18:46:37 +0200 | [diff] [blame] | 4 | |
| 5 | #define TICK_DO_TIMER_NONE -1 |
| 6 | #define TICK_DO_TIMER_BOOT -2 |
| 7 | |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 8 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 9 | extern ktime_t tick_next_period; |
| 10 | extern ktime_t tick_period; |
Thomas Gleixner | d3ed782 | 2007-05-08 00:30:03 -0700 | [diff] [blame] | 11 | extern int tick_do_timer_cpu __read_mostly; |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 12 | |
| 13 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); |
| 14 | extern void tick_handle_periodic(struct clock_event_device *dev); |
| 15 | |
Thomas Gleixner | 2344abb | 2008-09-16 11:32:50 -0700 | [diff] [blame] | 16 | extern void clockevents_shutdown(struct clock_event_device *dev); |
| 17 | |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 18 | /* |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 19 | * NO_HZ / high resolution timer shared code |
| 20 | */ |
| 21 | #ifdef CONFIG_TICK_ONESHOT |
| 22 | extern void tick_setup_oneshot(struct clock_event_device *newdev, |
| 23 | void (*handler)(struct clock_event_device *), |
| 24 | ktime_t nextevt); |
Thomas Gleixner | 1fb9b7d | 2008-09-03 21:37:14 +0000 | [diff] [blame] | 25 | extern int tick_dev_program_event(struct clock_event_device *dev, |
| 26 | ktime_t expires, int force); |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 27 | extern int tick_program_event(ktime_t expires, int force); |
| 28 | extern void tick_oneshot_notify(void); |
| 29 | extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)); |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 30 | extern void tick_resume_oneshot(void); |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 31 | # ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
| 32 | extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc); |
| 33 | extern void tick_broadcast_oneshot_control(unsigned long reason); |
| 34 | extern void tick_broadcast_switch_to_oneshot(void); |
| 35 | extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 36 | extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); |
Thomas Gleixner | 27ce4cb | 2008-09-22 19:04:02 +0200 | [diff] [blame] | 37 | extern int tick_broadcast_oneshot_active(void); |
Thomas Gleixner | fb02fbc | 2008-10-17 10:01:23 +0200 | [diff] [blame] | 38 | extern void tick_check_oneshot_broadcast(int cpu); |
Thomas Gleixner | 3a142a0 | 2011-02-25 22:34:23 +0100 | [diff] [blame^] | 39 | bool tick_broadcast_oneshot_available(void); |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 40 | # else /* BROADCAST */ |
| 41 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) |
| 42 | { |
| 43 | BUG(); |
| 44 | } |
| 45 | static inline void tick_broadcast_oneshot_control(unsigned long reason) { } |
| 46 | static inline void tick_broadcast_switch_to_oneshot(void) { } |
| 47 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } |
Thomas Gleixner | 27ce4cb | 2008-09-22 19:04:02 +0200 | [diff] [blame] | 48 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
Thomas Gleixner | fb02fbc | 2008-10-17 10:01:23 +0200 | [diff] [blame] | 49 | static inline void tick_check_oneshot_broadcast(int cpu) { } |
Thomas Gleixner | 3a142a0 | 2011-02-25 22:34:23 +0100 | [diff] [blame^] | 50 | static inline bool tick_broadcast_oneshot_available(void) { return true; } |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 51 | # endif /* !BROADCAST */ |
| 52 | |
| 53 | #else /* !ONESHOT */ |
| 54 | static inline |
| 55 | void tick_setup_oneshot(struct clock_event_device *newdev, |
| 56 | void (*handler)(struct clock_event_device *), |
| 57 | ktime_t nextevt) |
| 58 | { |
| 59 | BUG(); |
| 60 | } |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 61 | static inline void tick_resume_oneshot(void) |
| 62 | { |
| 63 | BUG(); |
| 64 | } |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 65 | static inline int tick_program_event(ktime_t expires, int force) |
| 66 | { |
| 67 | return 0; |
| 68 | } |
| 69 | static inline void tick_oneshot_notify(void) { } |
| 70 | static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) |
| 71 | { |
| 72 | BUG(); |
| 73 | } |
| 74 | static inline void tick_broadcast_oneshot_control(unsigned long reason) { } |
| 75 | static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } |
Thomas Gleixner | cd05a1f | 2007-03-17 00:25:52 +0100 | [diff] [blame] | 76 | static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc) |
| 77 | { |
| 78 | return 0; |
| 79 | } |
Ingo Molnar | f8e256c | 2008-09-23 13:00:57 +0200 | [diff] [blame] | 80 | static inline int tick_broadcast_oneshot_active(void) { return 0; } |
Thomas Gleixner | 3a142a0 | 2011-02-25 22:34:23 +0100 | [diff] [blame^] | 81 | static inline bool tick_broadcast_oneshot_available(void) { return false; } |
Thomas Gleixner | 79bf2bb | 2007-02-16 01:28:03 -0800 | [diff] [blame] | 82 | #endif /* !TICK_ONESHOT */ |
| 83 | |
| 84 | /* |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 85 | * Broadcasting support |
| 86 | */ |
| 87 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 88 | extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu); |
| 89 | extern int tick_check_broadcast_device(struct clock_event_device *dev); |
| 90 | extern int tick_is_broadcast_device(struct clock_event_device *dev); |
| 91 | extern void tick_broadcast_on_off(unsigned long reason, int *oncpu); |
| 92 | extern void tick_shutdown_broadcast(unsigned int *cpup); |
Thomas Gleixner | 6321dd6 | 2007-03-06 08:25:42 +0100 | [diff] [blame] | 93 | extern void tick_suspend_broadcast(void); |
| 94 | extern int tick_resume_broadcast(void); |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 95 | |
| 96 | extern void |
| 97 | tick_set_periodic_handler(struct clock_event_device *dev, int broadcast); |
| 98 | |
| 99 | #else /* !BROADCAST */ |
| 100 | |
| 101 | static inline int tick_check_broadcast_device(struct clock_event_device *dev) |
| 102 | { |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | static inline int tick_is_broadcast_device(struct clock_event_device *dev) |
| 107 | { |
| 108 | return 0; |
| 109 | } |
| 110 | static inline int tick_device_uses_broadcast(struct clock_event_device *dev, |
| 111 | int cpu) |
| 112 | { |
| 113 | return 0; |
| 114 | } |
| 115 | static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { } |
| 116 | static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { } |
| 117 | static inline void tick_shutdown_broadcast(unsigned int *cpup) { } |
Thomas Gleixner | 6321dd6 | 2007-03-06 08:25:42 +0100 | [diff] [blame] | 118 | static inline void tick_suspend_broadcast(void) { } |
| 119 | static inline int tick_resume_broadcast(void) { return 0; } |
Thomas Gleixner | f8381cb | 2007-02-16 01:28:02 -0800 | [diff] [blame] | 120 | |
| 121 | /* |
| 122 | * Set the periodic handler in non broadcast mode |
| 123 | */ |
| 124 | static inline void tick_set_periodic_handler(struct clock_event_device *dev, |
| 125 | int broadcast) |
| 126 | { |
| 127 | dev->event_handler = tick_handle_periodic; |
| 128 | } |
| 129 | #endif /* !BROADCAST */ |
| 130 | |
| 131 | /* |
| 132 | * Check, if the device is functional or a dummy for broadcast |
| 133 | */ |
| 134 | static inline int tick_device_is_functional(struct clock_event_device *dev) |
| 135 | { |
| 136 | return !(dev->features & CLOCK_EVT_FEAT_DUMMY); |
| 137 | } |