Commit | Line | Data |
---|---|---|
ff3ead96 JS |
1 | #ifndef _LINUX_ALARMTIMER_H |
2 | #define _LINUX_ALARMTIMER_H | |
3 | ||
4 | #include <linux/time.h> | |
5 | #include <linux/hrtimer.h> | |
6 | #include <linux/timerqueue.h> | |
7 | #include <linux/rtc.h> | |
8 | ||
9 | enum alarmtimer_type { | |
10 | ALARM_REALTIME, | |
11 | ALARM_BOOTTIME, | |
12 | ||
4a057549 | 13 | /* Supported types end here */ |
ff3ead96 | 14 | ALARM_NUMTYPE, |
4a057549 BW |
15 | |
16 | /* Used for tracing information. No usable types. */ | |
17 | ALARM_REALTIME_FREEZER, | |
18 | ALARM_BOOTTIME_FREEZER, | |
ff3ead96 JS |
19 | }; |
20 | ||
4b41308d JS |
21 | enum alarmtimer_restart { |
22 | ALARMTIMER_NORESTART, | |
23 | ALARMTIMER_RESTART, | |
24 | }; | |
25 | ||
a28cde81 JS |
26 | |
27 | #define ALARMTIMER_STATE_INACTIVE 0x00 | |
28 | #define ALARMTIMER_STATE_ENQUEUED 0x01 | |
a28cde81 | 29 | |
180bf812 JS |
30 | /** |
31 | * struct alarm - Alarm timer structure | |
32 | * @node: timerqueue node for adding to the event list this value | |
33 | * also includes the expiration time. | |
af4afb40 | 34 | * @timer: hrtimer used to schedule events while running |
180bf812 | 35 | * @function: Function pointer to be executed when the timer fires. |
af4afb40 PP |
36 | * @type: Alarm type (BOOTTIME/REALTIME). |
37 | * @state: Flag that represents if the alarm is set to fire or not. | |
180bf812 JS |
38 | * @data: Internal data value. |
39 | */ | |
ff3ead96 JS |
40 | struct alarm { |
41 | struct timerqueue_node node; | |
dae373be | 42 | struct hrtimer timer; |
4b41308d | 43 | enum alarmtimer_restart (*function)(struct alarm *, ktime_t now); |
ff3ead96 | 44 | enum alarmtimer_type type; |
a28cde81 | 45 | int state; |
ff3ead96 JS |
46 | void *data; |
47 | }; | |
48 | ||
49 | void alarm_init(struct alarm *alarm, enum alarmtimer_type type, | |
4b41308d | 50 | enum alarmtimer_restart (*function)(struct alarm *, ktime_t)); |
b193217e TG |
51 | void alarm_start(struct alarm *alarm, ktime_t start); |
52 | void alarm_start_relative(struct alarm *alarm, ktime_t start); | |
6cffe00f | 53 | void alarm_restart(struct alarm *alarm); |
9082c465 JS |
54 | int alarm_try_to_cancel(struct alarm *alarm); |
55 | int alarm_cancel(struct alarm *alarm); | |
ff3ead96 | 56 | |
dce75a8c | 57 | u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval); |
6cffe00f TP |
58 | u64 alarm_forward_now(struct alarm *alarm, ktime_t interval); |
59 | ktime_t alarm_expires_remaining(const struct alarm *alarm); | |
dce75a8c | 60 | |
57c498fa JS |
61 | /* Provide way to access the rtc device being used by alarmtimers */ |
62 | struct rtc_device *alarmtimer_get_rtcdev(void); | |
63 | ||
ff3ead96 | 64 | #endif |