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