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