Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: rtc.h,v 1.1.1.1 2004/03/25 04:29:22 hitoshiy Exp $ */ |
| 2 | |
| 3 | #ifndef __RTC_H__ |
| 4 | #define __RTC_H__ |
| 5 | |
| 6 | |
| 7 | #include <linux/config.h> |
| 8 | |
| 9 | /* Dallas DS1302 clock/calendar register numbers. */ |
| 10 | # define RTC_SECONDS 0 |
| 11 | # define RTC_MINUTES 1 |
| 12 | # define RTC_HOURS 2 |
| 13 | # define RTC_DAY_OF_MONTH 3 |
| 14 | # define RTC_MONTH 4 |
| 15 | # define RTC_WEEKDAY 5 |
| 16 | # define RTC_YEAR 6 |
| 17 | # define RTC_CONTROL 7 |
| 18 | |
| 19 | /* Bits in CONTROL register. */ |
| 20 | # define RTC_CONTROL_WRITEPROTECT 0x80 |
| 21 | # define RTC_TRICKLECHARGER 8 |
| 22 | |
| 23 | /* Bits in TRICKLECHARGER register TCS TCS TCS TCS DS DS RS RS. */ |
| 24 | # define RTC_TCR_PATTERN 0xA0 /* 1010xxxx */ |
| 25 | # define RTC_TCR_1DIOD 0x04 /* xxxx01xx */ |
| 26 | # define RTC_TCR_2DIOD 0x08 /* xxxx10xx */ |
| 27 | # define RTC_TCR_DISABLED 0x00 /* xxxxxx00 Disabled */ |
| 28 | # define RTC_TCR_2KOHM 0x01 /* xxxxxx01 2KOhm */ |
| 29 | # define RTC_TCR_4KOHM 0x02 /* xxxxxx10 4kOhm */ |
| 30 | # define RTC_TCR_8KOHM 0x03 /* xxxxxx11 8kOhm */ |
| 31 | |
| 32 | #ifdef CONFIG_DS1302 |
| 33 | extern unsigned char ds1302_readreg(int reg); |
| 34 | extern void ds1302_writereg(int reg, unsigned char val); |
| 35 | extern int ds1302_init(void); |
| 36 | # define CMOS_READ(x) ds1302_readreg(x) |
| 37 | # define CMOS_WRITE(val,reg) ds1302_writereg(reg,val) |
| 38 | # define RTC_INIT() ds1302_init() |
| 39 | #else |
| 40 | /* No RTC configured so we shouldn't try to access any. */ |
| 41 | # define CMOS_READ(x) 42 |
| 42 | # define CMOS_WRITE(x,y) |
| 43 | # define RTC_INIT() (-1) |
| 44 | #endif |
| 45 | |
| 46 | /* |
| 47 | * The struct used to pass data via the following ioctl. Similar to the |
| 48 | * struct tm in <time.h>, but it needs to be here so that the kernel |
| 49 | * source is self contained, allowing cross-compiles, etc. etc. |
| 50 | */ |
| 51 | struct rtc_time { |
| 52 | int tm_sec; |
| 53 | int tm_min; |
| 54 | int tm_hour; |
| 55 | int tm_mday; |
| 56 | int tm_mon; |
| 57 | int tm_year; |
| 58 | int tm_wday; |
| 59 | int tm_yday; |
| 60 | int tm_isdst; |
| 61 | }; |
| 62 | |
| 63 | /* ioctl() calls that are permitted to the /dev/rtc interface. */ |
| 64 | #define RTC_MAGIC 'p' |
| 65 | #define RTC_RD_TIME _IOR(RTC_MAGIC, 0x09, struct rtc_time) /* Read RTC time. */ |
| 66 | #define RTC_SET_TIME _IOW(RTC_MAGIC, 0x0a, struct rtc_time) /* Set RTC time. */ |
| 67 | #define RTC_SET_CHARGE _IOW(RTC_MAGIC, 0x0b, int) |
| 68 | #define RTC_MAX_IOCTL 0x0b |
| 69 | |
| 70 | #endif /* __RTC_H__ */ |