blob: 3cf97aaebe4002381b32b1caba5cfb9ea363eecc [file] [log] [blame]
Russell Kingfa0fe482006-01-13 21:30:48 +00001/*
2 * linux/arch/arm/common/vic.c
3 *
4 * Copyright (C) 1999 - 2003 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
Hartley Sweetenbb06b732010-01-12 19:09:12 +010021
Jamie Ilesf9b28cc2011-09-27 11:00:46 +010022#include <linux/export.h>
Russell Kingfa0fe482006-01-13 21:30:48 +000023#include <linux/init.h>
24#include <linux/list.h>
Russell Kingfced80c2008-09-06 12:10:45 +010025#include <linux/io.h>
Jamie Ilesf9b28cc2011-09-27 11:00:46 +010026#include <linux/irqdomain.h>
27#include <linux/of.h>
28#include <linux/of_address.h>
29#include <linux/of_irq.h>
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +020030#include <linux/syscore_ops.h>
Linus Walleij59fcf482009-09-14 12:25:34 +010031#include <linux/device.h>
Linus Walleijf17a1f02009-08-04 01:01:02 +010032#include <linux/amba/bus.h>
Rob Herring9e47b8b2013-01-07 09:45:59 -060033#include <linux/irqchip/arm-vic.h>
Russell Kingfa0fe482006-01-13 21:30:48 +000034
Jamie Iles15583682011-09-28 09:40:11 +010035#include <asm/exception.h>
Russell Kingfa0fe482006-01-13 21:30:48 +000036#include <asm/mach/irq.h>
Russell Kingfa0fe482006-01-13 21:30:48 +000037
Rob Herring44430ec2012-10-27 17:25:26 -050038#include "irqchip.h"
39
Rob Herringcf21af52012-11-06 13:14:26 -060040#define VIC_IRQ_STATUS 0x00
41#define VIC_FIQ_STATUS 0x04
42#define VIC_INT_SELECT 0x0c /* 1 = FIQ, 0 = IRQ */
43#define VIC_INT_SOFT 0x18
44#define VIC_INT_SOFT_CLEAR 0x1c
45#define VIC_PROTECT 0x20
46#define VIC_PL190_VECT_ADDR 0x30 /* PL190 only */
47#define VIC_PL190_DEF_VECT_ADDR 0x34 /* PL190 only */
48
49#define VIC_VECT_ADDR0 0x100 /* 0 to 15 (0..31 PL192) */
50#define VIC_VECT_CNTL0 0x200 /* 0 to 15 (0..31 PL192) */
51#define VIC_ITCR 0x300 /* VIC test control register */
52
53#define VIC_VECT_CNTL_ENABLE (1 << 5)
54
55#define VIC_PL192_VECT_ADDR 0xF00
56
Ben Dooksc07f87f2009-03-24 15:30:07 +000057/**
58 * struct vic_device - VIC PM device
Ben Dooksc07f87f2009-03-24 15:30:07 +000059 * @irq: The IRQ number for the base of the VIC.
60 * @base: The register base for the VIC.
Linus Walleijce94df92012-04-20 08:02:36 +010061 * @valid_sources: A bitmask of valid interrupts
Ben Dooksc07f87f2009-03-24 15:30:07 +000062 * @resume_sources: A bitmask of interrupts for resume.
63 * @resume_irqs: The IRQs enabled for resume.
64 * @int_select: Save for VIC_INT_SELECT.
65 * @int_enable: Save for VIC_INT_ENABLE.
66 * @soft_int: Save for VIC_INT_SOFT.
67 * @protect: Save for VIC_PROTECT.
Jamie Ilesf9b28cc2011-09-27 11:00:46 +010068 * @domain: The IRQ domain for the VIC.
Ben Dooksc07f87f2009-03-24 15:30:07 +000069 */
70struct vic_device {
Ben Dooksc07f87f2009-03-24 15:30:07 +000071 void __iomem *base;
72 int irq;
Linus Walleijce94df92012-04-20 08:02:36 +010073 u32 valid_sources;
Ben Dooksc07f87f2009-03-24 15:30:07 +000074 u32 resume_sources;
75 u32 resume_irqs;
76 u32 int_select;
77 u32 int_enable;
78 u32 soft_int;
79 u32 protect;
Grant Likely75294952012-02-14 14:06:57 -070080 struct irq_domain *domain;
Ben Dooksc07f87f2009-03-24 15:30:07 +000081};
82
83/* we cannot allocate memory when VICs are initially registered */
84static struct vic_device vic_devices[CONFIG_ARM_VIC_NR];
85
Hartley Sweetenbb06b732010-01-12 19:09:12 +010086static int vic_id;
Ben Dooksc07f87f2009-03-24 15:30:07 +000087
Rob Herringa0368022012-11-05 16:32:29 -060088static void vic_handle_irq(struct pt_regs *regs);
89
Hartley Sweetenbb06b732010-01-12 19:09:12 +010090/**
91 * vic_init2 - common initialisation code
92 * @base: Base of the VIC.
93 *
Uwe Kleine-Königb5950762010-11-01 15:38:34 -040094 * Common initialisation code for registration
Hartley Sweetenbb06b732010-01-12 19:09:12 +010095 * and resume.
96*/
97static void vic_init2(void __iomem *base)
98{
99 int i;
Ben Dooksc07f87f2009-03-24 15:30:07 +0000100
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100101 for (i = 0; i < 16; i++) {
102 void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4);
103 writel(VIC_VECT_CNTL_ENABLE | i, reg);
104 }
105
106 writel(32, base + VIC_PL190_DEF_VECT_ADDR);
107}
108
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +0200109#ifdef CONFIG_PM
110static void resume_one_vic(struct vic_device *vic)
Ben Dooksc07f87f2009-03-24 15:30:07 +0000111{
Ben Dooksc07f87f2009-03-24 15:30:07 +0000112 void __iomem *base = vic->base;
113
114 printk(KERN_DEBUG "%s: resuming vic at %p\n", __func__, base);
115
116 /* re-initialise static settings */
117 vic_init2(base);
118
119 writel(vic->int_select, base + VIC_INT_SELECT);
120 writel(vic->protect, base + VIC_PROTECT);
121
122 /* set the enabled ints and then clear the non-enabled */
123 writel(vic->int_enable, base + VIC_INT_ENABLE);
124 writel(~vic->int_enable, base + VIC_INT_ENABLE_CLEAR);
125
126 /* and the same for the soft-int register */
127
128 writel(vic->soft_int, base + VIC_INT_SOFT);
129 writel(~vic->soft_int, base + VIC_INT_SOFT_CLEAR);
Ben Dooksc07f87f2009-03-24 15:30:07 +0000130}
131
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +0200132static void vic_resume(void)
Ben Dooksc07f87f2009-03-24 15:30:07 +0000133{
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +0200134 int id;
135
136 for (id = vic_id - 1; id >= 0; id--)
137 resume_one_vic(vic_devices + id);
138}
139
140static void suspend_one_vic(struct vic_device *vic)
141{
Ben Dooksc07f87f2009-03-24 15:30:07 +0000142 void __iomem *base = vic->base;
143
144 printk(KERN_DEBUG "%s: suspending vic at %p\n", __func__, base);
145
146 vic->int_select = readl(base + VIC_INT_SELECT);
147 vic->int_enable = readl(base + VIC_INT_ENABLE);
148 vic->soft_int = readl(base + VIC_INT_SOFT);
149 vic->protect = readl(base + VIC_PROTECT);
150
151 /* set the interrupts (if any) that are used for
152 * resuming the system */
153
154 writel(vic->resume_irqs, base + VIC_INT_ENABLE);
155 writel(~vic->resume_irqs, base + VIC_INT_ENABLE_CLEAR);
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +0200156}
157
158static int vic_suspend(void)
159{
160 int id;
161
162 for (id = 0; id < vic_id; id++)
163 suspend_one_vic(vic_devices + id);
Ben Dooksc07f87f2009-03-24 15:30:07 +0000164
165 return 0;
166}
167
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +0200168struct syscore_ops vic_syscore_ops = {
169 .suspend = vic_suspend,
170 .resume = vic_resume,
Ben Dooksc07f87f2009-03-24 15:30:07 +0000171};
172
173/**
Ben Dooksc07f87f2009-03-24 15:30:07 +0000174 * vic_pm_init - initicall to register VIC pm
175 *
176 * This is called via late_initcall() to register
177 * the resources for the VICs due to the early
178 * nature of the VIC's registration.
179*/
180static int __init vic_pm_init(void)
181{
Rafael J. Wysocki328f5cc2011-04-22 22:02:33 +0200182 if (vic_id > 0)
183 register_syscore_ops(&vic_syscore_ops);
Ben Dooksc07f87f2009-03-24 15:30:07 +0000184
185 return 0;
186}
Ben Dooksc07f87f2009-03-24 15:30:07 +0000187late_initcall(vic_pm_init);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100188#endif /* CONFIG_PM */
Ben Dooksc07f87f2009-03-24 15:30:07 +0000189
Linus Walleijce94df92012-04-20 08:02:36 +0100190static struct irq_chip vic_chip;
191
192static int vic_irqdomain_map(struct irq_domain *d, unsigned int irq,
193 irq_hw_number_t hwirq)
194{
195 struct vic_device *v = d->host_data;
196
197 /* Skip invalid IRQs, only register handlers for the real ones */
198 if (!(v->valid_sources & (1 << hwirq)))
199 return -ENOTSUPP;
200 irq_set_chip_and_handler(irq, &vic_chip, handle_level_irq);
201 irq_set_chip_data(irq, v->base);
202 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
203 return 0;
204}
205
Rob Herringa0368022012-11-05 16:32:29 -0600206/*
207 * Handle each interrupt in a single VIC. Returns non-zero if we've
208 * handled at least one interrupt. This reads the status register
209 * before handling each interrupt, which is necessary given that
210 * handle_IRQ may briefly re-enable interrupts for soft IRQ handling.
211 */
212static int handle_one_vic(struct vic_device *vic, struct pt_regs *regs)
213{
214 u32 stat, irq;
215 int handled = 0;
216
217 while ((stat = readl_relaxed(vic->base + VIC_IRQ_STATUS))) {
218 irq = ffs(stat) - 1;
219 handle_IRQ(irq_find_mapping(vic->domain, irq), regs);
220 handled = 1;
221 }
222
223 return handled;
224}
225
226/*
227 * Keep iterating over all registered VIC's until there are no pending
228 * interrupts.
229 */
230static asmlinkage void __exception_irq_entry vic_handle_irq(struct pt_regs *regs)
231{
232 int i, handled;
233
234 do {
235 for (i = 0, handled = 0; i < vic_id; ++i)
236 handled |= handle_one_vic(&vic_devices[i], regs);
237 } while (handled);
238}
239
Linus Walleijce94df92012-04-20 08:02:36 +0100240static struct irq_domain_ops vic_irqdomain_ops = {
241 .map = vic_irqdomain_map,
242 .xlate = irq_domain_xlate_onetwocell,
243};
244
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100245/**
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100246 * vic_register() - Register a VIC.
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100247 * @base: The base address of the VIC.
248 * @irq: The base IRQ for the VIC.
Linus Walleijfa943be2012-04-20 08:02:03 +0100249 * @valid_sources: bitmask of valid interrupts
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100250 * @resume_sources: bitmask of interrupts allowed for resume sources.
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100251 * @node: The device tree node associated with the VIC.
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100252 *
253 * Register the VIC with the system device tree so that it can be notified
254 * of suspend and resume requests and ensure that the correct actions are
255 * taken to re-instate the settings on resume.
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100256 *
257 * This also configures the IRQ domain for the VIC.
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100258 */
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100259static void __init vic_register(void __iomem *base, unsigned int irq,
Linus Walleijfa943be2012-04-20 08:02:03 +0100260 u32 valid_sources, u32 resume_sources,
261 struct device_node *node)
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100262{
263 struct vic_device *v;
Linus Walleij5ced33b2012-12-26 01:39:16 +0100264 int i;
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100265
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100266 if (vic_id >= ARRAY_SIZE(vic_devices)) {
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100267 printk(KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n", __func__);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100268 return;
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100269 }
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100270
271 v = &vic_devices[vic_id];
272 v->base = base;
Linus Walleijce94df92012-04-20 08:02:36 +0100273 v->valid_sources = valid_sources;
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100274 v->resume_sources = resume_sources;
275 v->irq = irq;
Rob Herring7fb7d8a2012-11-20 19:55:27 -0600276 set_handle_irq(vic_handle_irq);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100277 vic_id++;
Linus Walleij07c92492012-10-16 18:50:00 +0100278 v->domain = irq_domain_add_simple(node, fls(valid_sources), irq,
Linus Walleijfa943be2012-04-20 08:02:03 +0100279 &vic_irqdomain_ops, v);
Linus Walleij5ced33b2012-12-26 01:39:16 +0100280 /* create an IRQ mapping for each valid IRQ */
281 for (i = 0; i < fls(valid_sources); i++)
282 if (valid_sources & (1 << i))
283 irq_create_mapping(v->domain, i);
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100284}
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100285
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100286static void vic_ack_irq(struct irq_data *d)
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100287{
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100288 void __iomem *base = irq_data_get_irq_chip_data(d);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100289 unsigned int irq = d->hwirq;
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100290 writel(1 << irq, base + VIC_INT_ENABLE_CLEAR);
291 /* moreover, clear the soft-triggered, in case it was the reason */
292 writel(1 << irq, base + VIC_INT_SOFT_CLEAR);
293}
294
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100295static void vic_mask_irq(struct irq_data *d)
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100296{
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100297 void __iomem *base = irq_data_get_irq_chip_data(d);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100298 unsigned int irq = d->hwirq;
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100299 writel(1 << irq, base + VIC_INT_ENABLE_CLEAR);
300}
301
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100302static void vic_unmask_irq(struct irq_data *d)
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100303{
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100304 void __iomem *base = irq_data_get_irq_chip_data(d);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100305 unsigned int irq = d->hwirq;
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100306 writel(1 << irq, base + VIC_INT_ENABLE);
307}
308
309#if defined(CONFIG_PM)
Ben Dooksc07f87f2009-03-24 15:30:07 +0000310static struct vic_device *vic_from_irq(unsigned int irq)
311{
312 struct vic_device *v = vic_devices;
313 unsigned int base_irq = irq & ~31;
314 int id;
315
316 for (id = 0; id < vic_id; id++, v++) {
317 if (v->irq == base_irq)
318 return v;
319 }
320
321 return NULL;
322}
323
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100324static int vic_set_wake(struct irq_data *d, unsigned int on)
Ben Dooksc07f87f2009-03-24 15:30:07 +0000325{
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100326 struct vic_device *v = vic_from_irq(d->irq);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100327 unsigned int off = d->hwirq;
Ben Dooks3f1a5672009-06-02 09:31:03 +0100328 u32 bit = 1 << off;
Ben Dooksc07f87f2009-03-24 15:30:07 +0000329
330 if (!v)
331 return -EINVAL;
332
Ben Dooks3f1a5672009-06-02 09:31:03 +0100333 if (!(bit & v->resume_sources))
334 return -EINVAL;
335
Ben Dooksc07f87f2009-03-24 15:30:07 +0000336 if (on)
Ben Dooks3f1a5672009-06-02 09:31:03 +0100337 v->resume_irqs |= bit;
Ben Dooksc07f87f2009-03-24 15:30:07 +0000338 else
Ben Dooks3f1a5672009-06-02 09:31:03 +0100339 v->resume_irqs &= ~bit;
Ben Dooksc07f87f2009-03-24 15:30:07 +0000340
341 return 0;
342}
Ben Dooksc07f87f2009-03-24 15:30:07 +0000343#else
Ben Dooksc07f87f2009-03-24 15:30:07 +0000344#define vic_set_wake NULL
345#endif /* CONFIG_PM */
346
David Brownell38c677c2006-08-01 22:26:25 +0100347static struct irq_chip vic_chip = {
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100348 .name = "VIC",
Lennert Buytenhekf013c982010-11-29 10:20:21 +0100349 .irq_ack = vic_ack_irq,
350 .irq_mask = vic_mask_irq,
351 .irq_unmask = vic_unmask_irq,
352 .irq_set_wake = vic_set_wake,
Russell Kingfa0fe482006-01-13 21:30:48 +0000353};
354
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100355static void __init vic_disable(void __iomem *base)
356{
357 writel(0, base + VIC_INT_SELECT);
358 writel(0, base + VIC_INT_ENABLE);
359 writel(~0, base + VIC_INT_ENABLE_CLEAR);
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100360 writel(0, base + VIC_ITCR);
361 writel(~0, base + VIC_INT_SOFT_CLEAR);
362}
363
364static void __init vic_clear_interrupts(void __iomem *base)
365{
366 unsigned int i;
367
368 writel(0, base + VIC_PL190_VECT_ADDR);
369 for (i = 0; i < 19; i++) {
370 unsigned int value;
371
372 value = readl(base + VIC_PL190_VECT_ADDR);
373 writel(value, base + VIC_PL190_VECT_ADDR);
374 }
375}
376
Alessandro Rubini87e88242009-07-02 15:28:41 +0100377/*
378 * The PL190 cell from ARM has been modified by ST to handle 64 interrupts.
379 * The original cell has 32 interrupts, while the modified one has 64,
380 * replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case
381 * the probe function is called twice, with base set to offset 000
382 * and 020 within the page. We call this "second block".
383 */
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100384static void __init vic_init_st(void __iomem *base, unsigned int irq_start,
Jamie Ilesad622672011-12-01 11:16:46 +0100385 u32 vic_sources, struct device_node *node)
Alessandro Rubini87e88242009-07-02 15:28:41 +0100386{
387 unsigned int i;
388 int vic_2nd_block = ((unsigned long)base & ~PAGE_MASK) != 0;
389
390 /* Disable all interrupts initially. */
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100391 vic_disable(base);
Alessandro Rubini87e88242009-07-02 15:28:41 +0100392
393 /*
394 * Make sure we clear all existing interrupts. The vector registers
395 * in this cell are after the second block of general registers,
396 * so we can address them using standard offsets, but only from
397 * the second base address, which is 0x20 in the page
398 */
399 if (vic_2nd_block) {
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100400 vic_clear_interrupts(base);
Alessandro Rubini87e88242009-07-02 15:28:41 +0100401
Alessandro Rubini87e88242009-07-02 15:28:41 +0100402 /* ST has 16 vectors as well, but we don't enable them by now */
403 for (i = 0; i < 16; i++) {
404 void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4);
405 writel(0, reg);
406 }
407
408 writel(32, base + VIC_PL190_DEF_VECT_ADDR);
409 }
410
Linus Walleijfa943be2012-04-20 08:02:03 +0100411 vic_register(base, irq_start, vic_sources, 0, node);
Alessandro Rubini87e88242009-07-02 15:28:41 +0100412}
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100413
Linus Walleij07c92492012-10-16 18:50:00 +0100414void __init __vic_init(void __iomem *base, int irq_start,
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100415 u32 vic_sources, u32 resume_sources,
416 struct device_node *node)
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100417{
418 unsigned int i;
419 u32 cellid = 0;
420 enum amba_vendor vendor;
421
422 /* Identify which VIC cell this one is, by reading the ID */
423 for (i = 0; i < 4; i++) {
Arnd Bergmannd4f3add2011-09-23 10:13:49 +0200424 void __iomem *addr;
425 addr = (void __iomem *)((u32)base & PAGE_MASK) + 0xfe0 + (i * 4);
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100426 cellid |= (readl(addr) & 0xff) << (8 * i);
427 }
428 vendor = (cellid >> 12) & 0xff;
429 printk(KERN_INFO "VIC @%p: id 0x%08x, vendor 0x%02x\n",
430 base, cellid, vendor);
431
432 switch(vendor) {
433 case AMBA_VENDOR_ST:
Jamie Ilesad622672011-12-01 11:16:46 +0100434 vic_init_st(base, irq_start, vic_sources, node);
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100435 return;
436 default:
437 printk(KERN_WARNING "VIC: unknown vendor, continuing anyways\n");
438 /* fall through */
439 case AMBA_VENDOR_ARM:
440 break;
441 }
442
443 /* Disable all interrupts initially. */
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100444 vic_disable(base);
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100445
Hartley Sweetenb0c4c892010-04-02 18:04:47 +0100446 /* Make sure we clear all existing interrupts */
447 vic_clear_interrupts(base);
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100448
449 vic_init2(base);
450
Linus Walleijfa943be2012-04-20 08:02:03 +0100451 vic_register(base, irq_start, vic_sources, resume_sources, node);
Hartley Sweetenbb06b732010-01-12 19:09:12 +0100452}
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100453
454/**
455 * vic_init() - initialise a vectored interrupt controller
456 * @base: iomem base address
457 * @irq_start: starting interrupt number, must be muliple of 32
458 * @vic_sources: bitmask of interrupt sources to allow
459 * @resume_sources: bitmask of interrupt sources to allow for resume
460 */
461void __init vic_init(void __iomem *base, unsigned int irq_start,
462 u32 vic_sources, u32 resume_sources)
463{
464 __vic_init(base, irq_start, vic_sources, resume_sources, NULL);
465}
466
467#ifdef CONFIG_OF
468int __init vic_of_init(struct device_node *node, struct device_node *parent)
469{
470 void __iomem *regs;
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100471
472 if (WARN(parent, "non-root VICs are not supported"))
473 return -EINVAL;
474
475 regs = of_iomap(node, 0);
476 if (WARN_ON(!regs))
477 return -EIO;
478
Linus Walleij07c92492012-10-16 18:50:00 +0100479 /*
Linus Walleij5ced33b2012-12-26 01:39:16 +0100480 * Passing 0 as first IRQ makes the simple domain allocate descriptors
Linus Walleij07c92492012-10-16 18:50:00 +0100481 */
Linus Walleij5ced33b2012-12-26 01:39:16 +0100482 __vic_init(regs, 0, ~0, ~0, node);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100483
484 return 0;
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100485}
Rob Herring44430ec2012-10-27 17:25:26 -0500486IRQCHIP_DECLARE(arm_pl190_vic, "arm,pl190-vic", vic_of_init);
487IRQCHIP_DECLARE(arm_pl192_vic, "arm,pl192-vic", vic_of_init);
488IRQCHIP_DECLARE(arm_versatile_vic, "arm,versatile-vic", vic_of_init);
Jamie Ilesf9b28cc2011-09-27 11:00:46 +0100489#endif /* CONFIG OF */