projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pinctrl: Add help text to Kconfig
[oweals/u-boot.git]
/
drivers
/
rtc
/
bfin_rtc.c
diff --git
a/drivers/rtc/bfin_rtc.c
b/drivers/rtc/bfin_rtc.c
index 5755a20bc52e853db8771123a8601fdb8cc5afbc..a079a1d472365c95e72e5d00f2d216d0aeb6c9f1 100644
(file)
--- a/
drivers/rtc/bfin_rtc.c
+++ b/
drivers/rtc/bfin_rtc.c
@@
-11,7
+11,7
@@
#include <command.h>
#include <rtc.h>
#include <command.h>
#include <rtc.h>
-#if defined(CONFIG_
RTC_BFIN) && defined(CONFIG_
CMD_DATE)
+#if defined(CONFIG_CMD_DATE)
#include <asm/blackfin.h>
#include <asm/mach-common/bits/rtc.h>
#include <asm/blackfin.h>
#include <asm/mach-common/bits/rtc.h>
@@
-26,10
+26,17
@@
#define NUM_SECS_IN_HR HRS_TO_SECS(1)
#define NUM_SECS_IN_DAY DAYS_TO_SECS(1)
#define NUM_SECS_IN_HR HRS_TO_SECS(1)
#define NUM_SECS_IN_DAY DAYS_TO_SECS(1)
+/* Enable the RTC prescaler enable register */
+void rtc_init(void)
+{
+ if (!(bfin_read_RTC_PREN() & 0x1))
+ bfin_write_RTC_PREN(0x1);
+}
+
/* Our on-chip RTC has no notion of "reset" */
void rtc_reset(void)
{
/* Our on-chip RTC has no notion of "reset" */
void rtc_reset(void)
{
- r
eturn
;
+ r
tc_init()
;
}
/* Wait for pending writes to complete */
}
/* Wait for pending writes to complete */
@@
-42,18
+49,10
@@
static void wait_for_complete(void)
bfin_write_RTC_ISTAT(WRITE_COMPLETE);
}
bfin_write_RTC_ISTAT(WRITE_COMPLETE);
}
-/* Enable the RTC prescaler enable register */
-int rtc_init(void)
-{
- pr_stamp();
- bfin_write_RTC_PREN(0x1);
- return 0;
-}
-
/* Set the time. Get the time_in_secs which is the number of seconds since Jan 1970 and set the RTC registers
* based on this value.
*/
/* Set the time. Get the time_in_secs which is the number of seconds since Jan 1970 and set the RTC registers
* based on this value.
*/
-
void
rtc_set(struct rtc_time *tmp)
+
int
rtc_set(struct rtc_time *tmp)
{
unsigned long remain, days, hrs, mins, secs;
{
unsigned long remain, days, hrs, mins, secs;
@@
-61,14
+60,14
@@
void rtc_set(struct rtc_time *tmp)
if (tmp == NULL) {
puts("Error setting the date/time\n");
if (tmp == NULL) {
puts("Error setting the date/time\n");
- return;
+ return
-1
;
}
}
+ rtc_init();
wait_for_complete();
/* Calculate number of seconds this incoming time represents */
wait_for_complete();
/* Calculate number of seconds this incoming time represents */
- remain = mktime(tmp->tm_year, tmp->tm_mon, tmp->tm_mday,
- tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+ remain = rtc_mktime(tmp);
/* Figure out how many days since epoch */
days = remain / NUM_SECS_IN_DAY;
/* Figure out how many days since epoch */
days = remain / NUM_SECS_IN_DAY;
@@
-82,10
+81,12
@@
void rtc_set(struct rtc_time *tmp)
/* Encode these time values into our RTC_STAT register */
bfin_write_RTC_STAT(SET_ALARM(days, hrs, mins, secs));
/* Encode these time values into our RTC_STAT register */
bfin_write_RTC_STAT(SET_ALARM(days, hrs, mins, secs));
+
+ return 0;
}
/* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */
}
/* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */
-
void
rtc_get(struct rtc_time *tmp)
+
int
rtc_get(struct rtc_time *tmp)
{
uint32_t cur_rtc_stat;
int time_in_sec;
{
uint32_t cur_rtc_stat;
int time_in_sec;
@@
-95,9
+96,10
@@
void rtc_get(struct rtc_time *tmp)
if (tmp == NULL) {
puts("Error getting the date/time\n");
if (tmp == NULL) {
puts("Error getting the date/time\n");
- return;
+ return
-1
;
}
}
+ rtc_init();
wait_for_complete();
/* Read the RTC_STAT register */
wait_for_complete();
/* Read the RTC_STAT register */
@@
-111,7
+113,9
@@
void rtc_get(struct rtc_time *tmp)
/* Calculate the total number of seconds since epoch */
time_in_sec = (tm_sec) + MIN_TO_SECS(tm_min) + HRS_TO_SECS(tm_hr) + DAYS_TO_SECS(tm_day);
/* Calculate the total number of seconds since epoch */
time_in_sec = (tm_sec) + MIN_TO_SECS(tm_min) + HRS_TO_SECS(tm_hr) + DAYS_TO_SECS(tm_day);
- to_tm(time_in_sec, tmp);
+ rtc_to_tm(time_in_sec, tmp);
+
+ return 0;
}
#endif
}
#endif