irq.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. struct irq_chip cayman_irq_type = {
  83. .name = "Cayman-IRQ",
  84. .unmask = enable_cayman_irq,
  85. .mask = disable_cayman_irq,
  86. .mask_ack = ack_cayman_irq,
  87. };
  88. int cayman_irq_demux(int evt)
  89. {
  90. int irq = intc_evt_to_irq[evt];
  91. if (irq == SMSC_IRQ) {
  92. unsigned long status;
  93. int i;
  94. status = ctrl_inl(EPLD_STATUS_BASE) &
  95. ctrl_inl(EPLD_MASK_BASE) & 0xff;
  96. if (status == 0) {
  97. irq = -1;
  98. } else {
  99. for (i=0; i<8; i++) {
  100. if (status & (1<<i))
  101. break;
  102. }
  103. irq = START_EXT_IRQS + i;
  104. }
  105. }
  106. if (irq == PCI2_IRQ) {
  107. unsigned long status;
  108. int i;
  109. status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
  110. ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
  111. if (status == 0) {
  112. irq = -1;
  113. } else {
  114. for (i=0; i<8; i++) {
  115. if (status & (1<<i))
  116. break;
  117. }
  118. irq = START_EXT_IRQS + (3 * 8) + i;
  119. }
  120. }
  121. return irq;
  122. }
  123. #if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
  124. int cayman_irq_describe(char* p, int irq)
  125. {
  126. if (irq < NR_INTC_IRQS) {
  127. return intc_irq_describe(p, irq);
  128. } else if (irq < NR_INTC_IRQS + 8) {
  129. return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS);
  130. } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) {
  131. return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24));
  132. }
  133. return 0;
  134. }
  135. #endif
  136. void init_cayman_irq(void)
  137. {
  138. int i;
  139. epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
  140. if (!epld_virt) {
  141. printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
  142. return;
  143. }
  144. for (i = 0; i < NR_EXT_IRQS; i++) {
  145. set_irq_chip_and_handler(START_EXT_IRQS + i, &cayman_irq_type,
  146. handle_level_irq);
  147. }
  148. /* Setup the SMSC interrupt */
  149. setup_irq(SMSC_IRQ, &cayman_action_smsc);
  150. setup_irq(PCI2_IRQ, &cayman_action_pci2);
  151. }