1 /* irq-mb93091.c: MB93091 FPGA interrupt handling
3 * Copyright (C) 2003 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/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>
23 #include <asm/system.h>
24 #include <asm/bitops.h>
25 #include <asm/delay.h>
27 #include <asm/irc-regs.h>
28 #include <asm/irq-routing.h>
30 #define __reg16(ADDR) (*(volatile unsigned short *)(ADDR))
32 #define __get_IMR() ({ __reg16(0xffc00004); })
33 #define __set_IMR(M) do { __reg16(0xffc00004) = (M); wmb(); } while(0)
34 #define __get_IFR() ({ __reg16(0xffc0000c); })
35 #define __clr_IFR(M) do { __reg16(0xffc0000c) = ~(M); wmb(); } while(0)
37 static void frv_fpga_doirq(struct irq_source
*source
);
38 static void frv_fpga_control(struct irq_group
*group
, int irq
, int on
);
40 /*****************************************************************************/
42 * FPGA IRQ multiplexor
44 static struct irq_source frv_fpga
[4] = {
45 #define __FPGA(X, M) \
47 .muxname = "fpga."#X, \
49 .doirq = frv_fpga_doirq, \
58 static struct irq_group frv_fpga_irqs
= {
59 .first_irq
= IRQ_BASE_FPGA
,
60 .control
= frv_fpga_control
,
80 static void frv_fpga_control(struct irq_group
*group
, int index
, int on
)
82 uint16_t imr
= __get_IMR();
92 static void frv_fpga_doirq(struct irq_source
*source
)
97 mask
= source
->irqmask
& ~imr
& __get_IFR();
99 __set_IMR(imr
| mask
);
101 distribute_irqs(&frv_fpga_irqs
, mask
);
106 void __init
fpga_init(void)
111 frv_irq_route_external(&frv_fpga
[0], IRQ_CPU_EXTERNAL0
);
112 frv_irq_route_external(&frv_fpga
[1], IRQ_CPU_EXTERNAL1
);
113 frv_irq_route_external(&frv_fpga
[2], IRQ_CPU_EXTERNAL2
);
114 frv_irq_route_external(&frv_fpga
[3], IRQ_CPU_EXTERNAL3
);
115 frv_irq_set_group(&frv_fpga_irqs
);