isa-irq.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 <asm/mach/irq.h>
  22. #include <asm/hardware.h>
  23. #include <asm/hardware/dec21285.h>
  24. #include <asm/irq.h>
  25. #include <asm/io.h>
  26. #include <asm/mach-types.h>
  27. static void isa_mask_pic_lo_irq(unsigned int irq)
  28. {
  29. unsigned int mask = 1 << (irq & 7);
  30. outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
  31. }
  32. static void isa_ack_pic_lo_irq(unsigned int irq)
  33. {
  34. unsigned int mask = 1 << (irq & 7);
  35. outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
  36. outb(0x20, PIC_LO);
  37. }
  38. static void isa_unmask_pic_lo_irq(unsigned int irq)
  39. {
  40. unsigned int mask = 1 << (irq & 7);
  41. outb(inb(PIC_MASK_LO) & ~mask, PIC_MASK_LO);
  42. }
  43. static struct irq_chip isa_lo_chip = {
  44. .ack = isa_ack_pic_lo_irq,
  45. .mask = isa_mask_pic_lo_irq,
  46. .unmask = isa_unmask_pic_lo_irq,
  47. };
  48. static void isa_mask_pic_hi_irq(unsigned int irq)
  49. {
  50. unsigned int mask = 1 << (irq & 7);
  51. outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
  52. }
  53. static void isa_ack_pic_hi_irq(unsigned int irq)
  54. {
  55. unsigned int mask = 1 << (irq & 7);
  56. outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
  57. outb(0x62, PIC_LO);
  58. outb(0x20, PIC_HI);
  59. }
  60. static void isa_unmask_pic_hi_irq(unsigned int irq)
  61. {
  62. unsigned int mask = 1 << (irq & 7);
  63. outb(inb(PIC_MASK_HI) & ~mask, PIC_MASK_HI);
  64. }
  65. static struct irq_chip isa_hi_chip = {
  66. .ack = isa_ack_pic_hi_irq,
  67. .mask = isa_mask_pic_hi_irq,
  68. .unmask = isa_unmask_pic_hi_irq,
  69. };
  70. static void
  71. isa_irq_handler(unsigned int irq, struct irq_desc *desc)
  72. {
  73. unsigned int isa_irq = *(unsigned char *)PCIIACK_BASE;
  74. if (isa_irq < _ISA_IRQ(0) || isa_irq >= _ISA_IRQ(16)) {
  75. do_bad_IRQ(isa_irq, desc);
  76. return;
  77. }
  78. desc = irq_desc + isa_irq;
  79. desc_handle_irq(isa_irq, desc);
  80. }
  81. static struct irqaction irq_cascade = {
  82. .handler = no_action,
  83. .name = "cascade",
  84. };
  85. static struct resource pic1_resource = {
  86. .name = "pic1",
  87. .start = 0x20,
  88. .end = 0x3f,
  89. };
  90. static struct resource pic2_resource = {
  91. .name = "pic2",
  92. .start = 0xa0,
  93. .end = 0xbf,
  94. };
  95. void __init isa_init_irq(unsigned int host_irq)
  96. {
  97. unsigned int irq;
  98. /*
  99. * Setup, and then probe for an ISA PIC
  100. * If the PIC is not there, then we
  101. * ignore the PIC.
  102. */
  103. outb(0x11, PIC_LO);
  104. outb(_ISA_IRQ(0), PIC_MASK_LO); /* IRQ number */
  105. outb(0x04, PIC_MASK_LO); /* Slave on Ch2 */
  106. outb(0x01, PIC_MASK_LO); /* x86 */
  107. outb(0xf5, PIC_MASK_LO); /* pattern: 11110101 */
  108. outb(0x11, PIC_HI);
  109. outb(_ISA_IRQ(8), PIC_MASK_HI); /* IRQ number */
  110. outb(0x02, PIC_MASK_HI); /* Slave on Ch1 */
  111. outb(0x01, PIC_MASK_HI); /* x86 */
  112. outb(0xfa, PIC_MASK_HI); /* pattern: 11111010 */
  113. outb(0x0b, PIC_LO);
  114. outb(0x0b, PIC_HI);
  115. if (inb(PIC_MASK_LO) == 0xf5 && inb(PIC_MASK_HI) == 0xfa) {
  116. outb(0xff, PIC_MASK_LO);/* mask all IRQs */
  117. outb(0xff, PIC_MASK_HI);/* mask all IRQs */
  118. } else {
  119. printk(KERN_INFO "IRQ: ISA PIC not found\n");
  120. host_irq = (unsigned int)-1;
  121. }
  122. if (host_irq != (unsigned int)-1) {
  123. for (irq = _ISA_IRQ(0); irq < _ISA_IRQ(8); irq++) {
  124. set_irq_chip(irq, &isa_lo_chip);
  125. set_irq_handler(irq, handle_level_irq);
  126. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  127. }
  128. for (irq = _ISA_IRQ(8); irq < _ISA_IRQ(16); irq++) {
  129. set_irq_chip(irq, &isa_hi_chip);
  130. set_irq_handler(irq, handle_level_irq);
  131. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  132. }
  133. request_resource(&ioport_resource, &pic1_resource);
  134. request_resource(&ioport_resource, &pic2_resource);
  135. setup_irq(IRQ_ISA_CASCADE, &irq_cascade);
  136. set_irq_chained_handler(host_irq, isa_irq_handler);
  137. /*
  138. * On the NetWinder, don't automatically
  139. * enable ISA IRQ11 when it is requested.
  140. * There appears to be a missing pull-up
  141. * resistor on this line.
  142. */
  143. if (machine_is_netwinder())
  144. set_irq_flags(_ISA_IRQ(11), IRQF_VALID |
  145. IRQF_PROBE | IRQF_NOAUTOEN);
  146. }
  147. }