16xints.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * arch/m68k/mvme16x/16xints.c
  3. *
  4. * Copyright (C) 1995 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/system.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/irq.h>
  21. static irqreturn_t mvme16x_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[192];
  32. /*
  33. * void mvme16x_init_IRQ (void)
  34. *
  35. * Parameters: None
  36. *
  37. * Returns: Nothing
  38. *
  39. * This function is called during kernel startup to initialize
  40. * the mvme16x IRQ handling routines. Should probably ensure
  41. * that the base vectors for the VMEChip2 and PCCChip2 are valid.
  42. */
  43. void mvme16x_init_IRQ (void)
  44. {
  45. int i;
  46. for (i = 0; i < 192; i++) {
  47. irq_tab[i].handler = mvme16x_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 mvme16x_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 < 64 || irq > 255) {
  59. printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname);
  60. return -ENXIO;
  61. }
  62. if (!(irq_tab[irq-64].flags & IRQ_FLG_STD)) {
  63. if (irq_tab[irq-64].flags & IRQ_FLG_LOCK) {
  64. printk("%s: IRQ %d from %s is not replaceable\n",
  65. __FUNCTION__, irq, irq_tab[irq-64].devname);
  66. return -EBUSY;
  67. }
  68. if (flags & IRQ_FLG_REPLACE) {
  69. printk("%s: %s can't replace IRQ %d from %s\n",
  70. __FUNCTION__, devname, irq, irq_tab[irq-64].devname);
  71. return -EBUSY;
  72. }
  73. }
  74. irq_tab[irq-64].handler = handler;
  75. irq_tab[irq-64].flags = flags;
  76. irq_tab[irq-64].dev_id = dev_id;
  77. irq_tab[irq-64].devname = devname;
  78. return 0;
  79. }
  80. void mvme16x_free_irq(unsigned int irq, void *dev_id)
  81. {
  82. if (irq < 64 || irq > 255) {
  83. printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
  84. return;
  85. }
  86. if (irq_tab[irq-64].dev_id != dev_id)
  87. printk("%s: Removing probably wrong IRQ %d from %s\n",
  88. __FUNCTION__, irq, irq_tab[irq-64].devname);
  89. irq_tab[irq-64].handler = mvme16x_defhand;
  90. irq_tab[irq-64].flags = IRQ_FLG_STD;
  91. irq_tab[irq-64].dev_id = NULL;
  92. irq_tab[irq-64].devname = NULL;
  93. }
  94. irqreturn_t mvme16x_process_int (unsigned long vec, struct pt_regs *fp)
  95. {
  96. if (vec < 64 || vec > 255) {
  97. printk ("mvme16x_process_int: Illegal vector %ld", vec);
  98. return IRQ_NONE;
  99. } else {
  100. irq_tab[vec-64].count++;
  101. irq_tab[vec-64].handler(vec, irq_tab[vec-64].dev_id, fp);
  102. return IRQ_HANDLED;
  103. }
  104. }
  105. int show_mvme16x_interrupts (struct seq_file *p, void *v)
  106. {
  107. int i;
  108. for (i = 0; i < 192; i++) {
  109. if (irq_tab[i].count)
  110. seq_printf(p, "Vec 0x%02x: %8d %s\n",
  111. i+64, irq_tab[i].count,
  112. irq_tab[i].devname ? irq_tab[i].devname : "free");
  113. }
  114. return 0;
  115. }
  116. static irqreturn_t mvme16x_defhand (int irq, void *dev_id, struct pt_regs *fp)
  117. {
  118. printk ("Unknown interrupt 0x%02x\n", irq);
  119. return IRQ_NONE;
  120. }
  121. void mvme16x_enable_irq (unsigned int irq)
  122. {
  123. }
  124. void mvme16x_disable_irq (unsigned int irq)
  125. {
  126. }