blob: 7d0c7eb59f0971cc273aebfd1f24ba0a80684d99 [file] [log] [blame]
Lennert Buytenhek01eb5692008-03-27 14:51:40 -04001/*
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>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020015#include <plat/irq.h>
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040016
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010017static void orion_irq_mask(struct irq_data *d)
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040018{
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010019 void __iomem *maskaddr = irq_data_get_irq_chip_data(d);
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040020 u32 mask;
21
22 mask = readl(maskaddr);
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010023 mask &= ~(1 << (d->irq & 31));
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040024 writel(mask, maskaddr);
25}
26
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010027static void orion_irq_unmask(struct irq_data *d)
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040028{
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010029 void __iomem *maskaddr = irq_data_get_irq_chip_data(d);
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040030 u32 mask;
31
32 mask = readl(maskaddr);
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010033 mask |= 1 << (d->irq & 31);
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040034 writel(mask, maskaddr);
35}
36
37static struct irq_chip orion_irq_chip = {
38 .name = "orion_irq",
Lennert Buytenhek3b0c8d42010-11-29 11:17:38 +010039 .irq_mask = orion_irq_mask,
40 .irq_mask_ack = orion_irq_mask,
41 .irq_unmask = orion_irq_unmask,
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040042};
43
44void __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 set_irq_chip(irq, &orion_irq_chip);
60 set_irq_chip_data(irq, maskaddr);
61 set_irq_handler(irq, handle_level_irq);
Lennert Buytenhek000e99c2008-05-18 19:46:59 +020062 irq_desc[irq].status |= IRQ_LEVEL;
Lennert Buytenhek01eb5692008-03-27 14:51:40 -040063 set_irq_flags(irq, IRQF_VALID);
64 }
65}