ints.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. * 07/03/96: Timer initialization, and thus mach_sched_init(),
  9. * removed from request_irq() and moved to init_time().
  10. * We should therefore consider renaming our add_isr() and
  11. * remove_isr() to request_irq() and free_irq()
  12. * respectively, so they are compliant with the other
  13. * architectures. /Jes
  14. * 11/07/96: Changed all add_/remove_isr() to request_/free_irq() calls.
  15. * Removed irq list support, if any machine needs an irq server
  16. * it must implement this itself (as it's already done), instead
  17. * only default handler are used with mach_default_handler.
  18. * request_irq got some flags different from other architectures:
  19. * - IRQ_FLG_REPLACE : Replace an existing handler (the default one
  20. * can be replaced without this flag)
  21. * - IRQ_FLG_LOCK : handler can't be replaced
  22. * There are other machine depending flags, see there
  23. * If you want to replace a default handler you should know what
  24. * you're doing, since it might handle different other irq sources
  25. * which must be served /Roman Zippel
  26. */
  27. #include <linux/config.h>
  28. #include <linux/module.h>
  29. #include <linux/types.h>
  30. #include <linux/sched.h>
  31. #include <linux/kernel_stat.h>
  32. #include <linux/errno.h>
  33. #include <linux/init.h>
  34. #include <asm/setup.h>
  35. #include <asm/system.h>
  36. #include <asm/irq.h>
  37. #include <asm/traps.h>
  38. #include <asm/page.h>
  39. #include <asm/machdep.h>
  40. #ifdef CONFIG_Q40
  41. #include <asm/q40ints.h>
  42. #endif
  43. /* table for system interrupt handlers */
  44. static irq_handler_t irq_list[SYS_IRQS];
  45. static const char *default_names[SYS_IRQS] = {
  46. [0] = "spurious int",
  47. [1] = "int1 handler",
  48. [2] = "int2 handler",
  49. [3] = "int3 handler",
  50. [4] = "int4 handler",
  51. [5] = "int5 handler",
  52. [6] = "int6 handler",
  53. [7] = "int7 handler"
  54. };
  55. /* The number of spurious interrupts */
  56. volatile unsigned int num_spurious;
  57. #define NUM_IRQ_NODES 100
  58. static irq_node_t nodes[NUM_IRQ_NODES];
  59. static void dummy_enable_irq(unsigned int irq);
  60. static void dummy_disable_irq(unsigned int irq);
  61. static int dummy_request_irq(unsigned int irq,
  62. irqreturn_t (*handler) (int, void *, struct pt_regs *),
  63. unsigned long flags, const char *devname, void *dev_id);
  64. static void dummy_free_irq(unsigned int irq, void *dev_id);
  65. void (*enable_irq) (unsigned int) = dummy_enable_irq;
  66. void (*disable_irq) (unsigned int) = dummy_disable_irq;
  67. int (*mach_request_irq) (unsigned int, irqreturn_t (*)(int, void *, struct pt_regs *),
  68. unsigned long, const char *, void *) = dummy_request_irq;
  69. void (*mach_free_irq) (unsigned int, void *) = dummy_free_irq;
  70. void init_irq_proc(void);
  71. /*
  72. * void init_IRQ(void)
  73. *
  74. * Parameters: None
  75. *
  76. * Returns: Nothing
  77. *
  78. * This function should be called during kernel startup to initialize
  79. * the IRQ handling routines.
  80. */
  81. void __init init_IRQ(void)
  82. {
  83. int i;
  84. for (i = 0; i < SYS_IRQS; i++) {
  85. if (mach_default_handler)
  86. irq_list[i].handler = (*mach_default_handler)[i];
  87. irq_list[i].flags = 0;
  88. irq_list[i].dev_id = NULL;
  89. irq_list[i].devname = default_names[i];
  90. }
  91. for (i = 0; i < NUM_IRQ_NODES; i++)
  92. nodes[i].handler = NULL;
  93. mach_init_IRQ ();
  94. }
  95. irq_node_t *new_irq_node(void)
  96. {
  97. irq_node_t *node;
  98. short i;
  99. for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
  100. if (!node->handler)
  101. return node;
  102. printk ("new_irq_node: out of nodes\n");
  103. return NULL;
  104. }
  105. /*
  106. * We will keep these functions until I have convinced Linus to move
  107. * the declaration of them from include/linux/sched.h to
  108. * include/asm/irq.h.
  109. */
  110. int request_irq(unsigned int irq,
  111. irqreturn_t (*handler) (int, void *, struct pt_regs *),
  112. unsigned long flags, const char *devname, void *dev_id)
  113. {
  114. return mach_request_irq(irq, handler, flags, devname, dev_id);
  115. }
  116. EXPORT_SYMBOL(request_irq);
  117. void free_irq(unsigned int irq, void *dev_id)
  118. {
  119. mach_free_irq(irq, dev_id);
  120. }
  121. EXPORT_SYMBOL(free_irq);
  122. int cpu_request_irq(unsigned int irq,
  123. irqreturn_t (*handler)(int, void *, struct pt_regs *),
  124. unsigned long flags, const char *devname, void *dev_id)
  125. {
  126. if (irq < IRQ1 || irq > IRQ7) {
  127. printk("%s: Incorrect IRQ %d from %s\n",
  128. __FUNCTION__, irq, devname);
  129. return -ENXIO;
  130. }
  131. #if 0
  132. if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
  133. if (irq_list[irq].flags & IRQ_FLG_LOCK) {
  134. printk("%s: IRQ %d from %s is not replaceable\n",
  135. __FUNCTION__, irq, irq_list[irq].devname);
  136. return -EBUSY;
  137. }
  138. if (!(flags & IRQ_FLG_REPLACE)) {
  139. printk("%s: %s can't replace IRQ %d from %s\n",
  140. __FUNCTION__, devname, irq, irq_list[irq].devname);
  141. return -EBUSY;
  142. }
  143. }
  144. #endif
  145. irq_list[irq].handler = handler;
  146. irq_list[irq].flags = flags;
  147. irq_list[irq].dev_id = dev_id;
  148. irq_list[irq].devname = devname;
  149. return 0;
  150. }
  151. void cpu_free_irq(unsigned int irq, void *dev_id)
  152. {
  153. if (irq < IRQ1 || irq > IRQ7) {
  154. printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
  155. return;
  156. }
  157. if (irq_list[irq].dev_id != dev_id)
  158. printk("%s: Removing probably wrong IRQ %d from %s\n",
  159. __FUNCTION__, irq, irq_list[irq].devname);
  160. irq_list[irq].handler = (*mach_default_handler)[irq];
  161. irq_list[irq].flags = 0;
  162. irq_list[irq].dev_id = NULL;
  163. irq_list[irq].devname = default_names[irq];
  164. }
  165. /*
  166. * Do we need these probe functions on the m68k?
  167. *
  168. * ... may be useful with ISA devices
  169. */
  170. unsigned long probe_irq_on (void)
  171. {
  172. #ifdef CONFIG_Q40
  173. if (MACH_IS_Q40)
  174. return q40_probe_irq_on();
  175. #endif
  176. return 0;
  177. }
  178. EXPORT_SYMBOL(probe_irq_on);
  179. int probe_irq_off (unsigned long irqs)
  180. {
  181. #ifdef CONFIG_Q40
  182. if (MACH_IS_Q40)
  183. return q40_probe_irq_off(irqs);
  184. #endif
  185. return 0;
  186. }
  187. EXPORT_SYMBOL(probe_irq_off);
  188. static void dummy_enable_irq(unsigned int irq)
  189. {
  190. printk("calling uninitialized enable_irq()\n");
  191. }
  192. static void dummy_disable_irq(unsigned int irq)
  193. {
  194. printk("calling uninitialized disable_irq()\n");
  195. }
  196. static int dummy_request_irq(unsigned int irq,
  197. irqreturn_t (*handler) (int, void *, struct pt_regs *),
  198. unsigned long flags, const char *devname, void *dev_id)
  199. {
  200. printk("calling uninitialized request_irq()\n");
  201. return 0;
  202. }
  203. static void dummy_free_irq(unsigned int irq, void *dev_id)
  204. {
  205. printk("calling uninitialized disable_irq()\n");
  206. }
  207. asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
  208. {
  209. if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
  210. vec -= VEC_SPUR;
  211. kstat_cpu(0).irqs[vec]++;
  212. irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
  213. } else {
  214. if (mach_process_int)
  215. mach_process_int(vec, fp);
  216. else
  217. panic("Can't process interrupt vector %ld\n", vec);
  218. return;
  219. }
  220. }
  221. int show_interrupts(struct seq_file *p, void *v)
  222. {
  223. int i = *(loff_t *) v;
  224. /* autovector interrupts */
  225. if (i < SYS_IRQS) {
  226. if (mach_default_handler) {
  227. seq_printf(p, "auto %2d: %10u ", i,
  228. i ? kstat_cpu(0).irqs[i] : num_spurious);
  229. seq_puts(p, " ");
  230. seq_printf(p, "%s\n", irq_list[i].devname);
  231. }
  232. } else if (i == SYS_IRQS)
  233. mach_get_irq_list(p, v);
  234. return 0;
  235. }
  236. void init_irq_proc(void)
  237. {
  238. /* Insert /proc/irq driver here */
  239. }