blob: c48feaf4e8e9538655a7586c2a69fe340f87d0c8 [file] [log] [blame]
Leo Chenb7462d62009-08-07 19:59:04 +01001/*
2 *
3 * Copyright (C) 1999 ARM Limited
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#include <linux/init.h>
20#include <linux/stddef.h>
21#include <linux/list.h>
22#include <linux/timer.h>
23#include <linux/version.h>
24#include <linux/io.h>
25
26#include <mach/hardware.h>
27#include <asm/irq.h>
28
29#include <asm/mach/irq.h>
30#include <mach/csp/intcHw_reg.h>
31#include <mach/csp/mm_io.h>
32
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010033static void bcmring_mask_irq0(struct irq_data *d)
Leo Chenb7462d62009-08-07 19:59:04 +010034{
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010035 writel(1 << (d->irq - IRQ_INTC0_START),
Leo Chenb7462d62009-08-07 19:59:04 +010036 MM_IO_BASE_INTC0 + INTCHW_INTENCLEAR);
37}
38
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010039static void bcmring_unmask_irq0(struct irq_data *d)
Leo Chenb7462d62009-08-07 19:59:04 +010040{
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010041 writel(1 << (d->irq - IRQ_INTC0_START),
Leo Chenb7462d62009-08-07 19:59:04 +010042 MM_IO_BASE_INTC0 + INTCHW_INTENABLE);
43}
44
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010045static void bcmring_mask_irq1(struct irq_data *d)
Leo Chenb7462d62009-08-07 19:59:04 +010046{
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010047 writel(1 << (d->irq - IRQ_INTC1_START),
Leo Chenb7462d62009-08-07 19:59:04 +010048 MM_IO_BASE_INTC1 + INTCHW_INTENCLEAR);
49}
50
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010051static void bcmring_unmask_irq1(struct irq_data *d)
Leo Chenb7462d62009-08-07 19:59:04 +010052{
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010053 writel(1 << (d->irq - IRQ_INTC1_START),
Leo Chenb7462d62009-08-07 19:59:04 +010054 MM_IO_BASE_INTC1 + INTCHW_INTENABLE);
55}
56
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010057static void bcmring_mask_irq2(struct irq_data *d)
Leo Chenb7462d62009-08-07 19:59:04 +010058{
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010059 writel(1 << (d->irq - IRQ_SINTC_START),
Leo Chenb7462d62009-08-07 19:59:04 +010060 MM_IO_BASE_SINTC + INTCHW_INTENCLEAR);
61}
62
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010063static void bcmring_unmask_irq2(struct irq_data *d)
Leo Chenb7462d62009-08-07 19:59:04 +010064{
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010065 writel(1 << (d->irq - IRQ_SINTC_START),
Leo Chenb7462d62009-08-07 19:59:04 +010066 MM_IO_BASE_SINTC + INTCHW_INTENABLE);
67}
68
69static struct irq_chip bcmring_irq0_chip = {
Thomas Gleixnerd1ea13c2010-09-23 18:40:07 +020070 .name = "ARM-INTC0",
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010071 .irq_ack = bcmring_mask_irq0,
72 .irq_mask = bcmring_mask_irq0, /* mask a specific interrupt, blocking its delivery. */
73 .irq_unmask = bcmring_unmask_irq0, /* unmaks an interrupt */
Leo Chenb7462d62009-08-07 19:59:04 +010074};
75
76static struct irq_chip bcmring_irq1_chip = {
Thomas Gleixnerd1ea13c2010-09-23 18:40:07 +020077 .name = "ARM-INTC1",
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010078 .irq_ack = bcmring_mask_irq1,
79 .irq_mask = bcmring_mask_irq1,
80 .irq_unmask = bcmring_unmask_irq1,
Leo Chenb7462d62009-08-07 19:59:04 +010081};
82
83static struct irq_chip bcmring_irq2_chip = {
Thomas Gleixnerd1ea13c2010-09-23 18:40:07 +020084 .name = "ARM-SINTC",
Lennert Buytenhekcf1d4d52010-11-29 10:26:37 +010085 .irq_ack = bcmring_mask_irq2,
86 .irq_mask = bcmring_mask_irq2,
87 .irq_unmask = bcmring_unmask_irq2,
Leo Chenb7462d62009-08-07 19:59:04 +010088};
89
90static void vic_init(void __iomem *base, struct irq_chip *chip,
91 unsigned int irq_start, unsigned int vic_sources)
92{
93 unsigned int i;
94 for (i = 0; i < 32; i++) {
95 unsigned int irq = irq_start + i;
Thomas Gleixner6845664a2011-03-24 13:25:22 +010096 irq_set_chip(irq, chip);
97 irq_set_chip_data(irq, base);
Leo Chenb7462d62009-08-07 19:59:04 +010098
99 if (vic_sources & (1 << i)) {
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100100 irq_set_handler(irq, handle_level_irq);
Leo Chenb7462d62009-08-07 19:59:04 +0100101 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
102 }
103 }
104 writel(0, base + INTCHW_INTSELECT);
105 writel(0, base + INTCHW_INTENABLE);
106 writel(~0, base + INTCHW_INTENCLEAR);
107 writel(0, base + INTCHW_IRQSTATUS);
108 writel(~0, base + INTCHW_SOFTINTCLEAR);
109}
110
111void __init bcmring_init_irq(void)
112{
113 vic_init((void __iomem *)MM_IO_BASE_INTC0, &bcmring_irq0_chip,
114 IRQ_INTC0_START, IRQ_INTC0_VALID_MASK);
115 vic_init((void __iomem *)MM_IO_BASE_INTC1, &bcmring_irq1_chip,
116 IRQ_INTC1_START, IRQ_INTC1_VALID_MASK);
117 vic_init((void __iomem *)MM_IO_BASE_SINTC, &bcmring_irq2_chip,
118 IRQ_SINTC_START, IRQ_SINTC_VALID_MASK);
119
120 /* special cases */
121 if (INTCHW_INTC1_GPIO0 & IRQ_INTC1_VALID_MASK) {
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100122 irq_set_handler(IRQ_GPIO0, handle_simple_irq);
Leo Chenb7462d62009-08-07 19:59:04 +0100123 }
124 if (INTCHW_INTC1_GPIO1 & IRQ_INTC1_VALID_MASK) {
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100125 irq_set_handler(IRQ_GPIO1, handle_simple_irq);
Leo Chenb7462d62009-08-07 19:59:04 +0100126 }
127}