Index: sys/mips/cavium/octeon_ds1337.c =================================================================== --- sys/mips/cavium/octeon_ds1337.c (revision 225934) +++ sys/mips/cavium/octeon_ds1337.c (working copy) @@ -69,6 +69,7 @@ rc = -1; \ } \ } while(0); +#define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ static int validate_ct_struct(struct clocktime *ct) { @@ -77,6 +78,11 @@ if (!ct) return -1; +#ifdef CVMX_RTC_DEBUG + printf("%s: %04d-%02d-%02d WD%d %02d:%02d:%02d\n", __func__, + ct->year + 1900, ct->mon+1, ct->day, ct->dow+1, + ct->hour, ct->min, ct->sec); +#endif /* CVMX_RTC_DEBUG */ CT_CHECK(ct->sec < 0 || ct->sec > 60, "second"); /* + Leap sec */ CT_CHECK(ct->min < 0 || ct->min > 59, "minute"); CT_CHECK(ct->hour < 0 || ct->hour > 23, "hour"); @@ -127,12 +133,13 @@ ct.dow = (reg[3] & 0x7) - 1; /* Day of week field is 0..6 */ ct.day = bcd2bin(reg[4] & 0x3f); ct.mon = bcd2bin(reg[5] & 0x1f) - 1; /* Month field is 0..11 */ - ct.year = ((reg[5] & 0x80) ? 100 : 0) + bcd2bin(reg[6]); + ct.year = ((reg[5] & DS1337_BIT_CENTURY) ? 100 : 0) + bcd2bin(reg[6]); if (validate_ct_struct(&ct)) cvmx_dprintf("Warning: RTC calendar is not configured properly\n"); + ct.year += 1900; if (clock_ct_to_ts(&ct, &ts) != 0) { cvmx_dprintf("Warning: RTC calendar is not configured properly\n"); return 0; @@ -157,6 +164,7 @@ ts.tv_nsec = 0; clock_ts_to_ct(&ts, &ct); + ct.year -= 1900; if (validate_ct_struct(&ct)) { @@ -172,7 +180,7 @@ reg[5] = bin2bcd(ct.mon + 1); if (ct.year >= 100) /* Set century bit*/ { - reg[5] |= 0x80; + reg[5] |= DS1337_BIT_CENTURY; } reg[6] = bin2bcd(ct.year % 100); @@ -197,6 +205,7 @@ } #ifdef CVMX_RTC_DEBUG +void cvmx_rtc_ds1337_dump_state(void); void cvmx_rtc_ds1337_dump_state(void) {