ints.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file COPYING in the main directory of this archive
  6. * for more details.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/sched.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/errno.h>
  13. #include <linux/init.h>
  14. #include <linux/irq.h>
  15. #include <asm/setup.h>
  16. #include <asm/irq.h>
  17. #include <asm/traps.h>
  18. #include <asm/page.h>
  19. #include <asm/machdep.h>
  20. #include <asm/cacheflush.h>
  21. #include <asm/irq_regs.h>
  22. #ifdef CONFIG_Q40
  23. #include <asm/q40ints.h>
  24. #endif
  25. extern u32 auto_irqhandler_fixup[];
  26. extern u16 user_irqvec_fixup[];
  27. static int m68k_first_user_vec;
  28. static struct irq_chip auto_irq_chip = {
  29. .name = "auto",
  30. .irq_startup = m68k_irq_startup,
  31. .irq_shutdown = m68k_irq_shutdown,
  32. };
  33. static struct irq_chip user_irq_chip = {
  34. .name = "user",
  35. .irq_startup = m68k_irq_startup,
  36. .irq_shutdown = m68k_irq_shutdown,
  37. };
  38. /*
  39. * void init_IRQ(void)
  40. *
  41. * Parameters: None
  42. *
  43. * Returns: Nothing
  44. *
  45. * This function should be called during kernel startup to initialize
  46. * the IRQ handling routines.
  47. */
  48. void __init init_IRQ(void)
  49. {
  50. int i;
  51. for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
  52. irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
  53. mach_init_IRQ();
  54. }
  55. /**
  56. * m68k_setup_auto_interrupt
  57. * @handler: called from auto vector interrupts
  58. *
  59. * setup the handler to be called from auto vector interrupts instead of the
  60. * standard do_IRQ(), it will be called with irq numbers in the range
  61. * from IRQ_AUTO_1 - IRQ_AUTO_7.
  62. */
  63. void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
  64. {
  65. if (handler)
  66. *auto_irqhandler_fixup = (u32)handler;
  67. flush_icache();
  68. }
  69. /**
  70. * m68k_setup_user_interrupt
  71. * @vec: first user vector interrupt to handle
  72. * @cnt: number of active user vector interrupts
  73. *
  74. * setup user vector interrupts, this includes activating the specified range
  75. * of interrupts, only then these interrupts can be requested (note: this is
  76. * different from auto vector interrupts).
  77. */
  78. void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt)
  79. {
  80. int i;
  81. BUG_ON(IRQ_USER + cnt > NR_IRQS);
  82. m68k_first_user_vec = vec;
  83. for (i = 0; i < cnt; i++)
  84. irq_set_chip_and_handler(i, &user_irq_chip, handle_simple_irq);
  85. *user_irqvec_fixup = vec - IRQ_USER;
  86. flush_icache();
  87. }
  88. /**
  89. * m68k_setup_irq_controller
  90. * @chip: irq chip which controls specified irq
  91. * @handle: flow handler which handles specified irq
  92. * @irq: first irq to be managed by the controller
  93. * @cnt: number of irqs to be managed by the controller
  94. *
  95. * Change the controller for the specified range of irq, which will be used to
  96. * manage these irq. auto/user irq already have a default controller, which can
  97. * be changed as well, but the controller probably should use m68k_irq_startup/
  98. * m68k_irq_shutdown.
  99. */
  100. void m68k_setup_irq_controller(struct irq_chip *chip,
  101. irq_flow_handler_t handle, unsigned int irq,
  102. unsigned int cnt)
  103. {
  104. int i;
  105. for (i = 0; i < cnt; i++) {
  106. irq_set_chip(irq + i, chip);
  107. if (handle)
  108. irq_set_handler(irq + i, handle);
  109. }
  110. }
  111. unsigned int m68k_irq_startup_irq(unsigned int irq)
  112. {
  113. if (irq <= IRQ_AUTO_7)
  114. vectors[VEC_SPUR + irq] = auto_inthandler;
  115. else
  116. vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
  117. return 0;
  118. }
  119. unsigned int m68k_irq_startup(struct irq_data *data)
  120. {
  121. return m68k_irq_startup_irq(data->irq);
  122. }
  123. void m68k_irq_shutdown(struct irq_data *data)
  124. {
  125. unsigned int irq = data->irq;
  126. if (irq <= IRQ_AUTO_7)
  127. vectors[VEC_SPUR + irq] = bad_inthandler;
  128. else
  129. vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
  130. }
  131. unsigned int irq_canonicalize(unsigned int irq)
  132. {
  133. #ifdef CONFIG_Q40
  134. if (MACH_IS_Q40 && irq == 11)
  135. irq = 10;
  136. #endif
  137. return irq;
  138. }
  139. EXPORT_SYMBOL(irq_canonicalize);
  140. asmlinkage void handle_badint(struct pt_regs *regs)
  141. {
  142. atomic_inc(&irq_err_count);
  143. pr_warn("unexpected interrupt from %u\n", regs->vector);
  144. }