]> git.sur5r.net Git - u-boot/blobdiff - drivers/rtc/pcf8563.c
Merge branch 'master' into next
[u-boot] / drivers / rtc / pcf8563.c
index c384975f3559970897c9fd7451b28eeceb2d9ce5..339e5f60801d8301cc93cb24ceccf2fbaf767c5f 100644 (file)
 #include <rtc.h>
 #include <i2c.h>
 
-#if defined(CONFIG_RTC_PCF8563) && defined(CONFIG_CMD_DATE)
+#if defined(CONFIG_CMD_DATE)
 
 static uchar rtc_read  (uchar reg);
 static void  rtc_write (uchar reg, uchar val);
-static uchar bin2bcd   (unsigned int n);
-static unsigned bcd2bin(uchar c);
 
 /* ------------------------------------------------------------------------- */
 
@@ -86,7 +84,7 @@ int rtc_get (struct rtc_time *tmp)
        return rel;
 }
 
-void rtc_set (struct rtc_time *tmp)
+int rtc_set (struct rtc_time *tmp)
 {
        uchar century;
 
@@ -104,6 +102,8 @@ void rtc_set (struct rtc_time *tmp)
        rtc_write (0x04, bin2bcd(tmp->tm_hour));
        rtc_write (0x03, bin2bcd(tmp->tm_min ));
        rtc_write (0x02, bin2bcd(tmp->tm_sec ));
+
+       return 0;
 }
 
 void rtc_reset (void)
@@ -127,22 +127,12 @@ void rtc_reset (void)
 
 static uchar rtc_read (uchar reg)
 {
-       return (i2c_reg_read (CFG_I2C_RTC_ADDR, reg));
+       return (i2c_reg_read (CONFIG_SYS_I2C_RTC_ADDR, reg));
 }
 
 static void rtc_write (uchar reg, uchar val)
 {
-       i2c_reg_write (CFG_I2C_RTC_ADDR, reg, val);
-}
-
-static unsigned bcd2bin (uchar n)
-{
-       return ((((n >> 4) & 0x0F) * 10) + (n & 0x0F));
-}
-
-static unsigned char bin2bcd (unsigned int n)
-{
-       return (((n / 10) << 4) | (n % 10));
+       i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val);
 }
 
 #endif