]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - rtc/ds1306.c
TQM5200: fix spurious characters on second serial interface
[karo-tx-uboot.git] / rtc / ds1306.c
index 20f1a50856de2a574c5d0bac15bcd92855ae2d73..89e433dabd8894cddece689ebb84c0cd31e33a6d 100644 (file)
@@ -36,7 +36,7 @@
 #include <rtc.h>
 #include <spi.h>
 
-#if defined(CONFIG_RTC_DS1306) && (CONFIG_COMMANDS & CFG_CMD_DATE)
+#if defined(CONFIG_RTC_DS1306) && defined(CONFIG_CMD_DATE)
 
 #define        RTC_SECONDS             0x00
 #define        RTC_MINUTES             0x01
@@ -71,12 +71,6 @@ extern int spi_chipsel_cnt;
 
 static unsigned int bin2bcd (unsigned int n);
 static unsigned char bcd2bin (unsigned char c);
-static unsigned char rtc_read (unsigned char reg);
-static void rtc_write (unsigned char reg, unsigned char val);
-
-
-
-
 
 /* ************************************************************************* */
 #ifdef CONFIG_SXNI855T         /* !!! SHOULD BE CHANGED TO NEW CODE !!! */
@@ -306,9 +300,8 @@ void rtc_reset (void)
 #else  /* not CONFIG_SXNI855T */
 /* ************************************************************************* */
 
-
-
-
+static unsigned char rtc_read (unsigned char reg);
+static void rtc_write (unsigned char reg, unsigned char val);
 
 /* read clock time from DS1306 and return it in *tmp */
 void rtc_get (struct rtc_time *tmp)
@@ -367,13 +360,13 @@ void rtc_set (struct rtc_time *tmp)
               tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
               tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
 
-       rtc_write (RTC_YEAR, bin2bcd (tmp->tm_year - 2000));
-       rtc_write (RTC_MONTH, bin2bcd (tmp->tm_mon));
-       rtc_write (RTC_DATE_OF_MONTH, bin2bcd (tmp->tm_mday));
-       rtc_write (RTC_DAY_OF_WEEK, bin2bcd (tmp->tm_wday + 1));
-       rtc_write (RTC_HOURS, bin2bcd (tmp->tm_hour));
-       rtc_write (RTC_MINUTES, bin2bcd (tmp->tm_min));
        rtc_write (RTC_SECONDS, bin2bcd (tmp->tm_sec));
+       rtc_write (RTC_MINUTES, bin2bcd (tmp->tm_min));
+       rtc_write (RTC_HOURS, bin2bcd (tmp->tm_hour));
+       rtc_write (RTC_DAY_OF_WEEK, bin2bcd (tmp->tm_wday + 1));
+       rtc_write (RTC_DATE_OF_MONTH, bin2bcd (tmp->tm_mday));
+       rtc_write (RTC_MONTH, bin2bcd (tmp->tm_mon));
+       rtc_write (RTC_YEAR, bin2bcd (tmp->tm_year - 2000));
 }
 
 /* ------------------------------------------------------------------------- */