2 * Interrupt controller support for IBM Spruce
4 * Authors: Mark Greer, Matt Porter, and Johnnie Peters
9 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
15 #include <linux/stddef.h>
16 #include <linux/init.h>
17 #include <linux/sched.h>
18 #include <linux/signal.h>
19 #include <linux/irq.h>
22 #include <asm/system.h>
28 cpc700_unmask_irq(unsigned int irq
)
33 * IRQ 31 is largest IRQ supported.
34 * IRQs 17-19 are reserved.
36 if ((irq
<= 31) && ((irq
< 17) || (irq
> 19))) {
37 tr_bits
= CPC700_IN_32(CPC700_UIC_UICTR
);
39 if ((tr_bits
& (1 << (31 - irq
))) == 0) {
40 /* level trigger interrupt, clear bit in status
42 CPC700_OUT_32(CPC700_UIC_UICSR
, 1 << (31 - irq
));
45 /* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
46 ppc_cached_irq_mask
[0] |= CPC700_UIC_IRQ_BIT(irq
);
48 CPC700_OUT_32(CPC700_UIC_UICER
, ppc_cached_irq_mask
[0]);
54 cpc700_mask_irq(unsigned int irq
)
57 * IRQ 31 is largest IRQ supported.
58 * IRQs 17-19 are reserved.
60 if ((irq
<= 31) && ((irq
< 17) || (irq
> 19))) {
61 /* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
62 ppc_cached_irq_mask
[0] &=
63 ~CPC700_UIC_IRQ_BIT(irq
);
65 CPC700_OUT_32(CPC700_UIC_UICER
, ppc_cached_irq_mask
[0]);
71 cpc700_mask_and_ack_irq(unsigned int irq
)
76 * IRQ 31 is largest IRQ supported.
77 * IRQs 17-19 are reserved.
79 if ((irq
<= 31) && ((irq
< 17) || (irq
> 19))) {
80 /* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
81 bit
= CPC700_UIC_IRQ_BIT(irq
);
83 ppc_cached_irq_mask
[0] &= ~bit
;
84 CPC700_OUT_32(CPC700_UIC_UICER
, ppc_cached_irq_mask
[0]);
85 CPC700_OUT_32(CPC700_UIC_UICSR
, bit
); /* Write 1 clears IRQ */
90 static struct hw_interrupt_type cpc700_pic
= {
91 .typename
= "CPC700 PIC",
92 .enable
= cpc700_unmask_irq
,
93 .disable
= cpc700_mask_irq
,
94 .ack
= cpc700_mask_and_ack_irq
,
98 cpc700_pic_init_irq(unsigned int irq
)
102 /* Set interrupt sense */
103 tmp
= CPC700_IN_32(CPC700_UIC_UICTR
);
104 if (cpc700_irq_assigns
[irq
][0] == 0) {
105 tmp
&= ~CPC700_UIC_IRQ_BIT(irq
);
107 tmp
|= CPC700_UIC_IRQ_BIT(irq
);
109 CPC700_OUT_32(CPC700_UIC_UICTR
, tmp
);
111 /* Set interrupt polarity */
112 tmp
= CPC700_IN_32(CPC700_UIC_UICPR
);
113 if (cpc700_irq_assigns
[irq
][1]) {
114 tmp
|= CPC700_UIC_IRQ_BIT(irq
);
116 tmp
&= ~CPC700_UIC_IRQ_BIT(irq
);
118 CPC700_OUT_32(CPC700_UIC_UICPR
, tmp
);
120 /* Set interrupt critical */
121 tmp
= CPC700_IN_32(CPC700_UIC_UICCR
);
122 tmp
|= CPC700_UIC_IRQ_BIT(irq
);
123 CPC700_OUT_32(CPC700_UIC_UICCR
, tmp
);
129 cpc700_init_IRQ(void)
133 ppc_cached_irq_mask
[0] = 0;
134 CPC700_OUT_32(CPC700_UIC_UICER
, 0x00000000); /* Disable all irq's */
135 CPC700_OUT_32(CPC700_UIC_UICSR
, 0xffffffff); /* Clear cur intrs */
136 CPC700_OUT_32(CPC700_UIC_UICCR
, 0xffffffff); /* Gen INT not MCP */
137 CPC700_OUT_32(CPC700_UIC_UICPR
, 0x00000000); /* Active low */
138 CPC700_OUT_32(CPC700_UIC_UICTR
, 0x00000000); /* Level Sensitive */
139 CPC700_OUT_32(CPC700_UIC_UICVR
, CPC700_UIC_UICVCR_0_HI
);
140 /* IRQ 0 is highest */
142 for (i
= 0; i
< 17; i
++) {
143 irq_desc
[i
].chip
= &cpc700_pic
;
144 cpc700_pic_init_irq(i
);
147 for (i
= 20; i
< 32; i
++) {
148 irq_desc
[i
].chip
= &cpc700_pic
;
149 cpc700_pic_init_irq(i
);
158 * Find the highest IRQ that generating an interrupt, if any.
164 u_int irq_status
, irq_test
= 1;
166 irq_status
= CPC700_IN_32(CPC700_UIC_UICMSR
);
170 if (irq_status
& irq_test
)
174 } while (irq
< NR_IRQS
);