1+ /*
2+ * i8259 interrupt controller driver.
3+ *
4+ * This program is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU General Public License
6+ * as published by the Free Software Foundation; either version
7+ * 2 of the License, or (at your option) any later version.
8+ */
19#include <linux/init.h>
210#include <linux/ioport.h>
311#include <linux/interrupt.h>
412#include <asm/io.h>
513#include <asm/i8259.h>
614
7- static volatile unsigned char * pci_intack ; /* RO, gives us the irq vector */
15+ static volatile void __iomem * pci_intack ; /* RO, gives us the irq vector */
816
9- unsigned char cached_8259 [2 ] = { 0xff , 0xff };
17+ static unsigned char cached_8259 [2 ] = { 0xff , 0xff };
1018#define cached_A1 (cached_8259[0])
1119#define cached_21 (cached_8259[1])
1220
1321static DEFINE_SPINLOCK (i8259_lock );
1422
15- int i8259_pic_irq_offset ;
23+ static int i8259_pic_irq_offset ;
1624
1725/*
1826 * Acknowledge the IRQ using either the PCI host bridge's interrupt
1927 * acknowledge feature or poll. How i8259_init() is called determines
2028 * which is called. It should be noted that polling is broken on some
2129 * IBM and Motorola PReP boxes so we must use the int-ack feature on them.
2230 */
23- int
24- i8259_irq (struct pt_regs * regs )
31+ int i8259_irq (struct pt_regs * regs )
2532{
2633 int irq ;
2734
2835 spin_lock (& i8259_lock );
2936
3037 /* Either int-ack or poll for the IRQ */
3138 if (pci_intack )
32- irq = * pci_intack ;
39+ irq = readb ( pci_intack ) ;
3340 else {
3441 /* Perform an interrupt acknowledge cycle on controller 1. */
3542 outb (0x0C , 0x20 ); /* prepare for poll */
@@ -59,28 +66,31 @@ i8259_irq(struct pt_regs *regs)
5966 }
6067
6168 spin_unlock (& i8259_lock );
62- return irq ;
69+ return irq + i8259_pic_irq_offset ;
70+ }
71+
72+ int i8259_irq_cascade (struct pt_regs * regs , void * unused )
73+ {
74+ return i8259_irq (regs );
6375}
6476
6577static void i8259_mask_and_ack_irq (unsigned int irq_nr )
6678{
6779 unsigned long flags ;
6880
6981 spin_lock_irqsave (& i8259_lock , flags );
70- if ( irq_nr >= i8259_pic_irq_offset )
71- irq_nr -= i8259_pic_irq_offset ;
72-
82+ irq_nr -= i8259_pic_irq_offset ;
7383 if (irq_nr > 7 ) {
7484 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 */
85+ inb (0xA1 ); /* DUMMY */
86+ outb (cached_A1 , 0xA1 );
87+ outb (0x20 , 0xA0 ); /* Non-specific EOI */
88+ outb (0x20 , 0x20 ); /* Non-specific EOI to cascade */
7989 } else {
8090 cached_21 |= 1 << irq_nr ;
81- inb (0x21 ); /* DUMMY */
82- outb (cached_21 ,0x21 );
83- outb (0x20 ,0x20 ); /* Non-specific EOI */
91+ inb (0x21 ); /* DUMMY */
92+ outb (cached_21 , 0x21 );
93+ outb (0x20 , 0x20 ); /* Non-specific EOI */
8494 }
8595 spin_unlock_irqrestore (& i8259_lock , flags );
8696}
@@ -96,9 +106,8 @@ static void i8259_mask_irq(unsigned int irq_nr)
96106 unsigned long flags ;
97107
98108 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 )
109+ irq_nr -= i8259_pic_irq_offset ;
110+ if (irq_nr < 8 )
102111 cached_21 |= 1 << irq_nr ;
103112 else
104113 cached_A1 |= 1 << (irq_nr - 8 );
@@ -111,9 +120,8 @@ static void i8259_unmask_irq(unsigned int irq_nr)
111120 unsigned long flags ;
112121
113122 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 )
123+ irq_nr -= i8259_pic_irq_offset ;
124+ if (irq_nr < 8 )
117125 cached_21 &= ~(1 << irq_nr );
118126 else
119127 cached_A1 &= ~(1 << (irq_nr - 8 ));
@@ -169,12 +177,14 @@ static struct irqaction i8259_irqaction = {
169177 * intack_addr - PCI interrupt acknowledge (real) address which will return
170178 * the active irq from the 8259
171179 */
172- void __init
173- i8259_init (long intack_addr )
180+ void __init i8259_init (unsigned long intack_addr , int offset )
174181{
175182 unsigned long flags ;
183+ int i ;
176184
177185 spin_lock_irqsave (& i8259_lock , flags );
186+ i8259_pic_irq_offset = offset ;
187+
178188 /* init master interrupt controller */
179189 outb (0x11 , 0x20 ); /* Start init sequence */
180190 outb (0x00 , 0x21 ); /* Vector base */
@@ -198,11 +208,14 @@ i8259_init(long intack_addr)
198208 spin_unlock_irqrestore (& i8259_lock , flags );
199209
200210 /* reserve our resources */
201- setup_irq ( i8259_pic_irq_offset + 2 , & i8259_irqaction );
211+ setup_irq (offset + 2 , & i8259_irqaction );
202212 request_resource (& ioport_resource , & pic1_iores );
203213 request_resource (& ioport_resource , & pic2_iores );
204214 request_resource (& ioport_resource , & pic_edgectrl_iores );
205215
206216 if (intack_addr != 0 )
207217 pci_intack = ioremap (intack_addr , 1 );
218+
219+ for (i = 0 ; i < NUM_ISA_INTERRUPTS ; ++ i )
220+ irq_desc [offset + i ].handler = & i8259_pic ;
208221}
0 commit comments