Source
x
data[RTC_HOUR_ADDR] |= (tmp->tm_year - CONFIG_SYS_M41T11_BASE_YEAR) > 100 ? 0x40 : 0;
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2002
* Andrew May, Viasat Inc, amay@viasat.com
*/
/*
* M41T11 Serial Access Timekeeper(R) SRAM
* can you believe a trademark on that?
*/
/* #define DEBUG 1 */
/*
I Don't have an example config file but this
is what should be done.
#define CONFIG_RTC_M41T11 1
#define CONFIG_SYS_I2C_RTC_ADDR 0x68
#if 0
#define CONFIG_SYS_M41T11_EXT_CENTURY_DATA
#else
#define CONFIG_SYS_M41T11_BASE_YEAR 2000
#endif
*/
/* ------------------------------------------------------------------------- */
/*
these are simple defines for the chip local to here so they aren't too
verbose
DAY/DATE aren't nice but that is how they are on the data sheet
*/
/*
you only get 00-99 for the year we will asume you
want from the year 2000 if you don't set the config
*/
/* we will store extra year info in byte 9*/
int rtc_get (struct rtc_time *tmp)
{
int rel = 0;
uchar data[RTC_REG_CNT];
i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT);
if( data[RTC_SEC_ADDR] & 0x80 ){
printf( "m41t11 RTC Clock stopped!!!\n" );
rel = -1;
}
tmp->tm_sec = bcd2bin (data[RTC_SEC_ADDR] & 0x7F);
tmp->tm_min = bcd2bin (data[RTC_MIN_ADDR] & 0x7F);
tmp->tm_hour = bcd2bin (data[RTC_HOUR_ADDR] & 0x3F);
tmp->tm_mday = bcd2bin (data[RTC_DATE_ADDR] & 0x3F);
tmp->tm_mon = bcd2bin (data[RTC_MONTH_ADDR]& 0x1F);
tmp->tm_year = CONFIG_SYS_M41T11_BASE_YEAR
+ bcd2bin(data[RTC_YEARS_ADDR])