Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[sfrench/cifs-2.6.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/io.h>
14 #include <asm/r7780rp.h>
15
16 #ifdef CONFIG_SH_R7780MP
17 static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
18 #else
19 static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
20 #endif
21
22 static void enable_r7780rp_irq(unsigned int irq)
23 {
24         /* Set priority in IPR back to original value */
25         ctrl_outw(ctrl_inw(IRLCNTR1) | (1 << mask_pos[irq]), IRLCNTR1);
26 }
27
28 static void disable_r7780rp_irq(unsigned int irq)
29 {
30         /* Set the priority in IPR to 0 */
31         ctrl_outw(ctrl_inw(IRLCNTR1) & (0xffff ^ (1 << mask_pos[irq])),
32                   IRLCNTR1);
33 }
34
35 static struct irq_chip r7780rp_irq_chip __read_mostly = {
36         .name           = "R7780RP",
37         .mask           = disable_r7780rp_irq,
38         .unmask         = enable_r7780rp_irq,
39         .mask_ack       = disable_r7780rp_irq,
40 };
41
42 /*
43  * Initialize IRQ setting
44  */
45 void __init init_r7780rp_IRQ(void)
46 {
47         int i;
48
49         for (i = 0; i < 15; i++) {
50                 disable_irq_nosync(i);
51                 set_irq_chip_and_handler_name(i, &r7780rp_irq_chip,
52                                               handle_level_irq, "level");
53                 enable_r7780rp_irq(i);
54         }
55 }