blob: a60e0dc7c9b9406f19efb3e4bf9eb98ddb7b34a0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Ralf Baechle42a3b4f2005-09-03 15:56:17 -07002 * include/asm-mips/rtc.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * (Really an interface for drivers/char/genrtc.c)
5 *
6 * Copyright (C) 2004 MontaVista Software Inc.
7 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
8 *
9 * Please read the COPYING file for all license details.
10 */
11
12#ifndef _MIPS_RTC_H
13#define _MIPS_RTC_H
14
15#ifdef __KERNEL__
16
Ralf Baechle5bcb9a52005-09-01 20:42:46 +000017#include <linux/spinlock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/rtc.h>
Ralf Baechle5bcb9a52005-09-01 20:42:46 +000019#include <asm/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#define RTC_PIE 0x40 /* periodic interrupt enable */
22#define RTC_AIE 0x20 /* alarm interrupt enable */
23#define RTC_UIE 0x10 /* update-finished interrupt enable */
24
25/* some dummy definitions */
26#define RTC_BATT_BAD 0x100 /* battery bad */
27#define RTC_SQWE 0x08 /* enable square-wave output */
28#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
29#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
30#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
31
Ralf Baechle5bcb9a52005-09-01 20:42:46 +000032static DEFINE_SPINLOCK(mips_rtc_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Ralf Baechle5bcb9a52005-09-01 20:42:46 +000034static inline unsigned int get_rtc_time(struct rtc_time *time)
35{
36 unsigned long nowtime;
37
38 spin_lock(&mips_rtc_lock);
39 nowtime = rtc_get_time();
40 to_tm(nowtime, time);
41 time->tm_year -= 1900;
42 spin_unlock(&mips_rtc_lock);
43
44 return RTC_24H;
45}
46
47static inline int set_rtc_time(struct rtc_time *time)
48{
49 unsigned long nowtime;
50 int ret;
51
52 spin_lock(&mips_rtc_lock);
53 nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
54 time->tm_mday, time->tm_hour, time->tm_min,
55 time->tm_sec);
56 ret = rtc_set_time(nowtime);
57 spin_unlock(&mips_rtc_lock);
58
59 return ret;
60}
61
62static inline unsigned int get_rtc_ss(void)
63{
64 struct rtc_time h;
65
66 get_rtc_time(&h);
67 return h.tm_sec;
68}
69
70static inline int get_rtc_pll(struct rtc_pll_info *pll)
71{
72 return -EINVAL;
73}
74
75static inline int set_rtc_pll(struct rtc_pll_info *pll)
76{
77 return -EINVAL;
78}
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#endif
80#endif