aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clockchips.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/clockchips.h')
-rw-r--r--include/linux/clockchips.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 96c280b2c263..597a1e836f22 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -37,12 +37,15 @@ enum clock_event_mode {
37 * reached from DETACHED or SHUTDOWN. 37 * reached from DETACHED or SHUTDOWN.
38 * ONESHOT: Device is programmed to generate event only once. Can be reached 38 * ONESHOT: Device is programmed to generate event only once. Can be reached
39 * from DETACHED or SHUTDOWN. 39 * from DETACHED or SHUTDOWN.
40 * ONESHOT_STOPPED: Device was programmed in ONESHOT mode and is temporarily
41 * stopped.
40 */ 42 */
41enum clock_event_state { 43enum clock_event_state {
42 CLOCK_EVT_STATE_DETACHED, 44 CLOCK_EVT_STATE_DETACHED,
43 CLOCK_EVT_STATE_SHUTDOWN, 45 CLOCK_EVT_STATE_SHUTDOWN,
44 CLOCK_EVT_STATE_PERIODIC, 46 CLOCK_EVT_STATE_PERIODIC,
45 CLOCK_EVT_STATE_ONESHOT, 47 CLOCK_EVT_STATE_ONESHOT,
48 CLOCK_EVT_STATE_ONESHOT_STOPPED,
46}; 49};
47 50
48/* 51/*
@@ -84,12 +87,13 @@ enum clock_event_state {
84 * @mult: nanosecond to cycles multiplier 87 * @mult: nanosecond to cycles multiplier
85 * @shift: nanoseconds to cycles divisor (power of two) 88 * @shift: nanoseconds to cycles divisor (power of two)
86 * @mode: operating mode, relevant only to ->set_mode(), OBSOLETE 89 * @mode: operating mode, relevant only to ->set_mode(), OBSOLETE
87 * @state: current state of the device, assigned by the core code 90 * @state_use_accessors:current state of the device, assigned by the core code
88 * @features: features 91 * @features: features
89 * @retries: number of forced programming retries 92 * @retries: number of forced programming retries
90 * @set_mode: legacy set mode function, only for modes <= CLOCK_EVT_MODE_RESUME. 93 * @set_mode: legacy set mode function, only for modes <= CLOCK_EVT_MODE_RESUME.
91 * @set_state_periodic: switch state to periodic, if !set_mode 94 * @set_state_periodic: switch state to periodic, if !set_mode
92 * @set_state_oneshot: switch state to oneshot, if !set_mode 95 * @set_state_oneshot: switch state to oneshot, if !set_mode
96 * @set_state_oneshot_stopped: switch state to oneshot_stopped, if !set_mode
93 * @set_state_shutdown: switch state to shutdown, if !set_mode 97 * @set_state_shutdown: switch state to shutdown, if !set_mode
94 * @tick_resume: resume clkevt device, if !set_mode 98 * @tick_resume: resume clkevt device, if !set_mode
95 * @broadcast: function to broadcast events 99 * @broadcast: function to broadcast events
@@ -113,7 +117,7 @@ struct clock_event_device {
113 u32 mult; 117 u32 mult;
114 u32 shift; 118 u32 shift;
115 enum clock_event_mode mode; 119 enum clock_event_mode mode;
116 enum clock_event_state state; 120 enum clock_event_state state_use_accessors;
117 unsigned int features; 121 unsigned int features;
118 unsigned long retries; 122 unsigned long retries;
119 123
@@ -121,11 +125,12 @@ struct clock_event_device {
121 * State transition callback(s): Only one of the two groups should be 125 * State transition callback(s): Only one of the two groups should be
122 * defined: 126 * defined:
123 * - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME. 127 * - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME.
124 * - set_state_{shutdown|periodic|oneshot}(), tick_resume(). 128 * - set_state_{shutdown|periodic|oneshot|oneshot_stopped}(), tick_resume().
125 */ 129 */
126 void (*set_mode)(enum clock_event_mode mode, struct clock_event_device *); 130 void (*set_mode)(enum clock_event_mode mode, struct clock_event_device *);
127 int (*set_state_periodic)(struct clock_event_device *); 131 int (*set_state_periodic)(struct clock_event_device *);
128 int (*set_state_oneshot)(struct clock_event_device *); 132 int (*set_state_oneshot)(struct clock_event_device *);
133 int (*set_state_oneshot_stopped)(struct clock_event_device *);
129 int (*set_state_shutdown)(struct clock_event_device *); 134 int (*set_state_shutdown)(struct clock_event_device *);
130 int (*tick_resume)(struct clock_event_device *); 135 int (*tick_resume)(struct clock_event_device *);
131 136
@@ -144,6 +149,32 @@ struct clock_event_device {
144 struct module *owner; 149 struct module *owner;
145} ____cacheline_aligned; 150} ____cacheline_aligned;
146 151
152/* Helpers to verify state of a clockevent device */
153static inline bool clockevent_state_detached(struct clock_event_device *dev)
154{
155 return dev->state_use_accessors == CLOCK_EVT_STATE_DETACHED;
156}
157
158static inline bool clockevent_state_shutdown(struct clock_event_device *dev)
159{
160 return dev->state_use_accessors == CLOCK_EVT_STATE_SHUTDOWN;
161}
162
163static inline bool clockevent_state_periodic(struct clock_event_device *dev)
164{
165 return dev->state_use_accessors == CLOCK_EVT_STATE_PERIODIC;
166}
167
168static inline bool clockevent_state_oneshot(struct clock_event_device *dev)
169{
170 return dev->state_use_accessors == CLOCK_EVT_STATE_ONESHOT;
171}
172
173static inline bool clockevent_state_oneshot_stopped(struct clock_event_device *dev)
174{
175 return dev->state_use_accessors == CLOCK_EVT_STATE_ONESHOT_STOPPED;
176}
177
147/* 178/*
148 * Calculate a multiplication factor for scaled math, which is used to convert 179 * Calculate a multiplication factor for scaled math, which is used to convert
149 * nanoseconds based values to clock ticks: 180 * nanoseconds based values to clock ticks: