~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/drivers/rtc/mpc8xx.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (C) Copyright 2001
 
3
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
4
 *
 
5
 * SPDX-License-Identifier:     GPL-2.0+
 
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
 
 
18
#if defined(CONFIG_CMD_DATE)
 
19
 
 
20
/* ------------------------------------------------------------------------- */
 
21
 
 
22
int rtc_get (struct rtc_time *tmp)
 
23
{
 
24
        volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 
25
        ulong tim;
 
26
 
 
27
        tim = immr->im_sit.sit_rtc;
 
28
 
 
29
        to_tm (tim, tmp);
 
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);
 
34
 
 
35
        return 0;
 
36
}
 
37
 
 
38
int rtc_set (struct rtc_time *tmp)
 
39
{
 
40
        volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 
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
 
 
47
        tim = mktime (tmp->tm_year, tmp->tm_mon, tmp->tm_mday,
 
48
                      tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
 
49
 
 
50
        immr->im_sitk.sitk_rtck = KAPWR_KEY;
 
51
        immr->im_sit.sit_rtc = tim;
 
52
 
 
53
        return 0;
 
54
}
 
55
 
 
56
void rtc_reset (void)
 
57
{
 
58
        return; /* nothing to do */
 
59
}
 
60
 
 
61
#endif