From 8e585f02f82c17cc66cd229dbf0fd3066bbbf658 Mon Sep 17 00:00:00 2001 From: TsiChung Liew Date: Mon, 18 Jun 2007 13:50:13 -0500 Subject: Added M5329AFEE and M5329BFEE Platforms Added board/freescale/m5329evb, cpu/mcf532x, drivers/net, drivers/serial, immap_5329.h, m5329.h, mcfrtc.h, include/configs/M5329EVB.h, lib_m68k/interrupts.c, and rtc/mcfrtc.c Modified CREDITS, MAKEFILE, Makefile, README, common/cmd_bdinfo.c, common/cmd_mii.c, include/asm-m68k/byteorder.h, include/asm-m68k/fec.h, include/asm-m68k/io.h, include/asm-m68k/mcftimer.h, include/asm-m68k/mcfuart.h, include/asm-m68k/ptrace.h, include/asm-m68k/u-boot.h, lib_m68k/Makefile, lib_m68k/board.c, lib_m68k/time.c, net/eth.c and rtc/Makefile Signed-off-by: TsiChung Liew --- rtc/mcfrtc.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 rtc/mcfrtc.c (limited to 'rtc/mcfrtc.c') diff --git a/rtc/mcfrtc.c b/rtc/mcfrtc.c new file mode 100644 index 0000000..c7eb53f --- /dev/null +++ b/rtc/mcfrtc.c @@ -0,0 +1,120 @@ +/* + * (C) Copyright 2007 + * Freescale Semiconductor 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 +#include +#include + +#include + +#if defined(CONFIG_MCFRTC) && (CONFIG_COMMANDS & CFG_CMD_DATE) + +#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 && CFG_CMD_DATE */ -- cgit v1.1 From 5cdc07c7ef8f08ea55d3c47ed9221d91aa6d5fac Mon Sep 17 00:00:00 2001 From: TsiChungLiew Date: Thu, 5 Jul 2007 23:31:25 -0500 Subject: Update header files Include immap.h and renamed mcfrtc.h to rtc.h Signed-off-by: TsiChungLiew --- rtc/mcfrtc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'rtc/mcfrtc.c') diff --git a/rtc/mcfrtc.c b/rtc/mcfrtc.c index c7eb53f..0be5874 100644 --- a/rtc/mcfrtc.c +++ b/rtc/mcfrtc.c @@ -1,6 +1,6 @@ /* - * (C) Copyright 2007 - * Freescale Semiconductor Tsi-Chung.Liew@freescale.com + * 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. @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #if defined(CONFIG_MCFRTC) && (CONFIG_COMMANDS & CFG_CMD_DATE) -- cgit v1.1 From ab77bc547ba561c25ea34457ed17aa0b2f7c2723 Mon Sep 17 00:00:00 2001 From: TsiChungLiew Date: Wed, 15 Aug 2007 15:39:17 -0500 Subject: ColdFire: MCF5329 Update and cleanup Signed-off-by: TsiChungLiew --- rtc/mcfrtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rtc/mcfrtc.c') diff --git a/rtc/mcfrtc.c b/rtc/mcfrtc.c index 0be5874..76bb510 100644 --- a/rtc/mcfrtc.c +++ b/rtc/mcfrtc.c @@ -28,7 +28,7 @@ #include #include -#if defined(CONFIG_MCFRTC) && (CONFIG_COMMANDS & CFG_CMD_DATE) +#if defined(CONFIG_MCFRTC) && defined(CONFIG_CMD_DATE) #undef RTC_DEBUG @@ -118,4 +118,4 @@ void rtc_reset(void) rtc->cr |= RTC_CR_SWR; } -#endif /* CONFIG_MCFRTC && CFG_CMD_DATE */ +#endif /* CONFIG_MCFRTC && CONFIG_CMD_DATE */ -- cgit v1.1 From 3e66c078003607a7d1d214c15a5f262bc1b4032f Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Sun, 19 Aug 2007 10:27:34 +0200 Subject: Fix some build errors. Signed-off-by: Wolfgang Denk --- rtc/mcfrtc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rtc/mcfrtc.c') diff --git a/rtc/mcfrtc.c b/rtc/mcfrtc.c index 76bb510..27386e5 100644 --- a/rtc/mcfrtc.c +++ b/rtc/mcfrtc.c @@ -22,14 +22,14 @@ */ #include + +#if defined(CONFIG_MCFRTC) && defined(CONFIG_CMD_DATE) + #include #include - #include #include -#if defined(CONFIG_MCFRTC) && defined(CONFIG_CMD_DATE) - #undef RTC_DEBUG #ifndef CFG_MCFRTC_BASE -- cgit v1.1