ints.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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/kernel_stat.h>
  13. #include <linux/errno.h>
  14. #include <linux/init.h>
  15. #include <asm/setup.h>
  16. #include <asm/system.h>
  17. #include <asm/irq.h>
  18. #include <asm/traps.h>
  19. #include <asm/page.h>
  20. #include <asm/machdep.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/irq_regs.h>
  23. #ifdef CONFIG_Q40
  24. #include <asm/q40ints.h>
  25. #endif
  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. /* assembly irq entry code relies on this... */
  53. if (HARDIRQ_MASK != 0x00ff0000) {
  54. extern void hardirq_mask_is_broken(void);
  55. hardirq_mask_is_broken();
  56. }
  57. for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
  58. irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
  59. mach_init_IRQ();
  60. }
  61. /**
  62. * m68k_setup_auto_interrupt
  63. * @handler: called from auto vector interrupts
  64. *
  65. * setup the handler to be called from auto vector interrupts instead of the
  66. * standard do_IRQ(), it will be called with irq numbers in the range
  67. * from IRQ_AUTO_1 - IRQ_AUTO_7.
  68. */
  69. void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
  70. {
  71. if (handler)
  72. *auto_irqhandler_fixup = (u32)handler;
  73. flush_icache();
  74. }
  75. /**
  76. * m68k_setup_user_interrupt
  77. * @vec: first user vector interrupt to handle
  78. * @cnt: number of active user vector interrupts
  79. *
  80. * setup user vector interrupts, this includes activating the specified range
  81. * of interrupts, only then these interrupts can be requested (note: this is
  82. * different from auto vector interrupts).
  83. */
  84. void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt)
  85. {
  86. int i;
  87. BUG_ON(IRQ_USER + cnt > NR_IRQS);
  88. m68k_first_user_vec = vec;
  89. for (i = 0; i < cnt; i++)
  90. irq_set_chip(IRQ_USER + i, &user_irq_chip);
  91. *user_irqvec_fixup = vec - IRQ_USER;
  92. flush_icache();
  93. }
  94. /**
  95. * m68k_setup_irq_controller
  96. * @chip: irq chip which controls specified irq
  97. * @handle: flow handler which handles specified irq
  98. * @irq: first irq to be managed by the controller
  99. * @cnt: number of irqs to be managed by the controller
  100. *
  101. * Change the controller for the specified range of irq, which will be used to
  102. * manage these irq. auto/user irq already have a default controller, which can
  103. * be changed as well, but the controller probably should use m68k_irq_startup/
  104. * m68k_irq_shutdown.
  105. */
  106. void m68k_setup_irq_controller(struct irq_chip *chip,
  107. irq_flow_handler_t handle, unsigned int irq,
  108. unsigned int cnt)
  109. {
  110. int i;
  111. for (i = 0; i < cnt; i++) {
  112. irq_set_chip(irq + i, chip);
  113. if (handle)
  114. irq_set_handler(irq + i, handle);
  115. }
  116. }
  117. unsigned int m68k_irq_startup_irq(unsigned int irq)
  118. {
  119. if (irq <= IRQ_AUTO_7)
  120. vectors[VEC_SPUR + irq] = auto_inthandler;
  121. else
  122. vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
  123. return 0;
  124. }
  125. unsigned int m68k_irq_startup(struct irq_data *data)
  126. {
  127. return m68k_irq_startup_irq(data->irq);
  128. }
  129. void m68k_irq_shutdown(struct irq_data *data)
  130. {
  131. unsigned int irq = data->irq;
  132. if (irq <= IRQ_AUTO_7)
  133. vectors[VEC_SPUR + irq] = bad_inthandler;
  134. else
  135. vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
  136. }
  137. unsigned int irq_canonicalize(unsigned int irq)
  138. {
  139. #ifdef CONFIG_Q40
  140. if (MACH_IS_Q40 && irq == 11)
  141. irq = 10;
  142. #endif
  143. return irq;
  144. }
  145. EXPORT_SYMBOL(irq_canonicalize);
  146. asmlinkage void handle_badint(struct pt_regs *regs)
  147. {
  148. atomic_inc(&irq_err_count);
  149. pr_warn("unexpected interrupt from %u\n", regs->vector);
  150. }