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 int rtc_get (struct rtc_time *);
21 int rtc_set (struct rtc_time *);
22 void rtc_reset (void);
25 * rtc_read8() - Read an 8-bit register
27 * @reg: Register to read
30 int rtc_read8(int reg);
33 * rtc_write8() - Write an 8-bit register
35 * @reg: Register to write
36 * @value: Value to write
38 void rtc_write8(int reg, uchar val);
41 * rtc_read32() - Read a 32-bit value from the RTC
43 * @reg: Offset to start reading from
46 u32 rtc_read32(int reg);
49 * rtc_write32() - Write a 32-bit value to the RTC
51 * @reg: Register to start writing to
52 * @value: Value to write
54 void rtc_write32(int reg, u32 value);
57 * rtc_init() - Set up the real time clock ready for use
62 * rtc_calc_weekday() - Work out the weekday from a time
64 * This only works for the Gregorian calendar - i.e. after 1752 (in the UK).
65 * It sets time->tm_wdaay to the correct day of the week.
67 * @time: Time to inspect. tm_wday is updated
68 * @return 0 if OK, -EINVAL if the weekday could not be determined
70 int rtc_calc_weekday(struct rtc_time *time);
73 * rtc_to_tm() - Convert a time_t value into a broken-out time
75 * The following fields are set up by this function:
76 * tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday
78 * Note that tm_yday and tm_isdst are set to 0.
80 * @time_t: Number of seconds since 1970-01-01 00:00:00
81 * @time: Place to put the broken-out time
82 * @return 0 if OK, -EINVAL if the weekday could not be determined
84 int rtc_to_tm(int time_t, struct rtc_time *time);
87 * rtc_mktime() - Convert a broken-out time into a time_t value
89 * The following fields need to be valid for this function to work:
90 * tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year
92 * Note that tm_wday and tm_yday are ignored.
94 * @time: Broken-out time to convert
95 * @return corresponding time_t value, seconds since 1970-01-01 00:00:00
97 unsigned long rtc_mktime(const struct rtc_time *time);