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(struct irq_data
*data
)
73 unsigned int irq
= data
->irq
;
74 struct fpga_irq set
= get_fpga_irq(fpga2irq(irq
));
75 unsigned int bit
= irq
- set
.base
;
76 __raw_writew(__raw_readw(set
.mraddr
) | 0x0001 << bit
, set
.mraddr
);
79 static void enable_se7724_irq(struct irq_data
*data
)
81 unsigned int irq
= data
->irq
;
82 struct fpga_irq set
= get_fpga_irq(fpga2irq(irq
));
83 unsigned int bit
= irq
- set
.base
;
84 __raw_writew(__raw_readw(set
.mraddr
) & ~(0x0001 << bit
), set
.mraddr
);
87 static struct irq_chip se7724_irq_chip __read_mostly
= {
88 .name
= "SE7724-FPGA",
89 .irq_mask
= disable_se7724_irq
,
90 .irq_unmask
= enable_se7724_irq
,
93 static void se7724_irq_demux(unsigned int irq
, struct irq_desc
*desc
)
95 struct fpga_irq set
= get_fpga_irq(irq
);
96 unsigned short intv
= __raw_readw(set
.sraddr
);
97 unsigned int ext_irq
= set
.base
;
101 for (; intv
; intv
>>= 1, ext_irq
++) {
105 generic_handle_irq(ext_irq
);
110 * Initialize IRQ setting
112 void __init
init_se7724_IRQ(void)
114 int i
, nid
= cpu_to_node(boot_cpu_data
);
116 __raw_writew(0xffff, IRQ0_MR
); /* mask all */
117 __raw_writew(0xffff, IRQ1_MR
); /* mask all */
118 __raw_writew(0xffff, IRQ2_MR
); /* mask all */
119 __raw_writew(0x0000, IRQ0_SR
); /* clear irq */
120 __raw_writew(0x0000, IRQ1_SR
); /* clear irq */
121 __raw_writew(0x0000, IRQ2_SR
); /* clear irq */
122 __raw_writew(0x002a, IRQ_MODE
); /* set irq type */
124 for (i
= 0; i
< SE7724_FPGA_IRQ_NR
; i
++) {
127 wanted
= SE7724_FPGA_IRQ_BASE
+ i
;
129 irq
= create_irq_nr(wanted
, nid
);
130 if (unlikely(irq
== 0)) {
131 pr_err("%s: failed hooking irq %d for FPGA\n",
136 if (unlikely(irq
!= wanted
)) {
137 pr_err("%s: got irq %d but wanted %d, bailing.\n",
138 __func__
, irq
, wanted
);
143 irq_set_chip_and_handler_name(irq
, &se7724_irq_chip
,
144 handle_level_irq
, "level");
147 irq_set_chained_handler(IRQ0_IRQ
, se7724_irq_demux
);
148 irq_set_irq_type(IRQ0_IRQ
, IRQ_TYPE_LEVEL_LOW
);
150 irq_set_chained_handler(IRQ1_IRQ
, se7724_irq_demux
);
151 irq_set_irq_type(IRQ1_IRQ
, IRQ_TYPE_LEVEL_LOW
);
153 irq_set_chained_handler(IRQ2_IRQ
, se7724_irq_demux
);
154 irq_set_irq_type(IRQ2_IRQ
, IRQ_TYPE_LEVEL_LOW
);