From 1fb682d2dfdaa19a50073fec6239f2bda9dbcc71 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 30 Jan 2009 14:37:40 +0000 Subject: [PATCH 4/8] manage RTC alarm "pending" flag of PCF50633 Backported to .28, original message below: This patch adds setting and clearing of the "pending" flag of the RTC alarm. The semantics follow the UEFI specification 2.2 available at http://www.uefi.org/specs/, i.e., the "pending" flag is cleared by disabling the alarm, but not by any other condition (such as the passing of time, a successful wakeup, or setting of a new alarm.) Signed-off-by: Werner Almesberger --- drivers/rtc/rtc-pcf50633.c | 5 +++++ include/linux/mfd/pcf50633/rtc.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index ddd6f89..0fdadbd 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c @@ -185,6 +185,7 @@ static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) pcf = dev_get_drvdata(dev); alrm->enabled = pcf->rtc.alarm_enabled; + alrm->pending = pcf->rtc.alarm_pending; ret = pcf50633_read_block(pcf, PCF50633_REG_RTCSCA, PCF50633_TI_EXTENT, &pcf_tm.time[0]); @@ -221,6 +222,9 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) if (ret) dev_err(dev, "Failed to write alarm time %d\n", ret); + if (!alrm->enabled) + pcf->rtc.alarm_pending = 0; + if (!alarm_masked || alrm->enabled) pcf50633_irq_unmask(pcf, PCF50633_IRQ_ALARM); pcf->rtc.alarm_enabled = alrm->enabled; @@ -240,6 +244,7 @@ static void pcf50633_rtc_irq(struct pcf50633 *pcf, int irq, void *unused) switch (irq) { case PCF50633_IRQ_ALARM: rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_AF | RTC_IRQF); + pcf->rtc.alarm_pending = 1; break; case PCF50633_IRQ_SECOND: rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_PF | RTC_IRQF); diff --git a/include/linux/mfd/pcf50633/rtc.h b/include/linux/mfd/pcf50633/rtc.h index ce8ad8f..80cc6af 100644 --- a/include/linux/mfd/pcf50633/rtc.h +++ b/include/linux/mfd/pcf50633/rtc.h @@ -34,6 +34,7 @@ struct pcf50633_rtc { int alarm_enabled; int second_enabled; + int alarm_pending; struct rtc_device *rtc_dev; struct platform_device *pdev; -- 1.5.2.2