irq.c 3.5 KB

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