1 /* 1 /* 2 * arch/m68k/sun3/intersil.c 2 * arch/m68k/sun3/intersil.c 3 * 3 * 4 * basic routines for accessing the intersil c 4 * basic routines for accessing the intersil clock within the sun3 machines 5 * 5 * 6 * started 11/12/1999 Sam Creasey 6 * started 11/12/1999 Sam Creasey 7 * 7 * 8 * This file is subject to the terms and condi 8 * This file is subject to the terms and conditions of the GNU General Public 9 * License. See the file COPYING in the main 9 * License. See the file COPYING in the main directory of this archive 10 * for more details. 10 * for more details. 11 */ 11 */ 12 12 13 #include <linux/kernel.h> 13 #include <linux/kernel.h> 14 #include <linux/rtc.h> 14 #include <linux/rtc.h> 15 15 16 #include <asm/errno.h> 16 #include <asm/errno.h> 17 #include <asm/intersil.h> 17 #include <asm/intersil.h> 18 #include <asm/machdep.h> 18 #include <asm/machdep.h> 19 19 20 #include "sun3.h" 20 #include "sun3.h" 21 21 22 /* bits to set for start/run of the intersil * 22 /* bits to set for start/run of the intersil */ 23 #define STOP_VAL (INTERSIL_STOP | INTERSIL_INT 23 #define STOP_VAL (INTERSIL_STOP | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE) 24 #define START_VAL (INTERSIL_RUN | INTERSIL_INT 24 #define START_VAL (INTERSIL_RUN | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE) 25 25 26 /* get/set hwclock */ 26 /* get/set hwclock */ 27 27 28 int sun3_hwclk(int set, struct rtc_time *t) 28 int sun3_hwclk(int set, struct rtc_time *t) 29 { 29 { 30 volatile struct intersil_dt *todinters 30 volatile struct intersil_dt *todintersil; 31 unsigned long flags; 31 unsigned long flags; 32 32 33 todintersil = (struct intersil_dt *) & 33 todintersil = (struct intersil_dt *) &intersil_clock->counter; 34 34 35 local_irq_save(flags); 35 local_irq_save(flags); 36 36 37 intersil_clock->cmd_reg = STOP_VAL; 37 intersil_clock->cmd_reg = STOP_VAL; 38 38 39 /* set or read the clock */ 39 /* set or read the clock */ 40 if(set) { 40 if(set) { 41 todintersil->csec = 0; 41 todintersil->csec = 0; 42 todintersil->hour = t->tm_hour 42 todintersil->hour = t->tm_hour; 43 todintersil->minute = t->tm_mi 43 todintersil->minute = t->tm_min; 44 todintersil->second = t->tm_se 44 todintersil->second = t->tm_sec; 45 todintersil->month = t->tm_mon 45 todintersil->month = t->tm_mon + 1; 46 todintersil->day = t->tm_mday; 46 todintersil->day = t->tm_mday; 47 todintersil->year = (t->tm_yea 47 todintersil->year = (t->tm_year - 68) % 100; 48 todintersil->weekday = t->tm_w 48 todintersil->weekday = t->tm_wday; 49 } else { 49 } else { 50 /* read clock */ 50 /* read clock */ 51 t->tm_sec = todintersil->csec; 51 t->tm_sec = todintersil->csec; 52 t->tm_hour = todintersil->hour 52 t->tm_hour = todintersil->hour; 53 t->tm_min = todintersil->minut 53 t->tm_min = todintersil->minute; 54 t->tm_sec = todintersil->secon 54 t->tm_sec = todintersil->second; 55 t->tm_mon = todintersil->month 55 t->tm_mon = todintersil->month - 1; 56 t->tm_mday = todintersil->day; 56 t->tm_mday = todintersil->day; 57 t->tm_year = todintersil->year 57 t->tm_year = todintersil->year + 68; 58 t->tm_wday = todintersil->week 58 t->tm_wday = todintersil->weekday; 59 if (t->tm_year < 70) 59 if (t->tm_year < 70) 60 t->tm_year += 100; 60 t->tm_year += 100; 61 } 61 } 62 62 63 intersil_clock->cmd_reg = START_VAL; 63 intersil_clock->cmd_reg = START_VAL; 64 64 65 local_irq_restore(flags); 65 local_irq_restore(flags); 66 66 67 return 0; 67 return 0; 68 68 69 } 69 } 70 70 71 71
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.