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