29 #include <linux/stddef.h>
31 #include <linux/sched.h>
32 #include <linux/signal.h>
44 #define CPM2_IRQ_EXT1 19
45 #define CPM2_IRQ_EXT7 25
48 #define CPM2_IRQ_PORTC15 48
49 #define CPM2_IRQ_PORTC0 63
51 static intctl_cpm2_t
__iomem *cpm2_intctl;
54 static unsigned long ppc_cached_irq_mask[2];
56 static const u_char irq_to_siureg[] = {
57 1, 1, 1, 1, 1, 1, 1, 1,
58 1, 1, 1, 1, 1, 1, 1, 1,
59 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0,
61 1, 1, 1, 1, 1, 1, 1, 1,
62 1, 1, 1, 1, 1, 1, 1, 1,
63 0, 0, 0, 0, 0, 0, 0, 0,
64 0, 0, 0, 0, 0, 0, 0, 0
69 static const u_char irq_to_siubit[] = {
70 0, 15, 14, 13, 12, 11, 10, 9,
71 8, 7, 6, 5, 4, 3, 2, 1,
72 2, 1, 0, 14, 13, 12, 11, 10,
73 9, 8, 7, 6, 5, 4, 3, 0,
74 31, 30, 29, 28, 27, 26, 25, 24,
75 23, 22, 21, 20, 19, 18, 17, 16,
76 16, 17, 18, 19, 20, 21, 22, 23,
77 24, 25, 26, 27, 28, 29, 30, 31,
80 static void cpm2_mask_irq(
struct irq_data *
d)
83 unsigned int irq_nr = irqd_to_hwirq(d);
85 bit = irq_to_siubit[irq_nr];
86 word = irq_to_siureg[irq_nr];
88 ppc_cached_irq_mask[
word] &= ~(1 <<
bit);
89 out_be32(&cpm2_intctl->ic_simrh + word, ppc_cached_irq_mask[word]);
92 static void cpm2_unmask_irq(
struct irq_data *
d)
95 unsigned int irq_nr = irqd_to_hwirq(d);
97 bit = irq_to_siubit[irq_nr];
98 word = irq_to_siureg[irq_nr];
100 ppc_cached_irq_mask[
word] |= 1 <<
bit;
101 out_be32(&cpm2_intctl->ic_simrh + word, ppc_cached_irq_mask[word]);
107 unsigned int irq_nr = irqd_to_hwirq(d);
109 bit = irq_to_siubit[irq_nr];
110 word = irq_to_siureg[irq_nr];
112 out_be32(&cpm2_intctl->ic_sipnrh + word, 1 << bit);
115 static void cpm2_end_irq(
struct irq_data *
d)
118 unsigned int irq_nr = irqd_to_hwirq(d);
120 bit = irq_to_siubit[irq_nr];
121 word = irq_to_siureg[irq_nr];
123 ppc_cached_irq_mask[
word] |= 1 <<
bit;
124 out_be32(&cpm2_intctl->ic_simrh + word, ppc_cached_irq_mask[word]);
133 static int cpm2_set_irq_type(
struct irq_data *
d,
unsigned int flow_type)
135 unsigned int src = irqd_to_hwirq(d);
136 unsigned int vold, vnew, edibit;
157 irqd_set_trigger_type(d, flow_type);
172 return (flow_type & IRQ_TYPE_LEVEL_LOW) ?
175 vold =
in_be32(&cpm2_intctl->ic_siexr);
178 vnew = vold | (1 << edibit);
180 vnew = vold & ~(1 << edibit);
183 out_be32(&cpm2_intctl->ic_siexr, vnew);
187 pr_err(
"CPM2 PIC: sense type 0x%x not supported\n", flow_type);
193 .irq_mask = cpm2_mask_irq,
194 .irq_unmask = cpm2_unmask_irq,
196 .irq_eoi = cpm2_end_irq,
197 .irq_set_type = cpm2_set_irq_type,
208 bits =
in_be32(&cpm2_intctl->ic_sivec);
216 static int cpm2_pic_host_map(
struct irq_domain *
h,
unsigned int virq,
219 pr_debug(
"cpm2_pic_host_map(%d, 0x%lx)\n", virq, hw);
227 .map = cpm2_pic_host_map,
235 cpm2_intctl = cpm2_map(im_intctl);
243 out_be32(&cpm2_intctl->ic_simrh, 0x00000000);
244 out_be32(&cpm2_intctl->ic_simrl, 0x00000000);
249 out_be32(&cpm2_intctl->ic_sipnrh, 0xffffffff);
250 out_be32(&cpm2_intctl->ic_sipnrl, 0xffffffff);
254 i =
in_be32(&cpm2_intctl->ic_sivec);
261 out_be32(&cpm2_intctl->ic_scprrh, 0x05309770);
262 out_be32(&cpm2_intctl->ic_scprrl, 0x05309770);
266 if (cpm2_pic_host ==
NULL) {