]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Switch from per-driver to common definition of bin2bcd and bcd2bin
authorAlbin Tonnerre <albin.tonnerre@free-electrons.com>
Thu, 13 Aug 2009 13:31:12 +0000 (15:31 +0200)
committerWolfgang Denk <wd@denx.de>
Tue, 25 Aug 2009 10:57:55 +0000 (12:57 +0200)
Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Acked-by: Stefan Roese <sr@denx.de>
24 files changed:
drivers/rtc/ds12887.c
drivers/rtc/ds1306.c
drivers/rtc/ds1307.c
drivers/rtc/ds1337.c
drivers/rtc/ds1556.c
drivers/rtc/ds164x.c
drivers/rtc/ds174x.c
drivers/rtc/ds3231.c
drivers/rtc/isl1208.c
drivers/rtc/m41t11.c
drivers/rtc/m41t60.c
drivers/rtc/m41t62.c
drivers/rtc/m48t35ax.c
drivers/rtc/max6900.c
drivers/rtc/mc146818.c
drivers/rtc/mk48t59.c
drivers/rtc/pcf8563.c
drivers/rtc/rs5c372.c
drivers/rtc/rtc4543.c
drivers/rtc/rx8025.c
drivers/rtc/s3c24x0_rtc.c
drivers/rtc/s3c44b0_rtc.c
drivers/rtc/x1205.c
include/rtc.h

index 25ca1333e23166c00b122e2fb4f17c9c1fcf6e65..486105f5edb9eb6ef535ec1f1912f47159f10636 100644 (file)
@@ -76,18 +76,6 @@ static void rtc_write (uchar reg, uchar val)
 # error Board specific rtc access functions should be supplied
 #endif
 
-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));
-}
-
-/* ------------------------------------------------------------------------- */
-
 int rtc_get (struct rtc_time *tmp)
 {
        uchar sec, min, hour, mday, wday, mon, year;
index 75f88a9a529dd7fe80435381df8bac77afaa22f5..288c5f8c4acbf881730ecf4d5342fec384bcd100 100644 (file)
@@ -62,9 +62,6 @@
 
 #define        RTC_USER_RAM_BASE       0x20
 
-static unsigned int bin2bcd (unsigned int n);
-static unsigned char bcd2bin (unsigned char c);
-
 /* ************************************************************************* */
 #ifdef CONFIG_SXNI855T         /* !!! SHOULD BE CHANGED TO NEW CODE !!! */
 
@@ -459,19 +456,4 @@ static void rtc_write (unsigned char reg, unsigned char val)
 
 #endif /* end of code exclusion (see #ifdef CONFIG_SXNI855T above) */
 
-/* ------------------------------------------------------------------------- */
-
-static unsigned char bcd2bin (unsigned char n)
-{
-       return ((((n >> 4) & 0x0F) * 10) + (n & 0x0F));
-}
-
-/* ------------------------------------------------------------------------- */
-
-static unsigned int bin2bcd (unsigned int n)
-{
-       return (((n / 10) << 4) | (n % 10));
-}
-/* ------------------------------------------------------------------------- */
-
 #endif
index 0650d915abb80c72ef04b2bc5372c975c377bb05..079aa99e8b94bafe173b1d12fac93421eab3086e 100644 (file)
@@ -76,8 +76,6 @@
 
 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);
 
 /*
  * Get the current time from the RTC
@@ -195,15 +193,4 @@ static void rtc_write (uchar reg, uchar val)
 {
        i2c_reg_write (CONFIG_SYS_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));
-}
-
 #endif
index 58e3966ec7b0937a436e862f3d417b2c13036bc2..a71ab5daa3f9cd86e55efe3a6404ada26b792dd2 100644 (file)
@@ -77,9 +77,6 @@
 
 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);
-
 
 /*
  * Get the current time from the RTC
@@ -191,14 +188,4 @@ static void rtc_write (uchar reg, uchar val)
        i2c_reg_write (CONFIG_SYS_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));
-}
-
 #endif
index 763d22a03b1d4a2ab41c770c6a30c768aa5a9f09..25a0b64934b476f1507947daffe12b23cd560909 100644 (file)
@@ -40,8 +40,6 @@
 
 static uchar rtc_read( unsigned int addr );
 static void  rtc_write( unsigned int addr, uchar val);
-static uchar bin2bcd   (unsigned int n);
-static unsigned bcd2bin(uchar c);
 
 #define RTC_BASE               ( CONFIG_SYS_NVRAM_SIZE + CONFIG_SYS_NVRAM_BASE_ADDR )
 
@@ -195,14 +193,4 @@ static void rtc_write( unsigned int addr, uchar val )
        *(volatile unsigned char*)(addr) = 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));
-}
-
 #endif
index 1e96679de24af2e653051e2bf31b520f41e2417a..9f306d196152892a5a976e3d192260421a12461f 100644 (file)
@@ -41,8 +41,6 @@
 
 static uchar    rtc_read(unsigned int addr );
 static void     rtc_write(unsigned int addr, uchar val);
-static uchar    bin2bcd(unsigned int n);
-static unsigned bcd2bin(uchar c);
 
 #define RTC_EPOCH                 2000 /* century */
 
