irq.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. "ASIC-PCI",
  50. startup_pciasic_irq,
  51. shutdown_pciasic_irq,
  52. enable_pciasic_irq,
  53. disable_pciasic_irq,
  54. mask_and_ack_pciasic_irq,
  55. end_pciasic_irq,
  56. NULL
  57. };
  58. /*
  59. * hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
  60. * button interrupts. Later ...
  61. */
  62. void pciasic_hwint0(struct pt_regs *regs)
  63. {
  64. panic("Received int0 but no handler yet ...");
  65. }
  66. /* This interrupt was used for the com1 console on the first prototypes. */
  67. void pciasic_hwint2(struct pt_regs *regs)
  68. {
  69. /* I think this shouldn't happen on production machines. */
  70. panic("hwint2 and no handler yet");
  71. }
  72. /* hwint5 is the r4k count / compare interrupt */
  73. void pciasic_hwint5(struct pt_regs *regs)
  74. {
  75. panic("hwint5 and no handler yet");
  76. }
  77. static unsigned int ls1bit8(unsigned int x)
  78. {
  79. int b = 7, s;
  80. s = 4; if ((x & 0x0f) == 0) s = 0; b -= s; x <<= s;
  81. s = 2; if ((x & 0x30) == 0) s = 0; b -= s; x <<= s;
  82. s = 1; if ((x & 0x40) == 0) s = 0; b -= s;
  83. return b;
  84. }
  85. /*
  86. * hwint 1 deals with EISA and SCSI interrupts,
  87. *
  88. * The EISA_INT bit in CSITPEND is high active, all others are low active.
  89. */
  90. void pciasic_hwint1(struct pt_regs *regs)
  91. {
  92. u8 pend = *(volatile char *)PCIMT_CSITPEND;
  93. unsigned long flags;
  94. if (pend & IT_EISA) {
  95. int irq;
  96. /*
  97. * Note: ASIC PCI's builtin interrupt achknowledge feature is
  98. * broken. Using it may result in loss of some or all i8259
  99. * interupts, so don't use PCIMT_INT_ACKNOWLEDGE ...
  100. */
  101. irq = i8259_irq();
  102. if (unlikely(irq < 0))
  103. return;
  104. do_IRQ(irq, regs);
  105. }
  106. if (!(pend & IT_SCSI)) {
  107. flags = read_c0_status();
  108. clear_c0_status(ST0_IM);
  109. do_IRQ(PCIMT_IRQ_SCSI, regs);
  110. write_c0_status(flags);
  111. }
  112. }
  113. /*
  114. * hwint 3 should deal with the PCI A - D interrupts,
  115. */
  116. void pciasic_hwint3(struct pt_regs *regs)
  117. {
  118. u8 pend = *(volatile char *)PCIMT_CSITPEND;
  119. int irq;
  120. pend &= (IT_INTA | IT_INTB | IT_INTC | IT_INTD);
  121. clear_c0_status(IE_IRQ3);
  122. irq = PCIMT_IRQ_INT2 + ls1bit8(pend);
  123. do_IRQ(irq, regs);
  124. set_c0_status(IE_IRQ3);
  125. }
  126. /*
  127. * hwint 4 is used for only the onboard PCnet 32.
  128. */
  129. void pciasic_hwint4(struct pt_regs *regs)
  130. {
  131. clear_c0_status(IE_IRQ4);
  132. do_IRQ(PCIMT_IRQ_ETHERNET, regs);
  133. set_c0_status(IE_IRQ4);
  134. }
  135. void __init init_pciasic(void)
  136. {
  137. unsigned long flags;
  138. spin_lock_irqsave(&pciasic_lock, flags);
  139. * (volatile u8 *) PCIMT_IRQSEL =
  140. IT_EISA | IT_INTA | IT_INTB | IT_INTC | IT_INTD;
  141. spin_unlock_irqrestore(&pciasic_lock, flags);
  142. }
  143. /*
  144. * On systems with i8259-style interrupt controllers we assume for
  145. * driver compatibility reasons interrupts 0 - 15 to be the i8295
  146. * interrupts even if the hardware uses a different interrupt numbering.
  147. */
  148. void __init arch_init_irq(void)
  149. {
  150. int i;
  151. set_except_vector(0, sni_rm200_pci_handle_int);
  152. init_i8259_irqs(); /* Integrated i8259 */
  153. init_pciasic();
  154. /* Actually we've got more interrupts to handle ... */
  155. for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++) {
  156. irq_desc[i].status = IRQ_DISABLED;
  157. irq_desc[i].action = 0;
  158. irq_desc[i].depth = 1;
  159. irq_desc[i].handler = &pciasic_irq_type;
  160. }
  161. change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4);
  162. }