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 <asm/mach/irq.h>
13 #include <asm/mach-types.h>
14 #include <asm/arch-ns9xxx/regs-sys.h>
15 #include <asm/arch-ns9xxx/irqs.h>
16 #include <asm/arch-ns9xxx/board.h>
20 static void ns9xxx_ack_irq_timer(unsigned int irq
)
22 u32 tc
= SYS_TC(irq
- IRQ_TIMER0
);
24 REGSET(tc
, SYS_TCx
, INTC
, SET
);
25 SYS_TC(irq
- IRQ_TIMER0
) = tc
;
27 REGSET(tc
, SYS_TCx
, INTC
, UNSET
);
28 SYS_TC(irq
- IRQ_TIMER0
) = tc
;
31 void (*ns9xxx_ack_irq_functions
[NR_IRQS
])(unsigned int) = {
32 [IRQ_TIMER0
] = ns9xxx_ack_irq_timer
,
33 [IRQ_TIMER1
] = ns9xxx_ack_irq_timer
,
34 [IRQ_TIMER2
] = ns9xxx_ack_irq_timer
,
35 [IRQ_TIMER3
] = ns9xxx_ack_irq_timer
,
38 static void ns9xxx_mask_irq(unsigned int irq
)
40 /* XXX: better use cpp symbols */
41 SYS_IC(irq
/ 4) &= ~(1 << (7 + 8 * (3 - (irq
& 3))));
44 static void ns9xxx_ack_irq(unsigned int irq
)
46 if (!ns9xxx_ack_irq_functions
[irq
]) {
47 printk(KERN_ERR
"no ack function for irq %u\n", irq
);
51 ns9xxx_ack_irq_functions
[irq
](irq
);
55 static void ns9xxx_maskack_irq(unsigned int irq
)
61 static void ns9xxx_unmask_irq(unsigned int irq
)
63 /* XXX: better use cpp symbols */
64 SYS_IC(irq
/ 4) |= 1 << (7 + 8 * (3 - (irq
& 3)));
67 static struct irq_chip ns9xxx_chip
= {
68 .ack
= ns9xxx_ack_irq
,
69 .mask
= ns9xxx_mask_irq
,
70 .mask_ack
= ns9xxx_maskack_irq
,
71 .unmask
= ns9xxx_unmask_irq
,
74 void __init
ns9xxx_init_irq(void)
78 /* disable all IRQs */
79 for (i
= 0; i
< 8; ++i
)
80 SYS_IC(i
) = (4 * i
) << 24 | (4 * i
+ 1) << 16 |
81 (4 * i
+ 2) << 8 | (4 * i
+ 3);
83 /* simple interrupt prio table:
84 * prio(x) < prio(y) <=> x < y
86 for (i
= 0; i
< 32; ++i
)
89 for (i
= IRQ_WATCHDOG
; i
<= IRQ_EXT3
; ++i
) {
90 set_irq_chip(i
, &ns9xxx_chip
);
91 set_irq_handler(i
, handle_level_irq
);
92 set_irq_flags(i
, IRQF_VALID
);