linux-old/include/asm-cris/rtc.h
<<
>>
Prefs
   1#ifndef __RTC_H__
   2#define __RTC_H__
   3
   4#include <linux/config.h>
   5
   6#ifdef CONFIG_ETRAX_DS1302
   7   /* Dallas DS1302 clock/calendar register numbers. */
   8#  define RTC_SECONDS      0
   9#  define RTC_MINUTES      1
  10#  define RTC_HOURS        2
  11#  define RTC_DAY_OF_MONTH 3
  12#  define RTC_MONTH        4
  13#  define RTC_WEEKDAY      5
  14#  define RTC_YEAR         6
  15#  define RTC_CONTROL      7
  16
  17   /* Bits in CONTROL register. */
  18#  define RTC_CONTROL_WRITEPROTECT      0x80
  19#  define RTC_TRICKLECHARGER            8
  20
  21  /* Bits in TRICKLECHARGER register TCS TCS TCS TCS DS DS RS RS. */
  22#  define RTC_TCR_PATTERN       0xA0    /* 1010xxxx */
  23#  define RTC_TCR_1DIOD         0x04    /* xxxx01xx */
  24#  define RTC_TCR_2DIOD         0x08    /* xxxx10xx */
  25#  define RTC_TCR_DISABLED      0x00    /* xxxxxx00 Disabled */
  26#  define RTC_TCR_2KOHM         0x01    /* xxxxxx01 2kOhm */
  27#  define RTC_TCR_4KOHM         0x02    /* xxxxxx10 4kOhm */
  28#  define RTC_TCR_8KOHM         0x03    /* xxxxxx11 8kOhm */
  29
  30#elif defined(CONFIG_ETRAX_PCF8563)
  31   /* I2C bus slave registers. */
  32#  define RTC_I2C_READ          0xa3
  33#  define RTC_I2C_WRITE         0xa2
  34
  35   /* Phillips PCF8563 registers. */
  36#  define RTC_CONTROL1          0x00    /* Control/Status register 1. */
  37#  define RTC_CONTROL2          0x01    /* Control/Status register 2. */
  38#  define RTC_CLOCKOUT_FREQ     0x0d    /* CLKOUT frequency. */
  39#  define RTC_TIMER_CONTROL     0x0e    /* Timer control. */
  40#  define RTC_TIMER_CNTDOWN     0x0f    /* Timer countdown. */
  41
  42   /* BCD encoded clock registers. */
  43#  define RTC_SECONDS           0x02
  44#  define RTC_MINUTES           0x03
  45#  define RTC_HOURS             0x04
  46#  define RTC_DAY_OF_MONTH      0x05
  47#  define RTC_WEEKDAY           0x06    /* Not coded in BCD! */
  48#  define RTC_MONTH             0x07
  49#  define RTC_YEAR              0x08
  50#  define RTC_MINUTE_ALARM      0x09
  51#  define RTC_HOUR_ALARM        0x0a
  52#  define RTC_DAY_ALARM         0x0b
  53#  define RTC_WEEKDAY_ALARM     0x0c    /* Not coded in BCD! */
  54
  55/* Control/Status 2 bits */
  56#  define RTC_CTRL2_TIE         0x01    /* Timer Interrupt Enable */
  57#  define RTC_CTRL2_AIE         0x02    /* Alarm Interrupt Enable */
  58#  define RTC_CTRL2_TF          0x04    /* Timer Flag */
  59#  define RTC_CTRL2_AF          0x08    /* Alarm Flag */
  60#  define RTC_CTRL2_TP          0x10    /* Timer Pulse */
  61
  62/* Timer Control bits */
  63#  define RTC_TC_TD0            0x01
  64#  define RTC_TC_TD1            0x02
  65#  define RTC_TC_TE             0x80    /* Timer Enable */
  66
  67/* Timer source clock frequency */
  68#  define RTC_TC_FREQ_MASK      (RTC_TC_TD0 | RTC_TC_TD1)
  69#  define RTC_TC_FREQ_4096      (0)
  70#  define RTC_TC_FREQ_64        (RTC_TC_TD0)
  71#  define RTC_TC_FREQ_1         (RTC_TC_TD1)
  72#  define RTC_TC_FREQ_1_60      (RTC_TC_TD0 | RTC_TC_TD1)
  73
  74#endif
  75
  76#ifdef CONFIG_ETRAX_DS1302
  77extern unsigned char ds1302_readreg(int reg);
  78extern void ds1302_writereg(int reg, unsigned char val);
  79extern int ds1302_init(void);
  80#  define CMOS_READ(x) ds1302_readreg(x)
  81#  define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
  82#  define RTC_INIT() ds1302_init()
  83#elif defined(CONFIG_ETRAX_PCF8563)
  84extern unsigned char pcf8563_readreg(int reg);
  85extern void pcf8563_writereg(int reg, unsigned char val);
  86extern int pcf8563_init(void);
  87#  define CMOS_READ(x) pcf8563_readreg(x)
  88#  define CMOS_WRITE(val,reg) pcf8563_writereg(reg,val)
  89#  define RTC_INIT() pcf8563_init()
  90#else
  91  /* No RTC configured so we shouldn't try to access any. */
  92#  define CMOS_READ(x) 42
  93#  define CMOS_WRITE(x,y)
  94#  define RTC_INIT() (-1)
  95#endif
  96
  97/* Conversions to and from the RTC BCD encoded format. */
  98#define BCD_TO_BIN(x) ((x)=((x)&15) + ((x)>>4)*10)
  99#define BIN_TO_BCD(x) ((x)=(((x)/10)<<4) + (x)%10)
 100
 101/*
 102 * The struct used to pass data via the following ioctl. Similar to the
 103 * struct tm in <time.h>, but it needs to be here so that the kernel
 104 * source is self contained, allowing cross-compiles, etc. etc.
 105 */
 106struct rtc_time {
 107        int tm_sec;
 108        int tm_min;
 109        int tm_hour;
 110        int tm_mday;
 111        int tm_mon;
 112        int tm_year;
 113        int tm_wday;
 114        int tm_yday;
 115        int tm_isdst;
 116};
 117
 118/* ioctl() calls that are permitted to the /dev/rtc interface. */
 119#define RTC_MAGIC 'p'
 120#define RTC_RD_TIME     _IOR(RTC_MAGIC, 0x09, struct rtc_time)  /* Read RTC time. */
 121#define RTC_SET_TIME    _IOW(RTC_MAGIC, 0x0a, struct rtc_time)  /* Set RTC time. */
 122#define RTC_SET_CHARGE  _IOW(RTC_MAGIC, 0x0b, int)
 123#define RTC_VLOW_RD     _IOR(RTC_MAGIC, 0x11, int)  /* Voltage Low detector */
 124#define RTC_VLOW_SET    _IO(RTC_MAGIC, 0x12)        /* Clear voltage low information */
 125#define RTC_MAX_IOCTL 0x12
 126
 127#endif /* __RTC_H__ */
 128
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.