time.c 2.2 KB

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