aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10/drivers/ds1302.c
diff options
context:
space:
mode:
authorMikael Starvik <mikael.starvik@axis.com>2005-07-27 14:44:34 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-27 19:25:59 -0400
commit7e9204265b4ec6680fad9abc7a78b94087983916 (patch)
tree50ff709f7d37193bb56599a4e1646509d8e353ff /arch/cris/arch-v10/drivers/ds1302.c
parent059163cabc01a15b9e2cf10e5de5b6dc06e0da1f (diff)
[PATCH] CRIS update: drivers
Updates to device drivers. * Use I/O and DMA allocators. * Use wait_event_interruptible instead of interrutiple_sleep_on. * Added spinlocks SMP. * Changed restore_flags to local_irq_restore etc. * Updated IDE driver include to fit 2.6.12. Signed-off-by: Mikael Starvik <starvik@axis.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/cris/arch-v10/drivers/ds1302.c')
-rw-r--r--arch/cris/arch-v10/drivers/ds1302.c71
1 files changed, 49 insertions, 22 deletions
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index fba530fcfaeb..10795f67f687 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -7,6 +7,15 @@
7*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init 7*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init
8*! 8*!
9*! $Log: ds1302.c,v $ 9*! $Log: ds1302.c,v $
10*! Revision 1.18 2005/01/24 09:11:26 mikaelam
11*! Minor changes to get DS1302 RTC chip driver to work
12*!
13*! Revision 1.17 2005/01/05 06:11:22 starvik
14*! No need to do local_irq_disable after local_irq_save.
15*!
16*! Revision 1.16 2004/12/13 12:21:52 starvik
17*! Added I/O and DMA allocators from Linux 2.4
18*!
10*! Revision 1.14 2004/08/24 06:48:43 starvik 19*! Revision 1.14 2004/08/24 06:48:43 starvik
11*! Whitespace cleanup 20*! Whitespace cleanup
12*! 21*!
@@ -124,9 +133,9 @@
124*! 133*!
125*! --------------------------------------------------------------------------- 134*! ---------------------------------------------------------------------------
126*! 135*!
127*! (C) Copyright 1999, 2000, 2001 Axis Communications AB, LUND, SWEDEN 136*! (C) Copyright 1999, 2000, 2001, 2002, 2003, 2004 Axis Communications AB, LUND, SWEDEN
128*! 137*!
129*! $Id: ds1302.c,v 1.14 2004/08/24 06:48:43 starvik Exp $ 138*! $Id: ds1302.c,v 1.18 2005/01/24 09:11:26 mikaelam Exp $
130*! 139*!
131*!***************************************************************************/ 140*!***************************************************************************/
132 141
@@ -145,6 +154,7 @@
145#include <asm/arch/svinto.h> 154#include <asm/arch/svinto.h>
146#include <asm/io.h> 155#include <asm/io.h>
147#include <asm/rtc.h> 156#include <asm/rtc.h>
157#include <asm/arch/io_interface_mux.h>
148 158
149#define RTC_MAJOR_NR 121 /* local major, change later */ 159#define RTC_MAJOR_NR 121 /* local major, change later */
150 160
@@ -320,7 +330,6 @@ get_rtc_time(struct rtc_time *rtc_tm)
320 unsigned long flags; 330 unsigned long flags;
321 331
322 local_irq_save(flags); 332 local_irq_save(flags);
323 local_irq_disable();
324 333
325 rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS); 334 rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
326 rtc_tm->tm_min = CMOS_READ(RTC_MINUTES); 335 rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);
@@ -358,7 +367,7 @@ static int
358rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 367rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
359 unsigned long arg) 368 unsigned long arg)
360{ 369{
361 unsigned long flags; 370 unsigned long flags;
362 371
363 switch(cmd) { 372 switch(cmd) {
364 case RTC_RD_TIME: /* read the time/date from RTC */ 373 case RTC_RD_TIME: /* read the time/date from RTC */
@@ -382,7 +391,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
382 return -EPERM; 391 return -EPERM;
383 392
384 if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time))) 393 if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time)))
385 return -EFAULT; 394 return -EFAULT;
386 395
387 yrs = rtc_tm.tm_year + 1900; 396 yrs = rtc_tm.tm_year + 1900;
388 mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */ 397 mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */
@@ -419,7 +428,6 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
419 BIN_TO_BCD(yrs); 428 BIN_TO_BCD(yrs);
420 429
421 local_irq_save(flags); 430 local_irq_save(flags);
422 local_irq_disable();
423 CMOS_WRITE(yrs, RTC_YEAR); 431 CMOS_WRITE(yrs, RTC_YEAR);
424 CMOS_WRITE(mon, RTC_MONTH); 432 CMOS_WRITE(mon, RTC_MONTH);
425 CMOS_WRITE(day, RTC_DAY_OF_MONTH); 433 CMOS_WRITE(day, RTC_DAY_OF_MONTH);
@@ -438,7 +446,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
438 446
439 case RTC_SET_CHARGE: /* set the RTC TRICKLE CHARGE register */ 447 case RTC_SET_CHARGE: /* set the RTC TRICKLE CHARGE register */
440 { 448 {
441 int tcs_val; 449 int tcs_val;
442 450
443 if (!capable(CAP_SYS_TIME)) 451 if (!capable(CAP_SYS_TIME))
444 return -EPERM; 452 return -EPERM;
@@ -492,8 +500,8 @@ print_rtc_status(void)
492/* The various file operations we support. */ 500/* The various file operations we support. */
493 501
494static struct file_operations rtc_fops = { 502static struct file_operations rtc_fops = {
495 .owner = THIS_MODULE, 503 .owner = THIS_MODULE,
496 .ioctl = rtc_ioctl, 504 .ioctl = rtc_ioctl,
497}; 505};
498 506
499/* Probe for the chip by writing something to its RAM and try reading it back. */ 507/* Probe for the chip by writing something to its RAM and try reading it back. */
@@ -532,7 +540,7 @@ ds1302_probe(void)
532 "PB", 540 "PB",
533#endif 541#endif
534 CONFIG_ETRAX_DS1302_RSTBIT); 542 CONFIG_ETRAX_DS1302_RSTBIT);
535 print_rtc_status(); 543 print_rtc_status();
536 retval = 1; 544 retval = 1;
537 } else { 545 } else {
538 stop(); 546 stop();
@@ -548,7 +556,9 @@ ds1302_probe(void)
548int __init 556int __init
549ds1302_init(void) 557ds1302_init(void)
550{ 558{
559#ifdef CONFIG_ETRAX_I2C
551 i2c_init(); 560 i2c_init();
561#endif
552 562
553 if (!ds1302_probe()) { 563 if (!ds1302_probe()) {
554#ifdef CONFIG_ETRAX_DS1302_RST_ON_GENERIC_PORT 564#ifdef CONFIG_ETRAX_DS1302_RST_ON_GENERIC_PORT
@@ -558,25 +568,42 @@ ds1302_init(void)
558 * 568 *
559 * Make sure that R_GEN_CONFIG is setup correct. 569 * Make sure that R_GEN_CONFIG is setup correct.
560 */ 570 */
561 genconfig_shadow = ((genconfig_shadow & 571 /* Allocating the ATA interface will grab almost all
562 ~IO_MASK(R_GEN_CONFIG, ata)) | 572 * pins in I/O groups a, b, c and d. A consequence of
563 (IO_STATE(R_GEN_CONFIG, ata, select))); 573 * allocating the ATA interface is that the fixed
564 *R_GEN_CONFIG = genconfig_shadow; 574 * interfaces shared RAM, parallel port 0, parallel
575 * port 1, parallel port W, SCSI-8 port 0, SCSI-8 port
576 * 1, SCSI-W, serial port 2, serial port 3,
577 * synchronous serial port 3 and USB port 2 and almost
578 * all GPIO pins on port g cannot be used.
579 */
580 if (cris_request_io_interface(if_ata, "ds1302/ATA")) {
581 printk(KERN_WARNING "ds1302: Failed to get IO interface\n");
582 return -1;
583 }
584
565#elif CONFIG_ETRAX_DS1302_RSTBIT == 0 585#elif CONFIG_ETRAX_DS1302_RSTBIT == 0
566 586 if (cris_io_interface_allocate_pins(if_gpio_grp_a,
567 /* Set the direction of this bit to out. */ 587 'g',
568 genconfig_shadow = ((genconfig_shadow & 588 CONFIG_ETRAX_DS1302_RSTBIT,
569 ~IO_MASK(R_GEN_CONFIG, g0dir)) | 589 CONFIG_ETRAX_DS1302_RSTBIT)) {
570 (IO_STATE(R_GEN_CONFIG, g0dir, out))); 590 printk(KERN_WARNING "ds1302: Failed to get IO interface\n");
571 *R_GEN_CONFIG = genconfig_shadow; 591 return -1;
592 }
593
594 /* Set the direction of this bit to out. */
595 genconfig_shadow = ((genconfig_shadow &
596 ~IO_MASK(R_GEN_CONFIG, g0dir)) |
597 (IO_STATE(R_GEN_CONFIG, g0dir, out)));
598 *R_GEN_CONFIG = genconfig_shadow;
572#endif 599#endif
573 if (!ds1302_probe()) { 600 if (!ds1302_probe()) {
574 printk(KERN_WARNING "%s: RTC not found.\n", ds1302_name); 601 printk(KERN_WARNING "%s: RTC not found.\n", ds1302_name);
575 return -1; 602 return -1;
576 } 603 }
577#else 604#else
578 printk(KERN_WARNING "%s: RTC not found.\n", ds1302_name); 605 printk(KERN_WARNING "%s: RTC not found.\n", ds1302_name);
579 return -1; 606 return -1;
580#endif 607#endif
581 } 608 }
582 /* Initialise trickle charger */ 609 /* Initialise trickle charger */