ints.c 4.0 KB

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