rtc.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* $Id: rtc.h,v 1.1.1.1 2004/03/25 04:29:22 hitoshiy Exp $ */
  2. #ifndef __RTC_H__
  3. #define __RTC_H__
  4. #include <linux/config.h>
  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. #ifdef CONFIG_DS1302
  26. extern unsigned char ds1302_readreg(int reg);
  27. extern void ds1302_writereg(int reg, unsigned char val);
  28. extern int ds1302_init(void);
  29. # define CMOS_READ(x) ds1302_readreg(x)
  30. # define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
  31. # define RTC_INIT() ds1302_init()
  32. #else
  33. /* No RTC configured so we shouldn't try to access any. */
  34. # define CMOS_READ(x) 42
  35. # define CMOS_WRITE(x,y)
  36. # define RTC_INIT() (-1)
  37. #endif
  38. /*
  39. * The struct used to pass data via the following ioctl. Similar to the
  40. * struct tm in <time.h>, but it needs to be here so that the kernel
  41. * source is self contained, allowing cross-compiles, etc. etc.
  42. */
  43. struct rtc_time {
  44. int tm_sec;
  45. int tm_min;
  46. int tm_hour;
  47. int tm_mday;
  48. int tm_mon;
  49. int tm_year;
  50. int tm_wday;
  51. int tm_yday;
  52. int tm_isdst;
  53. };
  54. /* ioctl() calls that are permitted to the /dev/rtc interface. */
  55. #define RTC_MAGIC 'p'
  56. #define RTC_RD_TIME _IOR(RTC_MAGIC, 0x09, struct rtc_time) /* Read RTC time. */
  57. #define RTC_SET_TIME _IOW(RTC_MAGIC, 0x0a, struct rtc_time) /* Set RTC time. */
  58. #define RTC_SET_CHARGE _IOW(RTC_MAGIC, 0x0b, int)
  59. #define RTC_MAX_IOCTL 0x0b
  60. #endif /* __RTC_H__ */