16xints.c 3.4 KB

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