1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_ALARMTIMER_H
3 #define _LINUX_ALARMTIMER_H
5 #include <linux/time.h>
6 #include <linux/hrtimer.h>
7 #include <linux/timerqueue.h>
11 enum alarmtimer_type {
15 /* Supported types end here */
18 /* Used for tracing information. No usable types. */
19 ALARM_REALTIME_FREEZER,
20 ALARM_BOOTTIME_FREEZER,
23 enum alarmtimer_restart {
29 #define ALARMTIMER_STATE_INACTIVE 0x00
30 #define ALARMTIMER_STATE_ENQUEUED 0x01
33 * struct alarm - Alarm timer structure
34 * @node: timerqueue node for adding to the event list this value
35 * also includes the expiration time.
36 * @timer: hrtimer used to schedule events while running
37 * @function: Function pointer to be executed when the timer fires.
38 * @type: Alarm type (BOOTTIME/REALTIME).
39 * @state: Flag that represents if the alarm is set to fire or not.
40 * @data: Internal data value.
43 struct timerqueue_node node;
45 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
46 enum alarmtimer_type type;
51 void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
52 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
53 void alarm_start(struct alarm *alarm, ktime_t start);
54 void alarm_start_relative(struct alarm *alarm, ktime_t start);
55 void alarm_restart(struct alarm *alarm);
56 int alarm_try_to_cancel(struct alarm *alarm);
57 int alarm_cancel(struct alarm *alarm);
59 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
60 u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
61 ktime_t alarm_expires_remaining(const struct alarm *alarm);
63 #ifdef CONFIG_RTC_CLASS
64 /* Provide way to access the rtc device being used by alarmtimers */
65 struct rtc_device *alarmtimer_get_rtcdev(void);
67 static inline struct rtc_device *alarmtimer_get_rtcdev(void) { return NULL; }