rtc.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * RealTime Clock
  4. *
  5. * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  6. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  7. */
  8. #ifndef __MCFRTC_H__
  9. #define __MCFRTC_H__
  10. /* Real time Clock */
  11. typedef struct rtc_ctrl {
  12. u32 hourmin; /* 0x00 Hours and Minutes Counter Register */
  13. u32 seconds; /* 0x04 Seconds Counter Register */
  14. u32 alrm_hm; /* 0x08 Hours and Minutes Alarm Register */
  15. u32 alrm_sec; /* 0x0C Seconds Alarm Register */
  16. u32 cr; /* 0x10 Control Register */
  17. u32 isr; /* 0x14 Interrupt Status Register */
  18. u32 ier; /* 0x18 Interrupt Enable Register */
  19. u32 stpwatch; /* 0x1C Stopwatch Minutes Register */
  20. u32 days; /* 0x20 Days Counter Register */
  21. u32 alrm_day; /* 0x24 Days Alarm Register */
  22. void *extended;
  23. } rtc_t;
  24. /* Bit definitions and macros for HOURMIN */
  25. #define RTC_HOURMIN_MINUTES(x) (((x)&0x0000003F))
  26. #define RTC_HOURMIN_HOURS(x) (((x)&0x0000001F)<<8)
  27. /* Bit definitions and macros for SECONDS */
  28. #define RTC_SECONDS_SECONDS(x) (((x)&0x0000003F))
  29. /* Bit definitions and macros for ALRM_HM */
  30. #define RTC_ALRM_HM_MINUTES(x) (((x)&0x0000003F))
  31. #define RTC_ALRM_HM_HOURS(x) (((x)&0x0000001F)<<8)
  32. /* Bit definitions and macros for ALRM_SEC */
  33. #define RTC_ALRM_SEC_SECONDS(x) (((x)&0x0000003F))
  34. /* Bit definitions and macros for CR */
  35. #define RTC_CR_SWR (0x00000001)
  36. #define RTC_CR_XTL(x) (((x)&0x00000003)<<5)
  37. #define RTC_CR_EN (0x00000080)
  38. #define RTC_CR_32768 (0x0)
  39. #define RTC_CR_32000 (0x1)
  40. #define RTC_CR_38400 (0x2)
  41. /* Bit definitions and macros for ISR */
  42. #define RTC_ISR_SW (0x00000001)
  43. #define RTC_ISR_MIN (0x00000002)
  44. #define RTC_ISR_ALM (0x00000004)
  45. #define RTC_ISR_DAY (0x00000008)
  46. #define RTC_ISR_1HZ (0x00000010)
  47. #define RTC_ISR_HR (0x00000020)
  48. #define RTC_ISR_2HZ (0x00000080)
  49. #define RTC_ISR_SAM0 (0x00000100)
  50. #define RTC_ISR_SAM1 (0x00000200)
  51. #define RTC_ISR_SAM2 (0x00000400)
  52. #define RTC_ISR_SAM3 (0x00000800)
  53. #define RTC_ISR_SAM4 (0x00001000)
  54. #define RTC_ISR_SAM5 (0x00002000)
  55. #define RTC_ISR_SAM6 (0x00004000)
  56. #define RTC_ISR_SAM7 (0x00008000)
  57. /* Bit definitions and macros for IER */
  58. #define RTC_IER_SW (0x00000001)
  59. #define RTC_IER_MIN (0x00000002)
  60. #define RTC_IER_ALM (0x00000004)
  61. #define RTC_IER_DAY (0x00000008)
  62. #define RTC_IER_1HZ (0x00000010)
  63. #define RTC_IER_HR (0x00000020)
  64. #define RTC_IER_2HZ (0x00000080)
  65. #define RTC_IER_SAM0 (0x00000100)
  66. #define RTC_IER_SAM1 (0x00000200)
  67. #define RTC_IER_SAM2 (0x00000400)
  68. #define RTC_IER_SAM3 (0x00000800)
  69. #define RTC_IER_SAM4 (0x00001000)
  70. #define RTC_IER_SAM5 (0x00002000)
  71. #define RTC_IER_SAM6 (0x00004000)
  72. #define RTC_IER_SAM7 (0x00008000)
  73. /* Bit definitions and macros for STPWCH */
  74. #define RTC_STPWCH_CNT(x) (((x)&0x0000003F))
  75. /* Bit definitions and macros for DAYS */
  76. #define RTC_DAYS_DAYS(x) (((x)&0x0000FFFF))
  77. /* Bit definitions and macros for ALRM_DAY */
  78. #define RTC_ALRM_DAY_DAYS(x) (((x)&0x0000FFFF))
  79. #endif /* __MCFRTC_H__ */