diff options
Diffstat (limited to 'rtc')
-rw-r--r-- | rtc/Makefile | 3 | ||||
-rw-r--r-- | rtc/bf5xx_rtc.c | 4 | ||||
-rw-r--r-- | rtc/date.c | 4 | ||||
-rw-r--r-- | rtc/ds12887.c | 4 | ||||
-rw-r--r-- | rtc/ds1302.c | 2 | ||||
-rw-r--r-- | rtc/ds1306.c | 2 | ||||
-rw-r--r-- | rtc/ds1307.c | 4 | ||||
-rw-r--r-- | rtc/ds1337.c | 4 | ||||
-rw-r--r-- | rtc/ds1374.c | 4 | ||||
-rw-r--r-- | rtc/ds1556.c | 4 | ||||
-rw-r--r-- | rtc/ds164x.c | 4 | ||||
-rw-r--r-- | rtc/ds174x.c | 4 | ||||
-rw-r--r-- | rtc/ds3231.c | 4 | ||||
-rw-r--r-- | rtc/m41t11.c | 4 | ||||
-rw-r--r-- | rtc/m48t35ax.c | 4 | ||||
-rw-r--r-- | rtc/max6900.c | 4 | ||||
-rw-r--r-- | rtc/mc146818.c | 4 | ||||
-rw-r--r-- | rtc/mcfrtc.c | 121 | ||||
-rw-r--r-- | rtc/mk48t59.c | 4 | ||||
-rw-r--r-- | rtc/mpc5xxx.c | 4 | ||||
-rw-r--r-- | rtc/mpc8xx.c | 6 | ||||
-rw-r--r-- | rtc/pcf8563.c | 4 | ||||
-rw-r--r-- | rtc/rs5c372.c | 4 | ||||
-rw-r--r-- | rtc/s3c24x0_rtc.c | 6 |
24 files changed, 165 insertions, 47 deletions
diff --git a/rtc/Makefile b/rtc/Makefile index 96c68c0..2e6f3bd 100644 --- a/rtc/Makefile +++ b/rtc/Makefile @@ -31,7 +31,8 @@ COBJS = date.o \ bf5xx_rtc.o ds12887.o ds1302.o ds1306.o ds1307.o \ ds1337.o ds1374.o ds1556.o ds164x.o ds174x.o ds3231.o \ m41t11.o max6900.o m48t35ax.o mc146818.o mk48t59.o \ - mpc5xxx.o mpc8xx.o pcf8563.o s3c24x0_rtc.o rs5c372.o + mpc5xxx.o mpc8xx.o pcf8563.o s3c24x0_rtc.o rs5c372.o \ + mcfrtc.o SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/rtc/bf5xx_rtc.c b/rtc/bf5xx_rtc.c index 85bbb56..8856bb9 100644 --- a/rtc/bf5xx_rtc.c +++ b/rtc/bf5xx_rtc.c @@ -49,7 +49,7 @@ #include <command.h> #include <rtc.h> -#if defined(CONFIG_RTC_BFIN) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_BFIN) && defined(CONFIG_CMD_DATE) #include <asm/blackfin.h> #include <asm/arch/bf5xx_rtc.h> @@ -140,4 +140,4 @@ void rtc_get(struct rtc_time *tmp) MIN_TO_SECS(tm_min) + HRS_TO_SECS(tm_hour) + DAYS_TO_SECS(tm_day); to_tm(time_in_sec, tmp); } -#endif /* CONFIG_RTC_BFIN && CFG_CMD_DATE */ +#endif @@ -29,7 +29,7 @@ #include <command.h> #include <rtc.h> -#if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP) +#if defined(CONFIG_CMD_DATE) || defined(CONFIG_TIMESTAMP) #define FEBRUARY 2 #define STARTOFTIME 1970 @@ -153,4 +153,4 @@ mktime (unsigned int year, unsigned int mon, )*60 + sec; /* finally seconds */ } -#endif /* CFG_CMD_DATE */ +#endif diff --git a/rtc/ds12887.c b/rtc/ds12887.c index 8b12893..84fecf0 100644 --- a/rtc/ds12887.c +++ b/rtc/ds12887.c @@ -28,7 +28,7 @@ #include <config.h> #include <rtc.h> -#if defined(CONFIG_RTC_DS12887) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS12887) && defined(CONFIG_CMD_DATE) #define RTC_SECONDS 0x00 #define RTC_SECONDS_ALARM 0x01 @@ -235,4 +235,4 @@ void rtc_reset (void) rtc_write(RTC_CONTROL_B,ctrl_rg); } -#endif /* (CONFIG_RTC_DS12887) && (CONFIG_COMMANDS & CFG_CMD_DATE) */ +#endif diff --git a/rtc/ds1302.c b/rtc/ds1302.c index 98dce89..55af130 100644 --- a/rtc/ds1302.c +++ b/rtc/ds1302.c @@ -9,7 +9,7 @@ #include <command.h> #include <rtc.h> -#if defined(CONFIG_RTC_DS1302) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS1302) && defined(CONFIG_CMD_DATE) /* GPP Pins */ #define DATA 0x200 diff --git a/rtc/ds1306.c b/rtc/ds1306.c index e01e1ce..89e433d 100644 --- a/rtc/ds1306.c +++ b/rtc/ds1306.c @@ -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 diff --git a/rtc/ds1307.c b/rtc/ds1307.c index 3b26a0a..c882d79 100644 --- a/rtc/ds1307.c +++ b/rtc/ds1307.c @@ -36,7 +36,7 @@ #include <i2c.h> #if (defined(CONFIG_RTC_DS1307) || defined(CONFIG_RTC_DS1338) ) && \ - (CONFIG_COMMANDS & CFG_CMD_DATE) + defined(CONFIG_CMD_DATE) /*---------------------------------------------------------------------*/ #undef DEBUG_RTC @@ -201,4 +201,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* (CONFIG_RTC_DS1307 || CONFIG_RTC_DS1338) && (CFG_COMMANDS & CFG_CMD_DATE) */ +#endif diff --git a/rtc/ds1337.c b/rtc/ds1337.c index 9f0c8c0..c636ac5 100644 --- a/rtc/ds1337.c +++ b/rtc/ds1337.c @@ -32,7 +32,7 @@ #include <rtc.h> #include <i2c.h> -#if defined(CONFIG_RTC_DS1337) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS1337) && defined(CONFIG_CMD_DATE) /*---------------------------------------------------------------------*/ #undef DEBUG_RTC @@ -188,4 +188,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_DS1337 && (CFG_COMMANDS & CFG_CMD_DATE) */ +#endif diff --git a/rtc/ds1374.c b/rtc/ds1374.c index 50a996c..e773dd9 100644 --- a/rtc/ds1374.c +++ b/rtc/ds1374.c @@ -35,7 +35,7 @@ #include <rtc.h> #include <i2c.h> -#if (defined(CONFIG_RTC_DS1374)) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if (defined(CONFIG_RTC_DS1374)) && defined(CONFIG_CMD_DATE) /*---------------------------------------------------------------------*/ #undef DEBUG_RTC @@ -250,4 +250,4 @@ static void rtc_write_raw (uchar reg, uchar val) { i2c_reg_write (CFG_I2C_RTC_ADDR, reg, val); } -#endif /* (CONFIG_RTC_DS1374) && (CFG_COMMANDS & CFG_CMD_DATE) */ +#endif diff --git a/rtc/ds1556.c b/rtc/ds1556.c index dd9ea5e..4365cfb 100644 --- a/rtc/ds1556.c +++ b/rtc/ds1556.c @@ -37,7 +37,7 @@ #include <rtc.h> -#if defined(CONFIG_RTC_DS1556) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS1556) && defined(CONFIG_CMD_DATE) static uchar rtc_read( unsigned int addr ); static void rtc_write( unsigned int addr, uchar val); @@ -203,4 +203,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_DS1556 && CFG_CMD_DATE */ +#endif diff --git a/rtc/ds164x.c b/rtc/ds164x.c index 3cc76ab..bff22b9 100644 --- a/rtc/ds164x.c +++ b/rtc/ds164x.c @@ -37,7 +37,7 @@ #include <rtc.h> -#if defined(CONFIG_RTC_DS164x) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS164x) && defined(CONFIG_CMD_DATE) static uchar rtc_read(unsigned int addr ); static void rtc_write(unsigned int addr, uchar val); @@ -197,4 +197,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_DS164x && CFG_CMD_DATE */ +#endif diff --git a/rtc/ds174x.c b/rtc/ds174x.c index 58b13e9..5f85a68 100644 --- a/rtc/ds174x.c +++ b/rtc/ds174x.c @@ -33,7 +33,7 @@ #include <command.h> #include <rtc.h> -#if defined(CONFIG_RTC_DS174x) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS174x) && defined(CONFIG_CMD_DATE) static uchar rtc_read( unsigned int addr ); static void rtc_write( unsigned int addr, uchar val); @@ -199,4 +199,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_MC146818 && CFG_CMD_DATE */ +#endif diff --git a/rtc/ds3231.c b/rtc/ds3231.c index 50aeeb5..fe11b86 100644 --- a/rtc/ds3231.c +++ b/rtc/ds3231.c @@ -33,7 +33,7 @@ #include <rtc.h> #include <i2c.h> -#if defined(CONFIG_RTC_DS3231) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_DS3231) && defined(CONFIG_CMD_DATE) /*---------------------------------------------------------------------*/ #undef DEBUG_RTC @@ -190,4 +190,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* (CONFIG_RTC_DS3231) && (CONFIG_COMMANDS & CFG_CMD_DATE) */ +#endif diff --git a/rtc/m41t11.c b/rtc/m41t11.c index c725cc9..81da33a 100644 --- a/rtc/m41t11.c +++ b/rtc/m41t11.c @@ -43,7 +43,7 @@ #endif */ -#if defined(CONFIG_RTC_M41T11) && defined(CFG_I2C_RTC_ADDR) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_M41T11) && defined(CFG_I2C_RTC_ADDR) && defined(CONFIG_CMD_DATE) static unsigned bcd2bin (uchar n) { @@ -199,4 +199,4 @@ int rtc_recall(int addr, unsigned char* data, int size) return i2c_read( CFG_I2C_RTC_ADDR, REG_CNT+addr, 1, data, size ); } -#endif /* CONFIG_RTC_M41T11 && CFG_I2C_RTC_ADDR && CFG_CMD_DATE */ +#endif diff --git a/rtc/m48t35ax.c b/rtc/m48t35ax.c index 6c38a53..0a0ffa8 100644 --- a/rtc/m48t35ax.c +++ b/rtc/m48t35ax.c @@ -33,7 +33,7 @@ #include <rtc.h> #include <config.h> -#if defined(CONFIG_RTC_M48T35A) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_M48T35A) && defined(CONFIG_CMD_DATE) static uchar rtc_read (uchar reg); static void rtc_write (uchar reg, uchar val); @@ -163,4 +163,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_M48T35A && CFG_CMD_DATE */ +#endif diff --git a/rtc/max6900.c b/rtc/max6900.c index 73919cd..c75a8e0 100644 --- a/rtc/max6900.c +++ b/rtc/max6900.c @@ -32,7 +32,7 @@ #include <rtc.h> #include <i2c.h> -#if defined(CONFIG_RTC_MAX6900) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_MAX6900) && defined(CONFIG_CMD_DATE) #ifndef CFG_I2C_RTC_ADDR #define CFG_I2C_RTC_ADDR 0x50 @@ -128,4 +128,4 @@ void rtc_reset (void) { } -#endif /* CONFIG_RTC_MAX6900 && CFG_CMD_DATE */ +#endif diff --git a/rtc/mc146818.c b/rtc/mc146818.c index 20b1b3e..ab377ed 100644 --- a/rtc/mc146818.c +++ b/rtc/mc146818.c @@ -31,7 +31,7 @@ #include <command.h> #include <rtc.h> -#if defined(CONFIG_RTC_MC146818) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_MC146818) && defined(CONFIG_CMD_DATE) static uchar rtc_read (uchar reg); static void rtc_write (uchar reg, uchar val); @@ -175,4 +175,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_MC146818 && CFG_CMD_DATE */ +#endif diff --git a/rtc/mcfrtc.c b/rtc/mcfrtc.c new file mode 100644 index 0000000..27386e5 --- /dev/null +++ b/rtc/mcfrtc.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. + * TsiChung Liew (Tsi-Chung.Liew@freescale.com) + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> + +#if defined(CONFIG_MCFRTC) && defined(CONFIG_CMD_DATE) + +#include <command.h> +#include <rtc.h> +#include <asm/immap.h> +#include <asm/rtc.h> + +#undef RTC_DEBUG + +#ifndef CFG_MCFRTC_BASE +#error RTC_BASE is not defined! +#endif + +#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) +#define STARTOFTIME 1970 + +void rtc_get(struct rtc_time *tmp) +{ + volatile rtc_t *rtc = (rtc_t *) (CFG_MCFRTC_BASE); + + int rtc_days, rtc_hrs, rtc_mins; + int tim; + + rtc_days = rtc->days; + rtc_hrs = rtc->hourmin >> 8; + rtc_mins = RTC_HOURMIN_MINUTES(rtc->hourmin); + + tim = (rtc_days * 24) + rtc_hrs; + tim = (tim * 60) + rtc_mins; + tim = (tim * 60) + rtc->seconds; + + to_tm(tim, tmp); + + tmp->tm_yday = 0; + tmp->tm_isdst = 0; + +#ifdef RTC_DEBUG + printf("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_hour, tmp->tm_min, tmp->tm_sec); +#endif +} + +void rtc_set(struct rtc_time *tmp) +{ + volatile rtc_t *rtc = (rtc_t *) (CFG_MCFRTC_BASE); + + static int month_days[12] = { + 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + int days, i, months; + + if (tmp->tm_year > 2037) { + printf("Unable to handle. Exceeding integer limitation!\n"); + tmp->tm_year = 2027; + } +#ifdef RTC_DEBUG + printf("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_hour, tmp->tm_min, tmp->tm_sec); +#endif + + /* calculate days by years */ + for (i = STARTOFTIME, days = 0; i < tmp->tm_year; i++) { + days += 365 + isleap(i); + } + + /* calculate days by months */ + months = tmp->tm_mon - 1; + for (i = 0; i < months; i++) { + days += month_days[i]; + + if (i == 1) + days += isleap(i); + } + + days += tmp->tm_mday - 1; + + rtc->days = days; + rtc->hourmin = (tmp->tm_hour << 8) | tmp->tm_min; + rtc->seconds = tmp->tm_sec; +} + +void rtc_reset(void) +{ + volatile rtc_t *rtc = (rtc_t *) (CFG_MCFRTC_BASE); + + if ((rtc->cr & RTC_CR_EN) == 0) { + printf("real-time-clock was stopped. Now starting...\n"); + rtc->cr |= RTC_CR_EN; + } + + rtc->cr |= RTC_CR_SWR; +} + +#endif /* CONFIG_MCFRTC && CONFIG_CMD_DATE */ diff --git a/rtc/mk48t59.c b/rtc/mk48t59.c index 64f751f..bacdb5b 100644 --- a/rtc/mk48t59.c +++ b/rtc/mk48t59.c @@ -131,7 +131,7 @@ void nvram_write(short dest, const void *src, size_t count) rtc_write(d++, *s++); } -#if (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_CMD_DATE) /* ------------------------------------------------------------------------- */ @@ -233,5 +233,5 @@ void rtc_set_watchdog(short multi, short res) rtc_write(RTC_WATCHDOG, wd_value); } -#endif /* (CONFIG_COMMANDS & CFG_CMD_DATE) */ +#endif #endif /* CONFIG_RTC_MK48T59 */ diff --git a/rtc/mpc5xxx.c b/rtc/mpc5xxx.c index 2053df1..216386a 100644 --- a/rtc/mpc5xxx.c +++ b/rtc/mpc5xxx.c @@ -32,7 +32,7 @@ #include <command.h> #include <rtc.h> -#if defined(CONFIG_RTC_MPC5200) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_MPC5200) && defined(CONFIG_CMD_DATE) /***************************************************************************** * this structure should be defined in mpc5200.h ... @@ -137,4 +137,4 @@ void rtc_reset (void) return; /* nothing to do */ } -#endif /* CONFIG_RTC_MPC5200 && CFG_CMD_DATE */ +#endif diff --git a/rtc/mpc8xx.c b/rtc/mpc8xx.c index 830e56e..8d10c0e 100644 --- a/rtc/mpc8xx.c +++ b/rtc/mpc8xx.c @@ -31,7 +31,7 @@ #include <command.h> #include <rtc.h> -#if defined(CONFIG_RTC_MPC8xx) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_MPC8xx) && defined(CONFIG_CMD_DATE) /* ------------------------------------------------------------------------- */ @@ -70,6 +70,4 @@ void rtc_reset (void) return; /* nothing to do */ } -/* ------------------------------------------------------------------------- */ - -#endif /* CONFIG_RTC_MPC8xx && CFG_CMD_DATE */ +#endif diff --git a/rtc/pcf8563.c b/rtc/pcf8563.c index 05ae97e..2d73d5d 100644 --- a/rtc/pcf8563.c +++ b/rtc/pcf8563.c @@ -32,7 +32,7 @@ #include <rtc.h> #include <i2c.h> -#if defined(CONFIG_RTC_PCF8563) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_PCF8563) && defined(CONFIG_CMD_DATE) static uchar rtc_read (uchar reg); static void rtc_write (uchar reg, uchar val); @@ -141,4 +141,4 @@ static unsigned char bin2bcd (unsigned int n) return (((n / 10) << 4) | (n % 10)); } -#endif /* CONFIG_RTC_PCF8563 && CFG_CMD_DATE */ +#endif diff --git a/rtc/rs5c372.c b/rtc/rs5c372.c index b56808b..3d1346e 100644 --- a/rtc/rs5c372.c +++ b/rtc/rs5c372.c @@ -34,7 +34,7 @@ #include <rtc.h> #include <i2c.h> -#if defined(CONFIG_RTC_RS5C372A) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_RS5C372A) && defined(CONFIG_CMD_DATE) /* * Reads are always done starting with register 15, which requires some * jumping-through-hoops to access the data correctly. @@ -299,4 +299,4 @@ bin2bcd (unsigned int n) { return (((n / 10) << 4) | (n % 10)); } -#endif /* defined(CONFIG_RTC_RS5C372A) && (CONFIG_COMMANDS & CFG_CMD_DATE) */ +#endif diff --git a/rtc/s3c24x0_rtc.c b/rtc/s3c24x0_rtc.c index 9e2191e..7f8b4fa 100644 --- a/rtc/s3c24x0_rtc.c +++ b/rtc/s3c24x0_rtc.c @@ -28,7 +28,7 @@ #include <common.h> #include <command.h> -#if defined(CONFIG_RTC_S3C24X0) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_RTC_S3C24X0) && (defined(CONFIG_CMD_DATE)) #if defined(CONFIG_S3C2400) #include <s3c2400.h> @@ -175,6 +175,4 @@ void rtc_reset (void) rtc->RTCCON &= ~(0x08|0x01); } -/* ------------------------------------------------------------------------- */ - -#endif /* CONFIG_RTC_S3C24X0 && CFG_CMD_DATE */ +#endif |