intersil.c 1.7 KB

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