blob: b1c05bf75ee0ce36e0664d3e2e71d00ac0e09edd [file] [log] [blame]
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08001/*
2 * tick internal variable and functions used by low/high res code
3 */
Thomas Gleixner64414022008-09-22 18:46:37 +02004
5#define TICK_DO_TIMER_NONE -1
6#define TICK_DO_TIMER_BOOT -2
7
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08008DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
9extern spinlock_t tick_device_lock;
10extern ktime_t tick_next_period;
11extern ktime_t tick_period;
Thomas Gleixnerd3ed7822007-05-08 00:30:03 -070012extern int tick_do_timer_cpu __read_mostly;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080013
14extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
15extern void tick_handle_periodic(struct clock_event_device *dev);
16
Thomas Gleixner2344abb2008-09-16 11:32:50 -070017extern void clockevents_shutdown(struct clock_event_device *dev);
18
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080019/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080020 * NO_HZ / high resolution timer shared code
21 */
22#ifdef CONFIG_TICK_ONESHOT
23extern void tick_setup_oneshot(struct clock_event_device *newdev,
24 void (*handler)(struct clock_event_device *),
25 ktime_t nextevt);
Thomas Gleixner1fb9b7d2008-09-03 21:37:14 +000026extern int tick_dev_program_event(struct clock_event_device *dev,
27 ktime_t expires, int force);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080028extern int tick_program_event(ktime_t expires, int force);
29extern void tick_oneshot_notify(void);
30extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010031extern void tick_resume_oneshot(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080032# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
33extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
34extern void tick_broadcast_oneshot_control(unsigned long reason);
35extern void tick_broadcast_switch_to_oneshot(void);
36extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010037extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020038extern int tick_broadcast_oneshot_active(void);
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020039extern void tick_check_oneshot_broadcast(int cpu);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080040# else /* BROADCAST */
41static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
42{
43 BUG();
44}
45static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
46static inline void tick_broadcast_switch_to_oneshot(void) { }
47static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020048static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020049static inline void tick_check_oneshot_broadcast(int cpu) { }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080050# endif /* !BROADCAST */
51
52#else /* !ONESHOT */
53static inline
54void tick_setup_oneshot(struct clock_event_device *newdev,
55 void (*handler)(struct clock_event_device *),
56 ktime_t nextevt)
57{
58 BUG();
59}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010060static inline void tick_resume_oneshot(void)
61{
62 BUG();
63}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080064static inline int tick_program_event(ktime_t expires, int force)
65{
66 return 0;
67}
68static inline void tick_oneshot_notify(void) { }
69static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
70{
71 BUG();
72}
73static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
74static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010075static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
76{
77 return 0;
78}
Ingo Molnarf8e256c2008-09-23 13:00:57 +020079static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080080#endif /* !TICK_ONESHOT */
81
82/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080083 * Broadcasting support
84 */
85#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080086extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
87extern int tick_check_broadcast_device(struct clock_event_device *dev);
88extern int tick_is_broadcast_device(struct clock_event_device *dev);
89extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
90extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010091extern void tick_suspend_broadcast(void);
92extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080093
94extern void
95tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
96
97#else /* !BROADCAST */
98
99static inline int tick_check_broadcast_device(struct clock_event_device *dev)
100{
101 return 0;
102}
103
104static inline int tick_is_broadcast_device(struct clock_event_device *dev)
105{
106 return 0;
107}
108static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
109 int cpu)
110{
111 return 0;
112}
113static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
114static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
115static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100116static inline void tick_suspend_broadcast(void) { }
117static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800118
119/*
120 * Set the periodic handler in non broadcast mode
121 */
122static 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 */
132static inline int tick_device_is_functional(struct clock_event_device *dev)
133{
134 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
135}