irq.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. };
  42. static struct irqaction cayman_action_pci2 = {
  43. .name = "Cayman PCI2 Mux",
  44. .handler = cayman_interrupt_pci2,
  45. };
  46. static void enable_cayman_irq(struct irq_data *data)
  47. {
  48. unsigned int irq = data->irq;
  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 = __raw_readl(reg);
  58. mask |= bit;
  59. __raw_writel(mask, reg);
  60. local_irq_restore(flags);
  61. }
  62. static void disable_cayman_irq(struct irq_data *data)
  63. {
  64. unsigned int irq = data->irq;
  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 = __raw_readl(reg);
  74. mask &= ~bit;
  75. __raw_writel(mask, reg);
  76. local_irq_restore(flags);
  77. }
  78. struct irq_chip cayman_irq_type = {
  79. .name = "Cayman-IRQ",
  80. .irq_unmask = enable_cayman_irq,
  81. .irq_mask = disable_cayman_irq,
  82. };
  83. int cayman_irq_demux(int evt)
  84. {
  85. int irq = intc_evt_to_irq[evt];
  86. if (irq == SMSC_IRQ) {
  87. unsigned long status;
  88. int i;
  89. status = __raw_readl(EPLD_STATUS_BASE) &
  90. __raw_readl(EPLD_MASK_BASE) & 0xff;
  91. if (status == 0) {
  92. irq = -1;
  93. } else {
  94. for (i=0; i<8; i++) {
  95. if (status & (1<<i))
  96. break;
  97. }
  98. irq = START_EXT_IRQS + i;
  99. }
  100. }
  101. if (irq == PCI2_IRQ) {
  102. unsigned long status;
  103. int i;
  104. status = __raw_readl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
  105. __raw_readl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
  106. if (status == 0) {
  107. irq = -1;
  108. } else {
  109. for (i=0; i<8; i++) {
  110. if (status & (1<<i))
  111. break;
  112. }
  113. irq = START_EXT_IRQS + (3 * 8) + i;
  114. }
  115. }
  116. return irq;
  117. }
  118. void init_cayman_irq(void)
  119. {
  120. int i;
  121. epld_virt = (unsigned long)ioremap_nocache(EPLD_BASE, 1024);
  122. if (!epld_virt) {
  123. printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
  124. return;
  125. }
  126. for (i = 0; i < NR_EXT_IRQS; i++) {
  127. irq_set_chip_and_handler(START_EXT_IRQS + i,
  128. &cayman_irq_type, handle_level_irq);
  129. }
  130. /* Setup the SMSC interrupt */
  131. setup_irq(SMSC_IRQ, &cayman_action_smsc);
  132. setup_irq(PCI2_IRQ, &cayman_action_pci2);
  133. }