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 #define L3_MODULES_MAX_LEN 12
42 static int __init omap3_l3_init(void)
45 struct omap_hwmod *oh;
46 struct omap_device *od;
47 char oh_name[L3_MODULES_MAX_LEN];
50 * To avoid code running on other OMAPs in
53 if (!(cpu_is_omap34xx()))
56 l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
58 oh = omap_hwmod_lookup(oh_name);
61 pr_err("could not look up %s\n", oh_name);
63 od = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
66 WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name);
70 postcore_initcall(omap3_l3_init);
72 static int __init omap4_l3_init(void)
75 struct omap_hwmod *oh[3];
76 struct omap_device *od;
77 char oh_name[L3_MODULES_MAX_LEN];
80 * To avoid code running on other OMAPs in
83 if (!(cpu_is_omap44xx()))
86 for (i = 0; i < L3_MODULES; i++) {
87 l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
89 oh[i] = omap_hwmod_lookup(oh_name);
91 pr_err("could not look up %s\n", oh_name);
94 od = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
97 WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name);
101 postcore_initcall(omap4_l3_init);
103 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
105 static struct resource cam_resources[] = {
107 .start = OMAP24XX_CAMERA_BASE,
108 .end = OMAP24XX_CAMERA_BASE + 0xfff,
109 .flags = IORESOURCE_MEM,
112 .start = INT_24XX_CAM_IRQ,
113 .flags = IORESOURCE_IRQ,
117 static struct platform_device omap_cam_device = {
118 .name = "omap24xxcam",
120 .num_resources = ARRAY_SIZE(cam_resources),
121 .resource = cam_resources,
124 static inline void omap_init_camera(void)
126 platform_device_register(&omap_cam_device);
129 #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
131 static struct resource omap3isp_resources[] = {
133 .start = OMAP3430_ISP_BASE,
134 .end = OMAP3430_ISP_END,
135 .flags = IORESOURCE_MEM,
138 .start = OMAP3430_ISP_CBUFF_BASE,
139 .end = OMAP3430_ISP_CBUFF_END,
140 .flags = IORESOURCE_MEM,
143 .start = OMAP3430_ISP_CCP2_BASE,
144 .end = OMAP3430_ISP_CCP2_END,
145 .flags = IORESOURCE_MEM,
148 .start = OMAP3430_ISP_CCDC_BASE,
149 .end = OMAP3430_ISP_CCDC_END,
150 .flags = IORESOURCE_MEM,
153 .start = OMAP3430_ISP_HIST_BASE,
154 .end = OMAP3430_ISP_HIST_END,
155 .flags = IORESOURCE_MEM,
158 .start = OMAP3430_ISP_H3A_BASE,
159 .end = OMAP3430_ISP_H3A_END,
160 .flags = IORESOURCE_MEM,
163 .start = OMAP3430_ISP_PREV_BASE,
164 .end = OMAP3430_ISP_PREV_END,
165 .flags = IORESOURCE_MEM,
168 .start = OMAP3430_ISP_RESZ_BASE,
169 .end = OMAP3430_ISP_RESZ_END,
170 .flags = IORESOURCE_MEM,
173 .start = OMAP3430_ISP_SBL_BASE,
174 .end = OMAP3430_ISP_SBL_END,
175 .flags = IORESOURCE_MEM,
178 .start = OMAP3430_ISP_CSI2A_BASE,
179 .end = OMAP3430_ISP_CSI2A_END,
180 .flags = IORESOURCE_MEM,
183 .start = OMAP3430_ISP_CSI2PHY_BASE,
184 .end = OMAP3430_ISP_CSI2PHY_END,
185 .flags = IORESOURCE_MEM,
188 .start = INT_34XX_CAM_IRQ,
189 .flags = IORESOURCE_IRQ,
193 static struct platform_device omap3isp_device = {
196 .num_resources = ARRAY_SIZE(omap3isp_resources),
197 .resource = omap3isp_resources,
200 static inline void omap_init_camera(void)
202 platform_device_register(&omap3isp_device);
205 static inline void omap_init_camera(void)
210 struct omap_device_pm_latency omap_keyboard_latency[] = {
212 .deactivate_func = omap_device_idle_hwmods,
213 .activate_func = omap_device_enable_hwmods,
214 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
218 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
219 *sdp4430_keypad_data)
221 struct omap_device *od;
222 struct omap_hwmod *oh;
223 struct omap4_keypad_platform_data *keypad_data;
224 unsigned int id = -1;
225 char *oh_name = "kbd";
226 char *name = "omap4-keypad";
228 oh = omap_hwmod_lookup(oh_name);
230 pr_err("Could not look up %s\n", oh_name);
234 keypad_data = sdp4430_keypad_data;
236 od = omap_device_build(name, id, oh, keypad_data,
237 sizeof(struct omap4_keypad_platform_data),
238 omap_keyboard_latency,
239 ARRAY_SIZE(omap_keyboard_latency), 0);
242 WARN(1, "Cant build omap_device for %s:%s.\n",
250 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
251 static struct omap_device_pm_latency mbox_latencies[] = {
253 .activate_func = omap_device_enable_hwmods,
254 .deactivate_func = omap_device_idle_hwmods,
255 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
259 static inline void omap_init_mbox(void)
261 struct omap_hwmod *oh;
262 struct omap_device *od;
264 oh = omap_hwmod_lookup("mailbox");
266 pr_err("%s: unable to find hwmod\n", __func__);
270 od = omap_device_build("omap-mailbox", -1, oh, NULL, 0,
271 mbox_latencies, ARRAY_SIZE(mbox_latencies), 0);
272 WARN(IS_ERR(od), "%s: could not build device, err %ld\n",
273 __func__, PTR_ERR(od));
276 static inline void omap_init_mbox(void) { }
277 #endif /* CONFIG_OMAP_MBOX_FWK */
279 static inline void omap_init_sti(void) {}
281 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
283 static struct platform_device omap_pcm = {
284 .name = "omap-pcm-audio",
289 * OMAP2420 has 2 McBSP ports
290 * OMAP2430 has 5 McBSP ports
291 * OMAP3 has 5 McBSP ports
292 * OMAP4 has 4 McBSP ports
294 OMAP_MCBSP_PLATFORM_DEVICE(1);
295 OMAP_MCBSP_PLATFORM_DEVICE(2);
296 OMAP_MCBSP_PLATFORM_DEVICE(3);
297 OMAP_MCBSP_PLATFORM_DEVICE(4);
298 OMAP_MCBSP_PLATFORM_DEVICE(5);
300 static void omap_init_audio(void)
302 platform_device_register(&omap_mcbsp1);
303 platform_device_register(&omap_mcbsp2);
304 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
305 platform_device_register(&omap_mcbsp3);
306 platform_device_register(&omap_mcbsp4);
308 if (cpu_is_omap243x() || cpu_is_omap34xx())
309 platform_device_register(&omap_mcbsp5);
311 platform_device_register(&omap_pcm);
315 static inline void omap_init_audio(void) {}
318 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
320 #include <plat/mcspi.h>
322 struct omap_device_pm_latency omap_mcspi_latency[] = {
324 .deactivate_func = omap_device_idle_hwmods,
325 .activate_func = omap_device_enable_hwmods,
326 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
330 static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
332 struct omap_device *od;
333 char *name = "omap2_mcspi";
334 struct omap2_mcspi_platform_config *pdata;
336 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
338 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
340 pr_err("Memory allocation for McSPI device failed\n");
344 pdata->num_cs = mcspi_attrib->num_chipselect;
345 switch (oh->class->rev) {
346 case OMAP2_MCSPI_REV:
347 case OMAP3_MCSPI_REV:
348 pdata->regs_offset = 0;
350 case OMAP4_MCSPI_REV:
351 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
354 pr_err("Invalid McSPI Revision value\n");
359 od = omap_device_build(name, spi_num, oh, pdata,
360 sizeof(*pdata), omap_mcspi_latency,
361 ARRAY_SIZE(omap_mcspi_latency), 0);
362 WARN(IS_ERR(od), "Cant build omap_device for %s:%s\n",
368 static void omap_init_mcspi(void)
370 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
374 static inline void omap_init_mcspi(void) {}
377 static struct resource omap2_pmu_resource = {
380 .flags = IORESOURCE_IRQ,
383 static struct resource omap3_pmu_resource = {
384 .start = INT_34XX_BENCH_MPU_EMUL,
385 .end = INT_34XX_BENCH_MPU_EMUL,
386 .flags = IORESOURCE_IRQ,
389 static struct platform_device omap_pmu_device = {
391 .id = ARM_PMU_DEVICE_CPU,
395 static void omap_init_pmu(void)
397 if (cpu_is_omap24xx())
398 omap_pmu_device.resource = &omap2_pmu_resource;
399 else if (cpu_is_omap34xx())
400 omap_pmu_device.resource = &omap3_pmu_resource;
404 platform_device_register(&omap_pmu_device);
408 #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
410 #ifdef CONFIG_ARCH_OMAP2
411 static struct resource omap2_sham_resources[] = {
413 .start = OMAP24XX_SEC_SHA1MD5_BASE,
414 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
415 .flags = IORESOURCE_MEM,
418 .start = INT_24XX_SHA1MD5,
419 .flags = IORESOURCE_IRQ,
422 static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
424 #define omap2_sham_resources NULL
425 #define omap2_sham_resources_sz 0
428 #ifdef CONFIG_ARCH_OMAP3
429 static struct resource omap3_sham_resources[] = {
431 .start = OMAP34XX_SEC_SHA1MD5_BASE,
432 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
433 .flags = IORESOURCE_MEM,
436 .start = INT_34XX_SHA1MD52_IRQ,
437 .flags = IORESOURCE_IRQ,
440 .start = OMAP34XX_DMA_SHA1MD5_RX,
441 .flags = IORESOURCE_DMA,
444 static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
446 #define omap3_sham_resources NULL
447 #define omap3_sham_resources_sz 0
450 static struct platform_device sham_device = {
455 static void omap_init_sham(void)
457 if (cpu_is_omap24xx()) {
458 sham_device.resource = omap2_sham_resources;
459 sham_device.num_resources = omap2_sham_resources_sz;
460 } else if (cpu_is_omap34xx()) {
461 sham_device.resource = omap3_sham_resources;
462 sham_device.num_resources = omap3_sham_resources_sz;
464 pr_err("%s: platform not supported\n", __func__);
467 platform_device_register(&sham_device);
470 static inline void omap_init_sham(void) { }
473 #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
475 #ifdef CONFIG_ARCH_OMAP2
476 static struct resource omap2_aes_resources[] = {
478 .start = OMAP24XX_SEC_AES_BASE,
479 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
480 .flags = IORESOURCE_MEM,
483 .start = OMAP24XX_DMA_AES_TX,
484 .flags = IORESOURCE_DMA,
487 .start = OMAP24XX_DMA_AES_RX,
488 .flags = IORESOURCE_DMA,
491 static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
493 #define omap2_aes_resources NULL
494 #define omap2_aes_resources_sz 0
497 #ifdef CONFIG_ARCH_OMAP3
498 static struct resource omap3_aes_resources[] = {
500 .start = OMAP34XX_SEC_AES_BASE,
501 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
502 .flags = IORESOURCE_MEM,
505 .start = OMAP34XX_DMA_AES2_TX,
506 .flags = IORESOURCE_DMA,
509 .start = OMAP34XX_DMA_AES2_RX,
510 .flags = IORESOURCE_DMA,
513 static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
515 #define omap3_aes_resources NULL
516 #define omap3_aes_resources_sz 0
519 static struct platform_device aes_device = {
524 static void omap_init_aes(void)
526 if (cpu_is_omap24xx()) {
527 aes_device.resource = omap2_aes_resources;
528 aes_device.num_resources = omap2_aes_resources_sz;
529 } else if (cpu_is_omap34xx()) {
530 aes_device.resource = omap3_aes_resources;
531 aes_device.num_resources = omap3_aes_resources_sz;
533 pr_err("%s: platform not supported\n", __func__);
536 platform_device_register(&aes_device);
540 static inline void omap_init_aes(void) { }
543 /*-------------------------------------------------------------------------*/
545 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
547 static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
550 if ((mmc_controller->slots[0].switch_pin > 0) && \
551 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
552 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
553 OMAP_PIN_INPUT_PULLUP);
554 if ((mmc_controller->slots[0].gpio_wp > 0) && \
555 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
556 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
557 OMAP_PIN_INPUT_PULLUP);
559 omap_mux_init_signal("sdmmc_cmd", 0);
560 omap_mux_init_signal("sdmmc_clki", 0);
561 omap_mux_init_signal("sdmmc_clko", 0);
562 omap_mux_init_signal("sdmmc_dat0", 0);
563 omap_mux_init_signal("sdmmc_dat_dir0", 0);
564 omap_mux_init_signal("sdmmc_cmd_dir", 0);
565 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
566 omap_mux_init_signal("sdmmc_dat1", 0);
567 omap_mux_init_signal("sdmmc_dat2", 0);
568 omap_mux_init_signal("sdmmc_dat3", 0);
569 omap_mux_init_signal("sdmmc_dat_dir1", 0);
570 omap_mux_init_signal("sdmmc_dat_dir2", 0);
571 omap_mux_init_signal("sdmmc_dat_dir3", 0);
575 * Use internal loop-back in MMC/SDIO Module Input Clock
578 if (mmc_controller->slots[0].internal_clock) {
579 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
581 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
585 void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
587 char *name = "mmci-omap";
590 pr_err("%s fails: Incomplete platform data\n", __func__);
594 omap242x_mmc_mux(mmc_data[0]);
595 omap_mmc_add(name, 0, OMAP2_MMC1_BASE, OMAP2420_MMC_SIZE,
596 INT_24XX_MMC_IRQ, mmc_data[0]);
601 /*-------------------------------------------------------------------------*/
603 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
604 #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
605 #define OMAP_HDQ_BASE 0x480B2000
607 static struct resource omap_hdq_resources[] = {
609 .start = OMAP_HDQ_BASE,
610 .end = OMAP_HDQ_BASE + 0x1C,
611 .flags = IORESOURCE_MEM,
614 .start = INT_24XX_HDQ_IRQ,
615 .flags = IORESOURCE_IRQ,
618 static struct platform_device omap_hdq_dev = {
622 .platform_data = NULL,
624 .num_resources = ARRAY_SIZE(omap_hdq_resources),
625 .resource = omap_hdq_resources,
627 static inline void omap_hdq_init(void)
629 (void) platform_device_register(&omap_hdq_dev);
632 static inline void omap_hdq_init(void) {}
635 /*---------------------------------------------------------------------------*/
637 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
638 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
639 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
640 static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
643 static struct resource omap_vout_resource[2] = {
647 static struct platform_device omap_vout_device = {
649 .num_resources = ARRAY_SIZE(omap_vout_resource),
650 .resource = &omap_vout_resource[0],
653 static void omap_init_vout(void)
655 if (platform_device_register(&omap_vout_device) < 0)
656 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
659 static inline void omap_init_vout(void) {}
662 /*-------------------------------------------------------------------------*/
664 static int __init omap2_init_devices(void)
667 * please keep these calls, and their implementations above,
668 * in alphabetical order so they're easier to sort through.
683 arch_initcall(omap2_init_devices);
685 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
686 static struct omap_device_pm_latency omap_wdt_latency[] = {
688 .deactivate_func = omap_device_idle_hwmods,
689 .activate_func = omap_device_enable_hwmods,
690 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
694 static int __init omap_init_wdt(void)
697 struct omap_device *od;
698 struct omap_hwmod *oh;
699 char *oh_name = "wd_timer2";
700 char *dev_name = "omap_wdt";
702 if (!cpu_class_is_omap2())
705 oh = omap_hwmod_lookup(oh_name);
707 pr_err("Could not look up wd_timer%d hwmod\n", id);
711 od = omap_device_build(dev_name, id, oh, NULL, 0,
713 ARRAY_SIZE(omap_wdt_latency), 0);
714 WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
718 subsys_initcall(omap_init_wdt);