Don't include linux/config.h from anywhere else in include/
[safe/jmp/linux-2.6] / include / asm-cris / rtc.h
1 /* $Id: rtc.h,v 1.7 2002/11/04 07:32:09 starvik Exp $ */
2
3 #ifndef __RTC_H__
4 #define __RTC_H__
5
6
7
8 #ifdef CONFIG_ETRAX_DS1302
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 #elif defined(CONFIG_ETRAX_PCF8563)
33    /* I2C bus slave registers. */
34 #  define RTC_I2C_READ          0xa3
35 #  define RTC_I2C_WRITE         0xa2
36
37    /* Phillips PCF8563 registers. */
38 #  define RTC_CONTROL1          0x00            /* Control/Status register 1. */
39 #  define RTC_CONTROL2          0x01            /* Control/Status register 2. */
40 #  define RTC_CLOCKOUT_FREQ     0x0d            /* CLKOUT frequency. */
41 #  define RTC_TIMER_CONTROL     0x0e            /* Timer control. */
42 #  define RTC_TIMER_CNTDOWN     0x0f            /* Timer countdown. */
43
44    /* BCD encoded clock registers. */
45 #  define RTC_SECONDS           0x02
46 #  define RTC_MINUTES           0x03
47 #  define RTC_HOURS             0x04
48 #  define RTC_DAY_OF_MONTH      0x05
49 #  define RTC_WEEKDAY           0x06    /* Not coded in BCD! */
50 #  define RTC_MONTH             0x07
51 #  define RTC_YEAR              0x08
52 #  define RTC_MINUTE_ALARM      0x09
53 #  define RTC_HOUR_ALARM        0x0a
54 #  define RTC_DAY_ALARM         0x0b
55 #  define RTC_WEEKDAY_ALARM 0x0c
56
57 #endif
58
59 #ifdef CONFIG_ETRAX_DS1302
60 extern unsigned char ds1302_readreg(int reg);
61 extern void ds1302_writereg(int reg, unsigned char val);
62 extern int ds1302_init(void);
63 #  define CMOS_READ(x) ds1302_readreg(x)
64 #  define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
65 #  define RTC_INIT() ds1302_init()
66 #elif defined(CONFIG_ETRAX_PCF8563)
67 extern unsigned char pcf8563_readreg(int reg);
68 extern void pcf8563_writereg(int reg, unsigned char val);
69 extern int pcf8563_init(void);
70 #  define CMOS_READ(x) pcf8563_readreg(x)
71 #  define CMOS_WRITE(val,reg) pcf8563_writereg(reg,val)
72 #  define RTC_INIT() pcf8563_init()
73 #else
74   /* No RTC configured so we shouldn't try to access any. */
75 #  define CMOS_READ(x) 42
76 #  define CMOS_WRITE(x,y)
77 #  define RTC_INIT() (-1)
78 #endif
79
80 /*
81  * The struct used to pass data via the following ioctl. Similar to the
82  * struct tm in <time.h>, but it needs to be here so that the kernel 
83  * source is self contained, allowing cross-compiles, etc. etc.
84  */
85 struct rtc_time {
86         int tm_sec;
87         int tm_min;
88         int tm_hour;
89         int tm_mday;
90         int tm_mon;
91         int tm_year;
92         int tm_wday;
93         int tm_yday;
94         int tm_isdst;
95 };
96
97 /* ioctl() calls that are permitted to the /dev/rtc interface. */
98 #define RTC_MAGIC 'p'
99 #define RTC_RD_TIME             _IOR(RTC_MAGIC, 0x09, struct rtc_time)  /* Read RTC time. */
100 #define RTC_SET_TIME            _IOW(RTC_MAGIC, 0x0a, struct rtc_time)  /* Set RTC time. */
101 #define RTC_SET_CHARGE          _IOW(RTC_MAGIC, 0x0b, int)              
102 #define RTC_VLOW_RD     _IOR(RTC_MAGIC, 0x11, int)  /* Voltage Low detector */
103 #define RTC_VLOW_SET    _IO(RTC_MAGIC, 0x12)        /* Clear voltage low information */
104 #define RTC_MAX_IOCTL 0x12
105
106 #endif /* __RTC_H__ */