aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common/vic.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/common/vic.c')
-rw-r--r--arch/arm/common/vic.c99
1 files changed, 98 insertions, 1 deletions
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index 6ed89836e908..bc1f9ad61ff6 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -26,6 +26,15 @@
26#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
27#include <asm/hardware/vic.h> 27#include <asm/hardware/vic.h>
28 28
29static void vic_ack_irq(unsigned int irq)
30{
31 void __iomem *base = get_irq_chip_data(irq);
32 irq &= 31;
33 writel(1 << irq, base + VIC_INT_ENABLE_CLEAR);
34 /* moreover, clear the soft-triggered, in case it was the reason */
35 writel(1 << irq, base + VIC_INT_SOFT_CLEAR);
36}
37
29static void vic_mask_irq(unsigned int irq) 38static void vic_mask_irq(unsigned int irq)
30{ 39{
31 void __iomem *base = get_irq_chip_data(irq); 40 void __iomem *base = get_irq_chip_data(irq);
@@ -253,12 +262,21 @@ static inline void vic_pm_register(void __iomem *base, unsigned int irq, u32 arg
253 262
254static struct irq_chip vic_chip = { 263static struct irq_chip vic_chip = {
255 .name = "VIC", 264 .name = "VIC",
256 .ack = vic_mask_irq, 265 .ack = vic_ack_irq,
257 .mask = vic_mask_irq, 266 .mask = vic_mask_irq,
258 .unmask = vic_unmask_irq, 267 .unmask = vic_unmask_irq,
259 .set_wake = vic_set_wake, 268 .set_wake = vic_set_wake,
260}; 269};
261 270
271/* The PL190 cell from ARM has been modified by ST, so handle both here */
272static void vik_init_st(void __iomem *base, unsigned int irq_start,
273 u32 vic_sources);
274
275enum vic_vendor {
276 VENDOR_ARM = 0x41,
277 VENDOR_ST = 0x80,
278};
279
262/** 280/**
263 * vic_init - initialise a vectored interrupt controller 281 * vic_init - initialise a vectored interrupt controller
264 * @base: iomem base address 282 * @base: iomem base address
@@ -270,6 +288,28 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,
270 u32 vic_sources, u32 resume_sources) 288 u32 vic_sources, u32 resume_sources)
271{ 289{
272 unsigned int i; 290 unsigned int i;
291 u32 cellid = 0;
292 enum vic_vendor vendor;
293
294 /* Identify which VIC cell this one is, by reading the ID */
295 for (i = 0; i < 4; i++) {
296 u32 addr = ((u32)base & PAGE_MASK) + 0xfe0 + (i * 4);
297 cellid |= (readl(addr) & 0xff) << (8 * i);
298 }
299 vendor = (cellid >> 12) & 0xff;
300 printk(KERN_INFO "VIC @%p: id 0x%08x, vendor 0x%02x\n",
301 base, cellid, vendor);
302
303 switch(vendor) {
304 case VENDOR_ST:
305 vik_init_st(base, irq_start, vic_sources);
306 return;
307 default:
308 printk(KERN_WARNING "VIC: unknown vendor, continuing anyways\n");
309 /* fall through */
310 case VENDOR_ARM:
311 break;
312 }
273 313
274 /* Disable all interrupts initially. */ 314 /* Disable all interrupts initially. */
275 315
@@ -306,3 +346,60 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,
306 346
307 vic_pm_register(base, irq_start, resume_sources); 347 vic_pm_register(base, irq_start, resume_sources);
308} 348}
349
350/*
351 * The PL190 cell from ARM has been modified by ST to handle 64 interrupts.
352 * The original cell has 32 interrupts, while the modified one has 64,
353 * replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case
354 * the probe function is called twice, with base set to offset 000
355 * and 020 within the page. We call this "second block".
356 */
357static void __init vik_init_st(void __iomem *base, unsigned int irq_start,
358 u32 vic_sources)
359{
360 unsigned int i;
361 int vic_2nd_block = ((unsigned long)base & ~PAGE_MASK) != 0;
362
363 /* Disable all interrupts initially. */
364
365 writel(0, base + VIC_INT_SELECT);
366 writel(0, base + VIC_INT_ENABLE);
367 writel(~0, base + VIC_INT_ENABLE_CLEAR);
368 writel(0, base + VIC_IRQ_STATUS);
369 writel(0, base + VIC_ITCR);
370 writel(~0, base + VIC_INT_SOFT_CLEAR);
371
372 /*
373 * Make sure we clear all existing interrupts. The vector registers
374 * in this cell are after the second block of general registers,
375 * so we can address them using standard offsets, but only from
376 * the second base address, which is 0x20 in the page
377 */
378 if (vic_2nd_block) {
379 writel(0, base + VIC_PL190_VECT_ADDR);
380 for (i = 0; i < 19; i++) {
381 unsigned int value;
382
383 value = readl(base + VIC_PL190_VECT_ADDR);
384 writel(value, base + VIC_PL190_VECT_ADDR);
385 }
386 /* ST has 16 vectors as well, but we don't enable them by now */
387 for (i = 0; i < 16; i++) {
388 void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4);
389 writel(0, reg);
390 }
391
392 writel(32, base + VIC_PL190_DEF_VECT_ADDR);
393 }
394
395 for (i = 0; i < 32; i++) {
396 if (vic_sources & (1 << i)) {
397 unsigned int irq = irq_start + i;
398
399 set_irq_chip(irq, &vic_chip);
400 set_irq_chip_data(irq, base);
401 set_irq_handler(irq, handle_level_irq);
402 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
403 }
404 }
405}