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
);
25 * If the timer is programmed to halt on terminal count, the
26 * timer must be disabled before clearing the interrupt.
28 if (REGGET(tc
, SYS_TCx
, REN
) == 0) {
29 REGSET(tc
, SYS_TCx
, TEN
, DIS
);
30 SYS_TC(irq
- IRQ_TIMER0
) = tc
;
33 REGSET(tc
, SYS_TCx
, INTC
, SET
);
34 SYS_TC(irq
- IRQ_TIMER0
) = tc
;
36 REGSET(tc
, SYS_TCx
, INTC
, UNSET
);
37 SYS_TC(irq
- IRQ_TIMER0
) = tc
;
40 static void (*ns9xxx_ack_irq_functions
[NR_IRQS
])(unsigned int) = {
41 [IRQ_TIMER0
] = ns9xxx_ack_irq_timer
,
42 [IRQ_TIMER1
] = ns9xxx_ack_irq_timer
,
43 [IRQ_TIMER2
] = ns9xxx_ack_irq_timer
,
44 [IRQ_TIMER3
] = ns9xxx_ack_irq_timer
,
47 static void ns9xxx_mask_irq(unsigned int irq
)
49 /* XXX: better use cpp symbols */
50 SYS_IC(irq
/ 4) &= ~(1 << (7 + 8 * (3 - (irq
& 3))));
53 static void ns9xxx_ack_irq(unsigned int irq
)
55 if (!ns9xxx_ack_irq_functions
[irq
]) {
56 printk(KERN_ERR
"no ack function for irq %u\n", irq
);
60 ns9xxx_ack_irq_functions
[irq
](irq
);
64 static void ns9xxx_maskack_irq(unsigned int irq
)
70 static void ns9xxx_unmask_irq(unsigned int irq
)
72 /* XXX: better use cpp symbols */
73 SYS_IC(irq
/ 4) |= 1 << (7 + 8 * (3 - (irq
& 3)));
76 static struct irq_chip ns9xxx_chip
= {
77 .ack
= ns9xxx_ack_irq
,
78 .mask
= ns9xxx_mask_irq
,
79 .mask_ack
= ns9xxx_maskack_irq
,
80 .unmask
= ns9xxx_unmask_irq
,
83 void __init
ns9xxx_init_irq(void)
87 /* disable all IRQs */
88 for (i
= 0; i
< 8; ++i
)
89 SYS_IC(i
) = (4 * i
) << 24 | (4 * i
+ 1) << 16 |
90 (4 * i
+ 2) << 8 | (4 * i
+ 3);
92 /* simple interrupt prio table:
93 * prio(x) < prio(y) <=> x < y
95 for (i
= 0; i
< 32; ++i
)
98 for (i
= IRQ_WATCHDOG
; i
<= IRQ_EXT3
; ++i
) {
99 set_irq_chip(i
, &ns9xxx_chip
);
100 set_irq_handler(i
, handle_level_irq
);
101 set_irq_flags(i
, IRQF_VALID
);