diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2014-07-30 00:10:18 +0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-31 07:30:51 +0200 |
commit | ed98f1522d2157a0266095b00ab1481da6085337 (patch) | |
tree | c84e29e556e102fe2548688123da19cba8a23c38 /include | |
parent | 6d3fc76b7720c6eeb5f38cce32290cbbe28ae146 (diff) | |
download | barebox-ed98f1522d2157a0266095b00ab1481da6085337.tar.gz barebox-ed98f1522d2157a0266095b00ab1481da6085337.tar.xz |
Add a simple rtc framework
This patch adds a simple rtc framework
for reading and setting board's RTC time.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/rtc.h | 46 | ||||
-rw-r--r-- | include/rtc.h | 2 |
2 files changed, 48 insertions, 0 deletions
diff --git a/include/linux/rtc.h b/include/linux/rtc.h new file mode 100644 index 0000000000..2e034f6da0 --- /dev/null +++ b/include/linux/rtc.h @@ -0,0 +1,46 @@ +/* + * Generic RTC interface. + * This version contains the part of the user interface to the Real Time Clock + * service. It is used with both the legacy mc146818 and also EFI + * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out + * from <linux/mc146818rtc.h> to this file for 2.4 kernels. + * + * Copyright (C) 1999 Hewlett-Packard Co. + * Copyright (C) 1999 Stephane Eranian <eranian@hpl.hp.com> + */ +#ifndef _LINUX_RTC_H_ +#define _LINUX_RTC_H_ + +#include <common.h> +#include <linux/types.h> + +extern int rtc_month_days(unsigned int month, unsigned int year); +extern int rtc_valid_tm(struct rtc_time *tm); +extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); + +struct rtc_class_ops; + +struct rtc_device { + struct device_d *dev; + struct device_d class_dev; + struct list_head list; + + const struct rtc_class_ops *ops; +}; + +struct rtc_class_ops { + int (*read_time)(struct rtc_device *, struct rtc_time *); + int (*set_time)(struct rtc_device *, struct rtc_time *); +}; + +extern int rtc_register(struct rtc_device *rtcdev); + +extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); +extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); + +static inline bool is_leap_year(unsigned int year) +{ + return (!(year % 4) && (year % 100)) || !(year % 400); +} + +#endif /* _LINUX_RTC_H_ */ diff --git a/include/rtc.h b/include/rtc.h index c2d8bcefed..e2414fb7b1 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -53,4 +53,6 @@ void to_tm (int, struct rtc_time *); unsigned long mktime (unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); +extern struct rtc_device *rtc_lookup(const char *name); + #endif /* _RTC_H_ */ |