ns9xxx: prepare for adding support for Digi ns921x processors
[linux-2.6/mini2440.git] / arch / arm / mach-ns9xxx / irq.c
blobd4a583cc44c5a110f90412166d916b60ebb95d07
1 /*
2 * arch/arm/mach-ns9xxx/irq.c
4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved.
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.
11 #include <linux/interrupt.h>
12 #include <asm/io.h>
13 #include <asm/mach/irq.h>
14 #include <asm/mach-types.h>
15 #include <asm/arch-ns9xxx/regs-sys-common.h>
16 #include <asm/arch-ns9xxx/irqs.h>
17 #include <asm/arch-ns9xxx/board.h>
19 #include "generic.h"
21 static void ns9xxx_mask_irq(unsigned int irq)
23 /* XXX: better use cpp symbols */
24 u32 ic = __raw_readl(SYS_IC(irq / 4));
25 ic &= ~(1 << (7 + 8 * (3 - (irq & 3))));
26 __raw_writel(ic, SYS_IC(irq / 4));
29 static void ns9xxx_ack_irq(unsigned int irq)
31 __raw_writel(0, SYS_ISRADDR);
34 static void ns9xxx_maskack_irq(unsigned int irq)
36 ns9xxx_mask_irq(irq);
37 ns9xxx_ack_irq(irq);
40 static void ns9xxx_unmask_irq(unsigned int irq)
42 /* XXX: better use cpp symbols */
43 u32 ic = __raw_readl(SYS_IC(irq / 4));
44 ic |= 1 << (7 + 8 * (3 - (irq & 3)));
45 __raw_writel(ic, SYS_IC(irq / 4));
48 static struct irq_chip ns9xxx_chip = {
49 .ack = ns9xxx_ack_irq,
50 .mask = ns9xxx_mask_irq,
51 .mask_ack = ns9xxx_maskack_irq,
52 .unmask = ns9xxx_unmask_irq,
55 void __init ns9xxx_init_irq(void)
57 int i;
59 /* disable all IRQs */
60 for (i = 0; i < 8; ++i)
61 __raw_writel((4 * i) << 24 | (4 * i + 1) << 16 |
62 (4 * i + 2) << 8 | (4 * i + 3), SYS_IC(i));
64 /* simple interrupt prio table:
65 * prio(x) < prio(y) <=> x < y
67 for (i = 0; i < 32; ++i)
68 __raw_writel(i, SYS_IVA(i));
70 for (i = 0; i <= 31; ++i) {
71 set_irq_chip(i, &ns9xxx_chip);
72 set_irq_handler(i, handle_level_irq);
73 set_irq_flags(i, IRQF_VALID);