18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * arch/m68k/sun3/intersil.c 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * basic routines for accessing the intersil clock within the sun3 machines 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * started 11/12/1999 Sam Creasey 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 98c2ecf20Sopenharmony_ci * License. See the file COPYING in the main directory of this archive 108c2ecf20Sopenharmony_ci * for more details. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/kernel.h> 148c2ecf20Sopenharmony_ci#include <linux/rtc.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <asm/errno.h> 178c2ecf20Sopenharmony_ci#include <asm/intersil.h> 188c2ecf20Sopenharmony_ci#include <asm/machdep.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* bits to set for start/run of the intersil */ 228c2ecf20Sopenharmony_ci#define STOP_VAL (INTERSIL_STOP | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE) 238c2ecf20Sopenharmony_ci#define START_VAL (INTERSIL_RUN | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* get/set hwclock */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciint sun3_hwclk(int set, struct rtc_time *t) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci volatile struct intersil_dt *todintersil; 308c2ecf20Sopenharmony_ci unsigned long flags; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci todintersil = (struct intersil_dt *) &intersil_clock->counter; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci local_irq_save(flags); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci intersil_clock->cmd_reg = STOP_VAL; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci /* set or read the clock */ 398c2ecf20Sopenharmony_ci if(set) { 408c2ecf20Sopenharmony_ci todintersil->csec = 0; 418c2ecf20Sopenharmony_ci todintersil->hour = t->tm_hour; 428c2ecf20Sopenharmony_ci todintersil->minute = t->tm_min; 438c2ecf20Sopenharmony_ci todintersil->second = t->tm_sec; 448c2ecf20Sopenharmony_ci todintersil->month = t->tm_mon + 1; 458c2ecf20Sopenharmony_ci todintersil->day = t->tm_mday; 468c2ecf20Sopenharmony_ci todintersil->year = (t->tm_year - 68) % 100; 478c2ecf20Sopenharmony_ci todintersil->weekday = t->tm_wday; 488c2ecf20Sopenharmony_ci } else { 498c2ecf20Sopenharmony_ci /* read clock */ 508c2ecf20Sopenharmony_ci t->tm_sec = todintersil->csec; 518c2ecf20Sopenharmony_ci t->tm_hour = todintersil->hour; 528c2ecf20Sopenharmony_ci t->tm_min = todintersil->minute; 538c2ecf20Sopenharmony_ci t->tm_sec = todintersil->second; 548c2ecf20Sopenharmony_ci t->tm_mon = todintersil->month - 1; 558c2ecf20Sopenharmony_ci t->tm_mday = todintersil->day; 568c2ecf20Sopenharmony_ci t->tm_year = todintersil->year + 68; 578c2ecf20Sopenharmony_ci t->tm_wday = todintersil->weekday; 588c2ecf20Sopenharmony_ci if (t->tm_year < 70) 598c2ecf20Sopenharmony_ci t->tm_year += 100; 608c2ecf20Sopenharmony_ci } 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci intersil_clock->cmd_reg = START_VAL; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci local_irq_restore(flags); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci return 0; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 70