patch-2.4.20 linux-2.4.20/include/asm-cris/rtc.h
Next file: linux-2.4.20/include/asm-cris/semaphore.h
Previous file: linux-2.4.20/include/asm-cris/pgtable.h
Back to the patch index
Back to the overall index
- Lines: 151
- Date:
Thu Nov 28 15:53:15 2002
- Orig file:
linux-2.4.19/include/asm-cris/rtc.h
- Orig date:
Tue May 1 16:05:00 2001
diff -urN linux-2.4.19/include/asm-cris/rtc.h linux-2.4.20/include/asm-cris/rtc.h
@@ -1,55 +1,86 @@
-/* $Id: rtc.h,v 1.3 2001/03/21 09:56:31 magnusmn Exp $ */
+/* $Id: rtc.h,v 1.5 2002/08/14 11:04:10 sebsjo Exp $ */
+
+#ifndef __RTC_H__
+#define __RTC_H__
-#ifndef RTC_H
-#define RTC_H
#include <linux/config.h>
-/* Dallas DS1302 clock/calendar register numbers */
+#ifdef CONFIG_ETRAX_DS1302
+ /* Dallas DS1302 clock/calendar register numbers. */
+# define RTC_SECONDS 0
+# define RTC_MINUTES 1
+# define RTC_HOURS 2
+# define RTC_DAY_OF_MONTH 3
+# define RTC_MONTH 4
+# define RTC_WEEKDAY 5
+# define RTC_YEAR 6
+# define RTC_CONTROL 7
+
+ /* Bits in CONTROL register. */
+# define RTC_CONTROL_WRITEPROTECT 0x80
+# define RTC_TRICKLECHARGER 8
+
+ /* Bits in TRICKLECHARGER register TCS TCS TCS TCS DS DS RS RS. */
+# define RTC_TCR_PATTERN 0xA0 /* 1010xxxx */
+# define RTC_TCR_1DIOD 0x04 /* xxxx01xx */
+# define RTC_TCR_2DIOD 0x08 /* xxxx10xx */
+# define RTC_TCR_DISABLED 0x00 /* xxxxxx00 Disabled */
+# define RTC_TCR_2KOHM 0x01 /* xxxxxx01 2KOhm */
+# define RTC_TCR_4KOHM 0x02 /* xxxxxx10 4kOhm */
+# define RTC_TCR_8KOHM 0x03 /* xxxxxx11 8kOhm */
+
+#elif defined(CONFIG_ETRAX_PCF8563)
+ /* I2C bus slave registers. */
+# define RTC_I2C_READ 0xa3
+# define RTC_I2C_WRITE 0xa2
+
+ /* Phillips PCF8563 registers. */
+# define RTC_CONTROL1 0x00 /* Control/Status register 1. */
+# define RTC_CONTROL2 0x01 /* Control/Status register 2. */
+# define RTC_CLOCKOUT_FREQ 0x0d /* CLKOUT frequency. */
+# define RTC_TIMER_CONTROL 0x0e /* Timer control. */
+# define RTC_TIMER_CNTDOWN 0x0f /* Timer countdown. */
+
+ /* BCD encoded clock registers. */
+# define RTC_SECONDS 0x02
+# define RTC_MINUTES 0x03
+# define RTC_HOURS 0x04
+# define RTC_DAY_OF_MONTH 0x05
+# define RTC_WEEKDAY 0x06 /* Not coded in BCD! */
+# define RTC_MONTH 0x07
+# define RTC_YEAR 0x08
+# define RTC_MINUTE_ALARM 0x09
+# define RTC_HOUR_ALARM 0x0a
+# define RTC_DAY_ALARM 0x0b
+# define RTC_WEEKDAY_ALARM 0x0c
-#define RTC_SECONDS 0
-#define RTC_MINUTES 1
-#define RTC_HOURS 2
-#define RTC_DAY_OF_MONTH 3
-#define RTC_MONTH 4
-#define RTC_WEEKDAY 5
-#define RTC_YEAR 6
-#define RTC_CONTROL 7
-
-/* Bits in CONTROL register */
-#define RTC_CONTROL_WRITEPROTECT 0x80
-#define RTC_TRICKLECHARGER 8
-/* Bits in TRICKLECHARGER register TCS TCS TCS TCS DS DS RS RS */
-#define RTC_TCR_PATTERN 0xA0 /* 1010xxxx */
-#define RTC_TCR_1DIOD 0x04 /* xxxx01xx */
-#define RTC_TCR_2DIOD 0x08 /* xxxx10xx */
-#define RTC_TCR_DISABLED 0x00 /* xxxxxx00 Disabled */
-#define RTC_TCR_2KOHM 0x01 /* xxxxxx01 2KOhm */
-#define RTC_TCR_4KOHM 0x02 /* xxxxxx10 4kOhm */
-#define RTC_TCR_8KOHM 0x03 /* xxxxxx11 8kOhm */
+#endif
#ifdef CONFIG_ETRAX_DS1302
-#define CMOS_READ(x) ds1302_readreg(x)
-#define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
-#define RTC_INIT() ds1302_init()
+# define CMOS_READ(x) ds1302_readreg(x)
+# define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
+# define RTC_INIT() ds1302_init()
+#elif defined(CONFIG_ETRAX_PCF8563)
+# define CMOS_READ(x) i2c_readreg(RTC_I2C_READ, x)
+# define CMOS_WRITE(val,reg) i2c_writereg(RTC_I2C_WRITE,reg,val)
+# define RTC_INIT() pcf8563_init()
#else
-/* no RTC configured so we shouldn't try to access any */
-#define CMOS_READ(x) 42
-#define CMOS_WRITE(x,y)
-#define RTC_INIT() (-1)
+ /* No RTC configured so we shouldn't try to access any. */
+# define CMOS_READ(x) 42
+# define CMOS_WRITE(x,y)
+# define RTC_INIT() (-1)
#endif
-/* conversions to and from the stupid RTC internal format */
-
-#define BCD_TO_BIN(x) x = (((x & 0xf0) >> 3) * 5 + (x & 0xf))
-#define BIN_TO_BCD(x) x = (x % 10) | ((x / 10) << 4)
+/* Conversions to and from the RTC BCD encoded format. */
+#define BCD_TO_BIN(x) ((x)=((x)&15) + ((x)>>4)*10)
+#define BIN_TO_BCD(x) ((x)=(((x)/10)<<4) + (x)%10)
/*
* The struct used to pass data via the following ioctl. Similar to the
* struct tm in <time.h>, but it needs to be here so that the kernel
* source is self contained, allowing cross-compiles, etc. etc.
*/
-
struct rtc_time {
int tm_sec;
int tm_min;
@@ -62,14 +93,18 @@
int tm_isdst;
};
-/*
- * ioctl calls that are permitted to the /dev/rtc interface
- */
-
-#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */
-#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */
-#define RTC_SET_CHARGE _IOW('p', 0x0b, int) /* Set CHARGE mode */
-
+/* ioctl() calls that are permitted to the /dev/rtc interface. */
+#ifdef CONFIG_ETRAX_DS1302
+# define DS1302_MAGIC 'p'
+# define RTC_RD_TIME _IOR(DS1302_MAGIC, 0x09, struct rtc_time) /* Read RTC time. */
+# define RTC_SET_TIME _IOW(DS1302_MAGIC, 0x0a, struct rtc_time) /* Set RTC time. */
+# define RTC_SET_CHARGE _IOW(DS1302_MAGIC, 0x0b, int) /* Set CHARGE mode. */
+#elif defined(CONFIG_ETRAX_PCF8563)
+# define PCF8563_MAGIC 'T'
+# define RTC_RD_TIME _IOR(PCF8563_MAGIC, 0x01, struct rtc_time) /* Read RTC time. */
+# define RTC_SET_TIME _IOW(PCF8563_MAGIC, 0x02, struct rtc_time) /* Set RTC time. */
+# define RTC_SET_CHARGE _IOW(PCF8563_MAGIC, 0x03, int)
+# define RTC_MAX_IOCTL 3
#endif
-
+#endif /* __RTC_H__ */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)