timer.c 2.5 KB

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