* [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux @ 2012-07-20 14:05 Benoît Thébaudeau 2012-08-03 23:06 ` Benoît Thébaudeau 2012-09-02 15:31 ` Wolfgang Denk 0 siblings, 2 replies; 4+ messages in thread From: Benoît Thébaudeau @ 2012-07-20 14:05 UTC (permalink / raw) To: u-boot This driver uses the century bit of this RTC in the opposite way Linux does. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux 2012-07-20 14:05 [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux Benoît Thébaudeau @ 2012-08-03 23:06 ` Benoît Thébaudeau 2012-08-10 14:40 ` Benoît Thébaudeau 2012-09-02 15:31 ` Wolfgang Denk 1 sibling, 1 reply; 4+ messages in thread From: Benoît Thébaudeau @ 2012-08-03 23:06 UTC (permalink / raw) To: u-boot On Fri, Jul 20, 2012 at 04:05:36 PM, Beno?t Th?baudeau wrote: > This driver uses the century bit of this RTC in the opposite way > Linux does. > From Linux's rtc-pcf8563.c: > /* > * The meaning of MO_C bit varies by the chip type. > * From PCF8563 datasheet: this bit is toggled when the years > * register overflows from 99 to 00 > * 0 indicates the century is 20xx > * 1 indicates the century is 19xx > * From RTC8564 datasheet: this bit indicates change of > * century. When the year digit data overflows from 99 to 00, > * this bit is set. By presetting it to 0 while still in the > * 20th century, it will be set in year 2000, ... > * There seems no reliable way to know how the system use this > * bit. So let's do it heuristically, assuming we are live in > * 1970...2069. > */ > > As U-Boot's PCF8563 driver does not say it is supposed to support the > RTC8564, > make this driver compatible with Linux's by giving the opposite > meaning to the > century bit. > > Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com> > Cc: Wolfgang Denk <wd@denx.de> > --- > .../drivers/rtc/pcf8563.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git u-boot-66714b1.orig/drivers/rtc/pcf8563.c > u-boot-66714b1/drivers/rtc/pcf8563.c > index 339e5f6..a028533 100644 > --- u-boot-66714b1.orig/drivers/rtc/pcf8563.c > +++ u-boot-66714b1/drivers/rtc/pcf8563.c > @@ -72,7 +72,7 @@ int rtc_get (struct rtc_time *tmp) > tmp->tm_hour = bcd2bin (hour & 0x3F); > tmp->tm_mday = bcd2bin (mday & 0x3F); > tmp->tm_mon = bcd2bin (mon_cent & 0x1F); > - tmp->tm_year = bcd2bin (year) + ((mon_cent & 0x80) ? 2000 : 1900); > + tmp->tm_year = bcd2bin (year) + ((mon_cent & 0x80) ? 1900 : 2000); > tmp->tm_wday = bcd2bin (wday & 0x07); > tmp->tm_yday = 0; > tmp->tm_isdst= 0; > @@ -94,7 +94,7 @@ int rtc_set (struct rtc_time *tmp) > > rtc_write (0x08, bin2bcd(tmp->tm_year % 100)); > > - century = (tmp->tm_year >= 2000) ? 0x80 : 0; > + century = (tmp->tm_year >= 2000) ? 0 : 0x80; > rtc_write (0x07, bin2bcd(tmp->tm_mon) | century); > > rtc_write (0x06, bin2bcd(tmp->tm_wday)); > Ping? Beno?t ^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux 2012-08-03 23:06 ` Benoît Thébaudeau @ 2012-08-10 14:40 ` Benoît Thébaudeau 0 siblings, 0 replies; 4+ messages in thread From: Benoît Thébaudeau @ 2012-08-10 14:40 UTC (permalink / raw) To: u-boot On Sat, Aug 4, 2012 at 01:06:16 AM, Beno?t Th?baudeau wrote: > On Fri, Jul 20, 2012 at 04:05:36 PM, Beno?t Th?baudeau wrote: > > This driver uses the century bit of this RTC in the opposite way > > Linux does. > > From Linux's rtc-pcf8563.c: > > /* > > * The meaning of MO_C bit varies by the chip type. > > * From PCF8563 datasheet: this bit is toggled when the years > > * register overflows from 99 to 00 > > * 0 indicates the century is 20xx > > * 1 indicates the century is 19xx > > * From RTC8564 datasheet: this bit indicates change of > > * century. When the year digit data overflows from 99 to 00, > > * this bit is set. By presetting it to 0 while still in the > > * 20th century, it will be set in year 2000, ... > > * There seems no reliable way to know how the system use this > > * bit. So let's do it heuristically, assuming we are live in > > * 1970...2069. > > */ > > > > As U-Boot's PCF8563 driver does not say it is supposed to support > > the > > RTC8564, > > make this driver compatible with Linux's by giving the opposite > > meaning to the > > century bit. > > > > Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com> > > Cc: Wolfgang Denk <wd@denx.de> > > --- > > .../drivers/rtc/pcf8563.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git u-boot-66714b1.orig/drivers/rtc/pcf8563.c > > u-boot-66714b1/drivers/rtc/pcf8563.c > > index 339e5f6..a028533 100644 > > --- u-boot-66714b1.orig/drivers/rtc/pcf8563.c > > +++ u-boot-66714b1/drivers/rtc/pcf8563.c > > @@ -72,7 +72,7 @@ int rtc_get (struct rtc_time *tmp) > > tmp->tm_hour = bcd2bin (hour & 0x3F); > > tmp->tm_mday = bcd2bin (mday & 0x3F); > > tmp->tm_mon = bcd2bin (mon_cent & 0x1F); > > - tmp->tm_year = bcd2bin (year) + ((mon_cent & 0x80) ? 2000 : > > 1900); > > + tmp->tm_year = bcd2bin (year) + ((mon_cent & 0x80) ? 1900 : > > 2000); > > tmp->tm_wday = bcd2bin (wday & 0x07); > > tmp->tm_yday = 0; > > tmp->tm_isdst= 0; > > @@ -94,7 +94,7 @@ int rtc_set (struct rtc_time *tmp) > > > > rtc_write (0x08, bin2bcd(tmp->tm_year % 100)); > > > > - century = (tmp->tm_year >= 2000) ? 0x80 : 0; > > + century = (tmp->tm_year >= 2000) ? 0 : 0x80; > > rtc_write (0x07, bin2bcd(tmp->tm_mon) | century); > > > > rtc_write (0x06, bin2bcd(tmp->tm_wday)); > > > > Ping? Can someone answer, please? Best regards, Beno?t ^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux 2012-07-20 14:05 [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux Benoît Thébaudeau 2012-08-03 23:06 ` Benoît Thébaudeau @ 2012-09-02 15:31 ` Wolfgang Denk 1 sibling, 0 replies; 4+ messages in thread From: Wolfgang Denk @ 2012-09-02 15:31 UTC (permalink / raw) To: u-boot Dear Beno?t Th?baudeau, In message <2136837803.335794.1342793136811.JavaMail.root@advansee.com> you wrote: > This driver uses the century bit of this RTC in the opposite way Linux does> . > From Linux's rtc-pcf8563.c: > /* > * The meaning of MO_C bit varies by the chip type. > * From PCF8563 datasheet: this bit is toggled when the years > * register overflows from 99 to 00 > * 0 indicates the century is 20xx > * 1 indicates the century is 19xx > * From RTC8564 datasheet: this bit indicates change of > * century. When the year digit data overflows from 99 to 00, > * this bit is set. By presetting it to 0 while still in the > * 20th century, it will be set in year 2000, ... > * There seems no reliable way to know how the system use this > * bit. So let's do it heuristically, assuming we are live in > * 1970...2069. > */ > > 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. > > Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com> > Cc: Wolfgang Denk <wd@denx.de> > --- > .../drivers/rtc/pcf8563.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Applied, thanks. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Shakespeare's Law of Prototyping: (Hamlet III, iv, 156-160) O, throw away the worser part of it, And live the purer with the other half. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-02 15:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-07-20 14:05 [U-Boot] [PATCH] rtc: pcf8563: Make century compatible with Linux Benoît Thébaudeau 2012-08-03 23:06 ` Benoît Thébaudeau 2012-08-10 14:40 ` Benoît Thébaudeau 2012-09-02 15:31 ` Wolfgang Denk
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox