3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 * Generic RTC interface.
14 /* bcd<->bin functions are needed by almost all the RTC drivers, let's include
15 * it there instead of in evey single driver */
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.
24 * Note that there are small but significant differences to the
25 * common "struct time":
27 * struct time: struct rtc_time:
28 * tm_mon 0 ... 11 1 ... 12
29 * tm_year years since 1900 years since 0
44 int rtc_get (struct rtc_time *);
45 int rtc_set (struct rtc_time *);
46 void rtc_reset (void);
48 unsigned long mktime (unsigned int, unsigned int, unsigned int,
49 unsigned int, unsigned int, unsigned int);
52 * rtc_read8() - Read an 8-bit register
54 * @reg: Register to read
57 int rtc_read8(int reg);
60 * rtc_write8() - Write an 8-bit register
62 * @reg: Register to write
63 * @value: Value to write
65 void rtc_write8(int reg, uchar val);
68 * rtc_read32() - Read a 32-bit value from the RTC
70 * @reg: Offset to start reading from
73 u32 rtc_read32(int reg);
76 * rtc_write32() - Write a 32-bit value to the RTC
78 * @reg: Register to start writing to
79 * @value: Value to write
81 void rtc_write32(int reg, u32 value);
84 * rtc_init() - Set up the real time clock ready for use
89 * rtc_calc_weekday() - Work out the weekday from a time
91 * This only works for the Gregorian calendar - i.e. after 1752 (in the UK).
92 * It sets time->tm_wdaay to the correct day of the week.
94 * @time: Time to inspect. tm_wday is updated
95 * @return 0 if OK, -EINVAL if the weekday could not be determined
97 int rtc_calc_weekday(struct rtc_time *time);
100 * rtc_to_tm() - Convert a time_t value into a broken-out time
102 * The following fields are set up by this function:
103 * tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday
105 * Note that tm_yday and tm_isdst are set to 0.
107 * @time_t: Number of seconds since 1970-01-01 00:00:00
108 * @time: Place to put the broken-out time
109 * @return 0 if OK, -EINVAL if the weekday could not be determined
111 int rtc_to_tm(int time_t, struct rtc_time *time);