summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2015-04-10 01:11:54 +0200
committerTom Rini <trini@konsulko.com>2015-04-23 14:56:08 -0400
commit1a1fa24066895dd4eca340c2c8fffd5f5df4d296 (patch)
treebf206085c642901c54eb7be8d33b4ccda1cd3816 /common
parent23f2f4329d95c1372a5ec18014a1c8e88c2c0251 (diff)
downloadu-boot-1a1fa24066895dd4eca340c2c8fffd5f5df4d296.tar.gz
u-boot-1a1fa24066895dd4eca340c2c8fffd5f5df4d296.tar.xz
u-boot-1a1fa24066895dd4eca340c2c8fffd5f5df4d296.zip
rtc: Set valid date after reset
Some RTC chips tend to set garbage date after reset. This patch sets the date to 2000-01-01 00:00 immediatelly after the RTC chip reset is issued using the "date reset" command. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Heiko Schocher <hs@denx.de> Cc: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_date.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/cmd_date.c b/common/cmd_date.c
index e3491662bc..4a653e5bcf 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -27,6 +27,8 @@ static const char * const weekdays[] = {
int mk_date (const char *, struct rtc_time *);
+static struct rtc_time default_tm = { 0, 0, 0, 1, 1, 2000, 6, 0, 0 };
+
static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
struct rtc_time tm;
@@ -47,6 +49,9 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (strcmp(argv[1],"reset") == 0) {
puts ("Reset RTC...\n");
rtc_reset ();
+ rcode = rtc_set(&default_tm);
+ if (rcode)
+ puts("## Failed to set date after RTC reset\n");
} else {
/* initialize tm with current time */
rcode = rtc_get (&tm);