[PATCH] w1_therm: support for ds18b20, ds1822 thermal sensors.
[linux-2.6/verdex.git] / arch / mips / kernel / genrtc.c
blob288bf51ad4ecd3c2da322ac3c658b39816a339b8
1 /*
2 * A glue layer that provides RTC read/write to drivers/char/genrtc.c driver
3 * based on MIPS internal RTC routines. It does take care locking
4 * issues so that we are SMP/Preemption safe.
6 * Copyright (C) 2004 MontaVista Software Inc.
7 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
9 * Please read the COPYING file for all license details.
12 #include <linux/spinlock.h>
14 #include <asm/rtc.h>
15 #include <asm/time.h>
17 static spinlock_t mips_rtc_lock = SPIN_LOCK_UNLOCKED;
19 unsigned int get_rtc_time(struct rtc_time *time)
21 unsigned long nowtime;
23 spin_lock(&mips_rtc_lock);
24 nowtime = rtc_get_time();
25 to_tm(nowtime, time);
26 time->tm_year -= 1900;
27 spin_unlock(&mips_rtc_lock);
29 return RTC_24H;
32 int set_rtc_time(struct rtc_time *time)
34 unsigned long nowtime;
35 int ret;
37 spin_lock(&mips_rtc_lock);
38 nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
39 time->tm_mday, time->tm_hour, time->tm_min,
40 time->tm_sec);
41 ret = rtc_set_time(nowtime);
42 spin_unlock(&mips_rtc_lock);
44 return ret;
47 unsigned int get_rtc_ss(void)
49 struct rtc_time h;
51 get_rtc_time(&h);
52 return h.tm_sec;
55 int get_rtc_pll(struct rtc_pll_info *pll)
57 return -EINVAL;
60 int set_rtc_pll(struct rtc_pll_info *pll)
62 return -EINVAL;