time.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * linux/arch/m68k/sun3x/time.c
  3. *
  4. * Sun3x-specific time handling
  5. */
  6. #include <linux/types.h>
  7. #include <linux/kd.h>
  8. #include <linux/init.h>
  9. #include <linux/sched.h>
  10. #include <linux/kernel_stat.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/rtc.h>
  13. #include <linux/bcd.h>
  14. #include <asm/irq.h>
  15. #include <asm/io.h>
  16. #include <asm/traps.h>
  17. #include <asm/sun3x.h>
  18. #include <asm/sun3ints.h>
  19. #include <asm/rtc.h>
  20. #include "time.h"
  21. #define M_CONTROL 0xf8
  22. #define M_SEC 0xf9
  23. #define M_MIN 0xfa
  24. #define M_HOUR 0xfb
  25. #define M_DAY 0xfc
  26. #define M_DATE 0xfd
  27. #define M_MONTH 0xfe
  28. #define M_YEAR 0xff
  29. #define C_WRITE 0x80
  30. #define C_READ 0x40
  31. #define C_SIGN 0x20
  32. #define C_CALIB 0x1f
  33. int sun3x_hwclk(int set, struct rtc_time *t)
  34. {
  35. volatile struct mostek_dt *h =
  36. (struct mostek_dt *)(SUN3X_EEPROM+M_CONTROL);
  37. unsigned long flags;
  38. local_irq_save(flags);
  39. if(set) {
  40. h->csr |= C_WRITE;
  41. h->sec = bin2bcd(t->tm_sec);
  42. h->min = bin2bcd(t->tm_min);
  43. h->hour = bin2bcd(t->tm_hour);
  44. h->wday = bin2bcd(t->tm_wday);
  45. h->mday = bin2bcd(t->tm_mday);
  46. h->month = bin2bcd(t->tm_mon);
  47. h->year = bin2bcd(t->tm_year);
  48. h->csr &= ~C_WRITE;
  49. } else {
  50. h->csr |= C_READ;
  51. t->tm_sec = bcd2bin(h->sec);
  52. t->tm_min = bcd2bin(h->min);
  53. t->tm_hour = bcd2bin(h->hour);
  54. t->tm_wday = bcd2bin(h->wday);
  55. t->tm_mday = bcd2bin(h->mday);
  56. t->tm_mon = bcd2bin(h->month);
  57. t->tm_year = bcd2bin(h->year);
  58. h->csr &= ~C_READ;
  59. }
  60. local_irq_restore(flags);
  61. return 0;
  62. }
  63. /* Not much we can do here */
  64. u32 sun3x_gettimeoffset(void)
  65. {
  66. return 0L;
  67. }
  68. #if 0
  69. static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
  70. {
  71. void (*vector)(int, void *, struct pt_regs *) = dev_id;
  72. /* Clear the pending interrupt - pulse the enable line low */
  73. disable_irq(5);
  74. enable_irq(5);
  75. vector(irq, NULL, regs);
  76. }
  77. #endif
  78. void __init sun3x_sched_init(irq_handler_t vector)
  79. {
  80. sun3_disable_interrupts();
  81. /* Pulse enable low to get the clock started */
  82. sun3_disable_irq(5);
  83. sun3_enable_irq(5);
  84. sun3_enable_interrupts();
  85. }