blob: f13f2b7f4fd46bda983d7138edce267b1a9e0c91 [file] [log] [blame]
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08001/*
2 * tick internal variable and functions used by low/high res code
3 */
4DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
5extern spinlock_t tick_device_lock;
6extern ktime_t tick_next_period;
7extern ktime_t tick_period;
Thomas Gleixnerd3ed7822007-05-08 00:30:03 -07008extern int tick_do_timer_cpu __read_mostly;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08009
10extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
11extern void tick_handle_periodic(struct clock_event_device *dev);
12
13/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080014 * NO_HZ / high resolution timer shared code
15 */
16#ifdef CONFIG_TICK_ONESHOT
17extern void tick_setup_oneshot(struct clock_event_device *newdev,
18 void (*handler)(struct clock_event_device *),
19 ktime_t nextevt);
20extern int tick_program_event(ktime_t expires, int force);
21extern void tick_oneshot_notify(void);
22extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010023extern void tick_resume_oneshot(void);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080024# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
25extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
26extern void tick_broadcast_oneshot_control(unsigned long reason);
27extern void tick_broadcast_switch_to_oneshot(void);
28extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010029extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080030# else /* BROADCAST */
31static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
32{
33 BUG();
34}
35static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
36static inline void tick_broadcast_switch_to_oneshot(void) { }
37static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
38# endif /* !BROADCAST */
39
40#else /* !ONESHOT */
41static inline
42void tick_setup_oneshot(struct clock_event_device *newdev,
43 void (*handler)(struct clock_event_device *),
44 ktime_t nextevt)
45{
46 BUG();
47}
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010048static inline void tick_resume_oneshot(void)
49{
50 BUG();
51}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080052static inline int tick_program_event(ktime_t expires, int force)
53{
54 return 0;
55}
56static inline void tick_oneshot_notify(void) { }
57static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
58{
59 BUG();
60}
61static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
62static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +010063static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
64{
65 return 0;
66}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080067#endif /* !TICK_ONESHOT */
68
69/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080070 * Broadcasting support
71 */
72#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080073extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
74extern int tick_check_broadcast_device(struct clock_event_device *dev);
75extern int tick_is_broadcast_device(struct clock_event_device *dev);
76extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
77extern void tick_shutdown_broadcast(unsigned int *cpup);
Thomas Gleixner6321dd62007-03-06 08:25:42 +010078extern void tick_suspend_broadcast(void);
79extern int tick_resume_broadcast(void);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080080
81extern void
82tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
83
84#else /* !BROADCAST */
85
86static inline int tick_check_broadcast_device(struct clock_event_device *dev)
87{
88 return 0;
89}
90
91static inline int tick_is_broadcast_device(struct clock_event_device *dev)
92{
93 return 0;
94}
95static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
96 int cpu)
97{
98 return 0;
99}
100static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
101static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
102static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100103static inline void tick_suspend_broadcast(void) { }
104static inline int tick_resume_broadcast(void) { return 0; }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800105
106/*
107 * Set the periodic handler in non broadcast mode
108 */
109static inline void tick_set_periodic_handler(struct clock_event_device *dev,
110 int broadcast)
111{
112 dev->event_handler = tick_handle_periodic;
113}
114#endif /* !BROADCAST */
115
116/*
117 * Check, if the device is functional or a dummy for broadcast
118 */
119static inline int tick_device_is_functional(struct clock_event_device *dev)
120{
121 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
122}