rtc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* $Id: rtc.h,v 1.7 2002/11/04 07:32:09 starvik Exp $ */
  2. #ifndef __RTC_H__
  3. #define __RTC_H__
  4. #ifdef CONFIG_ETRAX_DS1302
  5. /* Dallas DS1302 clock/calendar register numbers. */
  6. # define RTC_SECONDS 0
  7. # define RTC_MINUTES 1
  8. # define RTC_HOURS 2
  9. # define RTC_DAY_OF_MONTH 3
  10. # define RTC_MONTH 4
  11. # define RTC_WEEKDAY 5
  12. # define RTC_YEAR 6
  13. # define RTC_CONTROL 7
  14. /* Bits in CONTROL register. */
  15. # define RTC_CONTROL_WRITEPROTECT 0x80
  16. # define RTC_TRICKLECHARGER 8
  17. /* Bits in TRICKLECHARGER register TCS TCS TCS TCS DS DS RS RS. */
  18. # define RTC_TCR_PATTERN 0xA0 /* 1010xxxx */
  19. # define RTC_TCR_1DIOD 0x04 /* xxxx01xx */
  20. # define RTC_TCR_2DIOD 0x08 /* xxxx10xx */
  21. # define RTC_TCR_DISABLED 0x00 /* xxxxxx00 Disabled */
  22. # define RTC_TCR_2KOHM 0x01 /* xxxxxx01 2KOhm */
  23. # define RTC_TCR_4KOHM 0x02 /* xxxxxx10 4kOhm */
  24. # define RTC_TCR_8KOHM 0x03 /* xxxxxx11 8kOhm */
  25. #elif defined(CONFIG_ETRAX_PCF8563)
  26. /* I2C bus slave registers. */
  27. # define RTC_I2C_READ 0xa3
  28. # define RTC_I2C_WRITE 0xa2
  29. /* Phillips PCF8563 registers. */
  30. # define RTC_CONTROL1 0x00 /* Control/Status register 1. */
  31. # define RTC_CONTROL2 0x01 /* Control/Status register 2. */
  32. # define RTC_CLOCKOUT_FREQ 0x0d /* CLKOUT frequency. */
  33. # define RTC_TIMER_CONTROL 0x0e /* Timer control. */
  34. # define RTC_TIMER_CNTDOWN 0x0f /* Timer countdown. */
  35. /* BCD encoded clock registers. */
  36. # define RTC_SECONDS 0x02
  37. # define RTC_MINUTES 0x03
  38. # define RTC_HOURS 0x04
  39. # define RTC_DAY_OF_MONTH 0x05
  40. # define RTC_WEEKDAY 0x06 /* Not coded in BCD! */
  41. # define RTC_MONTH 0x07
  42. # define RTC_YEAR 0x08
  43. # define RTC_MINUTE_ALARM 0x09
  44. # define RTC_HOUR_ALARM 0x0a
  45. # define RTC_DAY_ALARM 0x0b
  46. # define RTC_WEEKDAY_ALARM 0x0c
  47. #endif
  48. #ifdef CONFIG_ETRAX_DS1302
  49. extern unsigned char ds1302_readreg(int reg);
  50. extern void ds1302_writereg(int reg, unsigned char val);
  51. extern int ds1302_init(void);
  52. # define CMOS_READ(x) ds1302_readreg(x)
  53. # define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
  54. # define RTC_INIT() ds1302_init()
  55. #elif defined(CONFIG_ETRAX_PCF8563)
  56. extern unsigned char pcf8563_readreg(int reg);
  57. extern void pcf8563_writereg(int reg, unsigned char val);
  58. extern int pcf8563_init(void);
  59. # define CMOS_READ(x) pcf8563_readreg(x)
  60. # define CMOS_WRITE(val,reg) pcf8563_writereg(reg,val)
  61. # define RTC_INIT() pcf8563_init()
  62. #else
  63. /* No RTC configured so we shouldn't try to access any. */
  64. # define CMOS_READ(x) 42
  65. # define CMOS_WRITE(x,y)
  66. # define RTC_INIT() (-1)
  67. #endif
  68. /*
  69. * The struct used to pass data via the following ioctl. Similar to the
  70. * struct tm in <time.h>, but it needs to be here so that the kernel
  71. * source is self contained, allowing cross-compiles, etc. etc.
  72. */
  73. struct rtc_time {
  74. int tm_sec;
  75. int tm_min;
  76. int tm_hour;
  77. int tm_mday;
  78. int tm_mon;
  79. int tm_year;
  80. int tm_wday;
  81. int tm_yday;
  82. int tm_isdst;
  83. };
  84. /* ioctl() calls that are permitted to the /dev/rtc interface. */
  85. #define RTC_MAGIC 'p'
  86. #define RTC_RD_TIME _IOR(RTC_MAGIC, 0x09, struct rtc_time) /* Read RTC time. */
  87. #define RTC_SET_TIME _IOW(RTC_MAGIC, 0x0a, struct rtc_time) /* Set RTC time. */
  88. #define RTC_SET_CHARGE _IOW(RTC_MAGIC, 0x0b, int)
  89. #define RTC_VLOW_RD _IOR(RTC_MAGIC, 0x11, int) /* Voltage Low detector */
  90. #define RTC_VLOW_SET _IO(RTC_MAGIC, 0x12) /* Clear voltage low information */
  91. #define RTC_MAX_IOCTL 0x12
  92. #endif /* __RTC_H__ */