blob: 37ab0a2b83ad59b3b83a0b35c9047f508333d497 [file] [log] [blame]
Uwe Kleine-König9918cda2007-02-16 15:36:55 +01001/*
2 * arch/arm/mach-ns9xxx/irq.c
3 *
4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11#include <linux/interrupt.h>
Uwe Kleine-König5e69b942008-02-29 13:27:53 +010012#include <linux/kernel_stat.h>
Russell Kingfced80c2008-09-06 12:10:45 +010013#include <linux/io.h>
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010014#include <asm/mach/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010015#include <mach/regs-sys-common.h>
16#include <mach/irqs.h>
17#include <mach/board.h>
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010018
19#include "generic.h"
20
Uwe Kleine-Königed6f5982007-12-11 16:52:50 +010021/* simple interrupt prio table: prio(x) < prio(y) <=> x < y */
22#define irq2prio(i) (i)
23#define prio2irq(p) (p)
24
Lennert Buytenhek9b3ffe52010-11-29 10:38:34 +010025static void ns9xxx_mask_irq(struct irq_data *d)
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010026{
27 /* XXX: better use cpp symbols */
Lennert Buytenhek9b3ffe52010-11-29 10:38:34 +010028 int prio = irq2prio(d->irq);
Uwe Kleine-Königed6f5982007-12-11 16:52:50 +010029 u32 ic = __raw_readl(SYS_IC(prio / 4));
30 ic &= ~(1 << (7 + 8 * (3 - (prio & 3))));
31 __raw_writel(ic, SYS_IC(prio / 4));
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010032}
33
Thomas Gleixner68293102011-02-02 21:41:27 +000034static void ns9xxx_eoi_irq(struct irq_data *d)
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010035{
Uwe Kleine-König361c7ad2007-09-30 20:36:33 +010036 __raw_writel(0, SYS_ISRADDR);
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010037}
38
Lennert Buytenhek9b3ffe52010-11-29 10:38:34 +010039static void ns9xxx_unmask_irq(struct irq_data *d)
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010040{
41 /* XXX: better use cpp symbols */
Lennert Buytenhek9b3ffe52010-11-29 10:38:34 +010042 int prio = irq2prio(d->irq);
Uwe Kleine-Königed6f5982007-12-11 16:52:50 +010043 u32 ic = __raw_readl(SYS_IC(prio / 4));
44 ic |= 1 << (7 + 8 * (3 - (prio & 3)));
45 __raw_writel(ic, SYS_IC(prio / 4));
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010046}
47
48static struct irq_chip ns9xxx_chip = {
Thomas Gleixner68293102011-02-02 21:41:27 +000049 .irq_eoi = ns9xxx_eoi_irq,
Lennert Buytenhek9b3ffe52010-11-29 10:38:34 +010050 .irq_mask = ns9xxx_mask_irq,
Lennert Buytenhek9b3ffe52010-11-29 10:38:34 +010051 .irq_unmask = ns9xxx_unmask_irq,
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010052};
53
54void __init ns9xxx_init_irq(void)
55{
56 int i;
57
58 /* disable all IRQs */
59 for (i = 0; i < 8; ++i)
Uwe Kleine-Königed6f5982007-12-11 16:52:50 +010060 __raw_writel(prio2irq(4 * i) << 24 |
61 prio2irq(4 * i + 1) << 16 |
62 prio2irq(4 * i + 2) << 8 |
63 prio2irq(4 * i + 3),
64 SYS_IC(i));
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010065
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010066 for (i = 0; i < 32; ++i)
Uwe Kleine-Königed6f5982007-12-11 16:52:50 +010067 __raw_writel(prio2irq(i), SYS_IVA(i));
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010068
Uwe Kleine-König724ce5e2008-02-15 08:41:06 +010069 for (i = 0; i <= 31; ++i) {
Thomas Gleixnerf38c02f2011-03-24 13:35:09 +010070 irq_set_chip_and_handler(i, &ns9xxx_chip, handle_fasteoi_irq);
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010071 set_irq_flags(i, IRQF_VALID);
Thomas Gleixner68293102011-02-02 21:41:27 +000072 irq_set_status_flags(i, IRQ_LEVEL);
Uwe Kleine-König9918cda2007-02-16 15:36:55 +010073 }
74}