19 #include <linux/module.h>
28 #if defined(CONFIG_M32R)
32 #define RTC_MAJOR_NR 121
35 static const char ds1302_name[] =
"ds1302";
39 out_byte_rtc(
unsigned int reg_addr,
unsigned char x)
56 in_byte_rtc(
unsigned int reg_addr)
65 outw(0x0001,(
unsigned long)PLD_RTCCR);
67 while(
inw((
unsigned long)PLD_RTCCR));
83 out_byte_rtc(0x8e,0x00);
91 out_byte_rtc(0x8e,0x80);
103 x=in_byte_rtc((0x81 | (reg << 1)));
114 out_byte_rtc((0x80 | (reg << 1)),val);
152 static unsigned char days_in_mo[] =
153 {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
157 static long rtc_ioctl(
struct file *
file,
unsigned int cmd,
unsigned long arg)
178 unsigned char mon,
day, hrs,
min,
sec, leap_yr;
187 yrs = rtc_tm.tm_year + 1900;
188 mon = rtc_tm.tm_mon + 1;
189 day = rtc_tm.tm_mday;
190 hrs = rtc_tm.tm_hour;
195 if ((yrs < 1970) || (yrs > 2069))
198 leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400));
200 if ((mon > 12) || (day == 0))
203 if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr)))
206 if ((hrs >= 24) || (min >= 60) || (sec >= 60))
277 "rtc_time\t: %02d:%02d:%02d\n"
278 "rtc_date\t: %04d-%02d-%02d\n",
290 .unlocked_ioctl = rtc_ioctl,
296 #define MAGIC_PATTERN 0x42
305 printk(
"%s: Set PLD_RTCBAUR = %d\n", ds1302_name,baur);
307 outw(0x0000,(
unsigned long)PLD_RTCCR);
322 printk(
"%s: RTC found.\n", ds1302_name);
327 printk(
"%s: RTC not found.\n", ds1302_name);
340 if (!ds1302_probe()) {
346 static int __init ds1302_register(
void)
349 if (register_chrdev(
RTC_MAJOR_NR, ds1302_name, &rtc_fops)) {