timer.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * linux/arch/h8300/platform/h8300h/generic/timer.c
  3. *
  4. * Yoshinori Sato <ysato@users.sourceforge.jp>
  5. *
  6. * Platform depend Timer Handler
  7. *
  8. */
  9. #include <linux/config.h>
  10. #include <linux/errno.h>
  11. #include <linux/sched.h>
  12. #include <linux/kernel.h>
  13. #include <linux/param.h>
  14. #include <linux/string.h>
  15. #include <linux/mm.h>
  16. #include <linux/interrupt.h>
  17. #include <asm/segment.h>
  18. #include <asm/io.h>
  19. #include <asm/irq.h>
  20. #include <linux/timex.h>
  21. #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
  22. #include <asm/regs306x.h>
  23. #define CMFA 6
  24. #define CMIEA 0x40
  25. #define CCLR_CMA 0x08
  26. #define CLK_DIV8192 0x03
  27. #define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
  28. void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
  29. {
  30. /* setup 8bit timer ch2 */
  31. ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
  32. ctrl_outb(0x00, _8TCSR2); /* no output */
  33. request_irq(40, timer_int, 0, "timer", 0);
  34. ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
  35. }
  36. void platform_timer_eoi(void)
  37. {
  38. *(volatile unsigned char *)_8TCSR2 &= ~(1 << CMFA);
  39. }
  40. #endif
  41. #if defined(CONFIG_H83002) || defined(CONFIG_H83048)
  42. /* FIXME! */
  43. #define TSTR 0x00ffff60
  44. #define TSNC 0x00ffff61
  45. #define TMDR 0x00ffff62
  46. #define TFCR 0x00ffff63
  47. #define TOER 0x00ffff90
  48. #define TOCR 0x00ffff91
  49. /* ITU0 */
  50. #define TCR 0x00ffff64
  51. #define TIOR 0x00ffff65
  52. #define TIER 0x00ffff66
  53. #define TSR 0x00ffff67
  54. #define TCNT 0x00ffff68
  55. #define GRA 0x00ffff6a
  56. #define GRB 0x00ffff6c
  57. #define CCLR_CMGRA 0x20
  58. #define CLK_DIV8 0x03
  59. #define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8 /* Timer input freq. */
  60. void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
  61. {
  62. *(unsigned short *)GRA= H8300_TIMER_FREQ / HZ; /* set interval */
  63. *(unsigned short *)TCNT=0; /* clear counter */
  64. ctrl_outb(0x80|CCLR_CMGRA|CLK_DIV8, TCR); /* set ITU0 clock */
  65. ctrl_outb(0x88, TIOR); /* no output */
  66. request_irq(26, timer_int, 0, "timer", 0);
  67. ctrl_outb(0xf9, TIER); /* compare match GRA interrupt */
  68. ctrl_outb(ctrl_inb(TSNC) & ~0x01, TSNC); /* ITU0 async */
  69. ctrl_outb(ctrl_inb(TMDR) & ~0x01, TMDR); /* ITU0 normal mode */
  70. ctrl_outb(ctrl_inb(TSTR) | 0x01, TSTR); /* ITU0 Start */
  71. return 0;
  72. }
  73. void platform_timer_eoi(void)
  74. {
  75. ctrl_outb(ctrl_inb(TSR) & ~0x01,TSR);
  76. }
  77. #endif
  78. void platform_gettod(int *year, int *mon, int *day, int *hour,
  79. int *min, int *sec)
  80. {
  81. *year = *mon = *day = *hour = *min = *sec = 0;
  82. }