Fix remaining sparse warnings in arch/arm/mach-omap2
[pandora-kernel.git] / arch / arm / mach-omap2 / devices.c
1 /*
2  * linux/arch/arm/mach-omap2/devices.c
3  *
4  * OMAP2 platform device setup/initialization
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/io.h>
17
18 #include <asm/hardware.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/map.h>
21
22 #include <asm/arch/tc.h>
23 #include <asm/arch/board.h>
24 #include <asm/arch/mux.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/eac.h>
27
28 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
29
30 static struct resource cam_resources[] = {
31         {
32                 .start          = OMAP24XX_CAMERA_BASE,
33                 .end            = OMAP24XX_CAMERA_BASE + 0xfff,
34                 .flags          = IORESOURCE_MEM,
35         },
36         {
37                 .start          = INT_24XX_CAM_IRQ,
38                 .flags          = IORESOURCE_IRQ,
39         }
40 };
41
42 static struct platform_device omap_cam_device = {
43         .name           = "omap24xxcam",
44         .id             = -1,
45         .num_resources  = ARRAY_SIZE(cam_resources),
46         .resource       = cam_resources,
47 };
48
49 static inline void omap_init_camera(void)
50 {
51         platform_device_register(&omap_cam_device);
52 }
53 #else
54 static inline void omap_init_camera(void)
55 {
56 }
57 #endif
58
59 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
60 #define OMAP2_MBOX_BASE         IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
61
62 static struct resource mbox_resources[] = {
63         {
64                 .start          = OMAP2_MBOX_BASE,
65                 .end            = OMAP2_MBOX_BASE + 0x11f,
66                 .flags          = IORESOURCE_MEM,
67         },
68         {
69                 .start          = INT_24XX_MAIL_U0_MPU,
70                 .flags          = IORESOURCE_IRQ,
71         },
72         {
73                 .start          = INT_24XX_MAIL_U3_MPU,
74                 .flags          = IORESOURCE_IRQ,
75         },
76 };
77
78 static struct platform_device mbox_device = {
79         .name           = "mailbox",
80         .id             = -1,
81         .num_resources  = ARRAY_SIZE(mbox_resources),
82         .resource       = mbox_resources,
83 };
84
85 static inline void omap_init_mbox(void)
86 {
87         platform_device_register(&mbox_device);
88 }
89 #else
90 static inline void omap_init_mbox(void) { }
91 #endif
92
93 #if defined(CONFIG_OMAP_STI)
94
95 #define OMAP2_STI_BASE          IO_ADDRESS(0x48068000)
96 #define OMAP2_STI_CHANNEL_BASE  0x54000000
97 #define OMAP2_STI_IRQ           4
98
99 static struct resource sti_resources[] = {
100         {
101                 .start          = OMAP2_STI_BASE,
102                 .end            = OMAP2_STI_BASE + 0x7ff,
103                 .flags          = IORESOURCE_MEM,
104         },
105         {
106                 .start          = OMAP2_STI_CHANNEL_BASE,
107                 .end            = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
108                 .flags          = IORESOURCE_MEM,
109         },
110         {
111                 .start          = OMAP2_STI_IRQ,
112                 .flags          = IORESOURCE_IRQ,
113         }
114 };
115
116 static struct platform_device sti_device = {
117         .name           = "sti",
118         .id             = -1,
119         .num_resources  = ARRAY_SIZE(sti_resources),
120         .resource       = sti_resources,
121 };
122
123 static inline void omap_init_sti(void)
124 {
125         platform_device_register(&sti_device);
126 }
127 #else
128 static inline void omap_init_sti(void) {}
129 #endif
130
131 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
132
133 #include <asm/arch/mcspi.h>
134
135 #define OMAP2_MCSPI1_BASE               0x48098000
136 #define OMAP2_MCSPI2_BASE               0x4809a000
137 #define OMAP2_MCSPI3_BASE               0x480b8000
138 #define OMAP2_MCSPI4_BASE               0x480ba000
139
140 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
141         .num_cs         = 4,
142 };
143
144 static struct resource omap2_mcspi1_resources[] = {
145         {
146                 .start          = OMAP2_MCSPI1_BASE,
147                 .end            = OMAP2_MCSPI1_BASE + 0xff,
148                 .flags          = IORESOURCE_MEM,
149         },
150 };
151
152 static struct platform_device omap2_mcspi1 = {
153         .name           = "omap2_mcspi",
154         .id             = 1,
155         .num_resources  = ARRAY_SIZE(omap2_mcspi1_resources),
156         .resource       = omap2_mcspi1_resources,
157         .dev            = {
158                 .platform_data = &omap2_mcspi1_config,
159         },
160 };
161
162 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
163         .num_cs         = 2,
164 };
165
166 static struct resource omap2_mcspi2_resources[] = {
167         {
168                 .start          = OMAP2_MCSPI2_BASE,
169                 .end            = OMAP2_MCSPI2_BASE + 0xff,
170                 .flags          = IORESOURCE_MEM,
171         },
172 };
173
174 static struct platform_device omap2_mcspi2 = {
175         .name           = "omap2_mcspi",
176         .id             = 2,
177         .num_resources  = ARRAY_SIZE(omap2_mcspi2_resources),
178         .resource       = omap2_mcspi2_resources,
179         .dev            = {
180                 .platform_data = &omap2_mcspi2_config,
181         },
182 };
183
184 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
185 static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
186         .num_cs         = 2,
187 };
188
189 static struct resource omap2_mcspi3_resources[] = {
190         {
191         .start          = OMAP2_MCSPI3_BASE,
192         .end            = OMAP2_MCSPI3_BASE + 0xff,
193         .flags          = IORESOURCE_MEM,
194         },
195 };
196
197 static struct platform_device omap2_mcspi3 = {
198         .name           = "omap2_mcspi",
199         .id             = 3,
200         .num_resources  = ARRAY_SIZE(omap2_mcspi3_resources),
201         .resource       = omap2_mcspi3_resources,
202         .dev            = {
203                 .platform_data = &omap2_mcspi3_config,
204         },
205 };
206 #endif
207
208 #ifdef CONFIG_ARCH_OMAP3
209 static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
210         .num_cs         = 1,
211 };
212
213 static struct resource omap2_mcspi4_resources[] = {
214         {
215                 .start          = OMAP2_MCSPI4_BASE,
216                 .end            = OMAP2_MCSPI4_BASE + 0xff,
217                 .flags          = IORESOURCE_MEM,
218         },
219 };
220
221 static struct platform_device omap2_mcspi4 = {
222         .name           = "omap2_mcspi",
223         .id             = 4,
224         .num_resources  = ARRAY_SIZE(omap2_mcspi4_resources),
225         .resource       = omap2_mcspi4_resources,
226         .dev            = {
227                 .platform_data = &omap2_mcspi4_config,
228         },
229 };
230 #endif
231
232 static void omap_init_mcspi(void)
233 {
234         platform_device_register(&omap2_mcspi1);
235         platform_device_register(&omap2_mcspi2);
236 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
237         platform_device_register(&omap2_mcspi3);
238 #endif
239 #ifdef CONFIG_ARCH_OMAP3
240         platform_device_register(&omap2_mcspi4);
241 #endif
242 }
243
244 #else
245 static inline void omap_init_mcspi(void) {}
246 #endif
247
248 #ifdef CONFIG_SND_OMAP24XX_EAC
249
250 #define OMAP2_EAC_BASE                  0x48090000
251
252 static struct resource omap2_eac_resources[] = {
253         {
254                 .start          = OMAP2_EAC_BASE,
255                 .end            = OMAP2_EAC_BASE + 0x109,
256                 .flags          = IORESOURCE_MEM,
257         },
258 };
259
260 static struct platform_device omap2_eac_device = {
261         .name           = "omap24xx-eac",
262         .id             = -1,
263         .num_resources  = ARRAY_SIZE(omap2_eac_resources),
264         .resource       = omap2_eac_resources,
265         .dev = {
266                 .platform_data = NULL,
267         },
268 };
269
270 void omap_init_eac(struct eac_platform_data *pdata)
271 {
272         omap2_eac_device.dev.platform_data = pdata;
273         platform_device_register(&omap2_eac_device);
274 }
275
276 #else
277 void omap_init_eac(struct eac_platform_data *pdata) {}
278 #endif
279
280 #ifdef CONFIG_OMAP_SHA1_MD5
281 static struct resource sha1_md5_resources[] = {
282         {
283                 .start  = OMAP24XX_SEC_SHA1MD5_BASE,
284                 .end    = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
285                 .flags  = IORESOURCE_MEM,
286         },
287         {
288                 .start  = INT_24XX_SHA1MD5,
289                 .flags  = IORESOURCE_IRQ,
290         }
291 };
292
293 static struct platform_device sha1_md5_device = {
294         .name           = "OMAP SHA1/MD5",
295         .id             = -1,
296         .num_resources  = ARRAY_SIZE(sha1_md5_resources),
297         .resource       = sha1_md5_resources,
298 };
299
300 static void omap_init_sha1_md5(void)
301 {
302         platform_device_register(&sha1_md5_device);
303 }
304 #else
305 static inline void omap_init_sha1_md5(void) { }
306 #endif
307
308 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
309 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
310 #define OMAP_HDQ_BASE   0x480B2000
311 #endif
312 static struct resource omap_hdq_resources[] = {
313         {
314                 .start          = OMAP_HDQ_BASE,
315                 .end            = OMAP_HDQ_BASE + 0x1C,
316                 .flags          = IORESOURCE_MEM,
317         },
318         {
319                 .start          = INT_24XX_HDQ_IRQ,
320                 .flags          = IORESOURCE_IRQ,
321         },
322 };
323 static struct platform_device omap_hdq_dev = {
324         .name = "omap_hdq",
325         .id = 0,
326         .dev = {
327                 .platform_data = NULL,
328         },
329         .num_resources  = ARRAY_SIZE(omap_hdq_resources),
330         .resource       = omap_hdq_resources,
331 };
332 static inline void omap_hdq_init(void)
333 {
334         (void) platform_device_register(&omap_hdq_dev);
335 }
336 #else
337 static inline void omap_hdq_init(void) {}
338 #endif
339
340 /*-------------------------------------------------------------------------*/
341
342 static int __init omap2_init_devices(void)
343 {
344         /* please keep these calls, and their implementations above,
345          * in alphabetical order so they're easier to sort through.
346          */
347         omap_init_camera();
348         omap_init_mbox();
349         omap_init_mcspi();
350         omap_hdq_init();
351         omap_init_sti();
352         omap_init_sha1_md5();
353
354         return 0;
355 }
356 arch_initcall(omap2_init_devices);