Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0adcbc0 authored by Mao Jinlong's avatar Mao Jinlong Committed by David Collins
Browse files

alarmtimer: add rtc irq support for alarm



Add the rtc irq support for alarmtimer to wakeup the
alarm during system suspend.

Change-Id: I41b774ed4e788359321e1c6a564551cc9cd40c8e
Signed-off-by: default avatarXiaocheng Li <lix@codeaurora.org>
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent 09055697
Loading
Loading
Loading
Loading
+31 −6
Original line number Diff line number Diff line
@@ -52,6 +52,18 @@ static struct rtc_timer rtctimer;
static struct rtc_device	*rtcdev;
static DEFINE_SPINLOCK(rtcdev_lock);

static void alarmtimer_triggered_func(void *p)
{
	struct rtc_device *rtc = rtcdev;

	if (!(rtc->irq_data & RTC_AF))
		return;
	__pm_wakeup_event(ws, 2 * MSEC_PER_SEC);
}

static struct rtc_task alarmtimer_rtc_task = {
	.func = alarmtimer_triggered_func
};
/**
 * alarmtimer_get_rtcdev - Return selected rtcdevice
 *
@@ -62,7 +74,7 @@ static DEFINE_SPINLOCK(rtcdev_lock);
struct rtc_device *alarmtimer_get_rtcdev(void)
{
	unsigned long flags;
	struct rtc_device *ret;
	struct rtc_device *ret = NULL;

	spin_lock_irqsave(&rtcdev_lock, flags);
	ret = rtcdev;
@@ -76,24 +88,36 @@ static int alarmtimer_rtc_add_device(struct device *dev,
				struct class_interface *class_intf)
{
	unsigned long flags;
	int err = 0;
	struct rtc_device *rtc = to_rtc_device(dev);

	if (rtcdev)
		return -EBUSY;

	if (!rtc->ops->set_alarm)
		return -1;
	if (!device_may_wakeup(rtc->dev.parent))
		return -1;

	spin_lock_irqsave(&rtcdev_lock, flags);
	if (!rtcdev) {
		err = rtc_irq_register(rtc, &alarmtimer_rtc_task);
		if (err)
			goto rtc_irq_reg_err;
		rtcdev = rtc;
		/* hold a reference so it doesn't go away */
		get_device(dev);
	}

rtc_irq_reg_err:
	spin_unlock_irqrestore(&rtcdev_lock, flags);
	return 0;
	return err;

}

static void alarmtimer_rtc_remove_device(struct device *dev,
				struct class_interface *class_intf)
{
	if (rtcdev && dev == &rtcdev->dev) {
		rtc_irq_unregister(rtcdev, &alarmtimer_rtc_task);
		rtcdev = NULL;
	}
}

static inline void alarmtimer_rtc_timer_init(void)
@@ -103,6 +127,7 @@ static inline void alarmtimer_rtc_timer_init(void)

static struct class_interface alarmtimer_rtc_interface = {
	.add_dev = &alarmtimer_rtc_add_device,
	.remove_dev = &alarmtimer_rtc_remove_device,
};

static int alarmtimer_rtc_interface_setup(void)