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