]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/devices.c
c7de03ea9309bb8109dd167ec7443514cdee7b03
[linux-2.6-omap-h63xx.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 <mach/hardware.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/map.h>
21
22 #include <mach/tc.h>
23 #include <mach/board.h>
24 #include <mach/mux.h>
25 #include <mach/gpio.h>
26 #include <mach/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 #if defined(CONFIG_ARCH_OMAP2)
96
97 #define OMAP2_STI_BASE          0x48068000
98 #define OMAP2_STI_CHANNEL_BASE  0x54000000
99 #define OMAP2_STI_IRQ           4
100
101 static struct resource sti_resources[] = {
102         {
103                 .start          = OMAP2_STI_BASE,
104                 .end            = OMAP2_STI_BASE + 0x7ff,
105                 .flags          = IORESOURCE_MEM,
106         },
107         {
108                 .start          = OMAP2_STI_CHANNEL_BASE,
109                 .end            = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
110                 .flags          = IORESOURCE_MEM,
111         },
112         {
113                 .start          = OMAP2_STI_IRQ,
114                 .flags          = IORESOURCE_IRQ,
115         }
116 };
117 #elif defined(CONFIG_ARCH_OMAP3)
118
119 #define OMAP3_SDTI_BASE         0x54500000
120 #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
121
122 static struct resource sti_resources[] = {
123         {
124                 .start          = OMAP3_SDTI_BASE,
125                 .end            = OMAP3_SDTI_BASE + 0xFFF,
126                 .flags          = IORESOURCE_MEM,
127         },
128         {
129                 .start          = OMAP3_SDTI_CHANNEL_BASE,
130                 .end            = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
131                 .flags          = IORESOURCE_MEM,
132         }
133 };
134
135 #endif
136
137 static struct platform_device sti_device = {
138         .name           = "sti",
139         .id             = -1,
140         .num_resources  = ARRAY_SIZE(sti_resources),
141         .resource       = sti_resources,
142 };
143
144 static inline void omap_init_sti(void)
145 {
146         platform_device_register(&sti_device);
147 }
148 #else
149 static inline void omap_init_sti(void) {}
150 #endif
151
152 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
153
154 #include <mach/mcspi.h>
155
156 #define OMAP2_MCSPI1_BASE               0x48098000
157 #define OMAP2_MCSPI2_BASE               0x4809a000
158 #define OMAP2_MCSPI3_BASE               0x480b8000
159 #define OMAP2_MCSPI4_BASE               0x480ba000
160
161 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
162         .num_cs         = 4,
163 };
164
165 static struct resource omap2_mcspi1_resources[] = {
166         {
167                 .start          = OMAP2_MCSPI1_BASE,
168                 .end            = OMAP2_MCSPI1_BASE + 0xff,
169                 .flags          = IORESOURCE_MEM,
170         },
171 };
172
173 static struct platform_device omap2_mcspi1 = {
174         .name           = "omap2_mcspi",
175         .id             = 1,
176         .num_resources  = ARRAY_SIZE(omap2_mcspi1_resources),
177         .resource       = omap2_mcspi1_resources,
178         .dev            = {
179                 .platform_data = &omap2_mcspi1_config,
180         },
181 };
182
183 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
184         .num_cs         = 2,
185 };
186
187 static struct resource omap2_mcspi2_resources[] = {
188         {
189                 .start          = OMAP2_MCSPI2_BASE,
190                 .end            = OMAP2_MCSPI2_BASE + 0xff,
191                 .flags          = IORESOURCE_MEM,
192         },
193 };
194
195 static struct platform_device omap2_mcspi2 = {
196         .name           = "omap2_mcspi",
197         .id             = 2,
198         .num_resources  = ARRAY_SIZE(omap2_mcspi2_resources),
199         .resource       = omap2_mcspi2_resources,
200         .dev            = {
201                 .platform_data = &omap2_mcspi2_config,
202         },
203 };
204
205 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
206 static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
207         .num_cs         = 2,
208 };
209
210 static struct resource omap2_mcspi3_resources[] = {
211         {
212         .start          = OMAP2_MCSPI3_BASE,
213         .end            = OMAP2_MCSPI3_BASE + 0xff,
214         .flags          = IORESOURCE_MEM,
215         },
216 };
217
218 static struct platform_device omap2_mcspi3 = {
219         .name           = "omap2_mcspi",
220         .id             = 3,
221         .num_resources  = ARRAY_SIZE(omap2_mcspi3_resources),
222         .resource       = omap2_mcspi3_resources,
223         .dev            = {
224                 .platform_data = &omap2_mcspi3_config,
225         },
226 };
227 #endif
228
229 #ifdef CONFIG_ARCH_OMAP3
230 static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
231         .num_cs         = 1,
232 };
233
234 static struct resource omap2_mcspi4_resources[] = {
235         {
236                 .start          = OMAP2_MCSPI4_BASE,
237                 .end            = OMAP2_MCSPI4_BASE + 0xff,
238                 .flags          = IORESOURCE_MEM,
239         },
240 };
241
242 static struct platform_device omap2_mcspi4 = {
243         .name           = "omap2_mcspi",
244         .id             = 4,
245         .num_resources  = ARRAY_SIZE(omap2_mcspi4_resources),
246         .resource       = omap2_mcspi4_resources,
247         .dev            = {
248                 .platform_data = &omap2_mcspi4_config,
249         },
250 };
251 #endif
252
253 static void omap_init_mcspi(void)
254 {
255         platform_device_register(&omap2_mcspi1);
256         platform_device_register(&omap2_mcspi2);
257 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
258         if (cpu_is_omap2430() || cpu_is_omap343x())
259                 platform_device_register(&omap2_mcspi3);
260 #endif
261 #ifdef CONFIG_ARCH_OMAP3
262         if (cpu_is_omap343x())
263                 platform_device_register(&omap2_mcspi4);
264 #endif
265 }
266
267 #else
268 static inline void omap_init_mcspi(void) {}
269 #endif
270
271 #ifdef CONFIG_SND_OMAP24XX_EAC
272
273 #define OMAP2_EAC_BASE                  (L4_24XX_BASE + 0x90000)
274
275 static struct resource omap2_eac_resources[] = {
276         {
277                 .start          = OMAP2_EAC_BASE,
278                 .end            = OMAP2_EAC_BASE + 0xfff,
279                 .flags          = IORESOURCE_MEM,
280         },
281 };
282
283 static struct platform_device omap2_eac_device = {
284         .name           = "omap24xx-eac",
285         .id             = -1,
286         .num_resources  = ARRAY_SIZE(omap2_eac_resources),
287         .resource       = omap2_eac_resources,
288         .dev = {
289                 .platform_data = NULL,
290         },
291 };
292
293 void omap_init_eac(struct eac_platform_data *pdata)
294 {
295         omap2_eac_device.dev.platform_data = pdata;
296         platform_device_register(&omap2_eac_device);
297 }
298
299 #else
300 void omap_init_eac(struct eac_platform_data *pdata) {}
301 #endif
302
303 #ifdef CONFIG_OMAP_SHA1_MD5
304 static struct resource sha1_md5_resources[] = {
305         {
306                 .start  = OMAP24XX_SEC_SHA1MD5_BASE,
307                 .end    = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
308                 .flags  = IORESOURCE_MEM,
309         },
310         {
311                 .start  = INT_24XX_SHA1MD5,
312                 .flags  = IORESOURCE_IRQ,
313         }
314 };
315
316 static struct platform_device sha1_md5_device = {
317         .name           = "OMAP SHA1/MD5",
318         .id             = -1,
319         .num_resources  = ARRAY_SIZE(sha1_md5_resources),
320         .resource       = sha1_md5_resources,
321 };
322
323 static void omap_init_sha1_md5(void)
324 {
325         platform_device_register(&sha1_md5_device);
326 }
327 #else
328 static inline void omap_init_sha1_md5(void) { }
329 #endif
330
331 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
332 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
333 #define OMAP_HDQ_BASE   0x480B2000
334 #endif
335 static struct resource omap_hdq_resources[] = {
336         {
337                 .start          = OMAP_HDQ_BASE,
338                 .end            = OMAP_HDQ_BASE + 0x1C,
339                 .flags          = IORESOURCE_MEM,
340         },
341         {
342                 .start          = INT_24XX_HDQ_IRQ,
343                 .flags          = IORESOURCE_IRQ,
344         },
345 };
346 static struct platform_device omap_hdq_dev = {
347         .name = "omap_hdq",
348         .id = 0,
349         .dev = {
350                 .platform_data = NULL,
351         },
352         .num_resources  = ARRAY_SIZE(omap_hdq_resources),
353         .resource       = omap_hdq_resources,
354 };
355 static inline void omap_hdq_init(void)
356 {
357         (void) platform_device_register(&omap_hdq_dev);
358 }
359 #else
360 static inline void omap_hdq_init(void) {}
361 #endif
362
363 /*-------------------------------------------------------------------------*/
364
365 static int __init omap2_init_devices(void)
366 {
367         /* please keep these calls, and their implementations above,
368          * in alphabetical order so they're easier to sort through.
369          */
370         omap_init_camera();
371         omap_init_mbox();
372         omap_init_mcspi();
373         omap_hdq_init();
374         omap_init_sti();
375         omap_init_sha1_md5();
376
377         return 0;
378 }
379 arch_initcall(omap2_init_devices);