intersil.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/intersil.h>
  16. #include <asm/machdep.h>
  17. #include "sun3.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. /* get/set hwclock */
  22. int sun3_hwclk(int set, struct rtc_time *t)
  23. {
  24. volatile struct intersil_dt *todintersil;
  25. unsigned long flags;
  26. todintersil = (struct intersil_dt *) &intersil_clock->counter;
  27. local_irq_save(flags);
  28. intersil_clock->cmd_reg = STOP_VAL;
  29. /* set or read the clock */
  30. if(set) {
  31. todintersil->csec = 0;
  32. todintersil->hour = t->tm_hour;
  33. todintersil->minute = t->tm_min;
  34. todintersil->second = t->tm_sec;
  35. todintersil->month = t->tm_mon + 1;
  36. todintersil->day = t->tm_mday;
  37. todintersil->year = (t->tm_year - 68) % 100;
  38. todintersil->weekday = t->tm_wday;
  39. } else {
  40. /* read clock */
  41. t->tm_sec = todintersil->csec;
  42. t->tm_hour = todintersil->hour;
  43. t->tm_min = todintersil->minute;
  44. t->tm_sec = todintersil->second;
  45. t->tm_mon = todintersil->month - 1;
  46. t->tm_mday = todintersil->day;
  47. t->tm_year = todintersil->year + 68;
  48. t->tm_wday = todintersil->weekday;
  49. if (t->tm_year < 70)
  50. t->tm_year += 100;
  51. }
  52. intersil_clock->cmd_reg = START_VAL;
  53. local_irq_restore(flags);
  54. return 0;
  55. }