summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-08-07 13:13:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-08-07 13:13:45 +0200
commit9cce00617bf67a462eabd8c473c423f78414a8e8 (patch)
tree950cab0665633f390ad04b9b2b5147f10a4be896 /include
parentba465b6c4dc4b0729e98f1581a13ad7e01032461 (diff)
parent642f8fbed8b4c55d56a0934b803146009539905e (diff)
downloadbarebox-9cce00617bf67a462eabd8c473c423f78414a8e8.tar.gz
barebox-9cce00617bf67a462eabd8c473c423f78414a8e8.tar.xz
Merge branch 'for-next/rtc'
Conflicts: arch/mips/dts/jz4755.dtsi commands/Makefile
Diffstat (limited to 'include')
-rw-r--r--include/linux/bcd.h22
-rw-r--r--include/linux/rtc.h47
-rw-r--r--include/rtc.h2
3 files changed, 71 insertions, 0 deletions
diff --git a/include/linux/bcd.h b/include/linux/bcd.h
new file mode 100644
index 0000000000..18fff11fb3
--- /dev/null
+++ b/include/linux/bcd.h
@@ -0,0 +1,22 @@
+#ifndef _BCD_H
+#define _BCD_H
+
+#include <linux/compiler.h>
+
+#define bcd2bin(x) \
+ (__builtin_constant_p((u8 )(x)) ? \
+ const_bcd2bin(x) : \
+ _bcd2bin(x))
+
+#define bin2bcd(x) \
+ (__builtin_constant_p((u8 )(x)) ? \
+ const_bin2bcd(x) : \
+ _bin2bcd(x))
+
+#define const_bcd2bin(x) (((x) & 0x0f) + ((x) >> 4) * 10)
+#define const_bin2bcd(x) ((((x) / 10) << 4) + (x) % 10)
+
+unsigned _bcd2bin(unsigned char val) __attribute_const__;
+unsigned char _bin2bcd(unsigned val) __attribute_const__;
+
+#endif /* _BCD_H */
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
new file mode 100644
index 0000000000..2dacb14239
--- /dev/null
+++ b/include/linux/rtc.h
@@ -0,0 +1,47 @@
+/*
+ * 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);
+extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
+
+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_ */