summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/mvrtc.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/drivers/rtc/mvrtc.c b/drivers/rtc/mvrtc.c
index f2a226650f..f7bf95c302 100644
--- a/drivers/rtc/mvrtc.c
+++ b/drivers/rtc/mvrtc.c
@@ -17,19 +17,16 @@
/* This RTC does not support century, so we assume 20 */
#define CENTURY 20
-int rtc_get(struct rtc_time *t)
+static int __mv_rtc_get(struct mvrtc_registers *regs, struct rtc_time *t)
{
u32 time;
u32 date;
- struct mvrtc_registers *mvrtc_regs;
-
- mvrtc_regs = (struct mvrtc_registers *)KW_RTC_BASE;
/* read the time register */
- time = readl(&mvrtc_regs->time);
+ time = readl(&regs->time);
/* read the date register */
- date = readl(&mvrtc_regs->date);
+ date = readl(&regs->date);
/* test for 12 hour clock (can't tell if it's am/pm) */
if (time & MVRTC_HRFMT_MSK) {
@@ -57,13 +54,20 @@ int rtc_get(struct rtc_time *t)
return 0;
}
-int rtc_set(struct rtc_time *t)
+#ifndef CONFIG_DM_RTC
+int rtc_get(struct rtc_time *t)
+{
+ struct mvrtc_registers *regs;
+
+ regs = (struct mvrtc_registers *)KW_RTC_BASE;
+ return __mv_rtc_get(regs, t);
+}
+#endif /* !CONFIG_DM_RTC */
+
+static int __mv_rtc_set(struct mvrtc_registers *regs, const struct rtc_time *t)
{
u32 time = 0; /* sets hour format bit to zero, 24hr format. */
u32 date = 0;
- struct mvrtc_registers *mvrtc_regs;
-
- mvrtc_regs = (struct mvrtc_registers *)KW_RTC_BASE;
/* check that this code isn't 80+ years old ;-) */
if ((t->tm_year / 100) != CENTURY)
@@ -81,28 +85,45 @@ int rtc_set(struct rtc_time *t)
date |= (bin2bcd(t->tm_year % 100) & MVRTC_YEAR_MSK) << MVRTC_YEAR_SFT;
/* write the time register */
- writel(time, &mvrtc_regs->time);
+ writel(time, &regs->time);
/* write the date register */
- writel(date, &mvrtc_regs->date);
+ writel(date, &regs->date);
return 0;
}
-void rtc_reset(void)
+#ifndef CONFIG_DM_RTC
+int rtc_set(struct rtc_time *t)
+{
+ struct mvrtc_registers *regs;
+
+ regs = (struct mvrtc_registers *)KW_RTC_BASE;
+ return __mv_rtc_set(regs, t);
+}
+#endif /* !CONFIG_DM_RTC */
+
+static void __mv_rtc_reset(struct mvrtc_registers *regs)
{
u32 time;
u32 sec;
- struct mvrtc_registers *mvrtc_regs;
-
- mvrtc_regs = (struct mvrtc_registers *)KW_RTC_BASE;
/* no init routine for this RTC needed, just check that it's working */
- time = readl(&mvrtc_regs->time);
+ time = readl(&regs->time);
sec = bcd2bin((time >> MVRTC_SEC_SFT) & MVRTC_SEC_MSK);
udelay(1000000);
- time = readl(&mvrtc_regs->time);
+ time = readl(&regs->time);
if (sec == bcd2bin((time >> MVRTC_SEC_SFT) & MVRTC_SEC_MSK))
printf("Error: RTC did not increment.\n");
}
+
+#ifndef CONFIG_DM_RTC
+void rtc_reset(void)
+{
+ struct mvrtc_registers *regs;
+
+ regs = (struct mvrtc_registers *)KW_RTC_BASE;
+ __mv_rtc_reset(regs);
+}
+#endif /* !CONFIG_DM_RTC */