itu.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * linux/arch/h8300/kernel/timer/itu.c
  3. *
  4. * Yoshinori Sato <ysato@users.sourcefoge.jp>
  5. *
  6. * ITU 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 <linux/init.h>
  17. #include <linux/timex.h>
  18. #include <asm/segment.h>
  19. #include <asm/io.h>
  20. #include <asm/irq.h>
  21. #include <asm/regs306x.h>
  22. #if CONFIG_H8300_ITU_CH == 0
  23. #define ITUBASE 0xffff64
  24. #define ITUIRQ 24
  25. #elif CONFIG_H8300_ITU_CH == 1
  26. #define ITUBASE 0xffff6e
  27. #define ITUIRQ 28
  28. #elif CONFIG_H8300_ITU_CH == 2
  29. #define ITUBASE 0xffff78
  30. #define ITUIRQ 32
  31. #elif CONFIG_H8300_ITU_CH == 3
  32. #define ITUBASE 0xffff82
  33. #define ITUIRQ 36
  34. #elif CONFIG_H8300_ITU_CH == 4
  35. #define ITUBASE 0xffff92
  36. #define ITUIRQ 40
  37. #else
  38. #error Unknown timer channel.
  39. #endif
  40. #define TCR 0
  41. #define TIOR 1
  42. #define TIER 2
  43. #define TSR 3
  44. #define TCNT 4
  45. #define GRA 6
  46. #define GRB 8
  47. static irqreturn_t timer_interrupt(int irq, void *dev_id)
  48. {
  49. h8300_timer_tick();
  50. ctrl_bclr(IMFA, ITUBASE + TSR);
  51. return IRQ_HANDLED;
  52. }
  53. static struct irqaction itu_irq = {
  54. .name = "itu",
  55. .handler = timer_interrupt,
  56. .flags = IRQF_DISABLED | IRQF_TIMER,
  57. };
  58. static const int __initdata divide_rate[] = {1, 2, 4, 8};
  59. void __init h8300_timer_setup(void)
  60. {
  61. unsigned int div;
  62. unsigned int cnt;
  63. calc_param(cnt, div, divide_rate, 0x10000);
  64. setup_irq(ITUIRQ, &itu_irq);
  65. /* initalize timer */
  66. ctrl_outb(0, TSTR);
  67. ctrl_outb(CCLR0 | div, ITUBASE + TCR);
  68. ctrl_outb(0x01, ITUBASE + TIER);
  69. ctrl_outw(cnt, ITUBASE + GRA);
  70. ctrl_bset(CONFIG_H8300_ITU_CH, TSTR);
  71. }