intersil.c 1.7 KB

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