blob: e18014fadf953303a0e822edff601568f4ab6faf [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 Gleixner79bf2bb2007-02-16 01:28:03 -080038# else /* BROADCAST */
39static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
40{
41 BUG();
42}
43static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
44static inline void tick_broadcast_switch_to_oneshot(void) { }
45static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
46# endif /* !BROADCAST */
47
48#else /* !ONESHOT */
49static inline
50void tick_setup_oneshot(struct clock_event_device *newdev,
51 void (*handler)(struct clock_event_device *),
52 ktime_t nextevt)
53{
54 BUG();
55}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010056static inline void tick_resume_oneshot(void)
57{
58 BUG();
59}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080060static inline int tick_program_event(ktime_t expires, int force)
61{
62 return 0;
63}
64static inline void tick_oneshot_notify(void) { }
65static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
66{
67 BUG();
68}
69static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
70static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010071static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
72{
73 return 0;
74}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080075#endif /* !TICK_ONESHOT */
76
77/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080078 * Broadcasting support
79 */
80#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080081extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
82extern int tick_check_broadcast_device(struct clock_event_device *dev);
83extern int tick_is_broadcast_device(struct clock_event_device *dev);
84extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
85extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010086extern void tick_suspend_broadcast(void);
87extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080088
89extern void
90tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
91
92#else /* !BROADCAST */
93
94static inline int tick_check_broadcast_device(struct clock_event_device *dev)
95{
96 return 0;
97}
98
99static inline int tick_is_broadcast_device(struct clock_event_device *dev)
100{
101 return 0;
102}
103static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
104 int cpu)
105{
106 return 0;
107}
108static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
109static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
110static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100111static inline void tick_suspend_broadcast(void) { }
112static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800113
114/*
115 * Set the periodic handler in non broadcast mode
116 */
117static inline void tick_set_periodic_handler(struct clock_event_device *dev,
118 int broadcast)
119{
120 dev->event_handler = tick_handle_periodic;
121}
122#endif /* !BROADCAST */
123
124/*
125 * Check, if the device is functional or a dummy for broadcast
126 */
127static inline int tick_device_is_functional(struct clock_event_device *dev)
128{
129 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
130}