rtc.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * include/asm-mips/rtc.h
  3. *
  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. #ifndef _MIPS_RTC_H
  12. #define _MIPS_RTC_H
  13. #ifdef __KERNEL__
  14. #include <linux/spinlock.h>
  15. #include <linux/rtc.h>
  16. #include <asm/time.h>
  17. #define RTC_PIE 0x40 /* periodic interrupt enable */
  18. #define RTC_AIE 0x20 /* alarm interrupt enable */
  19. #define RTC_UIE 0x10 /* update-finished interrupt enable */
  20. /* some dummy definitions */
  21. #define RTC_BATT_BAD 0x100 /* battery bad */
  22. #define RTC_SQWE 0x08 /* enable square-wave output */
  23. #define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
  24. #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
  25. #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
  26. static DEFINE_SPINLOCK(mips_rtc_lock);
  27. static inline unsigned int get_rtc_time(struct rtc_time *time)
  28. {
  29. unsigned long nowtime;
  30. spin_lock(&mips_rtc_lock);
  31. nowtime = rtc_get_time();
  32. to_tm(nowtime, time);
  33. time->tm_year -= 1900;
  34. spin_unlock(&mips_rtc_lock);
  35. return RTC_24H;
  36. }
  37. static inline int set_rtc_time(struct rtc_time *time)
  38. {
  39. unsigned long nowtime;
  40. int ret;
  41. spin_lock(&mips_rtc_lock);
  42. nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
  43. time->tm_mday, time->tm_hour, time->tm_min,
  44. time->tm_sec);
  45. ret = rtc_set_time(nowtime);
  46. spin_unlock(&mips_rtc_lock);
  47. return ret;
  48. }
  49. static inline unsigned int get_rtc_ss(void)
  50. {
  51. struct rtc_time h;
  52. get_rtc_time(&h);
  53. return h.tm_sec;
  54. }
  55. static inline int get_rtc_pll(struct rtc_pll_info *pll)
  56. {
  57. return -EINVAL;
  58. }
  59. static inline int set_rtc_pll(struct rtc_pll_info *pll)
  60. {
  61. return -EINVAL;
  62. }
  63. #endif
  64. #endif