FRV: Convert genirq namespace
[cris-mirror.git] / arch / frv / kernel / irq.c
bloba5631e940a008204f32dceb02ecacbcb951a341d
1 /* irq.c: FRV IRQ handling
3 * Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/ptrace.h>
13 #include <linux/errno.h>
14 #include <linux/signal.h>
15 #include <linux/sched.h>
16 #include <linux/ioport.h>
17 #include <linux/interrupt.h>
18 #include <linux/timex.h>
19 #include <linux/random.h>
20 #include <linux/init.h>
21 #include <linux/kernel_stat.h>
22 #include <linux/irq.h>
23 #include <linux/proc_fs.h>
24 #include <linux/seq_file.h>
25 #include <linux/module.h>
26 #include <linux/bitops.h>
28 #include <asm/atomic.h>
29 #include <asm/io.h>
30 #include <asm/smp.h>
31 #include <asm/system.h>
32 #include <asm/uaccess.h>
33 #include <asm/pgalloc.h>
34 #include <asm/delay.h>
35 #include <asm/irq.h>
36 #include <asm/irc-regs.h>
37 #include <asm/gdb-stub.h>
39 #define set_IRR(N,A,B,C,D) __set_IRR(N, (A << 28) | (B << 24) | (C << 20) | (D << 16))
41 extern void __init fpga_init(void);
42 #ifdef CONFIG_FUJITSU_MB93493
43 extern void __init mb93493_init(void);
44 #endif
46 #define __reg16(ADDR) (*(volatile unsigned short *)(ADDR))
48 atomic_t irq_err_count;
51 * Generic, controller-independent functions:
53 int show_interrupts(struct seq_file *p, void *v)
55 int i = *(loff_t *) v, cpu;
56 struct irqaction * action;
57 unsigned long flags;
59 if (i == 0) {
60 char cpuname[12];
62 seq_printf(p, " ");
63 for_each_present_cpu(cpu) {
64 sprintf(cpuname, "CPU%d", cpu);
65 seq_printf(p, " %10s", cpuname);
67 seq_putc(p, '\n');
70 if (i < NR_IRQS) {
71 raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
72 action = irq_desc[i].action;
73 if (action) {
74 seq_printf(p, "%3d: ", i);
75 for_each_present_cpu(cpu)
76 seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu));
77 seq_printf(p, " %10s",
78 irq_desc[i].irq_data.chip->name ? : "-");
79 seq_printf(p, " %s", action->name);
80 for (action = action->next;
81 action;
82 action = action->next)
83 seq_printf(p, ", %s", action->name);
85 seq_putc(p, '\n');
88 raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
89 } else if (i == NR_IRQS) {
90 seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
93 return 0;
97 * on-CPU PIC operations
99 static void frv_cpupic_ack(struct irq_data *d)
101 __clr_RC(d->irq);
102 __clr_IRL();
105 static void frv_cpupic_mask(struct irq_data *d)
107 __set_MASK(d->irq);
110 static void frv_cpupic_mask_ack(struct irq_data *d)
112 __set_MASK(d->irq);
113 __clr_RC(d->irq);
114 __clr_IRL();
117 static void frv_cpupic_unmask(struct irq_data *d)
119 __clr_MASK(d->irq);
122 static struct irq_chip frv_cpu_pic = {
123 .name = "cpu",
124 .irq_ack = frv_cpupic_ack,
125 .irq_mask = frv_cpupic_mask,
126 .irq_mask_ack = frv_cpupic_mask_ack,
127 .irq_unmask = frv_cpupic_unmask,
131 * handles all normal device IRQs
132 * - registers are referred to by the __frame variable (GR28)
133 * - IRQ distribution is complicated in this arch because of the many PICs, the
134 * way they work and the way they cascade
136 asmlinkage void do_IRQ(void)
138 irq_enter();
139 generic_handle_irq(__get_IRL());
140 irq_exit();
144 * handles all NMIs when not co-opted by the debugger
145 * - registers are referred to by the __frame variable (GR28)
147 asmlinkage void do_NMI(void)
152 * initialise the interrupt system
154 void __init init_IRQ(void)
156 int level;
158 for (level = 1; level <= 14; level++)
159 irq_set_chip_and_handler(level, &frv_cpu_pic,
160 handle_level_irq);
162 irq_set_handler(IRQ_CPU_TIMER0, handle_edge_irq);
164 /* set the trigger levels for internal interrupt sources
165 * - timers all falling-edge
166 * - ERR0 is rising-edge
167 * - all others are high-level
169 __set_IITMR(0, 0x003f0000); /* DMA0-3, TIMER0-2 */
170 __set_IITMR(1, 0x20000000); /* ERR0-1, UART0-1, DMA4-7 */
172 /* route internal interrupts */
173 set_IRR(4, IRQ_DMA3_LEVEL, IRQ_DMA2_LEVEL, IRQ_DMA1_LEVEL,
174 IRQ_DMA0_LEVEL);
175 set_IRR(5, 0, IRQ_TIMER2_LEVEL, IRQ_TIMER1_LEVEL, IRQ_TIMER0_LEVEL);
176 set_IRR(6, IRQ_GDBSTUB_LEVEL, IRQ_GDBSTUB_LEVEL,
177 IRQ_UART1_LEVEL, IRQ_UART0_LEVEL);
178 set_IRR(7, IRQ_DMA7_LEVEL, IRQ_DMA6_LEVEL, IRQ_DMA5_LEVEL,
179 IRQ_DMA4_LEVEL);
181 /* route external interrupts */
182 set_IRR(2, IRQ_XIRQ7_LEVEL, IRQ_XIRQ6_LEVEL, IRQ_XIRQ5_LEVEL,
183 IRQ_XIRQ4_LEVEL);
184 set_IRR(3, IRQ_XIRQ3_LEVEL, IRQ_XIRQ2_LEVEL, IRQ_XIRQ1_LEVEL,
185 IRQ_XIRQ0_LEVEL);
187 #if defined(CONFIG_MB93091_VDK)
188 __set_TM1(0x55550000); /* XIRQ7-0 all active low */
189 #elif defined(CONFIG_MB93093_PDK)
190 __set_TM1(0x15550000); /* XIRQ7 active high, 6-0 all active low */
191 #else
192 #error dont know external IRQ trigger levels for this setup
193 #endif
195 fpga_init();
196 #ifdef CONFIG_FUJITSU_MB93493
197 mb93493_init();
198 #endif