isa-irq.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * linux/arch/arm/mach-footbridge/irq.c
  3. *
  4. * Copyright (C) 1996-2000 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Changelog:
  11. * 22-Aug-1998 RMK Restructured IRQ routines
  12. * 03-Sep-1998 PJB Merged CATS support
  13. * 20-Jan-1998 RMK Started merge of EBSA286, CATS and NetWinder
  14. * 26-Jan-1999 PJB Don't use IACK on CATS
  15. * 16-Mar-1999 RMK Added autodetect of ISA PICs
  16. */
  17. #include <linux/ioport.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/list.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/spinlock.h>
  23. #include <asm/mach/irq.h>
  24. #include <mach/hardware.h>
  25. #include <asm/hardware/dec21285.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach-types.h>
  28. #include "common.h"
  29. static void isa_mask_pic_lo_irq(struct irq_data *d)
  30. {
  31. unsigned int mask = 1 << (d->irq & 7);
  32. outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
  33. }
  34. static void isa_ack_pic_lo_irq(struct irq_data *d)
  35. {
  36. unsigned int mask = 1 << (d->irq & 7);
  37. outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
  38. outb(0x20, PIC_LO);
  39. }
  40. static void isa_unmask_pic_lo_irq(struct irq_data *d)
  41. {
  42. unsigned int mask = 1 << (d->irq & 7);
  43. outb(inb(PIC_MASK_LO) & ~mask, PIC_MASK_LO);
  44. }
  45. static struct irq_chip isa_lo_chip = {
  46. .irq_ack = isa_ack_pic_lo_irq,
  47. .irq_mask = isa_mask_pic_lo_irq,
  48. .irq_unmask = isa_unmask_pic_lo_irq,
  49. };
  50. static void isa_mask_pic_hi_irq(struct irq_data *d)
  51. {
  52. unsigned int mask = 1 << (d->irq & 7);
  53. outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
  54. }
  55. static void isa_ack_pic_hi_irq(struct irq_data *d)
  56. {
  57. unsigned int mask = 1 << (d->irq & 7);
  58. outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
  59. outb(0x62, PIC_LO);
  60. outb(0x20, PIC_HI);
  61. }
  62. static void isa_unmask_pic_hi_irq(struct irq_data *d)
  63. {
  64. unsigned int mask = 1 << (d->irq & 7);
  65. outb(inb(PIC_MASK_HI) & ~mask, PIC_MASK_HI);
  66. }
  67. static struct irq_chip isa_hi_chip = {
  68. .irq_ack = isa_ack_pic_hi_irq,
  69. .irq_mask = isa_mask_pic_hi_irq,
  70. .irq_unmask = isa_unmask_pic_hi_irq,
  71. };
  72. static void
  73. isa_irq_handler(unsigned int irq, struct irq_desc *desc)
  74. {
  75. unsigned int isa_irq = *(unsigned char *)PCIIACK_BASE;
  76. if (isa_irq < _ISA_IRQ(0) || isa_irq >= _ISA_IRQ(16)) {
  77. do_bad_IRQ(isa_irq, desc);
  78. return;
  79. }
  80. generic_handle_irq(isa_irq);
  81. }
  82. static struct irqaction irq_cascade = {
  83. .handler = no_action,
  84. .name = "cascade",
  85. };
  86. static struct resource pic1_resource = {
  87. .name = "pic1",
  88. .start = 0x20,
  89. .end = 0x3f,
  90. };
  91. static struct resource pic2_resource = {
  92. .name = "pic2",
  93. .start = 0xa0,
  94. .end = 0xbf,
  95. };
  96. void __init isa_init_irq(unsigned int host_irq)
  97. {
  98. unsigned int irq;
  99. /*
  100. * Setup, and then probe for an ISA PIC
  101. * If the PIC is not there, then we
  102. * ignore the PIC.
  103. */
  104. outb(0x11, PIC_LO);
  105. outb(_ISA_IRQ(0), PIC_MASK_LO); /* IRQ number */
  106. outb(0x04, PIC_MASK_LO); /* Slave on Ch2 */
  107. outb(0x01, PIC_MASK_LO); /* x86 */
  108. outb(0xf5, PIC_MASK_LO); /* pattern: 11110101 */
  109. outb(0x11, PIC_HI);
  110. outb(_ISA_IRQ(8), PIC_MASK_HI); /* IRQ number */
  111. outb(0x02, PIC_MASK_HI); /* Slave on Ch1 */
  112. outb(0x01, PIC_MASK_HI); /* x86 */
  113. outb(0xfa, PIC_MASK_HI); /* pattern: 11111010 */
  114. outb(0x0b, PIC_LO);
  115. outb(0x0b, PIC_HI);
  116. if (inb(PIC_MASK_LO) == 0xf5 && inb(PIC_MASK_HI) == 0xfa) {
  117. outb(0xff, PIC_MASK_LO);/* mask all IRQs */
  118. outb(0xff, PIC_MASK_HI);/* mask all IRQs */
  119. } else {
  120. printk(KERN_INFO "IRQ: ISA PIC not found\n");
  121. host_irq = (unsigned int)-1;
  122. }
  123. if (host_irq != (unsigned int)-1) {
  124. for (irq = _ISA_IRQ(0); irq < _ISA_IRQ(8); irq++) {
  125. irq_set_chip_and_handler(irq, &isa_lo_chip,
  126. handle_level_irq);
  127. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  128. }
  129. for (irq = _ISA_IRQ(8); irq < _ISA_IRQ(16); irq++) {
  130. irq_set_chip_and_handler(irq, &isa_hi_chip,
  131. handle_level_irq);
  132. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  133. }
  134. request_resource(&ioport_resource, &pic1_resource);
  135. request_resource(&ioport_resource, &pic2_resource);
  136. setup_irq(IRQ_ISA_CASCADE, &irq_cascade);
  137. irq_set_chained_handler(host_irq, isa_irq_handler);
  138. /*
  139. * On the NetWinder, don't automatically
  140. * enable ISA IRQ11 when it is requested.
  141. * There appears to be a missing pull-up
  142. * resistor on this line.
  143. */
  144. if (machine_is_netwinder())
  145. set_irq_flags(_ISA_IRQ(11), IRQF_VALID |
  146. IRQF_PROBE | IRQF_NOAUTOEN);
  147. }
  148. }