rtc.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. mach_hwclk(0, time);
  34. return RTC_24H;
  35. }
  36. static inline int set_rtc_time(struct rtc_time *time)
  37. {
  38. return mach_hwclk(1, time);
  39. }
  40. static inline unsigned int get_rtc_ss(void)
  41. {
  42. if (mach_get_ss)
  43. return mach_get_ss();
  44. else{
  45. struct rtc_time h;
  46. get_rtc_time(&h);
  47. return h.tm_sec;
  48. }
  49. }
  50. static inline int get_rtc_pll(struct rtc_pll_info *pll)
  51. {
  52. if (mach_get_rtc_pll)
  53. return mach_get_rtc_pll(pll);
  54. else
  55. return -EINVAL;
  56. }
  57. static inline int set_rtc_pll(struct rtc_pll_info *pll)
  58. {
  59. if (mach_set_rtc_pll)
  60. return mach_set_rtc_pll(pll);
  61. else
  62. return -EINVAL;
  63. }
  64. #endif /* __KERNEL__ */
  65. #endif /* _ASM__RTC_H */