bvmeints.c 3.6 KB

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