bvmeints.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * arch/m68k/bvme6000/bvmeints.c
  3. *
  4. * Copyright (C) 1997 Richard Hirst [richard@sleepie.demon.co.uk]
  5. *
  6. * based on amiints.c -- Amiga Linux interrupt handling code
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file README.legal in the main directory of this archive
  10. * for more details.
  11. *
  12. */
  13. #include <linux/types.h>
  14. #include <linux/kernel.h>
  15. #include <linux/errno.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/seq_file.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/system.h>
  20. #include <asm/irq.h>
  21. #include <asm/traps.h>
  22. static irqreturn_t bvme6000_defhand (int irq, void *dev_id, struct pt_regs *fp);
  23. /*
  24. * This should ideally be 4 elements only, for speed.
  25. */
  26. static struct {
  27. irqreturn_t (*handler)(int, void *, struct pt_regs *);
  28. unsigned long flags;
  29. void *dev_id;
  30. const char *devname;
  31. unsigned count;
  32. } irq_tab[256];
  33. /*
  34. * void bvme6000_init_IRQ (void)
  35. *
  36. * Parameters: None
  37. *
  38. * Returns: Nothing
  39. *
  40. * This function is called during kernel startup to initialize
  41. * the bvme6000 IRQ handling routines.
  42. */
  43. void bvme6000_init_IRQ (void)
  44. {
  45. int i;
  46. for (i = 0; i < 256; i++) {
  47. irq_tab[i].handler = bvme6000_defhand;
  48. irq_tab[i].flags = IRQ_FLG_STD;
  49. irq_tab[i].dev_id = NULL;
  50. irq_tab[i].devname = NULL;
  51. irq_tab[i].count = 0;
  52. }
  53. }
  54. int bvme6000_request_irq(unsigned int irq,
  55. irqreturn_t (*handler)(int, void *, struct pt_regs *),
  56. unsigned long flags, const char *devname, void *dev_id)
  57. {
  58. if (irq > 255) {
  59. printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname);
  60. return -ENXIO;
  61. }
  62. #if 0
  63. /* Nothing special about auto-vectored devices for the BVME6000,
  64. * but treat it specially to avoid changes elsewhere.
  65. */
  66. if (irq >= VEC_INT1 && irq <= VEC_INT7)
  67. return cpu_request_irq(irq - VEC_SPUR, handler, flags,
  68. devname, dev_id);
  69. #endif
  70. if (!(irq_tab[irq].flags & IRQ_FLG_STD)) {
  71. if (irq_tab[irq].flags & IRQ_FLG_LOCK) {
  72. printk("%s: IRQ %d from %s is not replaceable\n",
  73. __FUNCTION__, irq, irq_tab[irq].devname);
  74. return -EBUSY;
  75. }
  76. if (flags & IRQ_FLG_REPLACE) {
  77. printk("%s: %s can't replace IRQ %d from %s\n",
  78. __FUNCTION__, devname, irq, irq_tab[irq].devname);
  79. return -EBUSY;
  80. }
  81. }
  82. irq_tab[irq].handler = handler;
  83. irq_tab[irq].flags = flags;
  84. irq_tab[irq].dev_id = dev_id;
  85. irq_tab[irq].devname = devname;
  86. return 0;
  87. }
  88. void bvme6000_free_irq(unsigned int irq, void *dev_id)
  89. {
  90. if (irq > 255) {
  91. printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
  92. return;
  93. }
  94. #if 0
  95. if (irq >= VEC_INT1 && irq <= VEC_INT7) {
  96. cpu_free_irq(irq - VEC_SPUR, dev_id);
  97. return;
  98. }
  99. #endif
  100. if (irq_tab[irq].dev_id != dev_id)
  101. printk("%s: Removing probably wrong IRQ %d from %s\n",
  102. __FUNCTION__, irq, irq_tab[irq].devname);
  103. irq_tab[irq].handler = bvme6000_defhand;
  104. irq_tab[irq].flags = IRQ_FLG_STD;
  105. irq_tab[irq].dev_id = NULL;
  106. irq_tab[irq].devname = NULL;
  107. }
  108. irqreturn_t bvme6000_process_int (unsigned long vec, struct pt_regs *fp)
  109. {
  110. if (vec > 255) {
  111. printk ("bvme6000_process_int: Illegal vector %ld", vec);
  112. return IRQ_NONE;
  113. } else {
  114. irq_tab[vec].count++;
  115. irq_tab[vec].handler(vec, irq_tab[vec].dev_id, fp);
  116. return IRQ_HANDLED;
  117. }
  118. }
  119. int show_bvme6000_interrupts(struct seq_file *p, void *v)
  120. {
  121. int i;
  122. for (i = 0; i < 256; i++) {
  123. if (irq_tab[i].count)
  124. seq_printf(p, "Vec 0x%02x: %8d %s\n",
  125. i, irq_tab[i].count,
  126. irq_tab[i].devname ? irq_tab[i].devname : "free");
  127. }
  128. return 0;
  129. }
  130. static irqreturn_t bvme6000_defhand (int irq, void *dev_id, struct pt_regs *fp)
  131. {
  132. printk ("Unknown interrupt 0x%02x\n", irq);
  133. return IRQ_NONE;
  134. }
  135. void bvme6000_enable_irq (unsigned int irq)
  136. {
  137. }
  138. void bvme6000_disable_irq (unsigned int irq)
  139. {
  140. }