summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorramesh.chandrasekaran <ramesh.chandrasekaran@stericsson.com>2012-04-23 07:55:42 +0200
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:01:43 +0200
commit88ee8490ab4f6401fe4d60533161a0266680543d (patch)
tree99b8917b8b511460ddd0198cfde1bc80c33782f2
parent169b92e33260f1616046880de89ee8103dcdf156 (diff)
RTC: Fix to correct improper implementation of clock update irq (RTC_UIE) and enable UIE Emulation
Signed-off-by: ramesh.chandrasekaran <ramesh.chandrasekaran@stericsson.com>
-rw-r--r--drivers/rtc/Kconfig1
-rw-r--r--drivers/rtc/rtc-ab8500.c15
2 files changed, 14 insertions, 2 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 595d02b1117..3e47885660e 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -722,6 +722,7 @@ config RTC_DRV_AB3100
config RTC_DRV_AB8500
tristate "ST-Ericsson AB8500 RTC"
depends on AB8500_CORE
+ select RTC_INTF_DEV_UIE_EMUL
help
Select this to enable the ST-Ericsson AB8500 power management IC RTC
support. This chip contains a battery- and capacitor-backed RTC.
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index baae8548781..63b3a672a17 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -219,8 +219,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
int retval, i;
unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)];
- unsigned long mins, secs = 0;
-
+ unsigned long mins, secs = 0, cursec=0;
+ struct rtc_time curtm;
if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
dev_dbg(dev, "year should be equal to or greater than %d\n",
AB8500_RTC_EPOCH);
@@ -230,6 +230,17 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
/* Get the number of seconds since 1970 */
rtc_tm_to_time(&alarm->time, &secs);
+ /* Check whether alarm is set less than 1min.
+ * Since our RTC doesn't support alarm resolution less than 1min,
+ * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON
+ */
+ ab8500_rtc_read_time(dev, &curtm); /* Read current time */
+ rtc_tm_to_time(&curtm, &cursec);
+ if ((secs - cursec) < 59) {
+ dev_dbg(dev, "Alarm less than 1 minute not supported\n");
+ return -EINVAL;
+ }
+
/*
* Convert it to the number of seconds since 01-01-2000 00:00:00, since
* we only have a small counter in the RTC.