#define RTC_RV3029_CTRL1 0x00
#define RTC_RV3029_CTRL1_EERE (1 << 3)
#define RTC_RV3029_CTRL_STATUS 0x03
#define RTC_RV3029_CTRLS_EEBUSY (1 << 7)
#define RTC_RV3029_CTRL_RESET 0x04
#define RTC_RV3029_CTRL_SYS_R (1 << 4)
#define RTC_RV3029_CLOCK_PAGE 0x08
#define RTC_RV3029_PAGE_LEN 7
#define RV3029C2_W_SECONDS 0x00
#define RV3029C2_W_MINUTES 0x01
#define RV3029C2_W_HOURS 0x02
#define RV3029C2_W_DATE 0x03
#define RV3029C2_W_DAYS 0x04
#define RV3029C2_W_MONTHS 0x05
#define RV3029C2_W_YEARS 0x06
#define RV3029C2_REG_HR_12_24 (1 << 6)
#define RV3029C2_REG_HR_PM (1 << 5)
#define RTC_RV3029_EEPROM_CTRL 0x30
#define RTC_RV3029_TRICKLE_1K (1 << 4)
#define RTC_RV3029_TRICKLE_5K (1 << 5)
#define RTC_RV3029_TRICKLE_20K (1 << 6)
#define RTC_RV3029_TRICKLE_80K (1 << 7)
int rtc_get( struct rtc_time *tmp )
unsigned char buf[RTC_RV3029_PAGE_LEN];
ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_CLOCK_PAGE, 1, buf, \
printf("%s: error reading RTC: %x\n", __func__, ret);
tmp->tm_sec = bcd2bin( buf[RV3029C2_W_SECONDS] & 0x7f);
tmp->tm_min = bcd2bin( buf[RV3029C2_W_MINUTES] & 0x7f);
if (buf[RV3029C2_W_HOURS] & RV3029C2_REG_HR_12_24) {
tmp->tm_hour = bcd2bin(buf[RV3029C2_W_HOURS] & 0x1f);
if (buf[RV3029C2_W_HOURS] & RV3029C2_REG_HR_PM)
tmp->tm_hour = bcd2bin(buf[RV3029C2_W_HOURS] & 0x3f);
tmp->tm_mday = bcd2bin( buf[RV3029C2_W_DATE] & 0x3F );
tmp->tm_mon = bcd2bin( buf[RV3029C2_W_MONTHS] & 0x1F );