]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/devices.c
241e41800d4aedb60704aecc8c375b699d4a710c
[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/control.h>
23 #include <mach/tc.h>
24 #include <mach/board.h>
25 #include <mach/mux.h>
26 #include <mach/gpio.h>
27 #include <mach/eac.h>
28 #include <mach/mmc.h>
29
30 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
31
32 static struct resource cam_resources[] = {
33         {
34                 .start          = OMAP24XX_CAMERA_BASE,
35                 .end            = OMAP24XX_CAMERA_BASE + 0xfff,
36                 .flags          = IORESOURCE_MEM,
37         },
38         {
39                 .start          = INT_24XX_CAM_IRQ,
40                 .flags          = IORESOURCE_IRQ,
41         }
42 };
43
44 static struct platform_device omap_cam_device = {
45         .name           = "omap24xxcam",
46         .id             = -1,
47         .num_resources  = ARRAY_SIZE(cam_resources),
48         .resource       = cam_resources,
49 };
50
51 static inline void omap_init_camera(void)
52 {
53         platform_device_register(&omap_cam_device);
54 }
55
56 #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
57
58 static struct resource cam_resources[] = {
59         {
60                 .start          = OMAP34XX_CAMERA_BASE,
61                 .end            = OMAP34XX_CAMERA_BASE + 0x1B70,
62                 .flags          = IORESOURCE_MEM,
63         },
64         {
65                 .start          = INT_34XX_CAM_IRQ,
66                 .flags          = IORESOURCE_IRQ,
67         }
68 };
69
70 static struct platform_device omap_cam_device = {
71         .name           = "omap34xxcam",
72         .id             = -1,
73         .num_resources  = ARRAY_SIZE(cam_resources),
74         .resource       = cam_resources,
75 };
76
77 static inline void omap_init_camera(void)
78 {
79         platform_device_register(&omap_cam_device);
80 }
81 #else
82 static inline void omap_init_camera(void)
83 {
84 }
85 #endif
86
87 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
88 #define OMAP2_MBOX_BASE         IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
89
90 static struct resource mbox_resources[] = {
91         {
92                 .start          = OMAP2_MBOX_BASE,
93                 .end            = OMAP2_MBOX_BASE + 0x11f,
94                 .flags          = IORESOURCE_MEM,
95         },
96         {
97                 .start          = INT_24XX_MAIL_U0_MPU,
98                 .flags          = IORESOURCE_IRQ,
99         },
100         {
101                 .start          = INT_24XX_MAIL_U3_MPU,
102                 .flags          = IORESOURCE_IRQ,
103         },
104 };
105
106 static struct platform_device mbox_device = {
107         .name           = "mailbox",
108         .id             = -1,
109         .num_resources  = ARRAY_SIZE(mbox_resources),
110         .resource       = mbox_resources,
111 };
112
113 static inline void omap_init_mbox(void)
114 {
115         platform_device_register(&mbox_device);
116 }
117 #else
118 static inline void omap_init_mbox(void) { }
119 #endif
120
121 #if defined(CONFIG_OMAP_STI)
122
123 #if defined(CONFIG_ARCH_OMAP2)
124
125 #define OMAP2_STI_BASE          0x48068000
126 #define OMAP2_STI_CHANNEL_BASE  0x54000000
127 #define OMAP2_STI_IRQ           4
128
129 static struct resource sti_resources[] = {
130         {
131                 .start          = OMAP2_STI_BASE,
132                 .end            = OMAP2_STI_BASE + 0x7ff,
133                 .flags          = IORESOURCE_MEM,
134         },
135         {
136                 .start          = OMAP2_STI_CHANNEL_BASE,
137                 .end            = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
138                 .flags          = IORESOURCE_MEM,
139         },
140         {
141                 .start          = OMAP2_STI_IRQ,
142                 .flags          = IORESOURCE_IRQ,
143         }
144 };
145 #elif defined(CONFIG_ARCH_OMAP3)
146
147 #define OMAP3_SDTI_BASE         0x54500000
148 #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
149
150 static struct resource sti_resources[] = {
151         {
152                 .start          = OMAP3_SDTI_BASE,
153                 .end            = OMAP3_SDTI_BASE + 0xFFF,
154                 .flags          = IORESOURCE_MEM,
155         },
156         {
157                 .start          = OMAP3_SDTI_CHANNEL_BASE,
158                 .end            = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
159                 .flags          = IORESOURCE_MEM,
160         }
161 };
162
163 #endif
164
165 static struct platform_device sti_device = {
166         .name           = "sti",
167         .id             = -1,
168         .num_resources  = ARRAY_SIZE(sti_resources),
169         .resource       = sti_resources,
170 };
171
172 static inline void omap_init_sti(void)
173 {
174         platform_device_register(&sti_device);
175 }
176 #else
177 static inline void omap_init_sti(void) {}
178 #endif
179
180 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
181
182 #include <mach/mcspi.h>
183
184 #define OMAP2_MCSPI1_BASE               0x48098000
185 #define OMAP2_MCSPI2_BASE               0x4809a000
186 #define OMAP2_MCSPI3_BASE               0x480b8000
187 #define OMAP2_MCSPI4_BASE               0x480ba000
188
189 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
190         .num_cs         = 4,
191 };
192
193 static struct resource omap2_mcspi1_resources[] = {
194         {
195                 .start          = OMAP2_MCSPI1_BASE,
196                 .end            = OMAP2_MCSPI1_BASE + 0xff,
197                 .flags          = IORESOURCE_MEM,
198         },
199 };
200
201 static struct platform_device omap2_mcspi1 = {
202         .name           = "omap2_mcspi",
203         .id             = 1,
204         .num_resources  = ARRAY_SIZE(omap2_mcspi1_resources),
205         .resource       = omap2_mcspi1_resources,
206         .dev            = {
207                 .platform_data = &omap2_mcspi1_config,
208         },
209 };
210
211 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
212         .num_cs         = 2,
213 };
214
215 static struct resource omap2_mcspi2_resources[] = {
216         {
217                 .start          = OMAP2_MCSPI2_BASE,
218                 .end            = OMAP2_MCSPI2_BASE + 0xff,
219                 .flags          = IORESOURCE_MEM,
220         },
221 };
222
223 static struct platform_device omap2_mcspi2 = {
224         .name           = "omap2_mcspi",
225         .id             = 2,
226         .num_resources  = ARRAY_SIZE(omap2_mcspi2_resources),
227         .resource       = omap2_mcspi2_resources,
228         .dev            = {
229                 .platform_data = &omap2_mcspi2_config,
230         },
231 };
232
233 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
234 static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
235         .num_cs         = 2,
236 };
237
238 static struct resource omap2_mcspi3_resources[] = {
239         {
240         .start          = OMAP2_MCSPI3_BASE,
241         .end            = OMAP2_MCSPI3_BASE + 0xff,
242         .flags          = IORESOURCE_MEM,
243         },
244 };
245
246 static struct platform_device omap2_mcspi3 = {
247         .name           = "omap2_mcspi",
248         .id             = 3,
249         .num_resources  = ARRAY_SIZE(omap2_mcspi3_resources),
250         .resource       = omap2_mcspi3_resources,
251         .dev            = {
252                 .platform_data = &omap2_mcspi3_config,
253         },
254 };
255 #endif
256
257 #ifdef CONFIG_ARCH_OMAP3
258 static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
259         .num_cs         = 1,
260 };
261
262 static struct resource omap2_mcspi4_resources[] = {
263         {
264                 .start          = OMAP2_MCSPI4_BASE,
265                 .end            = OMAP2_MCSPI4_BASE + 0xff,
266                 .flags          = IORESOURCE_MEM,
267         },
268 };
269
270 static struct platform_device omap2_mcspi4 = {
271         .name           = "omap2_mcspi",
272         .id             = 4,
273         .num_resources  = ARRAY_SIZE(omap2_mcspi4_resources),
274         .resource       = omap2_mcspi4_resources,
275         .dev            = {
276                 .platform_data = &omap2_mcspi4_config,
277         },
278 };
279 #endif
280
281 static void omap_init_mcspi(void)
282 {
283         platform_device_register(&omap2_mcspi1);
284         platform_device_register(&omap2_mcspi2);
285 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
286         if (cpu_is_omap2430() || cpu_is_omap343x())
287                 platform_device_register(&omap2_mcspi3);
288 #endif
289 #ifdef CONFIG_ARCH_OMAP3
290         if (cpu_is_omap343x())
291                 platform_device_register(&omap2_mcspi4);
292 #endif
293 }
294
295 #else
296 static inline void omap_init_mcspi(void) {}
297 #endif
298
299 #ifdef CONFIG_SND_OMAP24XX_EAC
300
301 #define OMAP2_EAC_BASE                  (L4_24XX_BASE + 0x90000)
302
303 static struct resource omap2_eac_resources[] = {
304         {
305                 .start          = OMAP2_EAC_BASE,
306                 .end            = OMAP2_EAC_BASE + 0xfff,
307                 .flags          = IORESOURCE_MEM,
308         },
309 };
310
311 static struct platform_device omap2_eac_device = {
312         .name           = "omap24xx-eac",
313         .id             = -1,
314         .num_resources  = ARRAY_SIZE(omap2_eac_resources),
315         .resource       = omap2_eac_resources,
316         .dev = {
317                 .platform_data = NULL,
318         },
319 };
320
321 void omap_init_eac(struct eac_platform_data *pdata)
322 {
323         omap2_eac_device.dev.platform_data = pdata;
324         platform_device_register(&omap2_eac_device);
325 }
326
327 #else
328 void omap_init_eac(struct eac_platform_data *pdata) {}
329 #endif
330
331 #ifdef CONFIG_OMAP_SHA1_MD5
332 static struct resource sha1_md5_resources[] = {
333         {
334                 .start  = OMAP24XX_SEC_SHA1MD5_BASE,
335                 .end    = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
336                 .flags  = IORESOURCE_MEM,
337         },
338         {
339                 .start  = INT_24XX_SHA1MD5,
340                 .flags  = IORESOURCE_IRQ,
341         }
342 };
343
344 static struct platform_device sha1_md5_device = {
345         .name           = "OMAP SHA1/MD5",
346         .id             = -1,
347         .num_resources  = ARRAY_SIZE(sha1_md5_resources),
348         .resource       = sha1_md5_resources,
349 };
350
351 static void omap_init_sha1_md5(void)
352 {
353         platform_device_register(&sha1_md5_device);
354 }
355 #else
356 static inline void omap_init_sha1_md5(void) { }
357 #endif
358
359 /*-------------------------------------------------------------------------*/
360
361 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
362         defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
363
364 static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
365                         int controller_nr)
366 {
367         if (cpu_is_omap2420() && controller_nr == 0) {
368                 omap_cfg_reg(H18_24XX_MMC_CMD);
369                 omap_cfg_reg(H15_24XX_MMC_CLKI);
370                 omap_cfg_reg(G19_24XX_MMC_CLKO);
371                 omap_cfg_reg(F20_24XX_MMC_DAT0);
372                 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
373                 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
374                 if (mmc_controller->slots[0].wires == 4) {
375                         omap_cfg_reg(H14_24XX_MMC_DAT1);
376                         omap_cfg_reg(E19_24XX_MMC_DAT2);
377                         omap_cfg_reg(D19_24XX_MMC_DAT3);
378                         omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
379                         omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
380                         omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
381                 }
382
383                 /*
384                  * Use internal loop-back in MMC/SDIO Module Input Clock
385                  * selection
386                  */
387                 if (mmc_controller->slots[0].internal_clock) {
388                         u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
389                         v |= (1 << 24);
390                         omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
391                 }
392         }
393 }
394
395 void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
396                         int nr_controllers)
397 {
398         int i;
399
400         for (i = 0; i < nr_controllers; i++) {
401                 unsigned long base, size;
402                 unsigned int irq = 0;
403
404                 if (!mmc_data[i])
405                         continue;
406
407                 omap2_mmc_mux(mmc_data[i], i);
408
409                 switch (i) {
410                 case 0:
411                         base = OMAP2_MMC1_BASE;
412                         irq = INT_24XX_MMC_IRQ;
413                         break;
414                 case 1:
415                         base = OMAP2_MMC2_BASE;
416                         irq = INT_24XX_MMC2_IRQ;
417                         break;
418                 case 2:
419                         if (!cpu_is_omap34xx())
420                                 return;
421                         base = OMAP3_MMC3_BASE;
422                         irq = INT_34XX_MMC3_IRQ;
423                         break;
424                 default:
425                         continue;
426                 }
427
428                 if (cpu_is_omap2420())
429                         size = OMAP2420_MMC_SIZE;
430                 else
431                         size = HSMMC_SIZE;
432
433                 omap_mmc_add(i, base, size, irq, mmc_data[i]);
434         };
435 }
436
437 #endif
438
439 /*-------------------------------------------------------------------------*/
440
441 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
442 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
443 #define OMAP_HDQ_BASE   0x480B2000
444 #endif
445 static struct resource omap_hdq_resources[] = {
446         {
447                 .start          = OMAP_HDQ_BASE,
448                 .end            = OMAP_HDQ_BASE + 0x1C,
449                 .flags          = IORESOURCE_MEM,
450         },
451         {
452                 .start          = INT_24XX_HDQ_IRQ,
453                 .flags          = IORESOURCE_IRQ,
454         },
455 };
456 static struct platform_device omap_hdq_dev = {
457         .name = "omap_hdq",
458         .id = 0,
459         .dev = {
460                 .platform_data = NULL,
461         },
462         .num_resources  = ARRAY_SIZE(omap_hdq_resources),
463         .resource       = omap_hdq_resources,
464 };
465 static inline void omap_hdq_init(void)
466 {
467         (void) platform_device_register(&omap_hdq_dev);
468 }
469 #else
470 static inline void omap_hdq_init(void) {}
471 #endif
472
473 /*-------------------------------------------------------------------------*/
474
475 static int __init omap2_init_devices(void)
476 {
477         /* please keep these calls, and their implementations above,
478          * in alphabetical order so they're easier to sort through.
479          */
480         omap_init_camera();
481         omap_init_mbox();
482         omap_init_mcspi();
483         omap_hdq_init();
484         omap_init_sti();
485         omap_init_sha1_md5();
486
487         return 0;
488 }
489 arch_initcall(omap2_init_devices);