]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/devices.c
ARM: OMAP: Clean-up MMC device init
[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 #define OMAP2_MMC1_BASE         0x4809c000
365 #define OMAP2_MMC1_END          (OMAP2_MMC1_BASE + 0x1fc)
366 #define OMAP2_MMC1_INT          INT_24XX_MMC_IRQ
367
368 #define OMAP2_MMC2_BASE         0x480b4000
369 #define OMAP2_MMC2_END          (OMAP2_MMC2_BASE + 0x1fc)
370 #define OMAP2_MMC2_INT          INT_24XX_MMC2_IRQ
371
372 static u64 omap2_mmc1_dmamask = 0xffffffff;
373
374 static struct resource omap2_mmc1_resources[] = {
375         {
376                 .start          = OMAP2_MMC1_BASE,
377                 .end            = OMAP2_MMC1_END,
378                 .flags          = IORESOURCE_MEM,
379         },
380         {
381                 .start          = OMAP2_MMC1_INT,
382                 .flags          = IORESOURCE_IRQ,
383         },
384 };
385
386 static struct platform_device omap2_mmc1_device = {
387         .name           = "mmci-omap",
388         .id             = 1,
389         .dev = {
390                 .dma_mask       = &omap2_mmc1_dmamask,
391         },
392         .num_resources  = ARRAY_SIZE(omap2_mmc1_resources),
393         .resource       = omap2_mmc1_resources,
394 };
395
396 static u64 omap2_mmc2_dmamask = 0xffffffff;
397
398 static struct resource omap2_mmc2_resources[] = {
399         {
400                 .start          = OMAP2_MMC2_BASE,
401                 .end            = OMAP2_MMC2_END,
402                 .flags          = IORESOURCE_MEM,
403         },
404         {
405                 .start          = OMAP2_MMC2_INT,
406                 .flags          = IORESOURCE_IRQ,
407         },
408 };
409
410 static struct platform_device omap2_mmc2_device = {
411         .name           = "mmci-omap",
412         .id             = 2,
413         .dev = {
414                 .dma_mask       = &omap2_mmc2_dmamask,
415         },
416         .num_resources  = ARRAY_SIZE(omap2_mmc2_resources),
417         .resource       = omap2_mmc2_resources,
418 };
419
420 static inline void omap2_mmc_mux(struct omap_mmc_platform_data *info)
421 {
422         if (!cpu_is_omap2420())
423                 return;
424
425         if (info->slots[0].enabled) {
426                 omap_cfg_reg(H18_24XX_MMC_CMD);
427                 omap_cfg_reg(H15_24XX_MMC_CLKI);
428                 omap_cfg_reg(G19_24XX_MMC_CLKO);
429                 omap_cfg_reg(F20_24XX_MMC_DAT0);
430                 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
431                 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
432                 if (info->slots[0].wire4) {
433                         omap_cfg_reg(H14_24XX_MMC_DAT1);
434                         omap_cfg_reg(E19_24XX_MMC_DAT2);
435                         omap_cfg_reg(D19_24XX_MMC_DAT3);
436                         omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
437                         omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
438                         omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
439                 }
440
441                 /*
442                  * Use internal loop-back in MMC/SDIO Module Input Clock
443                  * selection
444                  */
445                 if (info->slots[0].internal_clock) {
446                         u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
447                         v |= (1 << 24);
448                         omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
449                 }
450         }
451 }
452
453 void omap2_init_mmc(struct omap_mmc_platform_data *info)
454 {
455         if (!info)
456                 return;
457
458         omap2_mmc_mux(info);
459         omap2_mmc1_device.dev.platform_data = info;
460         omap2_mmc2_device.dev.platform_data = info;
461         omap_init_mmc(info, &omap2_mmc1_device, &omap2_mmc2_device);
462 }
463
464 #endif
465
466 /*-------------------------------------------------------------------------*/
467
468 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
469 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
470 #define OMAP_HDQ_BASE   0x480B2000
471 #endif
472 static struct resource omap_hdq_resources[] = {
473         {
474                 .start          = OMAP_HDQ_BASE,
475                 .end            = OMAP_HDQ_BASE + 0x1C,
476                 .flags          = IORESOURCE_MEM,
477         },
478         {
479                 .start          = INT_24XX_HDQ_IRQ,
480                 .flags          = IORESOURCE_IRQ,
481         },
482 };
483 static struct platform_device omap_hdq_dev = {
484         .name = "omap_hdq",
485         .id = 0,
486         .dev = {
487                 .platform_data = NULL,
488         },
489         .num_resources  = ARRAY_SIZE(omap_hdq_resources),
490         .resource       = omap_hdq_resources,
491 };
492 static inline void omap_hdq_init(void)
493 {
494         (void) platform_device_register(&omap_hdq_dev);
495 }
496 #else
497 static inline void omap_hdq_init(void) {}
498 #endif
499
500 /*-------------------------------------------------------------------------*/
501
502 static int __init omap2_init_devices(void)
503 {
504         /* please keep these calls, and their implementations above,
505          * in alphabetical order so they're easier to sort through.
506          */
507         omap_init_camera();
508         omap_init_mbox();
509         omap_init_mcspi();
510         omap_hdq_init();
511         omap_init_sti();
512         omap_init_sha1_md5();
513
514         return 0;
515 }
516 arch_initcall(omap2_init_devices);