m32r: Cleanup direct irq_desc access
[cascardo/linux.git] / arch / m32r / platforms / mappi / setup.c
1 /*
2  *  linux/arch/m32r/platforms/mappi/setup.c
3  *
4  *  Setup routines for Renesas MAPPI Board
5  *
6  *  Copyright (c) 2001-2005  Hiroyuki Kondo, Hirokazu Takata,
7  *                           Hitoshi Yamamoto
8  */
9
10 #include <linux/irq.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14
15 #include <asm/system.h>
16 #include <asm/m32r.h>
17 #include <asm/io.h>
18
19 #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
20
21 icu_data_t icu_data[NR_IRQS];
22
23 static void disable_mappi_irq(unsigned int irq)
24 {
25         unsigned long port, data;
26
27         port = irq2port(irq);
28         data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
29         outl(data, port);
30 }
31
32 static void enable_mappi_irq(unsigned int irq)
33 {
34         unsigned long port, data;
35
36         port = irq2port(irq);
37         data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
38         outl(data, port);
39 }
40
41 static void mask_and_ack_mappi(unsigned int irq)
42 {
43         disable_mappi_irq(irq);
44 }
45
46 static void end_mappi_irq(unsigned int irq)
47 {
48                 enable_mappi_irq(irq);
49 }
50
51 static unsigned int startup_mappi_irq(unsigned int irq)
52 {
53         enable_mappi_irq(irq);
54         return (0);
55 }
56
57 static void shutdown_mappi_irq(unsigned int irq)
58 {
59         unsigned long port;
60
61         port = irq2port(irq);
62         outl(M32R_ICUCR_ILEVEL7, port);
63 }
64
65 static struct irq_chip mappi_irq_type =
66 {
67         .name = "MAPPI-IRQ",
68         .startup = startup_mappi_irq,
69         .shutdown = shutdown_mappi_irq,
70         .enable = enable_mappi_irq,
71         .disable = disable_mappi_irq,
72         .ack = mask_and_ack_mappi,
73         .end = end_mappi_irq
74 };
75
76 void __init init_IRQ(void)
77 {
78         static int once = 0;
79
80         if (once)
81                 return;
82         else
83                 once++;
84
85 #ifdef CONFIG_NE2000
86         /* INT0 : LAN controller (RTL8019AS) */
87         set_irq_chip(M32R_IRQ_INT0, &mappi_irq_type);
88         icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
89         disable_mappi_irq(M32R_IRQ_INT0);
90 #endif /* CONFIG_M32R_NE2000 */
91
92         /* MFT2 : system timer */
93         set_irq_chip(M32R_IRQ_MFT2, &mappi_irq_type);
94         icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
95         disable_mappi_irq(M32R_IRQ_MFT2);
96
97 #ifdef CONFIG_SERIAL_M32R_SIO
98         /* SIO0_R : uart receive data */
99         set_irq_chip(M32R_IRQ_SIO0_R, &mappi_irq_type);
100         icu_data[M32R_IRQ_SIO0_R].icucr = 0;
101         disable_mappi_irq(M32R_IRQ_SIO0_R);
102
103         /* SIO0_S : uart send data */
104         set_irq_chip(M32R_IRQ_SIO0_S, &mappi_irq_type);
105         icu_data[M32R_IRQ_SIO0_S].icucr = 0;
106         disable_mappi_irq(M32R_IRQ_SIO0_S);
107
108         /* SIO1_R : uart receive data */
109         set_irq_chip(M32R_IRQ_SIO1_R, &mappi_irq_type);
110         icu_data[M32R_IRQ_SIO1_R].icucr = 0;
111         disable_mappi_irq(M32R_IRQ_SIO1_R);
112
113         /* SIO1_S : uart send data */
114         set_irq_chip(M32R_IRQ_SIO1_S, &mappi_irq_type);
115         icu_data[M32R_IRQ_SIO1_S].icucr = 0;
116         disable_mappi_irq(M32R_IRQ_SIO1_S);
117 #endif /* CONFIG_SERIAL_M32R_SIO */
118
119 #if defined(CONFIG_M32R_PCC)
120         /* INT1 : pccard0 interrupt */
121         set_irq_chip(M32R_IRQ_INT1, &mappi_irq_type);
122         icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
123         disable_mappi_irq(M32R_IRQ_INT1);
124
125         /* INT2 : pccard1 interrupt */
126         set_irq_chip(M32R_IRQ_INT2, &mappi_irq_type);
127         icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
128         disable_mappi_irq(M32R_IRQ_INT2);
129 #endif /* CONFIG_M32RPCC */
130 }
131
132 #if defined(CONFIG_FB_S1D13XXX)
133
134 #include <video/s1d13xxxfb.h>
135 #include <asm/s1d13806.h>
136
137 static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
138         .initregs               = s1d13xxxfb_initregs,
139         .initregssize           = ARRAY_SIZE(s1d13xxxfb_initregs),
140         .platform_init_video    = NULL,
141 #ifdef CONFIG_PM
142         .platform_suspend_video = NULL,
143         .platform_resume_video  = NULL,
144 #endif
145 };
146
147 static struct resource s1d13xxxfb_resources[] = {
148         [0] = {
149                 .start  = 0x10200000UL,
150                 .end    = 0x1033FFFFUL,
151                 .flags  = IORESOURCE_MEM,
152         },
153         [1] = {
154                 .start  = 0x10000000UL,
155                 .end    = 0x100001FFUL,
156                 .flags  = IORESOURCE_MEM,
157         }
158 };
159
160 static struct platform_device s1d13xxxfb_device = {
161         .name           = S1D_DEVICENAME,
162         .id             = 0,
163         .dev            = {
164                 .platform_data  = &s1d13xxxfb_data,
165         },
166         .num_resources  = ARRAY_SIZE(s1d13xxxfb_resources),
167         .resource       = s1d13xxxfb_resources,
168 };
169
170 static int __init platform_init(void)
171 {
172         platform_device_register(&s1d13xxxfb_device);
173         return 0;
174 }
175 arch_initcall(platform_init);
176 #endif