@@ -191,14 +189,4 @@ static void rtc_write( unsigned int addr, uchar val )
        *(volatile unsigned char*)(addr) = 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));
-}
-
 #endif
index 738d1185c2162ed8a5927b608117eb1ba6aa34a5..5a55dc8b7adb112657850d949b8a58a377efb656 100644 (file)
@@ -37,8 +37,6 @@
 
 static uchar rtc_read( unsigned int addr );
 static void  rtc_write( unsigned int addr, uchar val);
-static uchar bin2bcd   (unsigned int n);
-static unsigned bcd2bin(uchar c);
 
 #define RTC_BASE               ( CONFIG_SYS_NVRAM_SIZE + CONFIG_SYS_NVRAM_BASE_ADDR )
 
@@ -192,14 +190,4 @@ static void rtc_write( unsigned int addr, uchar val )
        out8( addr, 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));
-}
-
 #endif
index ef033588a9b5e5a6c9cee3207924c8add1e2fc81..134a0e4fc22b85f25a6182f2db2e5f4332503bf7 100644 (file)
@@ -79,8 +79,6 @@
 
 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);
 
 
 /*
@@ -186,14 +184,4 @@ static void rtc_write (uchar reg, uchar val)
        i2c_reg_write (CONFIG_SYS_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));
-}
-
 #endif
index 71f63d5fa006c311fbea7853e794b1735c6167a6..07591b7dba790afc2fc5f871826c280a599b7e0c 100644 (file)
@@ -66,8 +66,6 @@
 
 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);
 
 /*
  * Get the current time from the RTC
@@ -160,13 +158,3 @@ static void rtc_write (uchar reg, uchar val)
 {
        i2c_reg_write (CONFIG_SYS_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));
-}
index 3a77c1b63879f22057980ebcf9825a2ef8585cce..e0c27e18509825ccc66e2cef5a7cb29d92a0457b 100644 (file)
 
 #if defined(CONFIG_SYS_I2C_RTC_ADDR) && defined(CONFIG_CMD_DATE)
 
-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));
-}
-
-
 /* ------------------------------------------------------------------------- */
 /*
   these are simple defines for the chip local to here so they aren't too
index e34a5f47831c85960b383f8105bcdd1e2ffe0a0f..632fe4b14550173c41b3cb9c59b326ba6fb9709f 100644 (file)
 
 #if defined(CONFIG_SYS_I2C_RTC_ADDR) && defined(CONFIG_CMD_DATE)
 
-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));
-}
-
 /*
  * Convert between century and "century bits" (CB1 and CB0).  These routines
  * assume years are in the range 1900 - 2299.
index 3d7bb46b0e63d02d611e3b618d69dca01bba4599..62c2446939607fcd89440303aa2ee3011ee03662 100644 (file)
@@ -31,7 +31,6 @@
 #include <command.h>
 #include <rtc.h>
 #include <i2c.h>
-#include <bcd.h>
 
 #if defined(CONFIG_CMD_DATE)
 
index 1482edd607fc3381ce4e560e12e2f86fed087075..29b36c171c0dcbb17677f8c52640dfd7067c41b1 100644 (file)
@@ -37,8 +37,6 @@
 
 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);
 
 /* ------------------------------------------------------------------------- */
 
@@ -157,14 +155,4 @@ static void rtc_write (uchar reg, uchar val)
                ((CONFIG_SYS_NVRAM_BASE_ADDR + CONFIG_SYS_NVRAM_SIZE - 8) + 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));
-}
-
 #endif
index 7c99c5e5b1c9568a5511ff67881b60bce7baf5af..74637d1988d3281673837d1f21ba1ec5f363908f 100644 (file)
@@ -51,16 +51,6 @@ static void rtc_write (uchar reg, uchar val)
        udelay(2500);
 }
 
-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));
-}
-
 /* ------------------------------------------------------------------------- */
 
 int rtc_get (struct rtc_time *tmp)
index 38484ce26cf4837274bdee4fca5f44e6085cf630..d68b438efbc584209b61daffa12c69583697abd9 100644 (file)
@@ -35,8 +35,6 @@
 
 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);
 
 #define RTC_PORT_MC146818      CONFIG_SYS_ISA_IO_BASE_ADDRESS +  0x70
 #define RTC_SECONDS            0x00
