19 #include <linux/kernel.h>
20 #include <linux/types.h>
29 #include <linux/module.h>
31 #include <mach/irqs.h>
32 #include <mach/hardware.h>
33 #include <mach/platform.h>
40 #define MIC_APR_DEFAULT 0x3FF0EFE0
41 #define SIC1_APR_DEFAULT 0xFBD27186
42 #define SIC2_APR_DEFAULT 0x801810C0
48 #define MIC_ATR_DEFAULT 0x00000000
49 #define SIC1_ATR_DEFAULT 0x00026000
50 #define SIC2_ATR_DEFAULT 0x00000000
86 .event_group = &lpc32xx_event_pin_regs,
90 .event_group = &lpc32xx_event_pin_regs,
94 .event_group = &lpc32xx_event_pin_regs,
98 .event_group = &lpc32xx_event_pin_regs,
102 .event_group = &lpc32xx_event_pin_regs,
106 .event_group = &lpc32xx_event_pin_regs,
110 .event_group = &lpc32xx_event_pin_regs,
114 .event_group = &lpc32xx_event_pin_regs,
118 .event_group = &lpc32xx_event_pin_regs,
122 .event_group = &lpc32xx_event_pin_regs,
126 .event_group = &lpc32xx_event_pin_regs,
130 .event_group = &lpc32xx_event_pin_regs,
134 .event_group = &lpc32xx_event_int_regs,
138 .event_group = &lpc32xx_event_int_regs,
142 .event_group = &lpc32xx_event_int_regs,
146 .event_group = &lpc32xx_event_int_regs,
150 .event_group = &lpc32xx_event_int_regs,
154 .event_group = &lpc32xx_event_int_regs,
158 .event_group = &lpc32xx_event_int_regs,
162 .event_group = &lpc32xx_event_int_regs,
166 .event_group = &lpc32xx_event_int_regs,
170 .event_group = &lpc32xx_event_int_regs,
174 .event_group = &lpc32xx_event_int_regs,
178 .event_group = &lpc32xx_event_int_regs,
182 .event_group = &lpc32xx_event_int_regs,
186 .event_group = &lpc32xx_event_int_regs,
190 .event_group = &lpc32xx_event_int_regs,
195 static void get_controller(
unsigned int irq,
unsigned int *base,
196 unsigned int *irqbit)
201 }
else if (irq < 64) {
203 *irqbit = 1 << (irq - 32);
206 *irqbit = 1 << (irq - 64);
210 static void lpc32xx_mask_irq(
struct irq_data *
d)
214 get_controller(d->
hwirq, &ctrl, &mask);
220 static void lpc32xx_unmask_irq(
struct irq_data *d)
224 get_controller(d->
hwirq, &ctrl, &mask);
230 static void lpc32xx_ack_irq(
struct irq_data *d)
234 get_controller(d->
hwirq, &ctrl, &mask);
244 static void __lpc32xx_set_irq_type(
unsigned int irq,
int use_high_level,
249 get_controller(irq, &ctrl, &mask);
268 if (lpc32xx_events[irq].mask != 0) {
272 reg |= lpc32xx_events[irq].
mask;
274 reg &= ~lpc32xx_events[irq].
mask;
280 static int lpc32xx_set_irq_type(
struct irq_data *d,
unsigned int type)
285 __lpc32xx_set_irq_type(d->
hwirq, 1, 1);
291 __lpc32xx_set_irq_type(d->
hwirq, 0, 1);
297 __lpc32xx_set_irq_type(d->
hwirq, 0, 0);
303 __lpc32xx_set_irq_type(d->
hwirq, 1, 0);
315 static int lpc32xx_irq_wake(
struct irq_data *d,
unsigned int state)
317 unsigned long eventreg;
319 if (lpc32xx_events[d->
hwirq].
mask != 0) {
324 eventreg |= lpc32xx_events[d->
hwirq].
mask;
326 eventreg &= ~lpc32xx_events[d->
hwirq].
mask;
333 lpc32xx_events[d->
hwirq].
350 static void __init lpc32xx_set_default_mappings(
unsigned int apr,
351 unsigned int atr,
unsigned int offset)
358 __lpc32xx_set_irq_type(offset + i, ((apr >> i) & 0x1),
364 static struct irq_chip lpc32xx_irq_chip = {
366 .irq_ack = lpc32xx_ack_irq,
367 .irq_mask = lpc32xx_mask_irq,
368 .irq_unmask = lpc32xx_unmask_irq,
369 .irq_set_type = lpc32xx_set_irq_type,
370 .irq_set_wake = lpc32xx_irq_wake
373 static void lpc32xx_sic1_handler(
unsigned int irq,
struct irq_desc *
desc)
378 int irqno = fls(ints) - 1;
380 ints &= ~(1 << irqno);
386 static void lpc32xx_sic2_handler(
unsigned int irq,
struct irq_desc *desc)
391 int irqno = fls(ints) - 1;
393 ints &= ~(1 << irqno);
402 lpc32xx_mic_np =
node;
408 { .compatible =
"nxp,lpc3220-mic", .data = __lpc32xx_mic_of_init },
435 for (i = 0; i <
NR_IRQS; i++) {
436 irq_set_chip_and_handler(i, &lpc32xx_irq_chip,
478 irq_base = irq_alloc_descs(-1, 0, NR_IRQS, 0);
480 pr_warn(
"Cannot allocate irq_descs, assuming pre-allocated\n");
488 if (!lpc32xx_mic_domain)
489 panic(
"Unable to add MIC irq domain\n");