intersil.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /* does this need to be implemented? */
  21. u32 sun3_gettimeoffset(void)
  22. {
  23. return 1000;
  24. }
  25. /* get/set hwclock */
  26. int sun3_hwclk(int set, struct rtc_time *t)
  27. {
  28. volatile struct intersil_dt *todintersil;
  29. unsigned long flags;
  30. todintersil = (struct intersil_dt *) &intersil_clock->counter;
  31. local_irq_save(flags);
  32. intersil_clock->cmd_reg = STOP_VAL;
  33. /* set or read the clock */
  34. if(set) {
  35. todintersil->csec = 0;
  36. todintersil->hour = t->tm_hour;
  37. todintersil->minute = t->tm_min;
  38. todintersil->second = t->tm_sec;
  39. todintersil->month = t->tm_mon;
  40. todintersil->day = t->tm_mday;
  41. todintersil->year = t->tm_year - 68;
  42. todintersil->weekday = t->tm_wday;
  43. } else {
  44. /* read clock */
  45. t->tm_sec = todintersil->csec;
  46. t->tm_hour = todintersil->hour;
  47. t->tm_min = todintersil->minute;
  48. t->tm_sec = todintersil->second;
  49. t->tm_mon = todintersil->month;
  50. t->tm_mday = todintersil->day;
  51. t->tm_year = todintersil->year + 68;
  52. t->tm_wday = todintersil->weekday;
  53. }
  54. intersil_clock->cmd_reg = START_VAL;
  55. local_irq_restore(flags);
  56. return 0;
  57. }