ints.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. /* assembly irq entry code relies on this... */
  85. if (HARDIRQ_MASK != 0x00ff0000) {
  86. extern void hardirq_mask_is_broken(void);
  87. hardirq_mask_is_broken();
  88. }
  89. for (i = 0; i < SYS_IRQS; i++) {
  90. if (mach_default_handler)
  91. irq_list[i].handler = (*mach_default_handler)[i];
  92. irq_list[i].flags = 0;
  93. irq_list[i].dev_id = NULL;
  94. irq_list[i].devname = default_names[i];
  95. }
  96. for (i = 0; i < NUM_IRQ_NODES; i++)
  97. nodes[i].handler = NULL;
  98. mach_init_IRQ ();
  99. }
  100. irq_node_t *new_irq_node(void)
  101. {
  102. irq_node_t *node;
  103. short i;
  104. for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
  105. if (!node->handler)
  106. return node;
  107. printk ("new_irq_node: out of nodes\n");
  108. return NULL;
  109. }
  110. /*
  111. * We will keep these functions until I have convinced Linus to move
  112. * the declaration of them from include/linux/sched.h to
  113. * include/asm/irq.h.
  114. */
  115. int request_irq(unsigned int irq,
  116. irqreturn_t (*handler) (int, void *, struct pt_regs *),
  117. unsigned long flags, const char *devname, void *dev_id)
  118. {
  119. return mach_request_irq(irq, handler, flags, devname, dev_id);
  120. }
  121. EXPORT_SYMBOL(request_irq);
  122. void free_irq(unsigned int irq, void *dev_id)
  123. {
  124. mach_free_irq(irq, dev_id);
  125. }
  126. EXPORT_SYMBOL(free_irq);
  127. int cpu_request_irq(unsigned int irq,
  128. irqreturn_t (*handler)(int, void *, struct pt_regs *),
  129. unsigned long flags, const char *devname, void *dev_id)
  130. {
  131. if (irq < IRQ_AUTO_1 || irq > IRQ_AUTO_7) {
  132. printk("%s: Incorrect IRQ %d from %s\n",
  133. __FUNCTION__, irq, devname);
  134. return -ENXIO;
  135. }
  136. #if 0
  137. if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
  138. if (irq_list[irq].flags & IRQ_FLG_LOCK) {
  139. printk("%s: IRQ %d from %s is not replaceable\n",
  140. __FUNCTION__, irq, irq_list[irq].devname);
  141. return -EBUSY;
  142. }
  143. if (!(flags & IRQ_FLG_REPLACE)) {
  144. printk("%s: %s can't replace IRQ %d from %s\n",
  145. __FUNCTION__, devname, irq, irq_list[irq].devname);
  146. return -EBUSY;
  147. }
  148. }
  149. #endif
  150. irq_list[irq].handler = handler;
  151. irq_list[irq].flags = flags;
  152. irq_list[irq].dev_id = dev_id;
  153. irq_list[irq].devname = devname;
  154. return 0;
  155. }
  156. void cpu_free_irq(unsigned int irq, void *dev_id)
  157. {
  158. if (irq < IRQ_AUTO_1 || irq > IRQ_AUTO_7) {
  159. printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
  160. return;
  161. }
  162. if (irq_list[irq].dev_id != dev_id)
  163. printk("%s: Removing probably wrong IRQ %d from %s\n",
  164. __FUNCTION__, irq, irq_list[irq].devname);
  165. irq_list[irq].handler = (*mach_default_handler)[irq];
  166. irq_list[irq].flags = 0;
  167. irq_list[irq].dev_id = NULL;
  168. irq_list[irq].devname = default_names[irq];
  169. }
  170. /*
  171. * Do we need these probe functions on the m68k?
  172. *
  173. * ... may be useful with ISA devices
  174. */
  175. unsigned long probe_irq_on (void)
  176. {
  177. #ifdef CONFIG_Q40
  178. if (MACH_IS_Q40)
  179. return q40_probe_irq_on();
  180. #endif
  181. return 0;
  182. }
  183. EXPORT_SYMBOL(probe_irq_on);
  184. int probe_irq_off (unsigned long irqs)
  185. {
  186. #ifdef CONFIG_Q40
  187. if (MACH_IS_Q40)
  188. return q40_probe_irq_off(irqs);
  189. #endif
  190. return 0;
  191. }
  192. EXPORT_SYMBOL(probe_irq_off);
  193. static void dummy_enable_irq(unsigned int irq)
  194. {
  195. printk("calling uninitialized enable_irq()\n");
  196. }
  197. static void dummy_disable_irq(unsigned int irq)
  198. {
  199. printk("calling uninitialized disable_irq()\n");
  200. }
  201. static int dummy_request_irq(unsigned int irq,
  202. irqreturn_t (*handler) (int, void *, struct pt_regs *),
  203. unsigned long flags, const char *devname, void *dev_id)
  204. {
  205. printk("calling uninitialized request_irq()\n");
  206. return 0;
  207. }
  208. static void dummy_free_irq(unsigned int irq, void *dev_id)
  209. {
  210. printk("calling uninitialized disable_irq()\n");
  211. }
  212. asmlinkage void m68k_handle_int(unsigned int irq, struct pt_regs *regs)
  213. {
  214. kstat_cpu(0).irqs[irq]++;
  215. irq_list[irq].handler(irq, irq_list[irq].dev_id, regs);
  216. }
  217. asmlinkage void handle_badint(struct pt_regs *regs)
  218. {
  219. kstat_cpu(0).irqs[0]++;
  220. printk("unexpected interrupt from %u\n", regs->vector);
  221. }
  222. int show_interrupts(struct seq_file *p, void *v)
  223. {
  224. int i = *(loff_t *) v;
  225. /* autovector interrupts */
  226. if (i < SYS_IRQS) {
  227. if (mach_default_handler) {
  228. seq_printf(p, "auto %2d: %10u ", i,
  229. i ? kstat_cpu(0).irqs[i] : num_spurious);
  230. seq_puts(p, " ");
  231. seq_printf(p, "%s\n", irq_list[i].devname);
  232. }
  233. } else if (i == SYS_IRQS)
  234. mach_get_irq_list(p, v);
  235. return 0;
  236. }
  237. void init_irq_proc(void)
  238. {
  239. /* Insert /proc/irq driver here */
  240. }