rtc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* include/asm-m68k/rtc.h
  2. *
  3. * Copyright Richard Zidlicky
  4. * implementation details for genrtc/q40rtc driver
  5. */
  6. /* permission is hereby granted to copy, modify and redistribute this code
  7. * in terms of the GNU Library General Public License, Version 2 or later,
  8. * at your option.
  9. */
  10. #ifndef _ASM_RTC_H
  11. #define _ASM_RTC_H
  12. #ifdef __KERNEL__
  13. #include <linux/rtc.h>
  14. #include <asm/errno.h>
  15. #include <asm/machdep.h>
  16. #define RTC_PIE 0x40 /* periodic interrupt enable */
  17. #define RTC_AIE 0x20 /* alarm interrupt enable */
  18. #define RTC_UIE 0x10 /* update-finished interrupt enable */
  19. /* some dummy definitions */
  20. #define RTC_BATT_BAD 0x100 /* battery bad */
  21. #define RTC_SQWE 0x08 /* enable square-wave output */
  22. #define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
  23. #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
  24. #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
  25. static inline unsigned int get_rtc_time(struct rtc_time *time)
  26. {
  27. /*
  28. * Only the values that we read from the RTC are set. We leave
  29. * tm_wday, tm_yday and tm_isdst untouched. Even though the
  30. * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
  31. * by the RTC when initially set to a non-zero value.
  32. */
  33. if (mach_hwclk)
  34. mach_hwclk(0, time);
  35. return RTC_24H;
  36. }
  37. static inline int set_rtc_time(struct rtc_time *time)
  38. {
  39. if (mach_hwclk)
  40. return mach_hwclk(1, time);
  41. return -EINVAL;
  42. }
  43. static inline unsigned int get_rtc_ss(void)
  44. {
  45. if (mach_get_ss)
  46. return mach_get_ss();
  47. else{
  48. struct rtc_time h;
  49. get_rtc_time(&h);
  50. return h.tm_sec;
  51. }
  52. }
  53. static inline int get_rtc_pll(struct rtc_pll_info *pll)
  54. {
  55. if (mach_get_rtc_pll)
  56. return mach_get_rtc_pll(pll);
  57. else
  58. return -EINVAL;
  59. }
  60. static inline int set_rtc_pll(struct rtc_pll_info *pll)
  61. {
  62. if (mach_set_rtc_pll)
  63. return mach_set_rtc_pll(pll);
  64. else
  65. return -EINVAL;
  66. }
  67. #endif /* __KERNEL__ */
  68. #endif /* _ASM__RTC_H */