Skip to content

Commit

Permalink
timers: Introduce in-kernel alarm-timer interface
Browse files Browse the repository at this point in the history
This provides the in kernel interface and infrastructure for
alarm-timers.

Alarm-timers are a hybrid style timer, similar to hrtimers,
but when the system is suspended, the RTC device is set to
fire and wake the system for when the soonest alarm-timer
expires.

The concept for Alarm-timers was inspired by the Android Alarm
driver (by Arve Hjønnevåg) found in the Android kernel tree.

See: http://android.git.kernel.org/?p=kernel/common.git;a=blob;f=drivers/rtc/alarm.c;h=1250edfbdf3302f5e4ea6194847c6ef4bb7beb1c;hb=android-2.6.36

This in-kernel interface should be fairly compatible with the
Android alarm driver in-kernel interface, but has the advantage
of utilizing the new RTC timerqueue code instead of doing direct
RTC manipulation.

CC: Arve Hjønnevåg <arve@android.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Alessandro Zummo <a.zummo@towertech.it>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
  • Loading branch information
John Stultz committed Apr 26, 2011
1 parent 88d19cf commit ff3ead9
Show file tree
Hide file tree
Showing 3 changed files with 406 additions and 1 deletion.
30 changes: 30 additions & 0 deletions include/linux/alarmtimer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef _LINUX_ALARMTIMER_H
#define _LINUX_ALARMTIMER_H

#include <linux/time.h>
#include <linux/hrtimer.h>
#include <linux/timerqueue.h>
#include <linux/rtc.h>

enum alarmtimer_type {
ALARM_REALTIME,
ALARM_BOOTTIME,

ALARM_NUMTYPE,
};

struct alarm {
struct timerqueue_node node;
ktime_t period;
void (*function)(struct alarm *);
enum alarmtimer_type type;
char enabled;
void *data;
};

void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
void (*function)(struct alarm *));
void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
void alarm_cancel(struct alarm *alarm);

#endif
2 changes: 1 addition & 1 deletion kernel/time/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o timecompare.o
obj-y += timeconv.o posix-clock.o
obj-y += timeconv.o posix-clock.o alarmtimer.o

obj-$(CONFIG_GENERIC_CLOCKEVENTS_BUILD) += clockevents.o
obj-$(CONFIG_GENERIC_CLOCKEVENTS) += tick-common.o
Expand Down
Loading

0 comments on commit ff3ead9

Please sign in to comment.