From patchwork Thu Apr 9 23:11:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 459856 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 90C7E140134 for ; Fri, 10 Apr 2015 09:12:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3F9024A03B; Fri, 10 Apr 2015 01:12:13 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y97JeYAbpcYS; Fri, 10 Apr 2015 01:12:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 840034A01F; Fri, 10 Apr 2015 01:12:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 742464A01F for ; Fri, 10 Apr 2015 01:12:07 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 64TL2U4IgYn4 for ; Fri, 10 Apr 2015 01:12:07 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTPS id F42014A01C for ; Fri, 10 Apr 2015 01:12:03 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3lNJC65kwwz3hhdB; Fri, 10 Apr 2015 01:12:02 +0200 (CEST) X-Auth-Info: IuZX7GC6SVaSX63fgUL9zOPSh1Zdx5FPnDs3qKShBus= Received: from chi.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3lNJC63msnzvdWV; Fri, 10 Apr 2015 01:12:02 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Fri, 10 Apr 2015 01:11:54 +0200 Message-Id: <1428621114-6758-1-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.1.4 Cc: Marek Vasut , Tom Rini Subject: [U-Boot] [PATCH] rtc: Set valid date after reset X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Cc: Heiko Schocher Cc: Tom Rini --- common/cmd_date.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/cmd_date.c b/common/cmd_date.c index e349166..4a653e5 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);