diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 13:13:45 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 13:13:45 +0200 |
commit | 9cce00617bf67a462eabd8c473c423f78414a8e8 (patch) | |
tree | 950cab0665633f390ad04b9b2b5147f10a4be896 /include/linux | |
parent | ba465b6c4dc4b0729e98f1581a13ad7e01032461 (diff) | |
parent | 642f8fbed8b4c55d56a0934b803146009539905e (diff) | |
download | barebox-9cce00617bf67a462eabd8c473c423f78414a8e8.tar.gz barebox-9cce00617bf67a462eabd8c473c423f78414a8e8.tar.xz |
Merge branch 'for-next/rtc'
Conflicts:
arch/mips/dts/jz4755.dtsi
commands/Makefile
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/bcd.h | 22 | ||||
-rw-r--r-- | include/linux/rtc.h | 47 |
2 files changed, 69 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_ */ |