]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - kernel/time/tick-internal.h
clocksource/drivers/sun5i: Add clock notifiers
[mirror_ubuntu-artful-kernel.git] / kernel / time / tick-internal.h
CommitLineData
f8381cba
TG
1/*
2 * tick internal variable and functions used by low/high res code
3 */
e2830b5c
TH
4#include <linux/hrtimer.h>
5#include <linux/tick.h>
6441402b 6
8b094cd0
TG
7#include "timekeeping.h"
8
eb93e4d9
TG
9extern seqlock_t jiffies_lock;
10
c7e99fc7
TG
11#define CS_NAME_LEN 32
12
7cf37e87 13#ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD
6441402b
TG
14
15#define TICK_DO_TIMER_NONE -1
16#define TICK_DO_TIMER_BOOT -2
17
f8381cba 18DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
f8381cba
TG
19extern ktime_t tick_next_period;
20extern ktime_t tick_period;
d3ed7824 21extern int tick_do_timer_cpu __read_mostly;
f8381cba
TG
22
23extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
24extern void tick_handle_periodic(struct clock_event_device *dev);
7172a286 25extern void tick_check_new_device(struct clock_event_device *dev);
8c53daf6
TG
26extern void tick_handover_do_timer(int *cpup);
27extern void tick_shutdown(unsigned int *cpup);
28extern void tick_suspend(void);
29extern void tick_resume(void);
03e13cf5
TG
30extern bool tick_check_replacement(struct clock_event_device *curdev,
31 struct clock_event_device *newdev);
32extern void tick_install_replacement(struct clock_event_device *dev);
f8381cba 33
2344abbc 34extern void clockevents_shutdown(struct clock_event_device *dev);
554ef387 35extern int clockevents_tick_resume(struct clock_event_device *dev);
2344abbc 36
891292a7 37extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt);
03e13cf5 38
79bf2bb3
TG
39/*
40 * NO_HZ / high resolution timer shared code
41 */
42#ifdef CONFIG_TICK_ONESHOT
43extern void tick_setup_oneshot(struct clock_event_device *newdev,
44 void (*handler)(struct clock_event_device *),
45 ktime_t nextevt);
46extern int tick_program_event(ktime_t expires, int force);
47extern void tick_oneshot_notify(void);
48extern int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *));
cd05a1f8 49extern void tick_resume_oneshot(void);
79bf2bb3
TG
50# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
51extern void tick_broadcast_setup_oneshot(struct clock_event_device *bc);
da7e6f45 52extern int tick_broadcast_oneshot_control(unsigned long reason);
79bf2bb3
TG
53extern void tick_broadcast_switch_to_oneshot(void);
54extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
cd05a1f8 55extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
27ce4cb4 56extern int tick_broadcast_oneshot_active(void);
e8fcaa5c 57extern void tick_check_oneshot_broadcast_this_cpu(void);
3a142a06 58bool tick_broadcast_oneshot_available(void);
79bf2bb3
TG
59# else /* BROADCAST */
60static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
61{
62 BUG();
63}
da7e6f45 64static inline int tick_broadcast_oneshot_control(unsigned long reason) { return 0; }
79bf2bb3
TG
65static inline void tick_broadcast_switch_to_oneshot(void) { }
66static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
27ce4cb4 67static inline int tick_broadcast_oneshot_active(void) { return 0; }
e8fcaa5c 68static inline void tick_check_oneshot_broadcast_this_cpu(void) { }
3a142a06 69static inline bool tick_broadcast_oneshot_available(void) { return true; }
79bf2bb3
TG
70# endif /* !BROADCAST */
71
72#else /* !ONESHOT */
73static inline
74void tick_setup_oneshot(struct clock_event_device *newdev,
75 void (*handler)(struct clock_event_device *),
76 ktime_t nextevt)
77{
78 BUG();
79}
cd05a1f8
TG
80static inline void tick_resume_oneshot(void)
81{
82 BUG();
83}
79bf2bb3
TG
84static inline int tick_program_event(ktime_t expires, int force)
85{
86 return 0;
87}
88static inline void tick_oneshot_notify(void) { }
89static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
90{
91 BUG();
92}
da7e6f45 93static inline int tick_broadcast_oneshot_control(unsigned long reason) { return 0; }
79bf2bb3 94static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
cd05a1f8
TG
95static inline int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
96{
97 return 0;
98}
f8e256c6 99static inline int tick_broadcast_oneshot_active(void) { return 0; }
3a142a06 100static inline bool tick_broadcast_oneshot_available(void) { return false; }
79bf2bb3
TG
101#endif /* !TICK_ONESHOT */
102
a80e49e2
FW
103/* NO_HZ_FULL internal */
104#ifdef CONFIG_NO_HZ_FULL
105extern void tick_nohz_init(void);
106# else
107static inline void tick_nohz_init(void) { }
108#endif
109
f8381cba
TG
110/*
111 * Broadcasting support
112 */
113#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
f8381cba 114extern int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu);
7172a286 115extern void tick_install_broadcast_device(struct clock_event_device *dev);
f8381cba
TG
116extern int tick_is_broadcast_device(struct clock_event_device *dev);
117extern void tick_broadcast_on_off(unsigned long reason, int *oncpu);
118extern void tick_shutdown_broadcast(unsigned int *cpup);
6321dd60
TG
119extern void tick_suspend_broadcast(void);
120extern int tick_resume_broadcast(void);
b352bc1c 121extern void tick_broadcast_init(void);
f8381cba
TG
122extern void
123tick_set_periodic_handler(struct clock_event_device *dev, int broadcast);
627ee794 124int tick_broadcast_update_freq(struct clock_event_device *dev, u32 freq);
f8381cba
TG
125
126#else /* !BROADCAST */
127
7172a286 128static inline void tick_install_broadcast_device(struct clock_event_device *dev)
f8381cba 129{
f8381cba
TG
130}
131
132static inline int tick_is_broadcast_device(struct clock_event_device *dev)
133{
134 return 0;
135}
136static inline int tick_device_uses_broadcast(struct clock_event_device *dev,
137 int cpu)
138{
139 return 0;
140}
141static inline void tick_do_periodic_broadcast(struct clock_event_device *d) { }
142static inline void tick_broadcast_on_off(unsigned long reason, int *oncpu) { }
143static inline void tick_shutdown_broadcast(unsigned int *cpup) { }
6321dd60
TG
144static inline void tick_suspend_broadcast(void) { }
145static inline int tick_resume_broadcast(void) { return 0; }
b352bc1c 146static inline void tick_broadcast_init(void) { }
627ee794
TG
147static inline int tick_broadcast_update_freq(struct clock_event_device *dev,
148 u32 freq) { return -ENODEV; }
f8381cba
TG
149
150/*
151 * Set the periodic handler in non broadcast mode
152 */
153static inline void tick_set_periodic_handler(struct clock_event_device *dev,
154 int broadcast)
155{
156 dev->event_handler = tick_handle_periodic;
157}
158#endif /* !BROADCAST */
159
160/*
161 * Check, if the device is functional or a dummy for broadcast
162 */
163static inline int tick_device_is_functional(struct clock_event_device *dev)
164{
165 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
166}
e2830b5c 167
f1689bb7
TG
168int __clockevents_update_freq(struct clock_event_device *dev, u32 freq);
169
7cf37e87
TG
170#endif
171
e2830b5c 172extern void do_timer(unsigned long ticks);
47a1b796 173extern void update_wall_time(void);