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(unsigned int irq
)
27 /* XXX: better use cpp symbols */
28 int prio
= irq2prio(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_ack_irq(unsigned int irq
)
36 __raw_writel(0, SYS_ISRADDR
);
39 static void ns9xxx_maskack_irq(unsigned int irq
)
45 static void ns9xxx_unmask_irq(unsigned int irq
)
47 /* XXX: better use cpp symbols */
48 int prio
= irq2prio(irq
);
49 u32 ic
= __raw_readl(SYS_IC(prio
/ 4));
50 ic
|= 1 << (7 + 8 * (3 - (prio
& 3)));
51 __raw_writel(ic
, SYS_IC(prio
/ 4));
54 static struct irq_chip ns9xxx_chip
= {
55 .ack
= ns9xxx_ack_irq
,
56 .mask
= ns9xxx_mask_irq
,
57 .mask_ack
= ns9xxx_maskack_irq
,
58 .unmask
= ns9xxx_unmask_irq
,
62 #define handle_irq handle_level_irq
64 static void handle_prio_irq(unsigned int irq
, struct irq_desc
*desc
)
66 unsigned int cpu
= smp_processor_id();
67 struct irqaction
*action
;
68 irqreturn_t action_ret
;
70 spin_lock(&desc
->lock
);
72 BUG_ON(desc
->status
& IRQ_INPROGRESS
);
74 desc
->status
&= ~(IRQ_REPLAY
| IRQ_WAITING
);
75 kstat_cpu(cpu
).irqs
[irq
]++;
77 action
= desc
->action
;
78 if (unlikely(!action
|| (desc
->status
& IRQ_DISABLED
)))
81 desc
->status
|= IRQ_INPROGRESS
;
82 spin_unlock(&desc
->lock
);
84 action_ret
= handle_IRQ_event(irq
, action
);
86 /* XXX: There is no direct way to access noirqdebug, so check
87 * unconditionally for spurious irqs...
88 * Maybe this function should go to kernel/irq/chip.c? */
89 note_interrupt(irq
, desc
, action_ret
);
91 spin_lock(&desc
->lock
);
92 desc
->status
&= ~IRQ_INPROGRESS
;
94 if (desc
->status
& IRQ_DISABLED
)
96 desc
->chip
->mask(irq
);
98 /* ack unconditionally to unmask lower prio irqs */
101 spin_unlock(&desc
->lock
);
103 #define handle_irq handle_prio_irq
106 void __init
ns9xxx_init_irq(void)
110 /* disable all IRQs */
111 for (i
= 0; i
< 8; ++i
)
112 __raw_writel(prio2irq(4 * i
) << 24 |
113 prio2irq(4 * i
+ 1) << 16 |
114 prio2irq(4 * i
+ 2) << 8 |
118 for (i
= 0; i
< 32; ++i
)
119 __raw_writel(prio2irq(i
), SYS_IVA(i
));
121 for (i
= 0; i
<= 31; ++i
) {
122 set_irq_chip(i
, &ns9xxx_chip
);
123 set_irq_handler(i
, handle_irq
);
124 set_irq_flags(i
, IRQF_VALID
);
This page took 0.035359 seconds and 5 git commands to generate.