Merge remote-tracking branch 's5p/for-next'
[linux-2.6/next.git] / arch / arm / mach-footbridge / isa-irq.c
blobc3a0abbc9049a67db7a539c2540572d3033ccef9
1 /*
2 * linux/arch/arm/mach-footbridge/irq.c
4 * Copyright (C) 1996-2000 Russell King
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.
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
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>
24 #include <asm/mach/irq.h>
26 #include <mach/hardware.h>
27 #include <asm/hardware/dec21285.h>
28 #include <asm/irq.h>
29 #include <asm/mach-types.h>
31 #include "common.h"
33 static void isa_mask_pic_lo_irq(struct irq_data *d)
35 unsigned int mask = 1 << (d->irq & 7);
37 outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
40 static void isa_ack_pic_lo_irq(struct irq_data *d)
42 unsigned int mask = 1 << (d->irq & 7);
44 outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
45 outb(0x20, PIC_LO);
48 static void isa_unmask_pic_lo_irq(struct irq_data *d)
50 unsigned int mask = 1 << (d->irq & 7);
52 outb(inb(PIC_MASK_LO) & ~mask, PIC_MASK_LO);
55 static struct irq_chip isa_lo_chip = {
56 .irq_ack = isa_ack_pic_lo_irq,
57 .irq_mask = isa_mask_pic_lo_irq,
58 .irq_unmask = isa_unmask_pic_lo_irq,
61 static void isa_mask_pic_hi_irq(struct irq_data *d)
63 unsigned int mask = 1 << (d->irq & 7);
65 outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
68 static void isa_ack_pic_hi_irq(struct irq_data *d)
70 unsigned int mask = 1 << (d->irq & 7);
72 outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
73 outb(0x62, PIC_LO);
74 outb(0x20, PIC_HI);
77 static void isa_unmask_pic_hi_irq(struct irq_data *d)
79 unsigned int mask = 1 << (d->irq & 7);
81 outb(inb(PIC_MASK_HI) & ~mask, PIC_MASK_HI);
84 static struct irq_chip isa_hi_chip = {
85 .irq_ack = isa_ack_pic_hi_irq,
86 .irq_mask = isa_mask_pic_hi_irq,
87 .irq_unmask = isa_unmask_pic_hi_irq,
90 static void
91 isa_irq_handler(unsigned int irq, struct irq_desc *desc)
93 unsigned int isa_irq = *(unsigned char *)PCIIACK_BASE;
95 if (isa_irq < _ISA_IRQ(0) || isa_irq >= _ISA_IRQ(16)) {
96 do_bad_IRQ(isa_irq, desc);
97 return;
100 generic_handle_irq(isa_irq);
103 static struct irqaction irq_cascade = {
104 .handler = no_action,
105 .name = "cascade",
108 static struct resource pic1_resource = {
109 .name = "pic1",
110 .start = 0x20,
111 .end = 0x3f,
114 static struct resource pic2_resource = {
115 .name = "pic2",
116 .start = 0xa0,
117 .end = 0xbf,
120 void __init isa_init_irq(unsigned int host_irq)
122 unsigned int irq;
125 * Setup, and then probe for an ISA PIC
126 * If the PIC is not there, then we
127 * ignore the PIC.
129 outb(0x11, PIC_LO);
130 outb(_ISA_IRQ(0), PIC_MASK_LO); /* IRQ number */
131 outb(0x04, PIC_MASK_LO); /* Slave on Ch2 */
132 outb(0x01, PIC_MASK_LO); /* x86 */
133 outb(0xf5, PIC_MASK_LO); /* pattern: 11110101 */
135 outb(0x11, PIC_HI);
136 outb(_ISA_IRQ(8), PIC_MASK_HI); /* IRQ number */
137 outb(0x02, PIC_MASK_HI); /* Slave on Ch1 */
138 outb(0x01, PIC_MASK_HI); /* x86 */
139 outb(0xfa, PIC_MASK_HI); /* pattern: 11111010 */
141 outb(0x0b, PIC_LO);
142 outb(0x0b, PIC_HI);
144 if (inb(PIC_MASK_LO) == 0xf5 && inb(PIC_MASK_HI) == 0xfa) {
145 outb(0xff, PIC_MASK_LO);/* mask all IRQs */
146 outb(0xff, PIC_MASK_HI);/* mask all IRQs */
147 } else {
148 printk(KERN_INFO "IRQ: ISA PIC not found\n");
149 host_irq = (unsigned int)-1;
152 if (host_irq != (unsigned int)-1) {
153 for (irq = _ISA_IRQ(0); irq < _ISA_IRQ(8); irq++) {
154 irq_set_chip_and_handler(irq, &isa_lo_chip,
155 handle_level_irq);
156 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
159 for (irq = _ISA_IRQ(8); irq < _ISA_IRQ(16); irq++) {
160 irq_set_chip_and_handler(irq, &isa_hi_chip,
161 handle_level_irq);
162 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
165 request_resource(&ioport_resource, &pic1_resource);
166 request_resource(&ioport_resource, &pic2_resource);
167 setup_irq(IRQ_ISA_CASCADE, &irq_cascade);
169 irq_set_chained_handler(host_irq, isa_irq_handler);
172 * On the NetWinder, don't automatically
173 * enable ISA IRQ11 when it is requested.
174 * There appears to be a missing pull-up
175 * resistor on this line.
177 if (machine_is_netwinder())
178 set_irq_flags(_ISA_IRQ(11), IRQF_VALID |
179 IRQF_PROBE | IRQF_NOAUTOEN);