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.
11 #include <linux/gpio.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
16 #include <linux/clk.h>
17 #include <linux/err.h>
18 #include <linux/slab.h>
21 #include <mach/hardware.h>
22 #include <mach/irqs.h>
23 #include <asm/mach-types.h>
24 #include <asm/mach/map.h>
28 #include <plat/board.h>
29 #include <plat/mcbsp.h>
31 #include <plat/iommu.h>
33 #include <plat/omap_hwmod.h>
34 #include <plat/omap_device.h>
35 #include <plat/omap4-keypad.h>
41 #define L3_MODULES_MAX_LEN 12
44 static int __init
omap3_l3_init(void)
47 struct omap_hwmod
*oh
;
48 struct platform_device
*pdev
;
49 char oh_name
[L3_MODULES_MAX_LEN
];
52 * To avoid code running on other OMAPs in
55 if (!(cpu_is_omap34xx()))
58 l
= snprintf(oh_name
, L3_MODULES_MAX_LEN
, "l3_main");
60 oh
= omap_hwmod_lookup(oh_name
);
63 pr_err("could not look up %s\n", oh_name
);
65 pdev
= omap_device_build("omap_l3_smx", 0, oh
, NULL
, 0,
68 WARN(IS_ERR(pdev
), "could not build omap_device for %s\n", oh_name
);
70 return IS_ERR(pdev
) ? PTR_ERR(pdev
) : 0;
72 postcore_initcall(omap3_l3_init
);
74 static int __init
omap4_l3_init(void)
77 struct omap_hwmod
*oh
[3];
78 struct platform_device
*pdev
;
79 char oh_name
[L3_MODULES_MAX_LEN
];
81 /* If dtb is there, the devices will be created dynamically */
82 if (of_have_populated_dt())
86 * To avoid code running on other OMAPs in
89 if (!(cpu_is_omap44xx()))
92 for (i
= 0; i
< L3_MODULES
; i
++) {
93 l
= snprintf(oh_name
, L3_MODULES_MAX_LEN
, "l3_main_%d", i
+1);
95 oh
[i
] = omap_hwmod_lookup(oh_name
);
97 pr_err("could not look up %s\n", oh_name
);
100 pdev
= omap_device_build_ss("omap_l3_noc", 0, oh
, 3, NULL
,
103 WARN(IS_ERR(pdev
), "could not build omap_device for %s\n", oh_name
);
105 return IS_ERR(pdev
) ? PTR_ERR(pdev
) : 0;
107 postcore_initcall(omap4_l3_init
);
109 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
111 static struct resource omap2cam_resources
[] = {
113 .start
= OMAP24XX_CAMERA_BASE
,
114 .end
= OMAP24XX_CAMERA_BASE
+ 0xfff,
115 .flags
= IORESOURCE_MEM
,
118 .start
= INT_24XX_CAM_IRQ
,
119 .flags
= IORESOURCE_IRQ
,
123 static struct platform_device omap2cam_device
= {
124 .name
= "omap24xxcam",
126 .num_resources
= ARRAY_SIZE(omap2cam_resources
),
127 .resource
= omap2cam_resources
,
131 static struct resource omap3isp_resources
[] = {
133 .start
= OMAP3430_ISP_BASE
,
134 .end
= OMAP3430_ISP_END
,
135 .flags
= IORESOURCE_MEM
,
138 .start
= OMAP3430_ISP_CCP2_BASE
,
139 .end
= OMAP3430_ISP_CCP2_END
,
140 .flags
= IORESOURCE_MEM
,
143 .start
= OMAP3430_ISP_CCDC_BASE
,
144 .end
= OMAP3430_ISP_CCDC_END
,
145 .flags
= IORESOURCE_MEM
,
148 .start
= OMAP3430_ISP_HIST_BASE
,
149 .end
= OMAP3430_ISP_HIST_END
,
150 .flags
= IORESOURCE_MEM
,
153 .start
= OMAP3430_ISP_H3A_BASE
,
154 .end
= OMAP3430_ISP_H3A_END
,
155 .flags
= IORESOURCE_MEM
,
158 .start
= OMAP3430_ISP_PREV_BASE
,
159 .end
= OMAP3430_ISP_PREV_END
,
160 .flags
= IORESOURCE_MEM
,
163 .start
= OMAP3430_ISP_RESZ_BASE
,
164 .end
= OMAP3430_ISP_RESZ_END
,
165 .flags
= IORESOURCE_MEM
,
168 .start
= OMAP3430_ISP_SBL_BASE
,
169 .end
= OMAP3430_ISP_SBL_END
,
170 .flags
= IORESOURCE_MEM
,
173 .start
= OMAP3430_ISP_CSI2A_REGS1_BASE
,
174 .end
= OMAP3430_ISP_CSI2A_REGS1_END
,
175 .flags
= IORESOURCE_MEM
,
178 .start
= OMAP3430_ISP_CSIPHY2_BASE
,
179 .end
= OMAP3430_ISP_CSIPHY2_END
,
180 .flags
= IORESOURCE_MEM
,
183 .start
= OMAP3630_ISP_CSI2A_REGS2_BASE
,
184 .end
= OMAP3630_ISP_CSI2A_REGS2_END
,
185 .flags
= IORESOURCE_MEM
,
188 .start
= OMAP3630_ISP_CSI2C_REGS1_BASE
,
189 .end
= OMAP3630_ISP_CSI2C_REGS1_END
,
190 .flags
= IORESOURCE_MEM
,
193 .start
= OMAP3630_ISP_CSIPHY1_BASE
,
194 .end
= OMAP3630_ISP_CSIPHY1_END
,
195 .flags
= IORESOURCE_MEM
,
198 .start
= OMAP3630_ISP_CSI2C_REGS2_BASE
,
199 .end
= OMAP3630_ISP_CSI2C_REGS2_END
,
200 .flags
= IORESOURCE_MEM
,
203 .start
= INT_34XX_CAM_IRQ
,
204 .flags
= IORESOURCE_IRQ
,
208 static struct platform_device omap3isp_device
= {
211 .num_resources
= ARRAY_SIZE(omap3isp_resources
),
212 .resource
= omap3isp_resources
,
215 static struct omap_iommu_arch_data omap3_isp_iommu
= {
219 int omap3_init_camera(struct isp_platform_data
*pdata
)
221 omap3isp_device
.dev
.platform_data
= pdata
;
222 omap3isp_device
.dev
.archdata
.iommu
= &omap3_isp_iommu
;
224 return platform_device_register(&omap3isp_device
);
227 static inline void omap_init_camera(void)
229 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
230 if (cpu_is_omap24xx())
231 platform_device_register(&omap2cam_device
);
235 int __init
omap4_keyboard_init(struct omap4_keypad_platform_data
236 *sdp4430_keypad_data
, struct omap_board_data
*bdata
)
238 struct platform_device
*pdev
;
239 struct omap_hwmod
*oh
;
240 struct omap4_keypad_platform_data
*keypad_data
;
241 unsigned int id
= -1;
242 char *oh_name
= "kbd";
243 char *name
= "omap4-keypad";
245 oh
= omap_hwmod_lookup(oh_name
);
247 pr_err("Could not look up %s\n", oh_name
);
251 keypad_data
= sdp4430_keypad_data
;
253 pdev
= omap_device_build(name
, id
, oh
, keypad_data
,
254 sizeof(struct omap4_keypad_platform_data
), NULL
, 0, 0);
257 WARN(1, "Can't build omap_device for %s:%s.\n",
259 return PTR_ERR(pdev
);
261 oh
->mux
= omap_hwmod_mux_init(bdata
->pads
, bdata
->pads_cnt
);
266 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
267 static inline void omap_init_mbox(void)
269 struct omap_hwmod
*oh
;
270 struct platform_device
*pdev
;
272 oh
= omap_hwmod_lookup("mailbox");
274 pr_err("%s: unable to find hwmod\n", __func__
);
278 pdev
= omap_device_build("omap-mailbox", -1, oh
, NULL
, 0, NULL
, 0, 0);
279 WARN(IS_ERR(pdev
), "%s: could not build device, err %ld\n",
280 __func__
, PTR_ERR(pdev
));
283 static inline void omap_init_mbox(void) { }
284 #endif /* CONFIG_OMAP_MBOX_FWK */
286 static inline void omap_init_sti(void) {}
288 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
290 static struct platform_device omap_pcm
= {
291 .name
= "omap-pcm-audio",
296 * OMAP2420 has 2 McBSP ports
297 * OMAP2430 has 5 McBSP ports
298 * OMAP3 has 5 McBSP ports
299 * OMAP4 has 4 McBSP ports
301 OMAP_MCBSP_PLATFORM_DEVICE(1);
302 OMAP_MCBSP_PLATFORM_DEVICE(2);
303 OMAP_MCBSP_PLATFORM_DEVICE(3);
304 OMAP_MCBSP_PLATFORM_DEVICE(4);
305 OMAP_MCBSP_PLATFORM_DEVICE(5);
307 static void omap_init_audio(void)
309 platform_device_register(&omap_mcbsp1
);
310 platform_device_register(&omap_mcbsp2
);
311 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
312 platform_device_register(&omap_mcbsp3
);
313 platform_device_register(&omap_mcbsp4
);
315 if (cpu_is_omap243x() || cpu_is_omap34xx())
316 platform_device_register(&omap_mcbsp5
);
318 platform_device_register(&omap_pcm
);
322 static inline void omap_init_audio(void) {}
325 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
326 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
328 static void omap_init_mcpdm(void)
330 struct omap_hwmod
*oh
;
331 struct platform_device
*pdev
;
333 oh
= omap_hwmod_lookup("mcpdm");
335 printk(KERN_ERR
"Could not look up mcpdm hw_mod\n");
339 pdev
= omap_device_build("omap-mcpdm", -1, oh
, NULL
, 0, NULL
, 0, 0);
340 WARN(IS_ERR(pdev
), "Can't build omap_device for omap-mcpdm.\n");
343 static inline void omap_init_mcpdm(void) {}
346 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
348 #include <plat/mcspi.h>
350 static int omap_mcspi_init(struct omap_hwmod
*oh
, void *unused
)
352 struct platform_device
*pdev
;
353 char *name
= "omap2_mcspi";
354 struct omap2_mcspi_platform_config
*pdata
;
356 struct omap2_mcspi_dev_attr
*mcspi_attrib
= oh
->dev_attr
;
358 pdata
= kzalloc(sizeof(*pdata
), GFP_KERNEL
);
360 pr_err("Memory allocation for McSPI device failed\n");
364 pdata
->num_cs
= mcspi_attrib
->num_chipselect
;
365 switch (oh
->class->rev
) {
366 case OMAP2_MCSPI_REV
:
367 case OMAP3_MCSPI_REV
:
368 pdata
->regs_offset
= 0;
370 case OMAP4_MCSPI_REV
:
371 pdata
->regs_offset
= OMAP4_MCSPI_REG_OFFSET
;
374 pr_err("Invalid McSPI Revision value\n");
379 pdev
= omap_device_build(name
, spi_num
, oh
, pdata
,
380 sizeof(*pdata
), NULL
, 0, 0);
381 WARN(IS_ERR(pdev
), "Can't build omap_device for %s:%s\n",
387 static void omap_init_mcspi(void)
389 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init
, NULL
);
393 static inline void omap_init_mcspi(void) {}
396 static struct resource omap2_pmu_resource
= {
399 .flags
= IORESOURCE_IRQ
,
402 static struct resource omap3_pmu_resource
= {
403 .start
= INT_34XX_BENCH_MPU_EMUL
,
404 .end
= INT_34XX_BENCH_MPU_EMUL
,
405 .flags
= IORESOURCE_IRQ
,
408 static struct platform_device omap_pmu_device
= {
410 .id
= ARM_PMU_DEVICE_CPU
,
414 static void omap_init_pmu(void)
416 if (cpu_is_omap24xx())
417 omap_pmu_device
.resource
= &omap2_pmu_resource
;
418 else if (cpu_is_omap34xx())
419 omap_pmu_device
.resource
= &omap3_pmu_resource
;
423 platform_device_register(&omap_pmu_device
);
427 #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
429 #ifdef CONFIG_ARCH_OMAP2
430 static struct resource omap2_sham_resources
[] = {
432 .start
= OMAP24XX_SEC_SHA1MD5_BASE
,
433 .end
= OMAP24XX_SEC_SHA1MD5_BASE
+ 0x64,
434 .flags
= IORESOURCE_MEM
,
437 .start
= INT_24XX_SHA1MD5
,
438 .flags
= IORESOURCE_IRQ
,
441 static int omap2_sham_resources_sz
= ARRAY_SIZE(omap2_sham_resources
);
443 #define omap2_sham_resources NULL
444 #define omap2_sham_resources_sz 0
447 #ifdef CONFIG_ARCH_OMAP3
448 static struct resource omap3_sham_resources
[] = {
450 .start
= OMAP34XX_SEC_SHA1MD5_BASE
,
451 .end
= OMAP34XX_SEC_SHA1MD5_BASE
+ 0x64,
452 .flags
= IORESOURCE_MEM
,
455 .start
= INT_34XX_SHA1MD52_IRQ
,
456 .flags
= IORESOURCE_IRQ
,
459 .start
= OMAP34XX_DMA_SHA1MD5_RX
,
460 .flags
= IORESOURCE_DMA
,
463 static int omap3_sham_resources_sz
= ARRAY_SIZE(omap3_sham_resources
);
465 #define omap3_sham_resources NULL
466 #define omap3_sham_resources_sz 0
469 static struct platform_device sham_device
= {
474 static void omap_init_sham(void)
476 if (cpu_is_omap24xx()) {
477 sham_device
.resource
= omap2_sham_resources
;
478 sham_device
.num_resources
= omap2_sham_resources_sz
;
479 } else if (cpu_is_omap34xx()) {
480 sham_device
.resource
= omap3_sham_resources
;
481 sham_device
.num_resources
= omap3_sham_resources_sz
;
483 pr_err("%s: platform not supported\n", __func__
);
486 platform_device_register(&sham_device
);
489 static inline void omap_init_sham(void) { }
492 #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
494 #ifdef CONFIG_ARCH_OMAP2
495 static struct resource omap2_aes_resources
[] = {
497 .start
= OMAP24XX_SEC_AES_BASE
,
498 .end
= OMAP24XX_SEC_AES_BASE
+ 0x4C,
499 .flags
= IORESOURCE_MEM
,
502 .start
= OMAP24XX_DMA_AES_TX
,
503 .flags
= IORESOURCE_DMA
,
506 .start
= OMAP24XX_DMA_AES_RX
,
507 .flags
= IORESOURCE_DMA
,
510 static int omap2_aes_resources_sz
= ARRAY_SIZE(omap2_aes_resources
);
512 #define omap2_aes_resources NULL
513 #define omap2_aes_resources_sz 0
516 #ifdef CONFIG_ARCH_OMAP3
517 static struct resource omap3_aes_resources
[] = {
519 .start
= OMAP34XX_SEC_AES_BASE
,
520 .end
= OMAP34XX_SEC_AES_BASE
+ 0x4C,
521 .flags
= IORESOURCE_MEM
,
524 .start
= OMAP34XX_DMA_AES2_TX
,
525 .flags
= IORESOURCE_DMA
,
528 .start
= OMAP34XX_DMA_AES2_RX
,
529 .flags
= IORESOURCE_DMA
,
532 static int omap3_aes_resources_sz
= ARRAY_SIZE(omap3_aes_resources
);
534 #define omap3_aes_resources NULL
535 #define omap3_aes_resources_sz 0
538 static struct platform_device aes_device
= {
543 static void omap_init_aes(void)
545 if (cpu_is_omap24xx()) {
546 aes_device
.resource
= omap2_aes_resources
;
547 aes_device
.num_resources
= omap2_aes_resources_sz
;
548 } else if (cpu_is_omap34xx()) {
549 aes_device
.resource
= omap3_aes_resources
;
550 aes_device
.num_resources
= omap3_aes_resources_sz
;
552 pr_err("%s: platform not supported\n", __func__
);
555 platform_device_register(&aes_device
);
559 static inline void omap_init_aes(void) { }
562 /*-------------------------------------------------------------------------*/
564 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
566 static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
569 if ((mmc_controller
->slots
[0].switch_pin
> 0) && \
570 (mmc_controller
->slots
[0].switch_pin
< OMAP_MAX_GPIO_LINES
))
571 omap_mux_init_gpio(mmc_controller
->slots
[0].switch_pin
,
572 OMAP_PIN_INPUT_PULLUP
);
573 if ((mmc_controller
->slots
[0].gpio_wp
> 0) && \
574 (mmc_controller
->slots
[0].gpio_wp
< OMAP_MAX_GPIO_LINES
))
575 omap_mux_init_gpio(mmc_controller
->slots
[0].gpio_wp
,
576 OMAP_PIN_INPUT_PULLUP
);
578 omap_mux_init_signal("sdmmc_cmd", 0);
579 omap_mux_init_signal("sdmmc_clki", 0);
580 omap_mux_init_signal("sdmmc_clko", 0);
581 omap_mux_init_signal("sdmmc_dat0", 0);
582 omap_mux_init_signal("sdmmc_dat_dir0", 0);
583 omap_mux_init_signal("sdmmc_cmd_dir", 0);
584 if (mmc_controller
->slots
[0].caps
& MMC_CAP_4_BIT_DATA
) {
585 omap_mux_init_signal("sdmmc_dat1", 0);
586 omap_mux_init_signal("sdmmc_dat2", 0);
587 omap_mux_init_signal("sdmmc_dat3", 0);
588 omap_mux_init_signal("sdmmc_dat_dir1", 0);
589 omap_mux_init_signal("sdmmc_dat_dir2", 0);
590 omap_mux_init_signal("sdmmc_dat_dir3", 0);
594 * Use internal loop-back in MMC/SDIO Module Input Clock
597 if (mmc_controller
->slots
[0].internal_clock
) {
598 u32 v
= omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0
);
600 omap_ctrl_writel(v
, OMAP2_CONTROL_DEVCONF0
);
604 void __init
omap242x_init_mmc(struct omap_mmc_platform_data
**mmc_data
)
606 char *name
= "mmci-omap";
609 pr_err("%s fails: Incomplete platform data\n", __func__
);
613 omap242x_mmc_mux(mmc_data
[0]);
614 omap_mmc_add(name
, 0, OMAP2_MMC1_BASE
, OMAP2420_MMC_SIZE
,
615 INT_24XX_MMC_IRQ
, mmc_data
[0]);
620 /*-------------------------------------------------------------------------*/
622 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
623 #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
624 #define OMAP_HDQ_BASE 0x480B2000
626 static struct resource omap_hdq_resources
[] = {
628 .start
= OMAP_HDQ_BASE
,
629 .end
= OMAP_HDQ_BASE
+ 0x1C,
630 .flags
= IORESOURCE_MEM
,
633 .start
= INT_24XX_HDQ_IRQ
,
634 .flags
= IORESOURCE_IRQ
,
637 static struct platform_device omap_hdq_dev
= {
641 .platform_data
= NULL
,
643 .num_resources
= ARRAY_SIZE(omap_hdq_resources
),
644 .resource
= omap_hdq_resources
,
646 static inline void omap_hdq_init(void)
648 (void) platform_device_register(&omap_hdq_dev
);
651 static inline void omap_hdq_init(void) {}
654 /*---------------------------------------------------------------------------*/
656 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
657 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
658 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
659 static struct resource omap_vout_resource
[3 - CONFIG_FB_OMAP2_NUM_FBS
] = {
662 static struct resource omap_vout_resource
[2] = {
666 static struct platform_device omap_vout_device
= {
668 .num_resources
= ARRAY_SIZE(omap_vout_resource
),
669 .resource
= &omap_vout_resource
[0],
672 static void omap_init_vout(void)
674 if (platform_device_register(&omap_vout_device
) < 0)
675 printk(KERN_ERR
"Unable to register OMAP-VOUT device\n");
678 static inline void omap_init_vout(void) {}
681 /*-------------------------------------------------------------------------*/
683 static int __init
omap2_init_devices(void)
686 * please keep these calls, and their implementations above,
687 * in alphabetical order so they're easier to sort through.
703 arch_initcall(omap2_init_devices
);
705 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
706 static int __init
omap_init_wdt(void)
709 struct platform_device
*pdev
;
710 struct omap_hwmod
*oh
;
711 char *oh_name
= "wd_timer2";
712 char *dev_name
= "omap_wdt";
714 if (!cpu_class_is_omap2())
717 oh
= omap_hwmod_lookup(oh_name
);
719 pr_err("Could not look up wd_timer%d hwmod\n", id
);
723 pdev
= omap_device_build(dev_name
, id
, oh
, NULL
, 0, NULL
, 0, 0);
724 WARN(IS_ERR(pdev
), "Can't build omap_device for %s:%s.\n",
728 subsys_initcall(omap_init_wdt
);