blob: a4d08ea122ee3f310cd3f7caaf3205aa6b524fc1 [file] [log] [blame]
Kyle Swenson8d8f6542021-03-15 11:02:55 -06001/* include/asm-m68k/rtc.h
2 *
3 * Copyright Richard Zidlicky
4 * implementation details for genrtc/q40rtc driver
5 */
6/* permission is hereby granted to copy, modify and redistribute this code
7 * in terms of the GNU Library General Public License, Version 2 or later,
8 * at your option.
9 */
10
11#ifndef _ASM_RTC_H
12#define _ASM_RTC_H
13
14#ifdef __KERNEL__
15
16#include <linux/rtc.h>
17#include <asm/errno.h>
18#include <asm/machdep.h>
19
20#define RTC_PIE 0x40 /* periodic interrupt enable */
21#define RTC_AIE 0x20 /* alarm interrupt enable */
22#define RTC_UIE 0x10 /* update-finished interrupt enable */
23
24/* some dummy definitions */
25#define RTC_BATT_BAD 0x100 /* battery bad */
26#define RTC_SQWE 0x08 /* enable square-wave output */
27#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
28#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
29#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
30
31static inline unsigned int get_rtc_time(struct rtc_time *time)
32{
33 /*
34 * Only the values that we read from the RTC are set. We leave
35 * tm_wday, tm_yday and tm_isdst untouched. Even though the
36 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
37 * by the RTC when initially set to a non-zero value.
38 */
39 if (mach_hwclk)
40 mach_hwclk(0, time);
41 return RTC_24H;
42}
43
44static inline int set_rtc_time(struct rtc_time *time)
45{
46 if (mach_hwclk)
47 return mach_hwclk(1, time);
48 return -EINVAL;
49}
50
51static inline unsigned int get_rtc_ss(void)
52{
53 if (mach_get_ss)
54 return mach_get_ss();
55 else{
56 struct rtc_time h;
57
58 get_rtc_time(&h);
59 return h.tm_sec;
60 }
61}
62
63static inline int get_rtc_pll(struct rtc_pll_info *pll)
64{
65 if (mach_get_rtc_pll)
66 return mach_get_rtc_pll(pll);
67 else
68 return -EINVAL;
69}
70static inline int set_rtc_pll(struct rtc_pll_info *pll)
71{
72 if (mach_set_rtc_pll)
73 return mach_set_rtc_pll(pll);
74 else
75 return -EINVAL;
76}
77#endif /* __KERNEL__ */
78
79#endif /* _ASM__RTC_H */