Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / arch / sh / boards / renesas / r7780rp / irq.c
1 /*
2  * linux/arch/sh/boards/renesas/r7780rp/irq.c
3  *
4  * Copyright (C) 2000  Kazumoto Kojima
5  *
6  * Renesas Solutions Highlander R7780RP-1 Support.
7  *
8  * Modified for R7780RP-1 by
9  * Atom Create Engineering Co., Ltd. 2002.
10  */
11
12 #include <linux/config.h>
13 #include <linux/init.h>
14 #include <linux/irq.h>
15 #include <asm/io.h>
16 #include <asm/irq.h>
17 #include <asm/r7780rp/r7780rp.h>
18
19 #ifdef 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 #else
22 static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
23 #endif
24
25 static void enable_r7780rp_irq(unsigned int irq);
26 static void disable_r7780rp_irq(unsigned int irq);
27
28 /* shutdown is same as "disable" */
29 #define shutdown_r7780rp_irq disable_r7780rp_irq
30
31 static void ack_r7780rp_irq(unsigned int irq);
32 static void end_r7780rp_irq(unsigned int irq);
33
34 static unsigned int startup_r7780rp_irq(unsigned int irq)
35 {
36         enable_r7780rp_irq(irq);
37         return 0; /* never anything pending */
38 }
39
40 static void disable_r7780rp_irq(unsigned int irq)
41 {
42         unsigned short val;
43         unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
44
45         /* Set the priority in IPR to 0 */
46         val = ctrl_inw(IRLCNTR1);
47         val &= mask;
48         ctrl_outw(val, IRLCNTR1);
49 }
50
51 static void enable_r7780rp_irq(unsigned int irq)
52 {
53         unsigned short val;
54         unsigned short value = (0x0001 << mask_pos[irq]);
55
56         /* Set priority in IPR back to original value */
57         val = ctrl_inw(IRLCNTR1);
58         val |= value;
59         ctrl_outw(val, IRLCNTR1);
60 }
61
62 static void ack_r7780rp_irq(unsigned int irq)
63 {
64         disable_r7780rp_irq(irq);
65 }
66
67 static void end_r7780rp_irq(unsigned int irq)
68 {
69         if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
70                 enable_r7780rp_irq(irq);
71 }
72
73 static struct hw_interrupt_type r7780rp_irq_type = {
74         .typename = "R7780RP-IRQ",
75         .startup = startup_r7780rp_irq,
76         .shutdown = shutdown_r7780rp_irq,
77         .enable = enable_r7780rp_irq,
78         .disable = disable_r7780rp_irq,
79         .ack = ack_r7780rp_irq,
80         .end = end_r7780rp_irq,
81 };
82
83 static void make_r7780rp_irq(unsigned int irq)
84 {
85         disable_irq_nosync(irq);
86         irq_desc[irq].handler = &r7780rp_irq_type;
87         disable_r7780rp_irq(irq);
88 }
89
90 /*
91  * Initialize IRQ setting
92  */
93 void __init init_r7780rp_IRQ(void)
94 {
95         int i;
96
97         /* IRL0=PCI Slot #A
98          * IRL1=PCI Slot #B
99          * IRL2=PCI Slot #C
100          * IRL3=PCI Slot #D
101          * IRL4=CF Card
102          * IRL5=CF Card Insert
103          * IRL6=M66596
104          * IRL7=SD Card
105          * IRL8=Touch Panel
106          * IRL9=SCI
107          * IRL10=Serial
108          * IRL11=Extention #A
109          * IRL11=Extention #B
110          * IRL12=Debug LAN
111          * IRL13=Push Switch
112          * IRL14=ZiggBee IO
113          */
114
115         for (i=0; i<15; i++)
116                 make_r7780rp_irq(i);
117 }