irq.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992 Linus Torvalds
  7. * Copyright (C) 1994 - 2000 Ralf Baechle
  8. */
  9. #include <linux/delay.h>
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/irq.h>
  13. #include <linux/kernel.h>
  14. #include <linux/spinlock.h>
  15. #include <asm/i8259.h>
  16. #include <asm/io.h>
  17. #include <asm/sni.h>
  18. DEFINE_SPINLOCK(pciasic_lock);
  19. extern asmlinkage void sni_rm200_pci_handle_int(void);
  20. static void enable_pciasic_irq(unsigned int irq)
  21. {
  22. unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2);
  23. unsigned long flags;
  24. spin_lock_irqsave(&pciasic_lock, flags);
  25. *(volatile u8 *) PCIMT_IRQSEL |= mask;
  26. spin_unlock_irqrestore(&pciasic_lock, flags);
  27. }
  28. static unsigned int startup_pciasic_irq(unsigned int irq)
  29. {
  30. enable_pciasic_irq(irq);
  31. return 0; /* never anything pending */
  32. }
  33. #define shutdown_pciasic_irq disable_pciasic_irq
  34. void disable_pciasic_irq(unsigned int irq)
  35. {
  36. unsigned int mask = ~(1 << (irq - PCIMT_IRQ_INT2));
  37. unsigned long flags;
  38. spin_lock_irqsave(&pciasic_lock, flags);
  39. *(volatile u8 *) PCIMT_IRQSEL &= mask;
  40. spin_unlock_irqrestore(&pciasic_lock, flags);
  41. }
  42. #define mask_and_ack_pciasic_irq disable_pciasic_irq
  43. static void end_pciasic_irq(unsigned int irq)
  44. {
  45. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  46. enable_pciasic_irq(irq);
  47. }
  48. static struct hw_interrupt_type pciasic_irq_type = {
  49. .typename = "ASIC-PCI",
  50. .startup = startup_pciasic_irq,
  51. .shutdown = shutdown_pciasic_irq,
  52. .enable = enable_pciasic_irq,
  53. .disable = disable_pciasic_irq,
  54. .ack = mask_and_ack_pciasic_irq,
  55. .end = end_pciasic_irq,
  56. };
  57. /*
  58. * hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
  59. * button interrupts. Later ...
  60. */
  61. void pciasic_hwint0(struct pt_regs *regs)
  62. {
  63. panic("Received int0 but no handler yet ...");
  64. }
  65. /* This interrupt was used for the com1 console on the first prototypes. */
  66. void pciasic_hwint2(struct pt_regs *regs)
  67. {
  68. /* I think this shouldn't happen on production machines. */
  69. panic("hwint2 and no handler yet");
  70. }
  71. /* hwint5 is the r4k count / compare interrupt */
  72. void pciasic_hwint5(struct pt_regs *regs)
  73. {
  74. panic("hwint5 and no handler yet");
  75. }
  76. static unsigned int ls1bit8(unsigned int x)
  77. {
  78. int b = 7, s;
  79. s = 4; if ((x & 0x0f) == 0) s = 0; b -= s; x <<= s;
  80. s = 2; if ((x & 0x30) == 0) s = 0; b -= s; x <<= s;
  81. s = 1; if ((x & 0x40) == 0) s = 0; b -= s;
  82. return b;
  83. }
  84. /*
  85. * hwint 1 deals with EISA and SCSI interrupts,
  86. *
  87. * The EISA_INT bit in CSITPEND is high active, all others are low active.
  88. */
  89. void pciasic_hwint1(struct pt_regs *regs)
  90. {
  91. u8 pend = *(volatile char *)PCIMT_CSITPEND;
  92. unsigned long flags;
  93. if (pend & IT_EISA) {
  94. int irq;
  95. /*
  96. * Note: ASIC PCI's builtin interrupt achknowledge feature is
  97. * broken. Using it may result in loss of some or all i8259
  98. * interupts, so don't use PCIMT_INT_ACKNOWLEDGE ...
  99. */
  100. irq = i8259_irq();
  101. if (unlikely(irq < 0))
  102. return;
  103. do_IRQ(irq, regs);
  104. }
  105. if (!(pend & IT_SCSI)) {
  106. flags = read_c0_status();
  107. clear_c0_status(ST0_IM);
  108. do_IRQ(PCIMT_IRQ_SCSI, regs);
  109. write_c0_status(flags);
  110. }
  111. }
  112. /*
  113. * hwint 3 should deal with the PCI A - D interrupts,
  114. */
  115. void pciasic_hwint3(struct pt_regs *regs)
  116. {
  117. u8 pend = *(volatile char *)PCIMT_CSITPEND;
  118. int irq;
  119. pend &= (IT_INTA | IT_INTB | IT_INTC | IT_INTD);
  120. clear_c0_status(IE_IRQ3);
  121. irq = PCIMT_IRQ_INT2 + ls1bit8(pend);
  122. do_IRQ(irq, regs);
  123. set_c0_status(IE_IRQ3);
  124. }
  125. /*
  126. * hwint 4 is used for only the onboard PCnet 32.
  127. */
  128. void pciasic_hwint4(struct pt_regs *regs)
  129. {
  130. clear_c0_status(IE_IRQ4);
  131. do_IRQ(PCIMT_IRQ_ETHERNET, regs);
  132. set_c0_status(IE_IRQ4);
  133. }
  134. void __init init_pciasic(void)
  135. {
  136. unsigned long flags;
  137. spin_lock_irqsave(&pciasic_lock, flags);
  138. * (volatile u8 *) PCIMT_IRQSEL =
  139. IT_EISA | IT_INTA | IT_INTB | IT_INTC | IT_INTD;
  140. spin_unlock_irqrestore(&pciasic_lock, flags);
  141. }
  142. /*
  143. * On systems with i8259-style interrupt controllers we assume for
  144. * driver compatibility reasons interrupts 0 - 15 to be the i8295
  145. * interrupts even if the hardware uses a different interrupt numbering.
  146. */
  147. void __init arch_init_irq(void)
  148. {
  149. int i;
  150. set_except_vector(0, sni_rm200_pci_handle_int);
  151. init_i8259_irqs(); /* Integrated i8259 */
  152. init_pciasic();
  153. /* Actually we've got more interrupts to handle ... */
  154. for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++) {
  155. irq_desc[i].status = IRQ_DISABLED;
  156. irq_desc[i].action = 0;
  157. irq_desc[i].depth = 1;
  158. irq_desc[i].handler = &pciasic_irq_type;
  159. }
  160. change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4);
  161. }