timer.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * linux/arch/h8300/platform/h8s/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 <linux/init.h>
  18. #include <linux/timex.h>
  19. #include <asm/segment.h>
  20. #include <asm/io.h>
  21. #include <asm/irq.h>
  22. #include <asm/regs267x.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. /* 8bit timer module enabled */
  31. ctrl_outb(ctrl_inb(MSTPCRL) & ~0x01, MSTPCRL);
  32. /* setup 8bit timer ch1 */
  33. ctrl_outb(H8300_TIMER_FREQ / HZ, _8TCORA1); /* set interval */
  34. ctrl_outb(0x00, _8TCSR1); /* no output */
  35. request_irq(76, timer_int, 0, "timer" ,0);
  36. ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR1); /* start count */
  37. }
  38. void platform_timer_eoi(void)
  39. {
  40. *(volatile unsigned char *)_8TCSR1 &= ~(1 << CMFA);
  41. }
  42. void platform_gettod(int *year, int *mon, int *day, int *hour,
  43. int *min, int *sec)
  44. {
  45. *year = *mon = *day = *hour = *min = *sec = 0;
  46. }