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 <asm/mach-types.h>
16 #include <asm/arch-ns9xxx/regs-sys-common.h>
17 #include <asm/arch-ns9xxx/irqs.h>
18 #include <asm/arch-ns9xxx/board.h>
22 static void ns9xxx_mask_irq(unsigned int irq
)
24 /* XXX: better use cpp symbols */
25 u32 ic
= __raw_readl(SYS_IC(irq
/ 4));
26 ic
&= ~(1 << (7 + 8 * (3 - (irq
& 3))));
27 __raw_writel(ic
, SYS_IC(irq
/ 4));
30 static void ns9xxx_ack_irq(unsigned int irq
)
32 __raw_writel(0, SYS_ISRADDR
);
35 static void ns9xxx_maskack_irq(unsigned int irq
)
41 static void ns9xxx_unmask_irq(unsigned int irq
)
43 /* XXX: better use cpp symbols */
44 u32 ic
= __raw_readl(SYS_IC(irq
/ 4));
45 ic
|= 1 << (7 + 8 * (3 - (irq
& 3)));
46 __raw_writel(ic
, SYS_IC(irq
/ 4));
49 static struct irq_chip ns9xxx_chip
= {
50 .ack
= ns9xxx_ack_irq
,
51 .mask
= ns9xxx_mask_irq
,
52 .mask_ack
= ns9xxx_maskack_irq
,
53 .unmask
= ns9xxx_unmask_irq
,
57 #define handle_irq handle_level_irq
59 void handle_prio_irq(unsigned int irq
, struct irq_desc
*desc
)
61 unsigned int cpu
= smp_processor_id();
62 struct irqaction
*action
;
63 irqreturn_t action_ret
;
65 spin_lock(&desc
->lock
);
67 if (unlikely(desc
->status
& IRQ_INPROGRESS
))
70 desc
->status
&= ~(IRQ_REPLAY
| IRQ_WAITING
);
71 kstat_cpu(cpu
).irqs
[irq
]++;
73 action
= desc
->action
;
74 if (unlikely(!action
|| (desc
->status
& IRQ_DISABLED
)))
77 desc
->status
|= IRQ_INPROGRESS
;
78 spin_unlock(&desc
->lock
);
80 action_ret
= handle_IRQ_event(irq
, action
);
82 spin_lock(&desc
->lock
);
83 desc
->status
&= ~IRQ_INPROGRESS
;
84 if (!(desc
->status
& IRQ_DISABLED
) && desc
->chip
->ack
)
88 spin_unlock(&desc
->lock
);
90 #define handle_irq handle_prio_irq
93 void __init
ns9xxx_init_irq(void)
97 /* disable all IRQs */
98 for (i
= 0; i
< 8; ++i
)
99 __raw_writel((4 * i
) << 24 | (4 * i
+ 1) << 16 |
100 (4 * i
+ 2) << 8 | (4 * i
+ 3), SYS_IC(i
));
102 /* simple interrupt prio table:
103 * prio(x) < prio(y) <=> x < y
105 for (i
= 0; i
< 32; ++i
)
106 __raw_writel(i
, SYS_IVA(i
));
108 for (i
= 0; i
<= 31; ++i
) {
109 set_irq_chip(i
, &ns9xxx_chip
);
110 set_irq_handler(i
, handle_irq
);
111 set_irq_flags(i
, IRQF_VALID
);