dect
/
linux-2.6
Archived
13
0
Fork 0

drivers/rtc/rtc-mxc.c: fix setting time for MX1 SoC

There is no way to track year in the i.MX1 RTC: Days Counter register is
9-bit wide only.  Attempt to save date after 1970-01-01 plus 512 days
causes endless loop in mxc_rtc_set_mmss().  Fix this by resetting year to
1970.

[akpm@linux-foundation.org: use conventional comment layout]
Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Cc: Daniel Mack <daniel@caiaq.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Yauhen Kharuzhy 2012-01-10 15:10:32 -08:00 committed by Linus Torvalds
parent b43c1ea4d6
commit 7287be1d0a
1 changed files with 11 additions and 0 deletions

View File

@ -290,6 +290,17 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
*/
static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
{
/*
* TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only
*/
if (cpu_is_mx1()) {
struct rtc_time tm;
rtc_time_to_tm(time, &tm);
tm.tm_year = 70;
rtc_tm_to_time(&tm, &time);
}
/* Avoid roll-over from reading the different registers */
do {
set_alarm_or_time(dev, MXC_RTC_TIME, time);