wl1251: use wiphy_dev instead of wl->spi->dev
[linux/fpc-iii.git] / arch / arm / mach-omap2 / devices.c
blob894cc355818afacdb0119796cffd76d793972075
1 /*
2 * linux/arch/arm/mach-omap2/devices.c
4 * OMAP2 platform device setup/initialization
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.
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 #include <linux/clk.h>
19 #include <mach/hardware.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/map.h>
23 #include <mach/control.h>
24 #include <mach/tc.h>
25 #include <mach/board.h>
26 #include <mach/mux.h>
27 #include <mach/gpio.h>
28 #include <mach/mmc.h>
30 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
32 static struct resource cam_resources[] = {
34 .start = OMAP24XX_CAMERA_BASE,
35 .end = OMAP24XX_CAMERA_BASE + 0xfff,
36 .flags = IORESOURCE_MEM,
39 .start = INT_24XX_CAM_IRQ,
40 .flags = IORESOURCE_IRQ,
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,
51 static inline void omap_init_camera(void)
53 platform_device_register(&omap_cam_device);
56 #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
58 static struct resource omap3isp_resources[] = {
60 .start = OMAP3430_ISP_BASE,
61 .end = OMAP3430_ISP_END,
62 .flags = IORESOURCE_MEM,
65 .start = OMAP3430_ISP_CBUFF_BASE,
66 .end = OMAP3430_ISP_CBUFF_END,
67 .flags = IORESOURCE_MEM,
70 .start = OMAP3430_ISP_CCP2_BASE,
71 .end = OMAP3430_ISP_CCP2_END,
72 .flags = IORESOURCE_MEM,
75 .start = OMAP3430_ISP_CCDC_BASE,
76 .end = OMAP3430_ISP_CCDC_END,
77 .flags = IORESOURCE_MEM,
80 .start = OMAP3430_ISP_HIST_BASE,
81 .end = OMAP3430_ISP_HIST_END,
82 .flags = IORESOURCE_MEM,
85 .start = OMAP3430_ISP_H3A_BASE,
86 .end = OMAP3430_ISP_H3A_END,
87 .flags = IORESOURCE_MEM,
90 .start = OMAP3430_ISP_PREV_BASE,
91 .end = OMAP3430_ISP_PREV_END,
92 .flags = IORESOURCE_MEM,
95 .start = OMAP3430_ISP_RESZ_BASE,
96 .end = OMAP3430_ISP_RESZ_END,
97 .flags = IORESOURCE_MEM,
100 .start = OMAP3430_ISP_SBL_BASE,
101 .end = OMAP3430_ISP_SBL_END,
102 .flags = IORESOURCE_MEM,
105 .start = OMAP3430_ISP_CSI2A_BASE,
106 .end = OMAP3430_ISP_CSI2A_END,
107 .flags = IORESOURCE_MEM,
110 .start = OMAP3430_ISP_CSI2PHY_BASE,
111 .end = OMAP3430_ISP_CSI2PHY_END,
112 .flags = IORESOURCE_MEM,
115 .start = INT_34XX_CAM_IRQ,
116 .flags = IORESOURCE_IRQ,
120 static struct platform_device omap3isp_device = {
121 .name = "omap3isp",
122 .id = -1,
123 .num_resources = ARRAY_SIZE(omap3isp_resources),
124 .resource = omap3isp_resources,
127 static inline void omap_init_camera(void)
129 platform_device_register(&omap3isp_device);
131 #else
132 static inline void omap_init_camera(void)
135 #endif
137 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
139 #define MBOX_REG_SIZE 0x120
141 static struct resource omap2_mbox_resources[] = {
143 .start = OMAP24XX_MAILBOX_BASE,
144 .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
145 .flags = IORESOURCE_MEM,
148 .start = INT_24XX_MAIL_U0_MPU,
149 .flags = IORESOURCE_IRQ,
152 .start = INT_24XX_MAIL_U3_MPU,
153 .flags = IORESOURCE_IRQ,
157 static struct resource omap3_mbox_resources[] = {
159 .start = OMAP34XX_MAILBOX_BASE,
160 .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
161 .flags = IORESOURCE_MEM,
164 .start = INT_24XX_MAIL_U0_MPU,
165 .flags = IORESOURCE_IRQ,
169 static struct platform_device mbox_device = {
170 .name = "omap2-mailbox",
171 .id = -1,
174 static inline void omap_init_mbox(void)
176 if (cpu_is_omap2420()) {
177 mbox_device.num_resources = ARRAY_SIZE(omap2_mbox_resources);
178 mbox_device.resource = omap2_mbox_resources;
179 } else if (cpu_is_omap3430()) {
180 mbox_device.num_resources = ARRAY_SIZE(omap3_mbox_resources);
181 mbox_device.resource = omap3_mbox_resources;
182 } else {
183 pr_err("%s: platform not supported\n", __func__);
184 return;
186 platform_device_register(&mbox_device);
188 #else
189 static inline void omap_init_mbox(void) { }
190 #endif /* CONFIG_OMAP_MBOX_FWK */
192 #if defined(CONFIG_OMAP_STI)
194 #if defined(CONFIG_ARCH_OMAP2)
196 #define OMAP2_STI_BASE 0x48068000
197 #define OMAP2_STI_CHANNEL_BASE 0x54000000
198 #define OMAP2_STI_IRQ 4
200 static struct resource sti_resources[] = {
202 .start = OMAP2_STI_BASE,
203 .end = OMAP2_STI_BASE + 0x7ff,
204 .flags = IORESOURCE_MEM,
207 .start = OMAP2_STI_CHANNEL_BASE,
208 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
209 .flags = IORESOURCE_MEM,
212 .start = OMAP2_STI_IRQ,
213 .flags = IORESOURCE_IRQ,
216 #elif defined(CONFIG_ARCH_OMAP3)
218 #define OMAP3_SDTI_BASE 0x54500000
219 #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
221 static struct resource sti_resources[] = {
223 .start = OMAP3_SDTI_BASE,
224 .end = OMAP3_SDTI_BASE + 0xFFF,
225 .flags = IORESOURCE_MEM,
228 .start = OMAP3_SDTI_CHANNEL_BASE,
229 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
230 .flags = IORESOURCE_MEM,
234 #endif
236 static struct platform_device sti_device = {
237 .name = "sti",
238 .id = -1,
239 .num_resources = ARRAY_SIZE(sti_resources),
240 .resource = sti_resources,
243 static inline void omap_init_sti(void)
245 platform_device_register(&sti_device);
247 #else
248 static inline void omap_init_sti(void) {}
249 #endif
251 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
253 #include <mach/mcspi.h>
255 #define OMAP2_MCSPI1_BASE 0x48098000
256 #define OMAP2_MCSPI2_BASE 0x4809a000
257 #define OMAP2_MCSPI3_BASE 0x480b8000
258 #define OMAP2_MCSPI4_BASE 0x480ba000
260 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
261 .num_cs = 4,
264 static struct resource omap2_mcspi1_resources[] = {
266 .start = OMAP2_MCSPI1_BASE,
267 .end = OMAP2_MCSPI1_BASE + 0xff,
268 .flags = IORESOURCE_MEM,
272 static struct platform_device omap2_mcspi1 = {
273 .name = "omap2_mcspi",
274 .id = 1,
275 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
276 .resource = omap2_mcspi1_resources,
277 .dev = {
278 .platform_data = &omap2_mcspi1_config,
282 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
283 .num_cs = 2,
286 static struct resource omap2_mcspi2_resources[] = {
288 .start = OMAP2_MCSPI2_BASE,
289 .end = OMAP2_MCSPI2_BASE + 0xff,
290 .flags = IORESOURCE_MEM,
294 static struct platform_device omap2_mcspi2 = {
295 .name = "omap2_mcspi",
296 .id = 2,
297 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
298 .resource = omap2_mcspi2_resources,
299 .dev = {
300 .platform_data = &omap2_mcspi2_config,
304 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
305 static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
306 .num_cs = 2,
309 static struct resource omap2_mcspi3_resources[] = {
311 .start = OMAP2_MCSPI3_BASE,
312 .end = OMAP2_MCSPI3_BASE + 0xff,
313 .flags = IORESOURCE_MEM,
317 static struct platform_device omap2_mcspi3 = {
318 .name = "omap2_mcspi",
319 .id = 3,
320 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
321 .resource = omap2_mcspi3_resources,
322 .dev = {
323 .platform_data = &omap2_mcspi3_config,
326 #endif
328 #ifdef CONFIG_ARCH_OMAP3
329 static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
330 .num_cs = 1,
333 static struct resource omap2_mcspi4_resources[] = {
335 .start = OMAP2_MCSPI4_BASE,
336 .end = OMAP2_MCSPI4_BASE + 0xff,
337 .flags = IORESOURCE_MEM,
341 static struct platform_device omap2_mcspi4 = {
342 .name = "omap2_mcspi",
343 .id = 4,
344 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
345 .resource = omap2_mcspi4_resources,
346 .dev = {
347 .platform_data = &omap2_mcspi4_config,
350 #endif
352 static void omap_init_mcspi(void)
354 platform_device_register(&omap2_mcspi1);
355 platform_device_register(&omap2_mcspi2);
356 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
357 if (cpu_is_omap2430() || cpu_is_omap343x())
358 platform_device_register(&omap2_mcspi3);
359 #endif
360 #ifdef CONFIG_ARCH_OMAP3
361 if (cpu_is_omap343x())
362 platform_device_register(&omap2_mcspi4);
363 #endif
366 #else
367 static inline void omap_init_mcspi(void) {}
368 #endif
370 #ifdef CONFIG_OMAP_SHA1_MD5
371 static struct resource sha1_md5_resources[] = {
373 .start = OMAP24XX_SEC_SHA1MD5_BASE,
374 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
375 .flags = IORESOURCE_MEM,
378 .start = INT_24XX_SHA1MD5,
379 .flags = IORESOURCE_IRQ,
383 static struct platform_device sha1_md5_device = {
384 .name = "OMAP SHA1/MD5",
385 .id = -1,
386 .num_resources = ARRAY_SIZE(sha1_md5_resources),
387 .resource = sha1_md5_resources,
390 static void omap_init_sha1_md5(void)
392 platform_device_register(&sha1_md5_device);
394 #else
395 static inline void omap_init_sha1_md5(void) { }
396 #endif
398 /*-------------------------------------------------------------------------*/
400 #ifdef CONFIG_ARCH_OMAP3
402 #define MMCHS_SYSCONFIG 0x0010
403 #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
404 #define MMCHS_SYSSTATUS 0x0014
405 #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
407 static struct platform_device dummy_pdev = {
408 .dev = {
409 .bus = &platform_bus_type,
414 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
416 * Ensure that each MMC controller is fully reset. Controllers
417 * left in an unknown state (by bootloader) may prevent retention
418 * or OFF-mode. This is especially important in cases where the
419 * MMC driver is not enabled, _or_ built as a module.
421 * In order for reset to work, interface, functional and debounce
422 * clocks must be enabled. The debounce clock comes from func_32k_clk
423 * and is not under SW control, so we only enable i- and f-clocks.
425 static void __init omap_hsmmc_reset(void)
427 u32 i, nr_controllers = cpu_is_omap34xx() ? OMAP34XX_NR_MMC :
428 OMAP24XX_NR_MMC;
430 for (i = 0; i < nr_controllers; i++) {
431 u32 v, base = 0;
432 struct clk *iclk, *fclk;
433 struct device *dev = &dummy_pdev.dev;
435 switch (i) {
436 case 0:
437 base = OMAP2_MMC1_BASE;
438 break;
439 case 1:
440 base = OMAP2_MMC2_BASE;
441 break;
442 case 2:
443 base = OMAP3_MMC3_BASE;
444 break;
447 dummy_pdev.id = i;
448 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
449 iclk = clk_get(dev, "ick");
450 if (iclk && clk_enable(iclk))
451 iclk = NULL;
453 fclk = clk_get(dev, "fck");
454 if (fclk && clk_enable(fclk))
455 fclk = NULL;
457 if (!iclk || !fclk) {
458 printk(KERN_WARNING
459 "%s: Unable to enable clocks for MMC%d, "
460 "cannot reset.\n", __func__, i);
461 break;
464 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
465 v = omap_readl(base + MMCHS_SYSSTATUS);
466 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
467 MMCHS_SYSSTATUS_RESETDONE))
468 cpu_relax();
470 if (fclk) {
471 clk_disable(fclk);
472 clk_put(fclk);
474 if (iclk) {
475 clk_disable(iclk);
476 clk_put(iclk);
480 #else
481 static inline void omap_hsmmc_reset(void) {}
482 #endif
484 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
485 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
487 static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
488 int controller_nr)
490 if (cpu_is_omap2420() && controller_nr == 0) {
491 omap_cfg_reg(H18_24XX_MMC_CMD);
492 omap_cfg_reg(H15_24XX_MMC_CLKI);
493 omap_cfg_reg(G19_24XX_MMC_CLKO);
494 omap_cfg_reg(F20_24XX_MMC_DAT0);
495 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
496 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
497 if (mmc_controller->slots[0].wires == 4) {
498 omap_cfg_reg(H14_24XX_MMC_DAT1);
499 omap_cfg_reg(E19_24XX_MMC_DAT2);
500 omap_cfg_reg(D19_24XX_MMC_DAT3);
501 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
502 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
503 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
507 * Use internal loop-back in MMC/SDIO Module Input Clock
508 * selection
510 if (mmc_controller->slots[0].internal_clock) {
511 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
512 v |= (1 << 24);
513 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
518 void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
519 int nr_controllers)
521 int i;
522 char *name;
524 for (i = 0; i < nr_controllers; i++) {
525 unsigned long base, size;
526 unsigned int irq = 0;
528 if (!mmc_data[i])
529 continue;
531 omap2_mmc_mux(mmc_data[i], i);
533 switch (i) {
534 case 0:
535 base = OMAP2_MMC1_BASE;
536 irq = INT_24XX_MMC_IRQ;
537 break;
538 case 1:
539 base = OMAP2_MMC2_BASE;
540 irq = INT_24XX_MMC2_IRQ;
541 break;
542 case 2:
543 if (!cpu_is_omap34xx())
544 return;
545 base = OMAP3_MMC3_BASE;
546 irq = INT_34XX_MMC3_IRQ;
547 break;
548 default:
549 continue;
552 if (cpu_is_omap2420()) {
553 size = OMAP2420_MMC_SIZE;
554 name = "mmci-omap";
555 } else {
556 size = HSMMC_SIZE;
557 name = "mmci-omap-hs";
559 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
563 #endif
565 /*-------------------------------------------------------------------------*/
567 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
568 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
569 #define OMAP_HDQ_BASE 0x480B2000
570 #endif
571 static struct resource omap_hdq_resources[] = {
573 .start = OMAP_HDQ_BASE,
574 .end = OMAP_HDQ_BASE + 0x1C,
575 .flags = IORESOURCE_MEM,
578 .start = INT_24XX_HDQ_IRQ,
579 .flags = IORESOURCE_IRQ,
582 static struct platform_device omap_hdq_dev = {
583 .name = "omap_hdq",
584 .id = 0,
585 .dev = {
586 .platform_data = NULL,
588 .num_resources = ARRAY_SIZE(omap_hdq_resources),
589 .resource = omap_hdq_resources,
591 static inline void omap_hdq_init(void)
593 (void) platform_device_register(&omap_hdq_dev);
595 #else
596 static inline void omap_hdq_init(void) {}
597 #endif
599 /*-------------------------------------------------------------------------*/
601 static int __init omap2_init_devices(void)
603 /* please keep these calls, and their implementations above,
604 * in alphabetical order so they're easier to sort through.
606 omap_hsmmc_reset();
607 omap_init_camera();
608 omap_init_mbox();
609 omap_init_mcspi();
610 omap_hdq_init();
611 omap_init_sti();
612 omap_init_sha1_md5();
614 return 0;
616 arch_initcall(omap2_init_devices);