irq.c 4.2 KB

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