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