2 * arch/arm/mach-ns9xxx/irq.c
4 * Copyright (C) 2006,2007 by Digi International Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 #include <linux/interrupt.h>
12 #include <linux/kernel_stat.h>
14 #include <asm/mach/irq.h>
15 #include <mach/regs-sys-common.h>
16 #include <mach/irqs.h>
17 #include <mach/board.h>
21 /* simple interrupt prio table: prio(x) < prio(y) <=> x < y */
22 #define irq2prio(i) (i)
23 #define prio2irq(p) (p)
25 static void ns9xxx_mask_irq(struct irq_data
*d
)
27 /* XXX: better use cpp symbols */
28 int prio
= irq2prio(d
->irq
);
29 u32 ic
= __raw_readl(SYS_IC(prio
/ 4));
30 ic
&= ~(1 << (7 + 8 * (3 - (prio
& 3))));
31 __raw_writel(ic
, SYS_IC(prio
/ 4));
34 static void ns9xxx_eoi_irq(struct irq_data
*d
)
36 __raw_writel(0, SYS_ISRADDR
);
39 static void ns9xxx_unmask_irq(struct irq_data
*d
)
41 /* XXX: better use cpp symbols */
42 int prio
= irq2prio(d
->irq
);
43 u32 ic
= __raw_readl(SYS_IC(prio
/ 4));
44 ic
|= 1 << (7 + 8 * (3 - (prio
& 3)));
45 __raw_writel(ic
, SYS_IC(prio
/ 4));
48 static struct irq_chip ns9xxx_chip
= {
49 .irq_eoi
= ns9xxx_eoi_irq
,
50 .irq_mask
= ns9xxx_mask_irq
,
51 .irq_unmask
= ns9xxx_unmask_irq
,
54 void __init
ns9xxx_init_irq(void)
58 /* disable all IRQs */
59 for (i
= 0; i
< 8; ++i
)
60 __raw_writel(prio2irq(4 * i
) << 24 |
61 prio2irq(4 * i
+ 1) << 16 |
62 prio2irq(4 * i
+ 2) << 8 |
66 for (i
= 0; i
< 32; ++i
)
67 __raw_writel(prio2irq(i
), SYS_IVA(i
));
69 for (i
= 0; i
<= 31; ++i
) {
70 irq_set_chip_and_handler(i
, &ns9xxx_chip
, handle_fasteoi_irq
);
71 set_irq_flags(i
, IRQF_VALID
);
72 irq_set_status_flags(i
, IRQ_LEVEL
);