blob: 290eefbc1f608ec4d9c957fb5798eb53490f9e7c [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);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08009extern ktime_t tick_next_period;
10extern ktime_t tick_period;
Thomas Gleixnerd3ed7822007-05-08 00:30:03 -070011extern int tick_do_timer_cpu __read_mostly;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080012
13extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
14extern void tick_handle_periodic(struct clock_event_device *dev);
15
Thomas Gleixner2344abb2008-09-16 11:32:50 -070016extern void clockevents_shutdown(struct clock_event_device *dev);
17
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080018/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080019 * NO_HZ / high resolution timer shared code
20 */
21#ifdef CONFIG_TICK_ONESHOT
22extern void tick_setup_oneshot(struct clock_event_device *newdev,
23 void (*handler)(struct clock_event_device *),
24 ktime_t nextevt);
Thomas Gleixner1fb9b7d2008-09-03 21:37:14 +000025extern int tick_dev_program_event(struct clock_event_device *dev,
26 ktime_t expires, int force);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080027extern int tick_program_event(ktime_t expires, int force);
28extern void tick_oneshot_notify(void);
29extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010030extern void tick_resume_oneshot(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080031# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
32extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
33extern void tick_broadcast_oneshot_control(unsigned long reason);
34extern void tick_broadcast_switch_to_oneshot(void);
35extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010036extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020037extern int tick_broadcast_oneshot_active(void);
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020038extern void tick_check_oneshot_broadcast(int cpu);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080039# else /* BROADCAST */
40static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
41{
42 BUG();
43}
44static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
45static inline void tick_broadcast_switch_to_oneshot(void) { }
46static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +020047static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +020048static inline void tick_check_oneshot_broadcast(int cpu) { }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080049# endif /* !BROADCAST */
50
51#else /* !ONESHOT */
52static inline
53void tick_setup_oneshot(struct clock_event_device *newdev,
54 void (*handler)(struct clock_event_device *),
55 ktime_t nextevt)
56{
57 BUG();
58}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010059static inline void tick_resume_oneshot(void)
60{
61 BUG();
62}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080063static inline int tick_program_event(ktime_t expires, int force)
64{
65 return 0;
66}
67static inline void tick_oneshot_notify(void) { }
68static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
69{
70 BUG();
71}
72static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
73static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010074static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
75{
76 return 0;
77}
Ingo Molnarf8e256c2008-09-23 13:00:57 +020078static inline int tick_broadcast_oneshot_active(void) { return 0; }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080079#endif /* !TICK_ONESHOT */
80
81/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080082 * Broadcasting support
83 */
84#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080085extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
86extern int tick_check_broadcast_device(struct clock_event_device *dev);
87extern int tick_is_broadcast_device(struct clock_event_device *dev);
88extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
89extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010090extern void tick_suspend_broadcast(void);
91extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080092
93extern void
94tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
95
96#else /* !BROADCAST */
97
98static inline int tick_check_broadcast_device(struct clock_event_device *dev)
99{
100 return 0;
101}
102
103static inline int tick_is_broadcast_device(struct clock_event_device *dev)
104{
105 return 0;
106}
107static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
108 int cpu)
109{
110 return 0;
111}
112static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
113static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
114static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100115static inline void tick_suspend_broadcast(void) { }
116static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800117
118/*
119 * Set the periodic handler in non broadcast mode
120 */
121static inline void tick_set_periodic_handler(struct clock_event_device *dev,
122 int broadcast)
123{
124 dev->event_handler = tick_handle_periodic;
125}
126#endif /* !BROADCAST */
127
128/*
129 * Check, if the device is functional or a dummy for broadcast
130 */
131static inline int tick_device_is_functional(struct clock_event_device *dev)
132{
133 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
134}