From 87e8824b4588076409692b82ef4b1d98f25cd400 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Thu, 2 Jul 2009 15:28:41 +0100 Subject: [ARM] 5582/1: VIC: support ST-modified version with a split init The Nomadik SoC (not yet merged) has a modified PL090 VIC cell. This adds support for it by reading the PrimeCell ID at the end of the page and calling a separate init function. Signed-off-by: Alessandro Rubini Acked-by: Andrea Gallo Signed-off-by: Russell King --- arch/arm/common/vic.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'arch/arm/common/vic.c') diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c index 6ed89836e90..27714ab30f2 100644 --- a/arch/arm/common/vic.c +++ b/arch/arm/common/vic.c @@ -259,6 +259,15 @@ static struct irq_chip vic_chip = { .set_wake = vic_set_wake, }; +/* The PL190 cell from ARM has been modified by ST, so handle both here */ +static void vik_init_st(void __iomem *base, unsigned int irq_start, + u32 vic_sources); + +enum vic_vendor { + VENDOR_ARM = 0x41, + VENDOR_ST = 0x80, +}; + /** * vic_init - initialise a vectored interrupt controller * @base: iomem base address @@ -270,6 +279,28 @@ void __init vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources, u32 resume_sources) { unsigned int i; + u32 cellid = 0; + enum vic_vendor vendor; + + /* Identify which VIC cell this one is, by reading the ID */ + for (i = 0; i < 4; i++) { + u32 addr = ((u32)base & PAGE_MASK) + 0xfe0 + (i * 4); + cellid |= (readl(addr) & 0xff) << (8 * i); + } + vendor = (cellid >> 12) & 0xff; + printk(KERN_INFO "VIC @%p: id 0x%08x, vendor 0x%02x\n", + base, cellid, vendor); + + switch(vendor) { + case VENDOR_ST: + vik_init_st(base, irq_start, vic_sources); + return; + default: + printk(KERN_WARNING "VIC: unknown vendor, continuing anyways\n"); + /* fall through */ + case VENDOR_ARM: + break; + } /* Disable all interrupts initially. */ @@ -306,3 +337,60 @@ void __init vic_init(void __iomem *base, unsigned int irq_start, vic_pm_register(base, irq_start, resume_sources); } + +/* + * The PL190 cell from ARM has been modified by ST to handle 64 interrupts. + * The original cell has 32 interrupts, while the modified one has 64, + * replocating two blocks 0x00..0x1f in 0x20..0x3f. In that case + * the probe function is called twice, with base set to offset 000 + * and 020 within the page. We call this "second block". + */ +static void __init vik_init_st(void __iomem *base, unsigned int irq_start, + u32 vic_sources) +{ + unsigned int i; + int vic_2nd_block = ((unsigned long)base & ~PAGE_MASK) != 0; + + /* Disable all interrupts initially. */ + + writel(0, base + VIC_INT_SELECT); + writel(0, base + VIC_INT_ENABLE); + writel(~0, base + VIC_INT_ENABLE_CLEAR); + writel(0, base + VIC_IRQ_STATUS); + writel(0, base + VIC_ITCR); + writel(~0, base + VIC_INT_SOFT_CLEAR); + + /* + * Make sure we clear all existing interrupts. The vector registers + * in this cell are after the second block of general registers, + * so we can address them using standard offsets, but only from + * the second base address, which is 0x20 in the page + */ + if (vic_2nd_block) { + writel(0, base + VIC_PL190_VECT_ADDR); + for (i = 0; i < 19; i++) { + unsigned int value; + + value = readl(base + VIC_PL190_VECT_ADDR); + writel(value, base + VIC_PL190_VECT_ADDR); + } + /* ST has 16 vectors as well, but we don't enable them by now */ + for (i = 0; i < 16; i++) { + void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4); + writel(0, reg); + } + + writel(32, base + VIC_PL190_DEF_VECT_ADDR); + } + + for (i = 0; i < 32; i++) { + if (vic_sources & (1 << i)) { + unsigned int irq = irq_start + i; + + set_irq_chip(irq, &vic_chip); + set_irq_chip_data(irq, base); + set_irq_handler(irq, handle_level_irq); + set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); + } + } +} -- cgit v1.2.3 From 8c81b52422147b4b09f5adb8d0c6963342a336c6 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Thu, 2 Jul 2009 15:28:52 +0100 Subject: [ARM] 5583/1: VIC: acknowledge software interrupts The PrimeCell Vectored Interrupt Controller offers a way to trigger any interrupt through software. This is a useful tool for developing, but such software interrupt can only be acked by writing a bit in the "software clear" register, or the handler will loop forever. This splits ack from mask, and acks the soft irq in case it was the source. Signed-off-by: Alessandro Rubini Acked-by: Andrea Gallo Acked-by: Linus Walleij Signed-off-by: Russell King --- arch/arm/common/vic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'arch/arm/common/vic.c') diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c index 27714ab30f2..bc1f9ad61ff 100644 --- a/arch/arm/common/vic.c +++ b/arch/arm/common/vic.c @@ -26,6 +26,15 @@ #include #include +static void vic_ack_irq(unsigned int irq) +{ + void __iomem *base = get_irq_chip_data(irq); + irq &= 31; + writel(1 << irq, base + VIC_INT_ENABLE_CLEAR); + /* moreover, clear the soft-triggered, in case it was the reason */ + writel(1 << irq, base + VIC_INT_SOFT_CLEAR); +} + static void vic_mask_irq(unsigned int irq) { void __iomem *base = get_irq_chip_data(irq); @@ -253,7 +262,7 @@ static inline void vic_pm_register(void __iomem *base, unsigned int irq, u32 arg static struct irq_chip vic_chip = { .name = "VIC", - .ack = vic_mask_irq, + .ack = vic_ack_irq, .mask = vic_mask_irq, .unmask = vic_unmask_irq, .set_wake = vic_set_wake, -- cgit v1.2.3