wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Date & Time support for internal RTC of MPC8xx |
| 10 | */ |
| 11 | |
| 12 | /*#define DEBUG*/ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <command.h> |
| 16 | #include <rtc.h> |
| 17 | |
Michal Simek | c3e6c55 | 2008-07-14 19:45:37 +0200 | [diff] [blame] | 18 | #if defined(CONFIG_CMD_DATE) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 19 | |
| 20 | /* ------------------------------------------------------------------------- */ |
| 21 | |
Yuri Tikhonov | 9bacd94 | 2008-03-20 17:56:04 +0300 | [diff] [blame] | 22 | int rtc_get (struct rtc_time *tmp) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 23 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 24 | volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 25 | ulong tim; |
| 26 | |
| 27 | tim = immr->im_sit.sit_rtc; |
| 28 | |
Simon Glass | 1299466 | 2015-04-20 12:37:18 -0600 | [diff] [blame] | 29 | rtc_to_tm(tim, tmp); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 30 | |
| 31 | debug ( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", |
| 32 | tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, |
| 33 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
Yuri Tikhonov | 9bacd94 | 2008-03-20 17:56:04 +0300 | [diff] [blame] | 34 | |
| 35 | return 0; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Jean-Christophe PLAGNIOL-VILLARD | 97a2e10 | 2008-09-01 23:06:23 +0200 | [diff] [blame] | 38 | int rtc_set (struct rtc_time *tmp) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 39 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 41 | ulong tim; |
| 42 | |
| 43 | debug ( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", |
| 44 | tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, |
| 45 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 46 | |
Simon Glass | 4283e84 | 2015-04-20 12:37:19 -0600 | [diff] [blame] | 47 | tim = rtc_mktime(tmp); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 48 | |
| 49 | immr->im_sitk.sitk_rtck = KAPWR_KEY; |
| 50 | immr->im_sit.sit_rtc = tim; |
Jean-Christophe PLAGNIOL-VILLARD | 97a2e10 | 2008-09-01 23:06:23 +0200 | [diff] [blame] | 51 | |
| 52 | return 0; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void rtc_reset (void) |
| 56 | { |
| 57 | return; /* nothing to do */ |
| 58 | } |
| 59 | |
Jon Loeliger | 07efe2a | 2007-07-10 10:27:39 -0500 | [diff] [blame] | 60 | #endif |