1 #include <linux/stddef.h>
2 #include <linux/init.h>
3 #include <linux/sched.h>
4 #include <linux/signal.h>
6 #include <asm/immap_cpm2.h>
7 #include <asm/mpc8260.h>
10 /* The CPM2 internal interrupt controller. It is usually
11 * the only interrupt controller.
12 * There are two 32-bit registers (high/low) for up to 64
13 * possible interrupts.
15 * Now, the fun starts.....Interrupt Numbers DO NOT MAP
16 * in a simple arithmetic fashion to mask or pending registers.
17 * That is, interrupt 4 does not map to bit position 4.
18 * We create two tables, indexed by vector number, to indicate
19 * which register to use and which bit in the register to use.
21 static u_char irq_to_siureg[] = {
22 1, 1, 1, 1, 1, 1, 1, 1,
23 1, 1, 1, 1, 1, 1, 1, 1,
24 0, 0, 0, 0, 0, 0, 0, 0,
25 0, 0, 0, 0, 0, 0, 0, 0,
26 1, 1, 1, 1, 1, 1, 1, 1,
27 1, 1, 1, 1, 1, 1, 1, 1,
28 0, 0, 0, 0, 0, 0, 0, 0,
29 0, 0, 0, 0, 0, 0, 0, 0
32 static u_char irq_to_siubit[] = {
33 31, 16, 17, 18, 19, 20, 21, 22,
34 23, 24, 25, 26, 27, 28, 29, 30,
35 29, 30, 16, 17, 18, 19, 20, 21,
36 22, 23, 24, 25, 26, 27, 28, 31,
37 0, 1, 2, 3, 4, 5, 6, 7,
38 8, 9, 10, 11, 12, 13, 14, 15,
39 15, 14, 13, 12, 11, 10, 9, 8,
40 7, 6, 5, 4, 3, 2, 1, 0
43 static void cpm2_mask_irq(unsigned int irq_nr)
48 bit = irq_to_siubit[irq_nr];
49 word = irq_to_siureg[irq_nr];
51 simr = &(cpm2_immr->im_intctl.ic_simrh);
52 ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
53 simr[word] = ppc_cached_irq_mask[word];
56 static void cpm2_unmask_irq(unsigned int irq_nr)
61 bit = irq_to_siubit[irq_nr];
62 word = irq_to_siureg[irq_nr];
64 simr = &(cpm2_immr->im_intctl.ic_simrh);
65 ppc_cached_irq_mask[word] |= (1 << (31 - bit));
66 simr[word] = ppc_cached_irq_mask[word];
69 static void cpm2_mask_and_ack(unsigned int irq_nr)
72 volatile uint *simr, *sipnr;
74 bit = irq_to_siubit[irq_nr];
75 word = irq_to_siureg[irq_nr];
77 simr = &(cpm2_immr->im_intctl.ic_simrh);
78 sipnr = &(cpm2_immr->im_intctl.ic_sipnrh);
79 ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
80 simr[word] = ppc_cached_irq_mask[word];
81 sipnr[word] = 1 << (31 - bit);
84 static void cpm2_end_irq(unsigned int irq_nr)
89 if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))
90 && irq_desc[irq_nr].action) {
92 bit = irq_to_siubit[irq_nr];
93 word = irq_to_siureg[irq_nr];
95 simr = &(cpm2_immr->im_intctl.ic_simrh);
96 ppc_cached_irq_mask[word] |= (1 << (31 - bit));
97 simr[word] = ppc_cached_irq_mask[word];
101 struct hw_interrupt_type cpm2_pic = {
114 cpm2_get_irq(struct pt_regs *regs)
119 /* For CPM2, read the SIVEC register and shift the bits down
120 * to get the irq number. */
121 bits = cpm2_immr->im_intctl.ic_sivec;
127 irq += ppc8260_pic.irq_offset;