]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/frv/kernel/irq-mb93093.c
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / arch / frv / kernel / irq-mb93093.c
1 /* irq-mb93093.c: MB93093 FPGA interrupt handling
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
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.
10 */
11
12 #include <linux/config.h>
13 #include <linux/ptrace.h>
14 #include <linux/errno.h>
15 #include <linux/signal.h>
16 #include <linux/sched.h>
17 #include <linux/ioport.h>
18 #include <linux/interrupt.h>
19 #include <linux/init.h>
20 #include <linux/irq.h>
21
22 #include <asm/io.h>
23 #include <asm/system.h>
24 #include <asm/bitops.h>
25 #include <asm/delay.h>
26 #include <asm/irq.h>
27 #include <asm/irc-regs.h>
28 #include <asm/irq-routing.h>
29
30 #define __reg16(ADDR) (*(volatile unsigned short *)(__region_CS2 + (ADDR)))
31
32 #define __get_IMR() ({ __reg16(0x0a); })
33 #define __set_IMR(M) do { __reg16(0x0a) = (M); wmb(); } while(0)
34 #define __get_IFR() ({ __reg16(0x02); })
35 #define __clr_IFR(M) do { __reg16(0x02) = ~(M); wmb(); } while(0)
36
37 static void frv_fpga_doirq(struct irq_source *source);
38 static void frv_fpga_control(struct irq_group *group, int irq, int on);
39
40 /*****************************************************************************/
41 /*
42 * FPGA IRQ multiplexor
43 */
44 static struct irq_source frv_fpga[4] = {
45 #define __FPGA(X, M) \
46 [X] = { \
47 .muxname = "fpga."#X, \
48 .irqmask = M, \
49 .doirq = frv_fpga_doirq, \
50 }
51
52 __FPGA(0, 0x0700),
53 };
54
55 static struct irq_group frv_fpga_irqs = {
56 .first_irq = IRQ_BASE_FPGA,
57 .control = frv_fpga_control,
58 .sources = {
59 [ 8] = &frv_fpga[0],
60 [ 9] = &frv_fpga[0],
61 [10] = &frv_fpga[0],
62 },
63 };
64
65
66 static void frv_fpga_control(struct irq_group *group, int index, int on)
67 {
68 uint16_t imr = __get_IMR();
69
70 if (on)
71 imr &= ~(1 << index);
72 else
73 imr |= 1 << index;
74
75 __set_IMR(imr);
76 }
77
78 static void frv_fpga_doirq(struct irq_source *source)
79 {
80 uint16_t mask, imr;
81
82 imr = __get_IMR();
83 mask = source->irqmask & ~imr & __get_IFR();
84 if (mask) {
85 __set_IMR(imr | mask);
86 __clr_IFR(mask);
87 distribute_irqs(&frv_fpga_irqs, mask);
88 __set_IMR(imr);
89 }
90 }
91
92 void __init fpga_init(void)
93 {
94 __set_IMR(0x0700);
95 __clr_IFR(0x0000);
96
97 frv_irq_route_external(&frv_fpga[0], IRQ_CPU_EXTERNAL2);
98 frv_irq_set_group(&frv_fpga_irqs);
99 }