1 /*
2 * arch/arm/plat-orion/irq.c
3 *
4 * Marvell Orion SoC IRQ handling.
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <linux/io.h>
15 #include <plat/irq.h>
16
orion_irq_mask(struct irq_data * d)17 static void orion_irq_mask(struct irq_data *d)
18 {
19 void __iomem *maskaddr = irq_data_get_irq_chip_data(d);
20 u32 mask;
21
22 mask = readl(maskaddr);
23 mask &= ~(1 << (d->irq & 31));
24 writel(mask, maskaddr);
25 }
26
orion_irq_unmask(struct irq_data * d)27 static void orion_irq_unmask(struct irq_data *d)
28 {
29 void __iomem *maskaddr = irq_data_get_irq_chip_data(d);
30 u32 mask;
31
32 mask = readl(maskaddr);
33 mask |= 1 << (d->irq & 31);
34 writel(mask, maskaddr);
35 }
36
37 static struct irq_chip orion_irq_chip = {
38 .name = "orion_irq",
39 .irq_mask = orion_irq_mask,
40 .irq_mask_ack = orion_irq_mask,
41 .irq_unmask = orion_irq_unmask,
42 };
43
orion_irq_init(unsigned int irq_start,void __iomem * maskaddr)44 void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr)
45 {
46 unsigned int i;
47
48 /*
49 * Mask all interrupts initially.
50 */
51 writel(0, maskaddr);
52
53 /*
54 * Register IRQ sources.
55 */
56 for (i = 0; i < 32; i++) {
57 unsigned int irq = irq_start + i;
58
59 irq_set_chip_and_handler(irq, &orion_irq_chip,
60 handle_level_irq);
61 irq_set_chip_data(irq, maskaddr);
62 irq_set_status_flags(irq, IRQ_LEVEL);
63 set_irq_flags(irq, IRQF_VALID);
64 }
65 }
66