2 * arch/ppc/syslib/cpc700_pic.c
4 * Interrupt controller support for IBM Spruce
6 * Authors: Mark Greer, Matt Porter, and Johnnie Peters
11 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
12 * the terms of the GNU General Public License version 2. This program
13 * is licensed "as is" without any warranty of any kind, whether express
17 #include <linux/stddef.h>
18 #include <linux/init.h>
19 #include <linux/sched.h>
20 #include <linux/signal.h>
21 #include <linux/irq.h>
24 #include <asm/system.h>
30 cpc700_unmask_irq(unsigned int irq
)
35 * IRQ 31 is largest IRQ supported.
36 * IRQs 17-19 are reserved.
38 if ((irq
<= 31) && ((irq
< 17) || (irq
> 19))) {
39 tr_bits
= CPC700_IN_32(CPC700_UIC_UICTR
);
41 if ((tr_bits
& (1 << (31 - irq
))) == 0) {
42 /* level trigger interrupt, clear bit in status
44 CPC700_OUT_32(CPC700_UIC_UICSR
, 1 << (31 - irq
));
47 /* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
48 ppc_cached_irq_mask
[0] |= CPC700_UIC_IRQ_BIT(irq
);
50 CPC700_OUT_32(CPC700_UIC_UICER
, ppc_cached_irq_mask
[0]);
56 cpc700_mask_irq(unsigned int irq
)
59 * IRQ 31 is largest IRQ supported.
60 * IRQs 17-19 are reserved.
62 if ((irq
<= 31) && ((irq
< 17) || (irq
> 19))) {
63 /* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
64 ppc_cached_irq_mask
[0] &=
65 ~CPC700_UIC_IRQ_BIT(irq
);
67 CPC700_OUT_32(CPC700_UIC_UICER
, ppc_cached_irq_mask
[0]);
73 cpc700_mask_and_ack_irq(unsigned int irq
)
78 * IRQ 31 is largest IRQ supported.
79 * IRQs 17-19 are reserved.
81 if ((irq
<= 31) && ((irq
< 17) || (irq
> 19))) {
82 /* Know IRQ fits in entry 0 of ppc_cached_irq_mask[] */
83 bit
= CPC700_UIC_IRQ_BIT(irq
);
85 ppc_cached_irq_mask
[0] &= ~bit
;
86 CPC700_OUT_32(CPC700_UIC_UICER
, ppc_cached_irq_mask
[0]);
87 CPC700_OUT_32(CPC700_UIC_UICSR
, bit
); /* Write 1 clears IRQ */
92 static struct hw_interrupt_type cpc700_pic
= {
98 cpc700_mask_and_ack_irq
,
104 cpc700_pic_init_irq(unsigned int irq
)
108 /* Set interrupt sense */
109 tmp
= CPC700_IN_32(CPC700_UIC_UICTR
);
110 if (cpc700_irq_assigns
[irq
][0] == 0) {
111 tmp
&= ~CPC700_UIC_IRQ_BIT(irq
);
113 tmp
|= CPC700_UIC_IRQ_BIT(irq
);
115 CPC700_OUT_32(CPC700_UIC_UICTR
, tmp
);
117 /* Set interrupt polarity */
118 tmp
= CPC700_IN_32(CPC700_UIC_UICPR
);
119 if (cpc700_irq_assigns
[irq
][1]) {
120 tmp
|= CPC700_UIC_IRQ_BIT(irq
);
122 tmp
&= ~CPC700_UIC_IRQ_BIT(irq
);
124 CPC700_OUT_32(CPC700_UIC_UICPR
, tmp
);
126 /* Set interrupt critical */
127 tmp
= CPC700_IN_32(CPC700_UIC_UICCR
);
128 tmp
|= CPC700_UIC_IRQ_BIT(irq
);
129 CPC700_OUT_32(CPC700_UIC_UICCR
, tmp
);
135 cpc700_init_IRQ(void)
139 ppc_cached_irq_mask
[0] = 0;
140 CPC700_OUT_32(CPC700_UIC_UICER
, 0x00000000); /* Disable all irq's */
141 CPC700_OUT_32(CPC700_UIC_UICSR
, 0xffffffff); /* Clear cur intrs */
142 CPC700_OUT_32(CPC700_UIC_UICCR
, 0xffffffff); /* Gen INT not MCP */
143 CPC700_OUT_32(CPC700_UIC_UICPR
, 0x00000000); /* Active low */
144 CPC700_OUT_32(CPC700_UIC_UICTR
, 0x00000000); /* Level Sensitive */
145 CPC700_OUT_32(CPC700_UIC_UICVR
, CPC700_UIC_UICVCR_0_HI
);
146 /* IRQ 0 is highest */
148 for (i
= 0; i
< 17; i
++) {
149 irq_desc
[i
].handler
= &cpc700_pic
;
150 cpc700_pic_init_irq(i
);
153 for (i
= 20; i
< 32; i
++) {
154 irq_desc
[i
].handler
= &cpc700_pic
;
155 cpc700_pic_init_irq(i
);
164 * Find the highest IRQ that generating an interrupt, if any.
167 cpc700_get_irq(struct pt_regs
*regs
)
170 u_int irq_status
, irq_test
= 1;
172 irq_status
= CPC700_IN_32(CPC700_UIC_UICMSR
);
176 if (irq_status
& irq_test
)
180 } while (irq
< NR_IRQS
);