Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[pandora-kernel.git] / arch / sh / boards / renesas / rts7751r2d / irq.c
1 /*
2  * linux/arch/sh/boards/renesas/rts7751r2d/irq.c
3  *
4  * Copyright (C) 2000  Kazumoto Kojima
5  *
6  * Renesas Technology Sales RTS7751R2D Support.
7  *
8  * Modified for RTS7751R2D by
9  * Atom Create Engineering Co., Ltd. 2002.
10  */
11
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <asm/io.h>
15 #include <asm/irq.h>
16 #include <asm/rts7751r2d/rts7751r2d.h>
17
18 #if defined(CONFIG_RTS7751R2D_REV11)
19 static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0};
20 #else
21 static int mask_pos[] = {6, 11, 9, 8, 12, 10, 5, 4, 7, 14, 13, 0, 0, 0, 0};
22 #endif
23
24 extern int voyagergx_irq_demux(int irq);
25 extern void setup_voyagergx_irq(void);
26
27 static void enable_rts7751r2d_irq(unsigned int irq);
28 static void disable_rts7751r2d_irq(unsigned int irq);
29
30 /* shutdown is same as "disable" */
31 #define shutdown_rts7751r2d_irq disable_rts7751r2d_irq
32
33 static void ack_rts7751r2d_irq(unsigned int irq);
34 static void end_rts7751r2d_irq(unsigned int irq);
35
36 static unsigned int startup_rts7751r2d_irq(unsigned int irq)
37 {
38         enable_rts7751r2d_irq(irq);
39         return 0; /* never anything pending */
40 }
41
42 static void disable_rts7751r2d_irq(unsigned int irq)
43 {
44         unsigned short val;
45         unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
46
47         /* Set the priority in IPR to 0 */
48         val = ctrl_inw(IRLCNTR1);
49         val &= mask;
50         ctrl_outw(val, IRLCNTR1);
51 }
52
53 static void enable_rts7751r2d_irq(unsigned int irq)
54 {
55         unsigned short val;
56         unsigned short value = (0x0001 << mask_pos[irq]);
57
58         /* Set priority in IPR back to original value */
59         val = ctrl_inw(IRLCNTR1);
60         val |= value;
61         ctrl_outw(val, IRLCNTR1);
62 }
63
64 int rts7751r2d_irq_demux(int irq)
65 {
66         int demux_irq;
67
68         demux_irq = voyagergx_irq_demux(irq);
69         return demux_irq;
70 }
71
72 static void ack_rts7751r2d_irq(unsigned int irq)
73 {
74         disable_rts7751r2d_irq(irq);
75 }
76
77 static void end_rts7751r2d_irq(unsigned int irq)
78 {
79         if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
80                 enable_rts7751r2d_irq(irq);
81 }
82
83 static struct hw_interrupt_type rts7751r2d_irq_type = {
84         .typename = "RTS7751R2D IRQ",
85         .startup = startup_rts7751r2d_irq,
86         .shutdown = shutdown_rts7751r2d_irq,
87         .enable = enable_rts7751r2d_irq,
88         .disable = disable_rts7751r2d_irq,
89         .ack = ack_rts7751r2d_irq,
90         .end = end_rts7751r2d_irq,
91 };
92
93 static void make_rts7751r2d_irq(unsigned int irq)
94 {
95         disable_irq_nosync(irq);
96         irq_desc[irq].chip = &rts7751r2d_irq_type;
97         disable_rts7751r2d_irq(irq);
98 }
99
100 /*
101  * Initialize IRQ setting
102  */
103 void __init init_rts7751r2d_IRQ(void)
104 {
105         int i;
106
107         /* IRL0=KEY Input
108          * IRL1=Ethernet
109          * IRL2=CF Card
110          * IRL3=CF Card Insert
111          * IRL4=PCMCIA
112          * IRL5=VOYAGER
113          * IRL6=RTC Alarm
114          * IRL7=RTC Timer
115          * IRL8=SD Card
116          * IRL9=PCI Slot #1
117          * IRL10=PCI Slot #2
118          * IRL11=Extention #0
119          * IRL12=Extention #1
120          * IRL13=Extention #2
121          * IRL14=Extention #3
122          */
123
124         for (i=0; i<15; i++)
125                 make_rts7751r2d_irq(i);
126
127         setup_voyagergx_irq();
128 }