Skip to contentSkip to conversation

No subject

PATCH [email protected] 1 participant 1 message Dec 5, 2011 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

=09/*
=09 * The meaning of MO_C bit varies by the chip type. =09 * From PCF8563 datasheet: this bit is toggled when the years =09 * register overflows from 99 to 00
=09 * 0 indicates the century is 20xx
=09 * 1 indicates the century is 19xx
=09 * From RTC8564 datasheet: this bit indicates change of =09 * century. When the year digit data overflows from 99 to 00, =09 * this bit is set. By presetting it to 0 while still in the =09 * 20th century, it will be set in year 2000, ... =09 * There seems no reliable way to know how the system use this =09 * bit. So let's do it heuristically, assuming we are live in =09 * 1970...2069.
=09 */

As U-Boot's PCF8563 driver does not say it is supposed to support the RTC85= 64,
make this driver compatible with Linux's by giving the opposite meaning to = the
century bit.

---
 .../drivers/rtc/pcf8563.c                          |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
u-boot-66714b1/drivers= renamed from u-boot-66714b1.orig/drivers/rtc/pcf8563.c +0 -0

/rtc/pcf8563.c
index 339e5f6..a028533 100644

drivers/rtc/pcf8563.c +1 -1
@@ -72,7 +72,7 @@ int rtc_get (struct rtc_time *tmp)
 =09tmp->tm_hour =3D bcd2bin (hour & 0x3F);
 =09tmp->tm_mday =3D bcd2bin (mday & 0x3F);
 =09tmp->tm_mon  =3D bcd2bin (mon_cent & 0x1F);
-=09tmp->tm_year =3D bcd2bin (year) + ((mon_cent & 0x80) ? 2000 : 1900);
+=09tmp->tm_year =3D bcd2bin (year) + ((mon_cent & 0x80) ? 1900 : 2000);
 =09tmp->tm_wday =3D bcd2bin (wday & 0x07);
 =09tmp->tm_yday =3D 0;
 =09tmp->tm_isdst=3D 0;
@@ -94,7 +94,7 @@ int rtc_set (struct rtc_time *tmp)

=20
=09rtc_write (0x08, bin2bcd(tmp->tm_year % 100));
=20
-=09century =3D (tmp->tm_year >=3D 2000) ? 0x80 : 0;

+=09century =3D (tmp->tm_year >=3D 2000) ? 0 : 0x80;
 =09rtc_write (0x07, bin2bcd(tmp->tm_mon) | century);

=20
=09rtc_write (0x06, bin2bcd(tmp->tm_wday));