@@ -168,14 +166,4 @@ static void rtc_write (uchar reg, uchar val)
 }
 #endif
 
-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));
-}
-
 #endif
index dabf3222b8461114908a84a2a562e811ea2976de..b1768821182d4c793e3ea1d59c1c31a7a3026560 100644 (file)
@@ -97,16 +97,6 @@ static void rtc_write (short reg, uchar val)
 # error Board specific rtc access functions should be supplied
 #endif
 
-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));
-}
-
 /* ------------------------------------------------------------------------- */
 
 void *nvram_read(void *dest, const short src, size_t count)
index cd9fb65c3a414e0b58e64846c6fd4eba4053c398..339e5f60801d8301cc93cb24ceccf2fbaf767c5f 100644 (file)
@@ -36,8 +36,6 @@
 
 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);
 
 /* ------------------------------------------------------------------------- */
 
@@ -137,14 +135,4 @@ static void rtc_write (uchar reg, uchar val)
        i2c_reg_write (CONFIG_SYS_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));
-}
-
 #endif
index d6cd7c825df743b4735c8aa44326b175fa1c5188..90bbb4efa3c39c4857d9e95b00b64c2a4dd9b2a1 100644 (file)
@@ -67,9 +67,6 @@ static unsigned int rtc_debug = DEBUG;
 #define HOURS_24(n)    bcd2bin((n) & 0x3F)
 
 
-static uchar bin2bcd (unsigned int n);
-static unsigned bcd2bin (uchar c);
-
 static int setup_done = 0;
 
 static int
@@ -291,15 +288,4 @@ rtc_reset (void)
        return;
 }
 
-static unsigned int
-bcd2bin (unsigned char n)
-{
-       return ((((n >> 4) & 0x0F) * 10) + (n & 0x0F));
-}
-
-static unsigned char
-bin2bcd (unsigned int n)
-{
-       return (((n / 10) << 4) | (n % 10));
-}
 #endif
index b60e37d5be7a9cb10b3d9e1959f2de06fbf9573b..046aa67d9aa2f90974612ef4d9416bbe7eea9ac4 100644 (file)
@@ -25,7 +25,6 @@
 #include <common.h>
 #include <command.h>
 #include <config.h>
-#include <bcd.h>
 #include <rtc.h>
 #include <tws.h>
 
index da87394a085c15b41ddefd628d732da67d39d9e1..64eb1cda105d8ea6730d2ee1fd083b6ddfb059dd 100644 (file)
@@ -90,8 +90,6 @@
 #define rtc_read(reg) buf[((reg) + 1) & 0xf]
 
 static void rtc_write (uchar reg, uchar val);
-static uchar bin2bcd (unsigned int n);
-static unsigned bcd2bin (uchar c);
 
 /*
  * Get the current time from the RTC
@@ -226,14 +224,4 @@ static void rtc_write (uchar reg, uchar 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));
-}
-
 #endif /* CONFIG_RTC_RX8025 && CONFIG_CMD_DATE */
index 0d3372faca21dda427a2da7c3532a39bfff4ac16..e10db9acb86534f84157b7d08fae91d6b56741a0 100644 (file)
@@ -58,16 +58,6 @@ static inline void SetRTC_Access(RTC_ACCESS a)
        }
 }
 
-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));
-}
-
 /* ------------------------------------------------------------------------- */
 
 int rtc_get (struct rtc_time *tmp)
index a027fb1263bd309d9093ee40936bde4a8d0f41ea..d087d8adbd43032896204a4b0485d575c1a7203d 100644 (file)
@@ -32,7 +32,6 @@
 #include <command.h>
 #include <asm/hardware.h>
 #include <rtc.h>
-#include <bcd.h>
 
 int rtc_get (struct rtc_time* tm)
 {
index ceba7c34aca3884de2fbf08f541a0a4615716078..7adf3770d515461fdb59fc3d242365925923f24b 100644 (file)
@@ -38,7 +38,6 @@
 #include <command.h>
 #include <rtc.h>
 #include <i2c.h>
-#include <bcd.h>
 
 #if defined(CONFIG_CMD_DATE)
 
index 785fbe380797cb029e2d905e9730b44da8320dd4..772a54884197d47b55af5dddc0374d94d43dcc39 100644 (file)
 #ifndef _RTC_H_
 #define _RTC_H_
 
+/* bcd<->bin functions are needed by almost all the RTC drivers, let's include
+ * it there instead of in evey single driver */
+
+#include <bcd.h>
+
 /*
  * The struct used to pass data from the generic interface code to
  * the hardware dependend low-level code ande vice versa. Identical