[ARM] 3340/1: Fix the PCI setup for direct master access to SDRAM
[pv_ops_mirror.git] / arch / arm / mach-footbridge / isa-irq.c
blobe1c43b331d64d357ece5282be3929cd136bfe026
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>
22 #include <asm/mach/irq.h>
24 #include <asm/hardware.h>
25 #include <asm/hardware/dec21285.h>
26 #include <asm/irq.h>
27 #include <asm/io.h>
28 #include <asm/mach-types.h>
30 static void isa_mask_pic_lo_irq(unsigned int irq)
32 unsigned int mask = 1 << (irq & 7);
34 outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
37 static void isa_ack_pic_lo_irq(unsigned int irq)
39 unsigned int mask = 1 << (irq & 7);
41 outb(inb(PIC_MASK_LO) | mask, PIC_MASK_LO);
42 outb(0x20, PIC_LO);
45 static void isa_unmask_pic_lo_irq(unsigned int irq)
47 unsigned int mask = 1 << (irq & 7);
49 outb(inb(PIC_MASK_LO) & ~mask, PIC_MASK_LO);
52 static struct irqchip isa_lo_chip = {
53 .ack = isa_ack_pic_lo_irq,
54 .mask = isa_mask_pic_lo_irq,
55 .unmask = isa_unmask_pic_lo_irq,
58 static void isa_mask_pic_hi_irq(unsigned int irq)
60 unsigned int mask = 1 << (irq & 7);
62 outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
65 static void isa_ack_pic_hi_irq(unsigned int irq)
67 unsigned int mask = 1 << (irq & 7);
69 outb(inb(PIC_MASK_HI) | mask, PIC_MASK_HI);
70 outb(0x62, PIC_LO);
71 outb(0x20, PIC_HI);
74 static void isa_unmask_pic_hi_irq(unsigned int irq)
76 unsigned int mask = 1 << (irq & 7);
78 outb(inb(PIC_MASK_HI) & ~mask, PIC_MASK_HI);
81 static struct irqchip isa_hi_chip = {
82 .ack = isa_ack_pic_hi_irq,
83 .mask = isa_mask_pic_hi_irq,
84 .unmask = isa_unmask_pic_hi_irq,
87 static void
88 isa_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
90 unsigned int isa_irq = *(unsigned char *)PCIIACK_BASE;
92 if (isa_irq < _ISA_IRQ(0) || isa_irq >= _ISA_IRQ(16)) {
93 do_bad_IRQ(isa_irq, desc, regs);
94 return;
97 desc = irq_desc + isa_irq;
98 desc_handle_irq(isa_irq, desc, regs);
101 static struct irqaction irq_cascade = { .handler = no_action, .name = "cascade", };
102 static struct resource pic1_resource = { "pic1", 0x20, 0x3f };
103 static struct resource pic2_resource = { "pic2", 0xa0, 0xbf };
105 void __init isa_init_irq(unsigned int host_irq)
107 unsigned int irq;
110 * Setup, and then probe for an ISA PIC
111 * If the PIC is not there, then we
112 * ignore the PIC.
114 outb(0x11, PIC_LO);
115 outb(_ISA_IRQ(0), PIC_MASK_LO); /* IRQ number */
116 outb(0x04, PIC_MASK_LO); /* Slave on Ch2 */
117 outb(0x01, PIC_MASK_LO); /* x86 */
118 outb(0xf5, PIC_MASK_LO); /* pattern: 11110101 */
120 outb(0x11, PIC_HI);
121 outb(_ISA_IRQ(8), PIC_MASK_HI); /* IRQ number */
122 outb(0x02, PIC_MASK_HI); /* Slave on Ch1 */
123 outb(0x01, PIC_MASK_HI); /* x86 */
124 outb(0xfa, PIC_MASK_HI); /* pattern: 11111010 */
126 outb(0x0b, PIC_LO);
127 outb(0x0b, PIC_HI);
129 if (inb(PIC_MASK_LO) == 0xf5 && inb(PIC_MASK_HI) == 0xfa) {
130 outb(0xff, PIC_MASK_LO);/* mask all IRQs */
131 outb(0xff, PIC_MASK_HI);/* mask all IRQs */
132 } else {
133 printk(KERN_INFO "IRQ: ISA PIC not found\n");
134 host_irq = (unsigned int)-1;
137 if (host_irq != (unsigned int)-1) {
138 for (irq = _ISA_IRQ(0); irq < _ISA_IRQ(8); irq++) {
139 set_irq_chip(irq, &isa_lo_chip);
140 set_irq_handler(irq, do_level_IRQ);
141 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
144 for (irq = _ISA_IRQ(8); irq < _ISA_IRQ(16); irq++) {
145 set_irq_chip(irq, &isa_hi_chip);
146 set_irq_handler(irq, do_level_IRQ);
147 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
150 request_resource(&ioport_resource, &pic1_resource);
151 request_resource(&ioport_resource, &pic2_resource);
152 setup_irq(IRQ_ISA_CASCADE, &irq_cascade);
154 set_irq_chained_handler(host_irq, isa_irq_handler);
157 * On the NetWinder, don't automatically
158 * enable ISA IRQ11 when it is requested.
159 * There appears to be a missing pull-up
160 * resistor on this line.
162 if (machine_is_netwinder())
163 set_irq_flags(_ISA_IRQ(11), IRQF_VALID |
164 IRQF_PROBE | IRQF_NOAUTOEN);