1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-footbridge/irq.c
5 * Copyright (C) 1996-2000 Russell King
8 * 22-Aug-1998 RMK Restructured IRQ routines
9 * 03-Sep-1998 PJB Merged CATS support
10 * 20-Jan-1998 RMK Started merge of EBSA286, CATS and NetWinder
11 * 26-Jan-1999 PJB Don't use IACK on CATS
12 * 16-Mar-1999 RMK Added autodetect of ISA PICs
14 #include <linux/ioport.h>
15 #include <linux/interrupt.h>
16 #include <linux/list.h>
17 #include <linux/init.h>
19 #include <linux/spinlock.h>
21 #include <asm/mach/irq.h>
23 #include <mach/hardware.h>
24 #include <asm/hardware/dec21285.h>
26 #include <asm/mach-types.h>
30 static void isa_mask_pic_lo_irq(struct irq_data
*d
)
32 unsigned int mask
= 1 << (d
->irq
& 7);
34 outb(inb(PIC_MASK_LO
) | mask
, PIC_MASK_LO
);
37 static void isa_ack_pic_lo_irq(struct irq_data
*d
)
39 unsigned int mask
= 1 << (d
->irq
& 7);
41 outb(inb(PIC_MASK_LO
) | mask
, PIC_MASK_LO
);
45 static void isa_unmask_pic_lo_irq(struct irq_data
*d
)
47 unsigned int mask
= 1 << (d
->irq
& 7);
49 outb(inb(PIC_MASK_LO
) & ~mask
, PIC_MASK_LO
);
52 static struct irq_chip isa_lo_chip
= {
53 .irq_ack
= isa_ack_pic_lo_irq
,
54 .irq_mask
= isa_mask_pic_lo_irq
,
55 .irq_unmask
= isa_unmask_pic_lo_irq
,
58 static void isa_mask_pic_hi_irq(struct irq_data
*d
)
60 unsigned int mask
= 1 << (d
->irq
& 7);
62 outb(inb(PIC_MASK_HI
) | mask
, PIC_MASK_HI
);
65 static void isa_ack_pic_hi_irq(struct irq_data
*d
)
67 unsigned int mask
= 1 << (d
->irq
& 7);
69 outb(inb(PIC_MASK_HI
) | mask
, PIC_MASK_HI
);
74 static void isa_unmask_pic_hi_irq(struct irq_data
*d
)
76 unsigned int mask
= 1 << (d
->irq
& 7);
78 outb(inb(PIC_MASK_HI
) & ~mask
, PIC_MASK_HI
);
81 static struct irq_chip isa_hi_chip
= {
82 .irq_ack
= isa_ack_pic_hi_irq
,
83 .irq_mask
= isa_mask_pic_hi_irq
,
84 .irq_unmask
= isa_unmask_pic_hi_irq
,
87 static void isa_irq_handler(struct irq_desc
*desc
)
89 unsigned int isa_irq
= *(unsigned char *)PCIIACK_BASE
;
91 if (isa_irq
< _ISA_IRQ(0) || isa_irq
>= _ISA_IRQ(16)) {
96 generic_handle_irq(isa_irq
);
99 static struct irqaction irq_cascade
= {
100 .handler
= no_action
,
104 static struct resource pic1_resource
= {
110 static struct resource pic2_resource
= {
116 void __init
isa_init_irq(unsigned int host_irq
)
121 * Setup, and then probe for an ISA PIC
122 * If the PIC is not there, then we
126 outb(_ISA_IRQ(0), PIC_MASK_LO
); /* IRQ number */
127 outb(0x04, PIC_MASK_LO
); /* Slave on Ch2 */
128 outb(0x01, PIC_MASK_LO
); /* x86 */
129 outb(0xf5, PIC_MASK_LO
); /* pattern: 11110101 */
132 outb(_ISA_IRQ(8), PIC_MASK_HI
); /* IRQ number */
133 outb(0x02, PIC_MASK_HI
); /* Slave on Ch1 */
134 outb(0x01, PIC_MASK_HI
); /* x86 */
135 outb(0xfa, PIC_MASK_HI
); /* pattern: 11111010 */
140 if (inb(PIC_MASK_LO
) == 0xf5 && inb(PIC_MASK_HI
) == 0xfa) {
141 outb(0xff, PIC_MASK_LO
);/* mask all IRQs */
142 outb(0xff, PIC_MASK_HI
);/* mask all IRQs */
144 printk(KERN_INFO
"IRQ: ISA PIC not found\n");
145 host_irq
= (unsigned int)-1;
148 if (host_irq
!= (unsigned int)-1) {
149 for (irq
= _ISA_IRQ(0); irq
< _ISA_IRQ(8); irq
++) {
150 irq_set_chip_and_handler(irq
, &isa_lo_chip
,
152 irq_clear_status_flags(irq
, IRQ_NOREQUEST
| IRQ_NOPROBE
);
155 for (irq
= _ISA_IRQ(8); irq
< _ISA_IRQ(16); irq
++) {
156 irq_set_chip_and_handler(irq
, &isa_hi_chip
,
158 irq_clear_status_flags(irq
, IRQ_NOREQUEST
| IRQ_NOPROBE
);
161 request_resource(&ioport_resource
, &pic1_resource
);
162 request_resource(&ioport_resource
, &pic2_resource
);
163 setup_irq(IRQ_ISA_CASCADE
, &irq_cascade
);
165 irq_set_chained_handler(host_irq
, isa_irq_handler
);
168 * On the NetWinder, don't automatically
169 * enable ISA IRQ11 when it is requested.
170 * There appears to be a missing pull-up
171 * resistor on this line.
173 if (machine_is_netwinder())
174 irq_modify_status(_ISA_IRQ(11),
175 IRQ_NOREQUEST
| IRQ_NOPROBE
, IRQ_NOAUTOEN
);