irq.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * arch/sh/mach-cayman/irq.c - SH-5 Cayman Interrupt Support
  3. *
  4. * This file handles the board specific parts of the Cayman interrupt system
  5. *
  6. * Copyright (C) 2002 Stuart Menefy
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/io.h>
  13. #include <linux/irq.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/signal.h>
  16. #include <cpu/irq.h>
  17. #include <asm/page.h>
  18. /* Setup for the SMSC FDC37C935 / LAN91C100FD */
  19. #define SMSC_IRQ IRQ_IRL1
  20. /* Setup for PCI Bus 2, which transmits interrupts via the EPLD */
  21. #define PCI2_IRQ IRQ_IRL3
  22. unsigned long epld_virt;
  23. #define EPLD_BASE 0x04002000
  24. #define EPLD_STATUS_BASE (epld_virt + 0x10)
  25. #define EPLD_MASK_BASE (epld_virt + 0x20)
  26. /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
  27. the same SH-5 interrupt */
  28. static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id)
  29. {
  30. printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
  31. return IRQ_NONE;
  32. }
  33. static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
  34. {
  35. printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
  36. return IRQ_NONE;
  37. }
  38. static struct irqaction cayman_action_smsc = {
  39. .name = "Cayman SMSC Mux",
  40. .handler = cayman_interrupt_smsc,
  41. .flags = IRQF_DISABLED,
  42. };
  43. static struct irqaction cayman_action_pci2 = {
  44. .name = "Cayman PCI2 Mux",
  45. .handler = cayman_interrupt_pci2,
  46. .flags = IRQF_DISABLED,
  47. };
  48. static void enable_cayman_irq(unsigned int irq)
  49. {
  50. unsigned long flags;
  51. unsigned long mask;
  52. unsigned int reg;
  53. unsigned char bit;
  54. irq -= START_EXT_IRQS;
  55. reg = EPLD_MASK_BASE + ((irq / 8) << 2);
  56. bit = 1<<(irq % 8);
  57. local_irq_save(flags);
  58. mask = ctrl_inl(reg);
  59. mask |= bit;
  60. ctrl_outl(mask, reg);
  61. local_irq_restore(flags);
  62. }
  63. void disable_cayman_irq(unsigned int irq)
  64. {
  65. unsigned long flags;
  66. unsigned long mask;
  67. unsigned int reg;
  68. unsigned char bit;
  69. irq -= START_EXT_IRQS;
  70. reg = EPLD_MASK_BASE + ((irq / 8) << 2);
  71. bit = 1<<(irq % 8);
  72. local_irq_save(flags);
  73. mask = ctrl_inl(reg);
  74. mask &= ~bit;
  75. ctrl_outl(mask, reg);
  76. local_irq_restore(flags);
  77. }
  78. static void ack_cayman_irq(unsigned int irq)
  79. {
  80. disable_cayman_irq(irq);
  81. }
  82. static void end_cayman_irq(unsigned int irq)
  83. {
  84. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  85. enable_cayman_irq(irq);
  86. }
  87. static unsigned int startup_cayman_irq(unsigned int irq)
  88. {
  89. enable_cayman_irq(irq);
  90. return 0; /* never anything pending */
  91. }
  92. static void shutdown_cayman_irq(unsigned int irq)
  93. {
  94. disable_cayman_irq(irq);
  95. }
  96. struct hw_interrupt_type cayman_irq_type = {
  97. .typename = "Cayman-IRQ",
  98. .startup = startup_cayman_irq,
  99. .shutdown = shutdown_cayman_irq,
  100. .enable = enable_cayman_irq,
  101. .disable = disable_cayman_irq,
  102. .ack = ack_cayman_irq,
  103. .end = end_cayman_irq,
  104. };
  105. int cayman_irq_demux(int evt)
  106. {
  107. int irq = intc_evt_to_irq[evt];
  108. if (irq == SMSC_IRQ) {
  109. unsigned long status;
  110. int i;
  111. status = ctrl_inl(EPLD_STATUS_BASE) &
  112. ctrl_inl(EPLD_MASK_BASE) & 0xff;
  113. if (status == 0) {
  114. irq = -1;
  115. } else {
  116. for (i=0; i<8; i++) {
  117. if (status & (1<<i))
  118. break;
  119. }
  120. irq = START_EXT_IRQS + i;
  121. }
  122. }
  123. if (irq == PCI2_IRQ) {
  124. unsigned long status;
  125. int i;
  126. status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
  127. ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
  128. if (status == 0) {
  129. irq = -1;
  130. } else {
  131. for (i=0; i<8; i++) {
  132. if (status & (1<<i))
  133. break;
  134. }
  135. irq = START_EXT_IRQS + (3 * 8) + i;
  136. }
  137. }
  138. return irq;
  139. }
  140. #if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
  141. int cayman_irq_describe(char* p, int irq)
  142. {
  143. if (irq < NR_INTC_IRQS) {
  144. return intc_irq_describe(p, irq);
  145. } else if (irq < NR_INTC_IRQS + 8) {
  146. return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS);
  147. } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) {
  148. return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24));
  149. }
  150. return 0;
  151. }
  152. #endif
  153. void init_cayman_irq(void)
  154. {
  155. int i;
  156. epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
  157. if (!epld_virt) {
  158. printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
  159. return;
  160. }
  161. for (i=0; i<NR_EXT_IRQS; i++) {
  162. irq_desc[START_EXT_IRQS + i].chip = &cayman_irq_type;
  163. }
  164. /* Setup the SMSC interrupt */
  165. setup_irq(SMSC_IRQ, &cayman_action_smsc);
  166. setup_irq(PCI2_IRQ, &cayman_action_pci2);
  167. }