rtc.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * inclue/asm-ppc/rtc.h
  3. *
  4. * Author: Tom Rini <trini@mvista.com>
  5. *
  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.
  10. *
  11. * Based on:
  12. * include/asm-m68k/rtc.h
  13. *
  14. * Copyright Richard Zidlicky
  15. * implementation details for genrtc/q40rtc driver
  16. *
  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)
  20. *
  21. * With additional work by Paul Mackerras and Franz Sirl.
  22. */
  23. #ifndef __ASM_RTC_H__
  24. #define __ASM_RTC_H__
  25. #ifdef __KERNEL__
  26. #include <linux/rtc.h>
  27. #include <asm/machdep.h>
  28. #include <asm/time.h>
  29. #define RTC_PIE 0x40 /* periodic interrupt enable */
  30. #define RTC_AIE 0x20 /* alarm interrupt enable */
  31. #define RTC_UIE 0x10 /* update-finished interrupt enable */
  32. /* some dummy definitions */
  33. #define RTC_BATT_BAD 0x100 /* battery bad */
  34. #define RTC_SQWE 0x08 /* enable square-wave output */
  35. #define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
  36. #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
  37. #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
  38. static inline unsigned int get_rtc_time(struct rtc_time *time)
  39. {
  40. if (ppc_md.get_rtc_time) {
  41. unsigned long nowtime;
  42. nowtime = (ppc_md.get_rtc_time)();
  43. to_tm(nowtime, time);
  44. time->tm_year -= 1900;
  45. time->tm_mon -= 1; /* Make sure userland has a 0-based month */
  46. }
  47. return RTC_24H;
  48. }
  49. /* Set the current date and time in the real time clock. */
  50. static inline int set_rtc_time(struct rtc_time *time)
  51. {
  52. if (ppc_md.get_rtc_time) {
  53. unsigned long nowtime;
  54. nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
  55. time->tm_mday, time->tm_hour, time->tm_min,
  56. time->tm_sec);
  57. (ppc_md.set_rtc_time)(nowtime);
  58. return 0;
  59. } else
  60. return -EINVAL;
  61. }
  62. static inline unsigned int get_rtc_ss(void)
  63. {
  64. struct rtc_time h;
  65. get_rtc_time(&h);
  66. return h.tm_sec;
  67. }
  68. static inline int get_rtc_pll(struct rtc_pll_info *pll)
  69. {
  70. return -EINVAL;
  71. }
  72. static inline int set_rtc_pll(struct rtc_pll_info *pll)
  73. {
  74. return -EINVAL;
  75. }
  76. #endif /* __KERNEL__ */
  77. #endif /* __ASM_RTC_H__ */