|
@@ -84,12 +84,10 @@ int rtc_get( struct rtc_time *tmp )
|
|
tmp->tm_yday = 0;
|
|
tmp->tm_yday = 0;
|
|
tmp->tm_isdst = 0;
|
|
tmp->tm_isdst = 0;
|
|
|
|
|
|
-#ifdef RTC_DEBUG
|
|
|
|
- printf( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
|
|
|
|
|
+ debug( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
|
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
|
|
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
|
|
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
|
|
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
|
|
|
|
|
|
-#endif
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -97,11 +95,10 @@ int rtc_set( struct rtc_time *tmp )
|
|
{
|
|
{
|
|
int ret;
|
|
int ret;
|
|
unsigned char buf[RTC_RV3029_PAGE_LEN];
|
|
unsigned char buf[RTC_RV3029_PAGE_LEN];
|
|
-#ifdef RTC_DEBUG
|
|
|
|
- printf( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
|
|
|
|
|
+
|
|
|
|
+ debug( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
|
|
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
|
|
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
|
|
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
|
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
|
-#endif
|
|
|
|
|
|
|
|
if (tmp->tm_year < 2000) {
|
|
if (tmp->tm_year < 2000) {
|
|
printf("RTC: year %d < 2000 not possible\n", tmp->tm_year);
|
|
printf("RTC: year %d < 2000 not possible\n", tmp->tm_year);
|
|
@@ -122,16 +119,15 @@ int rtc_set( struct rtc_time *tmp )
|
|
|
|
|
|
/* give the RTC some time to update */
|
|
/* give the RTC some time to update */
|
|
udelay(1000);
|
|
udelay(1000);
|
|
- return 0;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
/* sets EERE-Bit (automatic EEPROM refresh) */
|
|
/* sets EERE-Bit (automatic EEPROM refresh) */
|
|
static void set_eere_bit(int state)
|
|
static void set_eere_bit(int state)
|
|
{
|
|
{
|
|
- int ret;
|
|
|
|
unsigned char reg_ctrl1;
|
|
unsigned char reg_ctrl1;
|
|
|
|
|
|
- ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL1, 1,
|
|
|
|
|
|
+ (void)i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL1, 1,
|
|
®_ctrl1, 1);
|
|
®_ctrl1, 1);
|
|
|
|
|
|
if (state)
|
|
if (state)
|
|
@@ -139,18 +135,18 @@ static void set_eere_bit(int state)
|
|
else
|
|
else
|
|
reg_ctrl1 &= (~RTC_RV3029_CTRL1_EERE);
|
|
reg_ctrl1 &= (~RTC_RV3029_CTRL1_EERE);
|
|
|
|
|
|
- ret = i2c_write(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL1, 1,
|
|
|
|
|
|
+ (void)i2c_write(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL1, 1,
|
|
®_ctrl1, 1);
|
|
®_ctrl1, 1);
|
|
}
|
|
}
|
|
|
|
|
|
/* waits until EEPROM page is no longer busy (times out after 10ms*loops) */
|
|
/* waits until EEPROM page is no longer busy (times out after 10ms*loops) */
|
|
static int wait_eebusy(int loops)
|
|
static int wait_eebusy(int loops)
|
|
{
|
|
{
|
|
- int i, ret;
|
|
|
|
|
|
+ int i;
|
|
unsigned char ctrl_status;
|
|
unsigned char ctrl_status;
|
|
|
|
|
|
for (i = 0; i < loops; i++) {
|
|
for (i = 0; i < loops; i++) {
|
|
- ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL_STATUS,
|
|
|
|
|
|
+ (void)i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL_STATUS,
|
|
1, &ctrl_status, 1);
|
|
1, &ctrl_status, 1);
|
|
|
|
|
|
if ((ctrl_status & RTC_RV3029_CTRLS_EEBUSY) == 0)
|
|
if ((ctrl_status & RTC_RV3029_CTRLS_EEBUSY) == 0)
|
|
@@ -162,11 +158,10 @@ static int wait_eebusy(int loops)
|
|
|
|
|
|
void rtc_reset (void)
|
|
void rtc_reset (void)
|
|
{
|
|
{
|
|
- int ret;
|
|
|
|
unsigned char buf[RTC_RV3029_PAGE_LEN];
|
|
unsigned char buf[RTC_RV3029_PAGE_LEN];
|
|
|
|
|
|
buf[0] = RTC_RV3029_CTRL_SYS_R;
|
|
buf[0] = RTC_RV3029_CTRL_SYS_R;
|
|
- ret = i2c_write(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL_RESET, 1,
|
|
|
|
|
|
+ (void)i2c_write(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CTRL_RESET, 1,
|
|
buf, 1);
|
|
buf, 1);
|
|
|
|
|
|
#if defined(CONFIG_SYS_RV3029_TCR)
|
|
#if defined(CONFIG_SYS_RV3029_TCR)
|
|
@@ -178,7 +173,7 @@ void rtc_reset (void)
|
|
set_eere_bit(0);
|
|
set_eere_bit(0);
|
|
wait_eebusy(100);
|
|
wait_eebusy(100);
|
|
/* read current trickle charger setting */
|
|
/* read current trickle charger setting */
|
|
- ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_EEPROM_CTRL,
|
|
|
|
|
|
+ (void)i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_EEPROM_CTRL,
|
|
1, buf, 1);
|
|
1, buf, 1);
|
|
/* enable automatic EEPROM refresh again */
|
|
/* enable automatic EEPROM refresh again */
|
|
set_eere_bit(1);
|
|
set_eere_bit(1);
|
|
@@ -195,7 +190,7 @@ void rtc_reset (void)
|
|
*/
|
|
*/
|
|
set_eere_bit(0);
|
|
set_eere_bit(0);
|
|
wait_eebusy(100);
|
|
wait_eebusy(100);
|
|
- ret = i2c_write(CONFIG_SYS_I2C_RTC_ADDR,
|
|
|
|
|
|
+ (void)i2c_write(CONFIG_SYS_I2C_RTC_ADDR,
|
|
RTC_RV3029_EEPROM_CTRL, 1, buf, 1);
|
|
RTC_RV3029_EEPROM_CTRL, 1, buf, 1);
|
|
/*
|
|
/*
|
|
* it is necessary to wait 10ms before EEBUSY-Bit may be read
|
|
* it is necessary to wait 10ms before EEBUSY-Bit may be read
|