aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/syslib/i8259.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-26 02:47:42 -0400
committerPaul Mackerras <paulus@samba.org>2005-10-26 02:47:42 -0400
commitf9bd170a87948a9e077149b70fb192c563770fdf (patch)
treec759b57b67ab41a859e19f7dcee571504b368202 /arch/ppc/syslib/i8259.c
parent25635c71e44111a6bd48f342e144e2fc02d0a314 (diff)
powerpc: Merge i8259.c into arch/powerpc/sysdev
This changes the parameters for i8259_init so that it takes two parameters: a physical address for generating an interrupt acknowledge cycle, and an interrupt number offset. i8259_init now sets the irq_desc[] for its interrupts; all the callers were doing this, and that code is gone now. This also defines a CONFIG_PPC_I8259 symbol to select i8259.o for inclusion, and makes the platforms that need it select that symbol. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc/syslib/i8259.c')
-rw-r--r--arch/ppc/syslib/i8259.c208
1 files changed, 0 insertions, 208 deletions
diff --git a/arch/ppc/syslib/i8259.c b/arch/ppc/syslib/i8259.c
deleted file mode 100644
index 5c7908c20e43..000000000000
--- a/arch/ppc/syslib/i8259.c
+++ /dev/null
@@ -1,208 +0,0 @@
1#include <linux/init.h>
2#include <linux/ioport.h>
3#include <linux/interrupt.h>
4#include <asm/io.h>
5#include <asm/i8259.h>
6
7static volatile unsigned char *pci_intack; /* RO, gives us the irq vector */
8
9unsigned char cached_8259[2] = { 0xff, 0xff };
10#define cached_A1 (cached_8259[0])
11#define cached_21 (cached_8259[1])
12
13static DEFINE_SPINLOCK(i8259_lock);
14
15int i8259_pic_irq_offset;
16
17/*
18 * Acknowledge the IRQ using either the PCI host bridge's interrupt
19 * acknowledge feature or poll. How i8259_init() is called determines
20 * which is called. It should be noted that polling is broken on some
21 * IBM and Motorola PReP boxes so we must use the int-ack feature on them.
22 */
23int
24i8259_irq(struct pt_regs *regs)
25{
26 int irq;
27
28 spin_lock(&i8259_lock);
29
30 /* Either int-ack or poll for the IRQ */
31 if (pci_intack)
32 irq = *pci_intack;
33 else {
34 /* Perform an interrupt acknowledge cycle on controller 1. */
35 outb(0x0C, 0x20); /* prepare for poll */
36 irq = inb(0x20) & 7;
37 if (irq == 2 ) {
38 /*
39 * Interrupt is cascaded so perform interrupt
40 * acknowledge on controller 2.
41 */
42 outb(0x0C, 0xA0); /* prepare for poll */
43 irq = (inb(0xA0) & 7) + 8;
44 }
45 }
46
47 if (irq == 7) {
48 /*
49 * This may be a spurious interrupt.
50 *
51 * Read the interrupt status register (ISR). If the most
52 * significant bit is not set then there is no valid
53 * interrupt.
54 */
55 if (!pci_intack)
56 outb(0x0B, 0x20); /* ISR register */
57 if(~inb(0x20) & 0x80)
58 irq = -1;
59 }
60
61 spin_unlock(&i8259_lock);
62 return irq;
63}
64
65static void i8259_mask_and_ack_irq(unsigned int irq_nr)
66{
67 unsigned long flags;
68
69 spin_lock_irqsave(&i8259_lock, flags);
70 if ( irq_nr >= i8259_pic_irq_offset )
71 irq_nr -= i8259_pic_irq_offset;
72
73 if (irq_nr > 7) {
74 cached_A1 |= 1 << (irq_nr-8);
75 inb(0xA1); /* DUMMY */
76 outb(cached_A1,0xA1);
77 outb(0x20,0xA0); /* Non-specific EOI */
78 outb(0x20,0x20); /* Non-specific EOI to cascade */
79 } else {
80 cached_21 |= 1 << irq_nr;
81 inb(0x21); /* DUMMY */
82 outb(cached_21,0x21);
83 outb(0x20,0x20); /* Non-specific EOI */
84 }
85 spin_unlock_irqrestore(&i8259_lock, flags);
86}
87
88static void i8259_set_irq_mask(int irq_nr)
89{
90 outb(cached_A1,0xA1);
91 outb(cached_21,0x21);
92}
93
94static void i8259_mask_irq(unsigned int irq_nr)
95{
96 unsigned long flags;
97
98 spin_lock_irqsave(&i8259_lock, flags);
99 if ( irq_nr >= i8259_pic_irq_offset )
100 irq_nr -= i8259_pic_irq_offset;
101 if ( irq_nr < 8 )
102 cached_21 |= 1 << irq_nr;
103 else
104 cached_A1 |= 1 << (irq_nr-8);
105 i8259_set_irq_mask(irq_nr);
106 spin_unlock_irqrestore(&i8259_lock, flags);
107}
108
109static void i8259_unmask_irq(unsigned int irq_nr)
110{
111 unsigned long flags;
112
113 spin_lock_irqsave(&i8259_lock, flags);
114 if ( irq_nr >= i8259_pic_irq_offset )
115 irq_nr -= i8259_pic_irq_offset;
116 if ( irq_nr < 8 )
117 cached_21 &= ~(1 << irq_nr);
118 else
119 cached_A1 &= ~(1 << (irq_nr-8));
120 i8259_set_irq_mask(irq_nr);
121 spin_unlock_irqrestore(&i8259_lock, flags);
122}
123
124static void i8259_end_irq(unsigned int irq)
125{
126 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))
127 && irq_desc[irq].action)
128 i8259_unmask_irq(irq);
129}
130
131struct hw_interrupt_type i8259_pic = {
132 .typename = " i8259 ",
133 .enable = i8259_unmask_irq,
134 .disable = i8259_mask_irq,
135 .ack = i8259_mask_and_ack_irq,
136 .end = i8259_end_irq,
137};
138
139static struct resource pic1_iores = {
140 .name = "8259 (master)",
141 .start = 0x20,
142 .end = 0x21,
143 .flags = IORESOURCE_BUSY,
144};
145
146static struct resource pic2_iores = {
147 .name = "8259 (slave)",
148 .start = 0xa0,
149 .end = 0xa1,
150 .flags = IORESOURCE_BUSY,
151};
152
153static struct resource pic_edgectrl_iores = {
154 .name = "8259 edge control",
155 .start = 0x4d0,
156 .end = 0x4d1,
157 .flags = IORESOURCE_BUSY,
158};
159
160static struct irqaction i8259_irqaction = {
161 .handler = no_action,
162 .flags = SA_INTERRUPT,
163 .mask = CPU_MASK_NONE,
164 .name = "82c59 secondary cascade",
165};
166
167/*
168 * i8259_init()
169 * intack_addr - PCI interrupt acknowledge (real) address which will return
170 * the active irq from the 8259
171 */
172void __init
173i8259_init(long intack_addr)
174{
175 unsigned long flags;
176
177 spin_lock_irqsave(&i8259_lock, flags);
178 /* init master interrupt controller */
179 outb(0x11, 0x20); /* Start init sequence */
180 outb(0x00, 0x21); /* Vector base */
181 outb(0x04, 0x21); /* edge tiggered, Cascade (slave) on IRQ2 */
182 outb(0x01, 0x21); /* Select 8086 mode */
183
184 /* init slave interrupt controller */
185 outb(0x11, 0xA0); /* Start init sequence */
186 outb(0x08, 0xA1); /* Vector base */
187 outb(0x02, 0xA1); /* edge triggered, Cascade (slave) on IRQ2 */
188 outb(0x01, 0xA1); /* Select 8086 mode */
189
190 /* always read ISR */
191 outb(0x0B, 0x20);
192 outb(0x0B, 0xA0);
193
194 /* Mask all interrupts */
195 outb(cached_A1, 0xA1);
196 outb(cached_21, 0x21);
197
198 spin_unlock_irqrestore(&i8259_lock, flags);
199
200 /* reserve our resources */
201 setup_irq( i8259_pic_irq_offset + 2, &i8259_irqaction);
202 request_resource(&ioport_resource, &pic1_iores);
203 request_resource(&ioport_resource, &pic2_iores);
204 request_resource(&ioport_resource, &pic_edgectrl_iores);
205
206 if (intack_addr != 0)
207 pci_intack = ioremap(intack_addr, 1);
208}