irq.c 4.1 KB

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