2 * linux/arch/sh/boards/se/7724/irq.c
4 * Copyright (C) 2009 Renesas Solutions Corp.
6 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
8 * Based on linux/arch/sh/boards/se/7722/irq.c
9 * Copyright (C) 2007 Nobuhiro Iwamatsu
11 * Hitachi UL SolutionEngine 7724 Support.
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
17 #include <linux/init.h>
18 #include <linux/irq.h>
19 #include <linux/interrupt.h>
22 #include <mach-se/mach/se7724.h>
31 static unsigned int fpga2irq(unsigned int irq
)
33 if (irq
>= IRQ0_BASE
&&
36 else if (irq
>= IRQ1_BASE
&&
43 static struct fpga_irq
get_fpga_irq(unsigned int irq
)
71 static void disable_se7724_irq(unsigned int irq
)
73 struct fpga_irq set
= get_fpga_irq(fpga2irq(irq
));
74 unsigned int bit
= irq
- set
.base
;
75 ctrl_outw(ctrl_inw(set
.mraddr
) | 0x0001 << bit
, set
.mraddr
);
78 static void enable_se7724_irq(unsigned int irq
)
80 struct fpga_irq set
= get_fpga_irq(fpga2irq(irq
));
81 unsigned int bit
= irq
- set
.base
;
82 ctrl_outw(ctrl_inw(set
.mraddr
) & ~(0x0001 << bit
), set
.mraddr
);
85 static struct irq_chip se7724_irq_chip __read_mostly
= {
86 .name
= "SE7724-FPGA",
87 .mask
= disable_se7724_irq
,
88 .unmask
= enable_se7724_irq
,
89 .mask_ack
= disable_se7724_irq
,
92 static void se7724_irq_demux(unsigned int irq
, struct irq_desc
*desc
)
94 struct fpga_irq set
= get_fpga_irq(irq
);
95 unsigned short intv
= ctrl_inw(set
.sraddr
);
96 struct irq_desc
*ext_desc
;
97 unsigned int ext_irq
= set
.base
;
103 ext_desc
= irq_desc
+ ext_irq
;
104 handle_level_irq(ext_irq
, ext_desc
);
112 * Initialize IRQ setting
114 void __init
init_se7724_IRQ(void)
118 ctrl_outw(0xffff, IRQ0_MR
); /* mask all */
119 ctrl_outw(0xffff, IRQ1_MR
); /* mask all */
120 ctrl_outw(0xffff, IRQ2_MR
); /* mask all */
121 ctrl_outw(0x0000, IRQ0_SR
); /* clear irq */
122 ctrl_outw(0x0000, IRQ1_SR
); /* clear irq */
123 ctrl_outw(0x0000, IRQ2_SR
); /* clear irq */
124 ctrl_outw(0x002a, IRQ_MODE
); /* set irq type */
126 for (i
= 0; i
< SE7724_FPGA_IRQ_NR
; i
++)
127 set_irq_chip_and_handler_name(SE7724_FPGA_IRQ_BASE
+ i
,
129 handle_level_irq
, "level");
131 set_irq_chained_handler(IRQ0_IRQ
, se7724_irq_demux
);
132 set_irq_type(IRQ0_IRQ
, IRQ_TYPE_LEVEL_LOW
);
134 set_irq_chained_handler(IRQ1_IRQ
, se7724_irq_demux
);
135 set_irq_type(IRQ1_IRQ
, IRQ_TYPE_LEVEL_LOW
);
137 set_irq_chained_handler(IRQ2_IRQ
, se7724_irq_demux
);
138 set_irq_type(IRQ2_IRQ
, IRQ_TYPE_LEVEL_LOW
);