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/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>
20 #include <mach/hardware.h>
21 #include <mach/irqs.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/map.h>
27 #include <plat/board.h>
28 #include <plat/mcbsp.h>
29 #include <mach/gpio.h>
32 #include <plat/omap_hwmod.h>
33 #include <plat/omap_device.h>
34 #include <plat/omap4-keypad.h>
39 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
41 static struct resource cam_resources
[] = {
43 .start
= OMAP24XX_CAMERA_BASE
,
44 .end
= OMAP24XX_CAMERA_BASE
+ 0xfff,
45 .flags
= IORESOURCE_MEM
,
48 .start
= INT_24XX_CAM_IRQ
,
49 .flags
= IORESOURCE_IRQ
,
53 static struct platform_device omap_cam_device
= {
54 .name
= "omap24xxcam",
56 .num_resources
= ARRAY_SIZE(cam_resources
),
57 .resource
= cam_resources
,
60 static inline void omap_init_camera(void)
62 platform_device_register(&omap_cam_device
);
65 #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
67 static struct resource omap3isp_resources
[] = {
69 .start
= OMAP3430_ISP_BASE
,
70 .end
= OMAP3430_ISP_END
,
71 .flags
= IORESOURCE_MEM
,
74 .start
= OMAP3430_ISP_CBUFF_BASE
,
75 .end
= OMAP3430_ISP_CBUFF_END
,
76 .flags
= IORESOURCE_MEM
,
79 .start
= OMAP3430_ISP_CCP2_BASE
,
80 .end
= OMAP3430_ISP_CCP2_END
,
81 .flags
= IORESOURCE_MEM
,
84 .start
= OMAP3430_ISP_CCDC_BASE
,
85 .end
= OMAP3430_ISP_CCDC_END
,
86 .flags
= IORESOURCE_MEM
,
89 .start
= OMAP3430_ISP_HIST_BASE
,
90 .end
= OMAP3430_ISP_HIST_END
,
91 .flags
= IORESOURCE_MEM
,
94 .start
= OMAP3430_ISP_H3A_BASE
,
95 .end
= OMAP3430_ISP_H3A_END
,
96 .flags
= IORESOURCE_MEM
,
99 .start
= OMAP3430_ISP_PREV_BASE
,
100 .end
= OMAP3430_ISP_PREV_END
,
101 .flags
= IORESOURCE_MEM
,
104 .start
= OMAP3430_ISP_RESZ_BASE
,
105 .end
= OMAP3430_ISP_RESZ_END
,
106 .flags
= IORESOURCE_MEM
,
109 .start
= OMAP3430_ISP_SBL_BASE
,
110 .end
= OMAP3430_ISP_SBL_END
,
111 .flags
= IORESOURCE_MEM
,
114 .start
= OMAP3430_ISP_CSI2A_BASE
,
115 .end
= OMAP3430_ISP_CSI2A_END
,
116 .flags
= IORESOURCE_MEM
,
119 .start
= OMAP3430_ISP_CSI2PHY_BASE
,
120 .end
= OMAP3430_ISP_CSI2PHY_END
,
121 .flags
= IORESOURCE_MEM
,
124 .start
= INT_34XX_CAM_IRQ
,
125 .flags
= IORESOURCE_IRQ
,
129 static struct platform_device omap3isp_device
= {
132 .num_resources
= ARRAY_SIZE(omap3isp_resources
),
133 .resource
= omap3isp_resources
,
136 static inline void omap_init_camera(void)
138 platform_device_register(&omap3isp_device
);
141 static inline void omap_init_camera(void)
146 struct omap_device_pm_latency omap_keyboard_latency
[] = {
148 .deactivate_func
= omap_device_idle_hwmods
,
149 .activate_func
= omap_device_enable_hwmods
,
150 .flags
= OMAP_DEVICE_LATENCY_AUTO_ADJUST
,
154 int __init
omap4_keyboard_init(struct omap4_keypad_platform_data
155 *sdp4430_keypad_data
)
157 struct omap_device
*od
;
158 struct omap_hwmod
*oh
;
159 struct omap4_keypad_platform_data
*keypad_data
;
160 unsigned int id
= -1;
161 char *oh_name
= "kbd";
162 char *name
= "omap4-keypad";
164 oh
= omap_hwmod_lookup(oh_name
);
166 pr_err("Could not look up %s\n", oh_name
);
170 keypad_data
= sdp4430_keypad_data
;
172 od
= omap_device_build(name
, id
, oh
, keypad_data
,
173 sizeof(struct omap4_keypad_platform_data
),
174 omap_keyboard_latency
,
175 ARRAY_SIZE(omap_keyboard_latency
), 0);
178 WARN(1, "Cant build omap_device for %s:%s.\n",
186 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
187 static struct omap_device_pm_latency mbox_latencies
[] = {
189 .activate_func
= omap_device_enable_hwmods
,
190 .deactivate_func
= omap_device_idle_hwmods
,
191 .flags
= OMAP_DEVICE_LATENCY_AUTO_ADJUST
,
195 static inline void omap_init_mbox(void)
197 struct omap_hwmod
*oh
;
198 struct omap_device
*od
;
200 oh
= omap_hwmod_lookup("mailbox");
202 pr_err("%s: unable to find hwmod\n", __func__
);
206 od
= omap_device_build("omap-mailbox", -1, oh
, NULL
, 0,
207 mbox_latencies
, ARRAY_SIZE(mbox_latencies
), 0);
208 WARN(IS_ERR(od
), "%s: could not build device, err %ld\n",
209 __func__
, PTR_ERR(od
));
212 static inline void omap_init_mbox(void) { }
213 #endif /* CONFIG_OMAP_MBOX_FWK */
215 static inline void omap_init_sti(void) {}
217 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
219 static struct platform_device omap_pcm
= {
220 .name
= "omap-pcm-audio",
225 * OMAP2420 has 2 McBSP ports
226 * OMAP2430 has 5 McBSP ports
227 * OMAP3 has 5 McBSP ports
228 * OMAP4 has 4 McBSP ports
230 OMAP_MCBSP_PLATFORM_DEVICE(1);
231 OMAP_MCBSP_PLATFORM_DEVICE(2);
232 OMAP_MCBSP_PLATFORM_DEVICE(3);
233 OMAP_MCBSP_PLATFORM_DEVICE(4);
234 OMAP_MCBSP_PLATFORM_DEVICE(5);
236 static void omap_init_audio(void)
238 platform_device_register(&omap_mcbsp1
);
239 platform_device_register(&omap_mcbsp2
);
240 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
241 platform_device_register(&omap_mcbsp3
);
242 platform_device_register(&omap_mcbsp4
);
244 if (cpu_is_omap243x() || cpu_is_omap34xx())
245 platform_device_register(&omap_mcbsp5
);
247 platform_device_register(&omap_pcm
);
251 static inline void omap_init_audio(void) {}
254 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
256 #include <plat/mcspi.h>
258 struct omap_device_pm_latency omap_mcspi_latency
[] = {
260 .deactivate_func
= omap_device_idle_hwmods
,
261 .activate_func
= omap_device_enable_hwmods
,
262 .flags
= OMAP_DEVICE_LATENCY_AUTO_ADJUST
,
266 static int omap_mcspi_init(struct omap_hwmod
*oh
, void *unused
)
268 struct omap_device
*od
;
269 char *name
= "omap2_mcspi";
270 struct omap2_mcspi_platform_config
*pdata
;
272 struct omap2_mcspi_dev_attr
*mcspi_attrib
= oh
->dev_attr
;
274 pdata
= kzalloc(sizeof(*pdata
), GFP_KERNEL
);
276 pr_err("Memory allocation for McSPI device failed\n");
280 pdata
->num_cs
= mcspi_attrib
->num_chipselect
;
281 switch (oh
->class->rev
) {
282 case OMAP2_MCSPI_REV
:
283 case OMAP3_MCSPI_REV
:
284 pdata
->regs_offset
= 0;
286 case OMAP4_MCSPI_REV
:
287 pdata
->regs_offset
= OMAP4_MCSPI_REG_OFFSET
;
290 pr_err("Invalid McSPI Revision value\n");
295 od
= omap_device_build(name
, spi_num
, oh
, pdata
,
296 sizeof(*pdata
), omap_mcspi_latency
,
297 ARRAY_SIZE(omap_mcspi_latency
), 0);
298 WARN(IS_ERR(od
), "Cant build omap_device for %s:%s\n",
304 static void omap_init_mcspi(void)
306 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init
, NULL
);
310 static inline void omap_init_mcspi(void) {}
313 static struct resource omap2_pmu_resource
= {
316 .flags
= IORESOURCE_IRQ
,
319 static struct resource omap3_pmu_resource
= {
320 .start
= INT_34XX_BENCH_MPU_EMUL
,
321 .end
= INT_34XX_BENCH_MPU_EMUL
,
322 .flags
= IORESOURCE_IRQ
,
325 static struct platform_device omap_pmu_device
= {
327 .id
= ARM_PMU_DEVICE_CPU
,
331 static void omap_init_pmu(void)
333 if (cpu_is_omap24xx())
334 omap_pmu_device
.resource
= &omap2_pmu_resource
;
335 else if (cpu_is_omap34xx())
336 omap_pmu_device
.resource
= &omap3_pmu_resource
;
340 platform_device_register(&omap_pmu_device
);
344 #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
346 #ifdef CONFIG_ARCH_OMAP2
347 static struct resource omap2_sham_resources
[] = {
349 .start
= OMAP24XX_SEC_SHA1MD5_BASE
,
350 .end
= OMAP24XX_SEC_SHA1MD5_BASE
+ 0x64,
351 .flags
= IORESOURCE_MEM
,
354 .start
= INT_24XX_SHA1MD5
,
355 .flags
= IORESOURCE_IRQ
,
358 static int omap2_sham_resources_sz
= ARRAY_SIZE(omap2_sham_resources
);
360 #define omap2_sham_resources NULL
361 #define omap2_sham_resources_sz 0
364 #ifdef CONFIG_ARCH_OMAP3
365 static struct resource omap3_sham_resources
[] = {
367 .start
= OMAP34XX_SEC_SHA1MD5_BASE
,
368 .end
= OMAP34XX_SEC_SHA1MD5_BASE
+ 0x64,
369 .flags
= IORESOURCE_MEM
,
372 .start
= INT_34XX_SHA1MD52_IRQ
,
373 .flags
= IORESOURCE_IRQ
,
376 .start
= OMAP34XX_DMA_SHA1MD5_RX
,
377 .flags
= IORESOURCE_DMA
,
380 static int omap3_sham_resources_sz
= ARRAY_SIZE(omap3_sham_resources
);
382 #define omap3_sham_resources NULL
383 #define omap3_sham_resources_sz 0
386 static struct platform_device sham_device
= {
391 static void omap_init_sham(void)
393 if (cpu_is_omap24xx()) {
394 sham_device
.resource
= omap2_sham_resources
;
395 sham_device
.num_resources
= omap2_sham_resources_sz
;
396 } else if (cpu_is_omap34xx()) {
397 sham_device
.resource
= omap3_sham_resources
;
398 sham_device
.num_resources
= omap3_sham_resources_sz
;
400 pr_err("%s: platform not supported\n", __func__
);
403 platform_device_register(&sham_device
);
406 static inline void omap_init_sham(void) { }
409 #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
411 #ifdef CONFIG_ARCH_OMAP2
412 static struct resource omap2_aes_resources
[] = {
414 .start
= OMAP24XX_SEC_AES_BASE
,
415 .end
= OMAP24XX_SEC_AES_BASE
+ 0x4C,
416 .flags
= IORESOURCE_MEM
,
419 .start
= OMAP24XX_DMA_AES_TX
,
420 .flags
= IORESOURCE_DMA
,
423 .start
= OMAP24XX_DMA_AES_RX
,
424 .flags
= IORESOURCE_DMA
,
427 static int omap2_aes_resources_sz
= ARRAY_SIZE(omap2_aes_resources
);
429 #define omap2_aes_resources NULL
430 #define omap2_aes_resources_sz 0
433 #ifdef CONFIG_ARCH_OMAP3
434 static struct resource omap3_aes_resources
[] = {
436 .start
= OMAP34XX_SEC_AES_BASE
,
437 .end
= OMAP34XX_SEC_AES_BASE
+ 0x4C,
438 .flags
= IORESOURCE_MEM
,
441 .start
= OMAP34XX_DMA_AES2_TX
,
442 .flags
= IORESOURCE_DMA
,
445 .start
= OMAP34XX_DMA_AES2_RX
,
446 .flags
= IORESOURCE_DMA
,
449 static int omap3_aes_resources_sz
= ARRAY_SIZE(omap3_aes_resources
);
451 #define omap3_aes_resources NULL
452 #define omap3_aes_resources_sz 0
455 static struct platform_device aes_device
= {
460 static void omap_init_aes(void)
462 if (cpu_is_omap24xx()) {
463 aes_device
.resource
= omap2_aes_resources
;
464 aes_device
.num_resources
= omap2_aes_resources_sz
;
465 } else if (cpu_is_omap34xx()) {
466 aes_device
.resource
= omap3_aes_resources
;
467 aes_device
.num_resources
= omap3_aes_resources_sz
;
469 pr_err("%s: platform not supported\n", __func__
);
472 platform_device_register(&aes_device
);
476 static inline void omap_init_aes(void) { }
479 /*-------------------------------------------------------------------------*/
481 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
483 static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
486 if ((mmc_controller
->slots
[0].switch_pin
> 0) && \
487 (mmc_controller
->slots
[0].switch_pin
< OMAP_MAX_GPIO_LINES
))
488 omap_mux_init_gpio(mmc_controller
->slots
[0].switch_pin
,
489 OMAP_PIN_INPUT_PULLUP
);
490 if ((mmc_controller
->slots
[0].gpio_wp
> 0) && \
491 (mmc_controller
->slots
[0].gpio_wp
< OMAP_MAX_GPIO_LINES
))
492 omap_mux_init_gpio(mmc_controller
->slots
[0].gpio_wp
,
493 OMAP_PIN_INPUT_PULLUP
);
495 omap_mux_init_signal("sdmmc_cmd", 0);
496 omap_mux_init_signal("sdmmc_clki", 0);
497 omap_mux_init_signal("sdmmc_clko", 0);
498 omap_mux_init_signal("sdmmc_dat0", 0);
499 omap_mux_init_signal("sdmmc_dat_dir0", 0);
500 omap_mux_init_signal("sdmmc_cmd_dir", 0);
501 if (mmc_controller
->slots
[0].caps
& MMC_CAP_4_BIT_DATA
) {
502 omap_mux_init_signal("sdmmc_dat1", 0);
503 omap_mux_init_signal("sdmmc_dat2", 0);
504 omap_mux_init_signal("sdmmc_dat3", 0);
505 omap_mux_init_signal("sdmmc_dat_dir1", 0);
506 omap_mux_init_signal("sdmmc_dat_dir2", 0);
507 omap_mux_init_signal("sdmmc_dat_dir3", 0);
511 * Use internal loop-back in MMC/SDIO Module Input Clock
514 if (mmc_controller
->slots
[0].internal_clock
) {
515 u32 v
= omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0
);
517 omap_ctrl_writel(v
, OMAP2_CONTROL_DEVCONF0
);
521 void __init
omap242x_init_mmc(struct omap_mmc_platform_data
**mmc_data
)
523 char *name
= "mmci-omap";
526 pr_err("%s fails: Incomplete platform data\n", __func__
);
530 omap242x_mmc_mux(mmc_data
[0]);
531 omap_mmc_add(name
, 0, OMAP2_MMC1_BASE
, OMAP2420_MMC_SIZE
,
532 INT_24XX_MMC_IRQ
, mmc_data
[0]);
537 /*-------------------------------------------------------------------------*/
539 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
540 #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
541 #define OMAP_HDQ_BASE 0x480B2000
543 static struct resource omap_hdq_resources
[] = {
545 .start
= OMAP_HDQ_BASE
,
546 .end
= OMAP_HDQ_BASE
+ 0x1C,
547 .flags
= IORESOURCE_MEM
,
550 .start
= INT_24XX_HDQ_IRQ
,
551 .flags
= IORESOURCE_IRQ
,
554 static struct platform_device omap_hdq_dev
= {
558 .platform_data
= NULL
,
560 .num_resources
= ARRAY_SIZE(omap_hdq_resources
),
561 .resource
= omap_hdq_resources
,
563 static inline void omap_hdq_init(void)
565 (void) platform_device_register(&omap_hdq_dev
);
568 static inline void omap_hdq_init(void) {}
571 /*---------------------------------------------------------------------------*/
573 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
574 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
575 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
576 static struct resource omap_vout_resource
[3 - CONFIG_FB_OMAP2_NUM_FBS
] = {
579 static struct resource omap_vout_resource
[2] = {
583 static struct platform_device omap_vout_device
= {
585 .num_resources
= ARRAY_SIZE(omap_vout_resource
),
586 .resource
= &omap_vout_resource
[0],
589 static void omap_init_vout(void)
591 if (platform_device_register(&omap_vout_device
) < 0)
592 printk(KERN_ERR
"Unable to register OMAP-VOUT device\n");
595 static inline void omap_init_vout(void) {}
598 /*-------------------------------------------------------------------------*/
600 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.
619 arch_initcall(omap2_init_devices
);
621 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
622 static struct omap_device_pm_latency omap_wdt_latency
[] = {
624 .deactivate_func
= omap_device_idle_hwmods
,
625 .activate_func
= omap_device_enable_hwmods
,
626 .flags
= OMAP_DEVICE_LATENCY_AUTO_ADJUST
,
630 static int __init
omap_init_wdt(void)
633 struct omap_device
*od
;
634 struct omap_hwmod
*oh
;
635 char *oh_name
= "wd_timer2";
636 char *dev_name
= "omap_wdt";
638 if (!cpu_class_is_omap2())
641 oh
= omap_hwmod_lookup(oh_name
);
643 pr_err("Could not look up wd_timer%d hwmod\n", id
);
647 od
= omap_device_build(dev_name
, id
, oh
, NULL
, 0,
649 ARRAY_SIZE(omap_wdt_latency
), 0);
650 WARN(IS_ERR(od
), "Cant build omap_device for %s:%s.\n",
654 subsys_initcall(omap_init_wdt
);