Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-ppc / rtc.h
blob05fbf912ab4dafcf785264a2becb03f373f65c5d
1 /*
2 * inclue/asm-ppc/rtc.h
4 * Author: Tom Rini <trini@mvista.com>
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
11 * Based on:
12 * include/asm-m68k/rtc.h
14 * Copyright Richard Zidlicky
15 * implementation details for genrtc/q40rtc driver
17 * And the old drivers/macintosh/rtc.c which was heavily based on:
18 * Linux/SPARC Real Time Clock Driver
19 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
21 * With additional work by Paul Mackerras and Franz Sirl.
24 #ifndef __ASM_RTC_H__
25 #define __ASM_RTC_H__
27 #ifdef __KERNEL__
29 #include <linux/rtc.h>
31 #include <asm/machdep.h>
32 #include <asm/time.h>
34 #define RTC_PIE 0x40 /* periodic interrupt enable */
35 #define RTC_AIE 0x20 /* alarm interrupt enable */
36 #define RTC_UIE 0x10 /* update-finished interrupt enable */
38 /* some dummy definitions */
39 #define RTC_BATT_BAD 0x100 /* battery bad */
40 #define RTC_SQWE 0x08 /* enable square-wave output */
41 #define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
42 #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
43 #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
45 static inline unsigned int get_rtc_time(struct rtc_time *time)
47 if (ppc_md.get_rtc_time) {
48 unsigned long nowtime;
50 nowtime = (ppc_md.get_rtc_time)();
52 to_tm(nowtime, time);
54 time->tm_year -= 1900;
55 time->tm_mon -= 1; /* Make sure userland has a 0-based month */
57 return RTC_24H;
60 /* Set the current date and time in the real time clock. */
61 static inline int set_rtc_time(struct rtc_time *time)
63 if (ppc_md.get_rtc_time) {
64 unsigned long nowtime;
66 nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
67 time->tm_mday, time->tm_hour, time->tm_min,
68 time->tm_sec);
70 (ppc_md.set_rtc_time)(nowtime);
72 return 0;
73 } else
74 return -EINVAL;
77 static inline unsigned int get_rtc_ss(void)
79 struct rtc_time h;
81 get_rtc_time(&h);
82 return h.tm_sec;
85 static inline int get_rtc_pll(struct rtc_pll_info *pll)
87 return -EINVAL;
89 static inline int set_rtc_pll(struct rtc_pll_info *pll)
91 return -EINVAL;
94 #endif /* __KERNEL__ */
95 #endif /* __ASM_RTC_H__ */