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