2 * include/asm-parisc/rtc.h
4 * Copyright 2002 Randolph CHung <tausq@debian.org>
6 * Based on: include/asm-ppc/rtc.h and the genrtc driver in the
7 * 2.4 parisc linux tree
15 #include <linux/rtc.h>
19 #define SECS_PER_HOUR (60 * 60)
20 #define SECS_PER_DAY (SECS_PER_HOUR * 24)
23 #define RTC_PIE 0x40 /* periodic interrupt enable */
24 #define RTC_AIE 0x20 /* alarm interrupt enable */
25 #define RTC_UIE 0x10 /* update-finished interrupt enable */
27 #define RTC_BATT_BAD 0x100 /* battery bad */
29 /* some dummy definitions */
30 #define RTC_SQWE 0x08 /* enable square-wave output */
31 #define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
32 #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
33 #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
35 # define __isleap(year) \
36 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
38 /* How many days come before each month (0-12). */
39 static const unsigned short int __mon_yday
[2][13] =
42 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
44 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
47 static inline unsigned int get_rtc_time(struct rtc_time
*wtime
)
49 struct pdc_tod tod_data
;
50 long int days
, rem
, y
;
51 const unsigned short int *ip
;
53 memset(wtime
, 0, sizeof(*wtime
));
54 if (pdc_tod_read(&tod_data
) < 0)
55 return RTC_24H
| RTC_BATT_BAD
;
57 // most of the remainder of this function is:
58 // Copyright (C) 1991, 1993, 1997, 1998 Free Software Foundation, Inc.
59 // This was originally a part of the GNU C Library.
60 // It is distributed under the GPL, and was swiped from offtime.c
63 days
= tod_data
.tod_sec
/ SECS_PER_DAY
;
64 rem
= tod_data
.tod_sec
% SECS_PER_DAY
;
66 wtime
->tm_hour
= rem
/ SECS_PER_HOUR
;
68 wtime
->tm_min
= rem
/ 60;
69 wtime
->tm_sec
= rem
% 60;
73 #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
74 #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
76 while (days
< 0 || days
>= (__isleap (y
) ? 366 : 365))
78 /* Guess a corrected year, assuming 365 days per year. */
79 long int yg
= y
+ days
/ 365 - (days
% 365 < 0);
81 /* Adjust DAYS and Y to match the guessed year. */
82 days
-= ((yg
- y
) * 365
83 + LEAPS_THRU_END_OF (yg
- 1)
84 - LEAPS_THRU_END_OF (y
- 1));
87 wtime
->tm_year
= y
- 1900;
89 ip
= __mon_yday
[__isleap(y
)];
90 for (y
= 11; days
< (long int) ip
[y
]; --y
)
94 wtime
->tm_mday
= days
+ 1;
99 static int set_rtc_time(struct rtc_time
*wtime
)
103 secs
= mktime(wtime
->tm_year
+ 1900, wtime
->tm_mon
+ 1, wtime
->tm_mday
,
104 wtime
->tm_hour
, wtime
->tm_min
, wtime
->tm_sec
);
106 if(pdc_tod_set(secs
, 0) < 0)
113 static inline unsigned int get_rtc_ss(void)
121 static inline int get_rtc_pll(struct rtc_pll_info
*pll
)
125 static inline int set_rtc_pll(struct rtc_pll_info
*pll
)
130 #endif /* __KERNEL__ */
131 #endif /* __ASM_RTC_H__ */