aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ab8500.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ab8500.c')
-rw-r--r--drivers/rtc/rtc-ab8500.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 370889d0489b..bf3c2f669c3c 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -89,22 +89,17 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
89 if (retval < 0) 89 if (retval < 0)
90 return retval; 90 return retval;
91 91
92 /* Early AB8500 chips will not clear the rtc read request bit */ 92 /* Wait for some cycles after enabling the rtc read in ab8500 */
93 if (abx500_get_chip_id(dev) == 0) { 93 while (time_before(jiffies, timeout)) {
94 usleep_range(1000, 1000); 94 retval = abx500_get_register_interruptible(dev,
95 } else { 95 AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value);
96 /* Wait for some cycles after enabling the rtc read in ab8500 */ 96 if (retval < 0)
97 while (time_before(jiffies, timeout)) { 97 return retval;
98 retval = abx500_get_register_interruptible(dev, 98
99 AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value); 99 if (!(value & RTC_READ_REQUEST))
100 if (retval < 0) 100 break;
101 return retval; 101
102 102 usleep_range(1000, 5000);
103 if (!(value & RTC_READ_REQUEST))
104 break;
105
106 usleep_range(1000, 5000);
107 }
108 } 103 }
109 104
110 /* Read the Watchtime registers */ 105 /* Read the Watchtime registers */
@@ -225,7 +220,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
225{ 220{
226 int retval, i; 221 int retval, i;
227 unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; 222 unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)];
228 unsigned long mins, secs = 0; 223 unsigned long mins, secs = 0, cursec = 0;
224 struct rtc_time curtm;
229 225
230 if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { 226 if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
231 dev_dbg(dev, "year should be equal to or greater than %d\n", 227 dev_dbg(dev, "year should be equal to or greater than %d\n",
@@ -237,6 +233,18 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
237 rtc_tm_to_time(&alarm->time, &secs); 233 rtc_tm_to_time(&alarm->time, &secs);
238 234
239 /* 235 /*
236 * Check whether alarm is set less than 1min.
237 * Since our RTC doesn't support alarm resolution less than 1min,
238 * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON
239 */
240 ab8500_rtc_read_time(dev, &curtm); /* Read current time */
241 rtc_tm_to_time(&curtm, &cursec);
242 if ((secs - cursec) < 59) {
243 dev_dbg(dev, "Alarm less than 1 minute not supported\r\n");
244 return -EINVAL;
245 }
246
247 /*
240 * Convert it to the number of seconds since 01-01-2000 00:00:00, since 248 * Convert it to the number of seconds since 01-01-2000 00:00:00, since
241 * we only have a small counter in the RTC. 249 * we only have a small counter in the RTC.
242 */ 250 */