Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-drm-fsl-dcu.git] / arch / sh / boards / renesas / r7780rp / irq.c
1 /*
2  * Renesas Solutions Highlander R7780RP-1 Support.
3  *
4  * Copyright (C) 2002  Atom Create Engineering Co., Ltd.
5  * Copyright (C) 2006  Paul Mundt
6  *
7  * This file is subject to the terms and conditions of the GNU General Public
8  * License.  See the file "COPYING" in the main directory of this archive
9  * for more details.
10  */
11 #include <linux/init.h>
12 #include <linux/irq.h>
13 #include <linux/interrupt.h>
14 #include <linux/io.h>
15 #include <asm/r7780rp.h>
16
17 #ifdef CONFIG_SH_R7780RP
18 static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
19 #elif defined(CONFIG_SH_R7780MP)
20 static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
21 #elif defined(CONFIG_SH_R7785RP)
22 static int mask_pos[] = {2, 11, 2, 2, 2, 2, 9, 8, 7, 5, 10, 2, 2, 2, 2, 2};
23 #endif
24
25 static void enable_r7780rp_irq(unsigned int irq)
26 {
27         /* Set priority in IPR back to original value */
28         ctrl_outw(ctrl_inw(IRLCNTR1) | (1 << mask_pos[irq]), IRLCNTR1);
29 }
30
31 static void disable_r7780rp_irq(unsigned int irq)
32 {
33         /* Set the priority in IPR to 0 */
34         ctrl_outw(ctrl_inw(IRLCNTR1) & (0xffff ^ (1 << mask_pos[irq])),
35                   IRLCNTR1);
36 }
37
38 static struct irq_chip r7780rp_irq_chip __read_mostly = {
39         .name           = "R7780RP",
40         .mask           = disable_r7780rp_irq,
41         .unmask         = enable_r7780rp_irq,
42         .mask_ack       = disable_r7780rp_irq,
43 };
44
45 void make_r7780rp_irq(unsigned int irq)
46 {
47         disable_irq_nosync(irq);
48         set_irq_chip_and_handler_name(irq, &r7780rp_irq_chip,
49                                       handle_level_irq, "level");
50         enable_r7780rp_irq(irq);
51 }