]>
Commit | Line | Data |
---|---|---|
a6840a6e WD |
1 | /* |
2 | * (C) Copyright 2001 | |
3 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
a6840a6e WD |
6 | */ |
7 | ||
8 | /* | |
9 | * Generic RTC interface. | |
10 | */ | |
11 | #ifndef _RTC_H_ | |
12 | #define _RTC_H_ | |
13 | ||
885fc78c AT |
14 | /* bcd<->bin functions are needed by almost all the RTC drivers, let's include |
15 | * it there instead of in evey single driver */ | |
16 | ||
17 | #include <bcd.h> | |
18 | ||
a6840a6e WD |
19 | /* |
20 | * The struct used to pass data from the generic interface code to | |
21 | * the hardware dependend low-level code ande vice versa. Identical | |
22 | * to struct rtc_time used by the Linux kernel. | |
23 | * | |
24 | * Note that there are small but significant differences to the | |
25 | * common "struct time": | |
26 | * | |
53677ef1 | 27 | * struct time: struct rtc_time: |
a6840a6e WD |
28 | * tm_mon 0 ... 11 1 ... 12 |
29 | * tm_year years since 1900 years since 0 | |
30 | */ | |
31 | ||
32 | struct rtc_time { | |
33 | int tm_sec; | |
34 | int tm_min; | |
35 | int tm_hour; | |
36 | int tm_mday; | |
37 | int tm_mon; | |
38 | int tm_year; | |
39 | int tm_wday; | |
40 | int tm_yday; | |
41 | int tm_isdst; | |
42 | }; | |
43 | ||
b73a19e1 | 44 | int rtc_get (struct rtc_time *); |
d1e23194 | 45 | int rtc_set (struct rtc_time *); |
a6840a6e WD |
46 | void rtc_reset (void); |
47 | ||
48 | void GregorianDay (struct rtc_time *); | |
49 | void to_tm (int, struct rtc_time *); | |
50 | unsigned long mktime (unsigned int, unsigned int, unsigned int, | |
51 | unsigned int, unsigned int, unsigned int); | |
52 | ||
fc4860c0 SG |
53 | /** |
54 | * rtc_read8() - Read an 8-bit register | |
55 | * | |
56 | * @reg: Register to read | |
57 | * @return value read | |
58 | */ | |
59 | int rtc_read8(int reg); | |
60 | ||
61 | /** | |
62 | * rtc_write8() - Write an 8-bit register | |
63 | * | |
64 | * @reg: Register to write | |
65 | * @value: Value to write | |
66 | */ | |
67 | void rtc_write8(int reg, uchar val); | |
68 | ||
69 | /** | |
70 | * rtc_read32() - Read a 32-bit value from the RTC | |
71 | * | |
72 | * @reg: Offset to start reading from | |
73 | * @return value read | |
74 | */ | |
75 | u32 rtc_read32(int reg); | |
76 | ||
77 | /** | |
78 | * rtc_write32() - Write a 32-bit value to the RTC | |
79 | * | |
80 | * @reg: Register to start writing to | |
81 | * @value: Value to write | |
82 | */ | |
83 | void rtc_write32(int reg, u32 value); | |
84 | ||
c6577f72 SG |
85 | /** |
86 | * rtc_init() - Set up the real time clock ready for use | |
87 | */ | |
88 | void rtc_init(void); | |
89 | ||
a6840a6e | 90 | #endif /* _RTC_H_ */ |