X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Frtc.h;h=0d964d56d5b1c208c3692f2efc778d7309c85357;hb=81b8e96511610b97eb86de42a76615e73ae78e95;hp=69fe8d4db05316703ad6e48fa36843185e099f45;hpb=850f788709cef8f7d53d571aec3bfb73b14c5531;p=oweals%2Fu-boot.git diff --git a/include/rtc.h b/include/rtc.h index 69fe8d4db0..0d964d56d5 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -1,8 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * (C) Copyright 2001 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -127,6 +126,26 @@ int rtc_read8(struct udevice *dev, unsigned int reg); */ int rtc_write8(struct udevice *dev, unsigned int reg, int val); +/** + * rtc_read16() - Read a 16-bit value from the RTC + * + * @dev: Device to read from + * @reg: Offset to start reading from + * @valuep: Place to put the value that is read + * @return 0 if OK, -ve on error + */ +int rtc_read16(struct udevice *dev, unsigned int reg, u16 *valuep); + +/** + * rtc_write16() - Write a 16-bit value to the RTC + * + * @dev: Device to write to + * @reg: Register to start writing to + * @value: Value to write + * @return 0 if OK, -ve on error + */ +int rtc_write16(struct udevice *dev, unsigned int reg, u16 value); + /** * rtc_read32() - Read a 32-bit value from the RTC * @@ -189,7 +208,18 @@ void rtc_write32(int reg, u32 value); * rtc_init() - Set up the real time clock ready for use */ void rtc_init(void); -#endif +#endif /* CONFIG_DM_RTC */ + +/** + * is_leap_year - Check if year is a leap year + * + * @year Year + * @return 1 if leap year + */ +static inline bool is_leap_year(unsigned int year) +{ + return (!(year % 4) && (year % 100)) || !(year % 400); +} /** * rtc_calc_weekday() - Work out the weekday from a time @@ -212,9 +242,8 @@ int rtc_calc_weekday(struct rtc_time *time); * * @time_t: Number of seconds since 1970-01-01 00:00:00 * @time: Place to put the broken-out time - * @return 0 if OK, -EINVAL if the weekday could not be determined */ -int rtc_to_tm(int time_t, struct rtc_time *time); +void rtc_to_tm(u64 time_t, struct rtc_time *time); /** * rtc_mktime() - Convert a broken-out time into a time_t value