mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-04 18:40:42 +09:00
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>
This commit is contained in:
parent
23f2f4329d
commit
1a1fa24066
@ -27,6 +27,8 @@ static const char * const weekdays[] = {
|
|||||||
|
|
||||||
int mk_date (const char *, struct rtc_time *);
|
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[])
|
static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
struct rtc_time tm;
|
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) {
|
if (strcmp(argv[1],"reset") == 0) {
|
||||||
puts ("Reset RTC...\n");
|
puts ("Reset RTC...\n");
|
||||||
rtc_reset ();
|
rtc_reset ();
|
||||||
|
rcode = rtc_set(&default_tm);
|
||||||
|
if (rcode)
|
||||||
|
puts("## Failed to set date after RTC reset\n");
|
||||||
} else {
|
} else {
|
||||||
/* initialize tm with current time */
|
/* initialize tm with current time */
|
||||||
rcode = rtc_get (&tm);
|
rcode = rtc_get (&tm);
|
||||||
|
Loading…
Reference in New Issue
Block a user