]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-ns9xxx/irq.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / mach-ns9xxx / irq.c
1 /*
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>
12 #include <asm/mach/irq.h>
13 #include <asm/mach-types.h>
14 #include <asm/arch-ns9xxx/regs-sys.h>
15 #include <asm/arch-ns9xxx/irqs.h>
16 #include <asm/arch-ns9xxx/board.h>
17
18 #include "generic.h"
19
20 static void ns9xxx_ack_irq_timer(unsigned int irq)
21 {
22         u32 tc = SYS_TC(irq - IRQ_TIMER0);
23
24         /*
25          * If the timer is programmed to halt on terminal count, the
26          * timer must be disabled before clearing the interrupt.
27          */
28         if (REGGET(tc, SYS_TCx, REN) == 0) {
29                 REGSET(tc, SYS_TCx, TEN, DIS);
30                 SYS_TC(irq - IRQ_TIMER0) = tc;
31         }
32
33         REGSET(tc, SYS_TCx, INTC, SET);
34         SYS_TC(irq - IRQ_TIMER0) = tc;
35
36         REGSET(tc, SYS_TCx, INTC, UNSET);
37         SYS_TC(irq - IRQ_TIMER0) = tc;
38 }
39
40 static void (*ns9xxx_ack_irq_functions[NR_IRQS])(unsigned int) = {
41         [IRQ_TIMER0] = ns9xxx_ack_irq_timer,
42         [IRQ_TIMER1] = ns9xxx_ack_irq_timer,
43         [IRQ_TIMER2] = ns9xxx_ack_irq_timer,
44         [IRQ_TIMER3] = ns9xxx_ack_irq_timer,
45 };
46
47 static void ns9xxx_mask_irq(unsigned int irq)
48 {
49         /* XXX: better use cpp symbols */
50         SYS_IC(irq / 4) &= ~(1 << (7 + 8 * (3 - (irq & 3))));
51 }
52
53 static void ns9xxx_ack_irq(unsigned int irq)
54 {
55         if (!ns9xxx_ack_irq_functions[irq]) {
56                 printk(KERN_ERR "no ack function for irq %u\n", irq);
57                 BUG();
58         }
59
60         ns9xxx_ack_irq_functions[irq](irq);
61         SYS_ISRADDR = 0;
62 }
63
64 static void ns9xxx_maskack_irq(unsigned int irq)
65 {
66         ns9xxx_mask_irq(irq);
67         ns9xxx_ack_irq(irq);
68 }
69
70 static void ns9xxx_unmask_irq(unsigned int irq)
71 {
72         /* XXX: better use cpp symbols */
73         SYS_IC(irq / 4) |= 1 << (7 + 8 * (3 - (irq & 3)));
74 }
75
76 static struct irq_chip ns9xxx_chip = {
77         .ack            = ns9xxx_ack_irq,
78         .mask           = ns9xxx_mask_irq,
79         .mask_ack       = ns9xxx_maskack_irq,
80         .unmask         = ns9xxx_unmask_irq,
81 };
82
83 void __init ns9xxx_init_irq(void)
84 {
85         int i;
86
87         /* disable all IRQs */
88         for (i = 0; i < 8; ++i)
89                 SYS_IC(i) = (4 * i) << 24 | (4 * i + 1) << 16 |
90                         (4 * i + 2) << 8 | (4 * i + 3);
91
92         /* simple interrupt prio table:
93          * prio(x) < prio(y) <=> x < y
94          */
95         for (i = 0; i < 32; ++i)
96                 SYS_IVA(i) = i;
97
98         for (i = IRQ_WATCHDOG; i <= IRQ_EXT3; ++i) {
99                 set_irq_chip(i, &ns9xxx_chip);
100                 set_irq_handler(i, handle_level_irq);
101                 set_irq_flags(i, IRQF_VALID);
102         }
103 }