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>
20 #include <linux/platform_data/omap4-keypad.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/map.h>
27 #include <plat/omap_hwmod.h>
28 #include <plat/omap_device.h>
29 #include <plat/omap4-keypad.h>
37 #define L3_MODULES_MAX_LEN 12
40 static int __init omap3_l3_init(void)
42 struct omap_hwmod *oh;
43 struct platform_device *pdev;
44 char oh_name[L3_MODULES_MAX_LEN];
47 * To avoid code running on other OMAPs in
50 if (!(cpu_is_omap34xx()))
53 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
55 oh = omap_hwmod_lookup(oh_name);
58 pr_err("could not look up %s\n", oh_name);
60 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
63 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
65 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
67 postcore_initcall(omap3_l3_init);
69 static int __init omap4_l3_init(void)
72 struct omap_hwmod *oh[3];
73 struct platform_device *pdev;
74 char oh_name[L3_MODULES_MAX_LEN];
76 /* If dtb is there, the devices will be created dynamically */
77 if (of_have_populated_dt())
81 * To avoid code running on other OMAPs in
84 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
87 for (i = 0; i < L3_MODULES; i++) {
88 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
90 oh[i] = omap_hwmod_lookup(oh_name);
92 pr_err("could not look up %s\n", oh_name);
95 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
98 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
100 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
102 postcore_initcall(omap4_l3_init);
104 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
106 static struct resource omap2cam_resources[] = {
108 .start = OMAP24XX_CAMERA_BASE,
109 .end = OMAP24XX_CAMERA_BASE + 0xfff,
110 .flags = IORESOURCE_MEM,
113 .start = 24 + OMAP_INTC_START,
114 .flags = IORESOURCE_IRQ,
118 static struct platform_device omap2cam_device = {
119 .name = "omap24xxcam",
121 .num_resources = ARRAY_SIZE(omap2cam_resources),
122 .resource = omap2cam_resources,
126 #if defined(CONFIG_IOMMU_API)
128 #include <plat/iommu.h>
130 static struct resource omap3isp_resources[] = {
132 .start = OMAP3430_ISP_BASE,
133 .end = OMAP3430_ISP_END,
134 .flags = IORESOURCE_MEM,
137 .start = OMAP3430_ISP_CCP2_BASE,
138 .end = OMAP3430_ISP_CCP2_END,
139 .flags = IORESOURCE_MEM,
142 .start = OMAP3430_ISP_CCDC_BASE,
143 .end = OMAP3430_ISP_CCDC_END,
144 .flags = IORESOURCE_MEM,
147 .start = OMAP3430_ISP_HIST_BASE,
148 .end = OMAP3430_ISP_HIST_END,
149 .flags = IORESOURCE_MEM,
152 .start = OMAP3430_ISP_H3A_BASE,
153 .end = OMAP3430_ISP_H3A_END,
154 .flags = IORESOURCE_MEM,
157 .start = OMAP3430_ISP_PREV_BASE,
158 .end = OMAP3430_ISP_PREV_END,
159 .flags = IORESOURCE_MEM,
162 .start = OMAP3430_ISP_RESZ_BASE,
163 .end = OMAP3430_ISP_RESZ_END,
164 .flags = IORESOURCE_MEM,
167 .start = OMAP3430_ISP_SBL_BASE,
168 .end = OMAP3430_ISP_SBL_END,
169 .flags = IORESOURCE_MEM,
172 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
173 .end = OMAP3430_ISP_CSI2A_REGS1_END,
174 .flags = IORESOURCE_MEM,
177 .start = OMAP3430_ISP_CSIPHY2_BASE,
178 .end = OMAP3430_ISP_CSIPHY2_END,
179 .flags = IORESOURCE_MEM,
182 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
183 .end = OMAP3630_ISP_CSI2A_REGS2_END,
184 .flags = IORESOURCE_MEM,
187 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
188 .end = OMAP3630_ISP_CSI2C_REGS1_END,
189 .flags = IORESOURCE_MEM,
192 .start = OMAP3630_ISP_CSIPHY1_BASE,
193 .end = OMAP3630_ISP_CSIPHY1_END,
194 .flags = IORESOURCE_MEM,
197 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
198 .end = OMAP3630_ISP_CSI2C_REGS2_END,
199 .flags = IORESOURCE_MEM,
202 .start = 24 + OMAP_INTC_START,
203 .flags = IORESOURCE_IRQ,
207 static struct platform_device omap3isp_device = {
210 .num_resources = ARRAY_SIZE(omap3isp_resources),
211 .resource = omap3isp_resources,
214 static struct omap_iommu_arch_data omap3_isp_iommu = {
218 int omap3_init_camera(struct isp_platform_data *pdata)
220 omap3isp_device.dev.platform_data = pdata;
221 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
223 return platform_device_register(&omap3isp_device);
226 #else /* !CONFIG_IOMMU_API */
228 int omap3_init_camera(struct isp_platform_data *pdata)
235 static inline void omap_init_camera(void)
237 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
238 if (cpu_is_omap24xx())
239 platform_device_register(&omap2cam_device);
243 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
244 *sdp4430_keypad_data, struct omap_board_data *bdata)
246 struct platform_device *pdev;
247 struct omap_hwmod *oh;
248 struct omap4_keypad_platform_data *keypad_data;
249 unsigned int id = -1;
250 char *oh_name = "kbd";
251 char *name = "omap4-keypad";
253 oh = omap_hwmod_lookup(oh_name);
255 pr_err("Could not look up %s\n", oh_name);
259 keypad_data = sdp4430_keypad_data;
261 pdev = omap_device_build(name, id, oh, keypad_data,
262 sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
265 WARN(1, "Can't build omap_device for %s:%s.\n",
267 return PTR_ERR(pdev);
269 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
274 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
275 static inline void __init omap_init_mbox(void)
277 struct omap_hwmod *oh;
278 struct platform_device *pdev;
280 oh = omap_hwmod_lookup("mailbox");
282 pr_err("%s: unable to find hwmod\n", __func__);
286 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
287 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
288 __func__, PTR_ERR(pdev));
291 static inline void omap_init_mbox(void) { }
292 #endif /* CONFIG_OMAP_MBOX_FWK */
294 static inline void omap_init_sti(void) {}
296 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
298 static struct platform_device omap_pcm = {
299 .name = "omap-pcm-audio",
303 static void omap_init_audio(void)
305 platform_device_register(&omap_pcm);
309 static inline void omap_init_audio(void) {}
312 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
313 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
315 static void __init omap_init_mcpdm(void)
317 struct omap_hwmod *oh;
318 struct platform_device *pdev;
320 oh = omap_hwmod_lookup("mcpdm");
322 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
326 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0, NULL, 0, 0);
327 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
330 static inline void omap_init_mcpdm(void) {}
333 #if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
334 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
336 static void __init omap_init_dmic(void)
338 struct omap_hwmod *oh;
339 struct platform_device *pdev;
341 oh = omap_hwmod_lookup("dmic");
343 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
347 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0, NULL, 0, 0);
348 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
351 static inline void omap_init_dmic(void) {}
354 #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
355 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
357 static struct platform_device omap_hdmi_audio = {
358 .name = "omap-hdmi-audio",
362 static void __init omap_init_hdmi_audio(void)
364 struct omap_hwmod *oh;
365 struct platform_device *pdev;
367 oh = omap_hwmod_lookup("dss_hdmi");
369 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
373 pdev = omap_device_build("omap-hdmi-audio-dai",
374 -1, oh, NULL, 0, NULL, 0, 0);
376 "Can't build omap_device for omap-hdmi-audio-dai.\n");
378 platform_device_register(&omap_hdmi_audio);
381 static inline void omap_init_hdmi_audio(void) {}
384 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
386 #include <plat/mcspi.h>
388 static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
390 struct platform_device *pdev;
391 char *name = "omap2_mcspi";
392 struct omap2_mcspi_platform_config *pdata;
394 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
396 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
398 pr_err("Memory allocation for McSPI device failed\n");
402 pdata->num_cs = mcspi_attrib->num_chipselect;
403 switch (oh->class->rev) {
404 case OMAP2_MCSPI_REV:
405 case OMAP3_MCSPI_REV:
406 pdata->regs_offset = 0;
408 case OMAP4_MCSPI_REV:
409 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
412 pr_err("Invalid McSPI Revision value\n");
418 pdev = omap_device_build(name, spi_num, oh, pdata,
419 sizeof(*pdata), NULL, 0, 0);
420 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
426 static void omap_init_mcspi(void)
428 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
432 static inline void omap_init_mcspi(void) {}
435 static struct resource omap2_pmu_resource = {
436 .start = 3 + OMAP_INTC_START,
437 .flags = IORESOURCE_IRQ,
440 static struct resource omap3_pmu_resource = {
441 .start = 3 + OMAP_INTC_START,
442 .flags = IORESOURCE_IRQ,
445 static struct platform_device omap_pmu_device = {
451 static void omap_init_pmu(void)
453 if (cpu_is_omap24xx())
454 omap_pmu_device.resource = &omap2_pmu_resource;
455 else if (cpu_is_omap34xx())
456 omap_pmu_device.resource = &omap3_pmu_resource;
460 platform_device_register(&omap_pmu_device);
464 #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
466 #ifdef CONFIG_ARCH_OMAP2
467 static struct resource omap2_sham_resources[] = {
469 .start = OMAP24XX_SEC_SHA1MD5_BASE,
470 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
471 .flags = IORESOURCE_MEM,
474 .start = 51 + OMAP_INTC_START,
475 .flags = IORESOURCE_IRQ,
478 static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
480 #define omap2_sham_resources NULL
481 #define omap2_sham_resources_sz 0
484 #ifdef CONFIG_ARCH_OMAP3
485 static struct resource omap3_sham_resources[] = {
487 .start = OMAP34XX_SEC_SHA1MD5_BASE,
488 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
489 .flags = IORESOURCE_MEM,
492 .start = 49 + OMAP_INTC_START,
493 .flags = IORESOURCE_IRQ,
496 .start = OMAP34XX_DMA_SHA1MD5_RX,
497 .flags = IORESOURCE_DMA,
500 static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
502 #define omap3_sham_resources NULL
503 #define omap3_sham_resources_sz 0
506 static struct platform_device sham_device = {
511 static void omap_init_sham(void)
513 if (cpu_is_omap24xx()) {
514 sham_device.resource = omap2_sham_resources;
515 sham_device.num_resources = omap2_sham_resources_sz;
516 } else if (cpu_is_omap34xx()) {
517 sham_device.resource = omap3_sham_resources;
518 sham_device.num_resources = omap3_sham_resources_sz;
520 pr_err("%s: platform not supported\n", __func__);
523 platform_device_register(&sham_device);
526 static inline void omap_init_sham(void) { }
529 #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
531 #ifdef CONFIG_ARCH_OMAP2
532 static struct resource omap2_aes_resources[] = {
534 .start = OMAP24XX_SEC_AES_BASE,
535 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
536 .flags = IORESOURCE_MEM,
539 .start = OMAP24XX_DMA_AES_TX,
540 .flags = IORESOURCE_DMA,
543 .start = OMAP24XX_DMA_AES_RX,
544 .flags = IORESOURCE_DMA,
547 static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
549 #define omap2_aes_resources NULL
550 #define omap2_aes_resources_sz 0
553 #ifdef CONFIG_ARCH_OMAP3
554 static struct resource omap3_aes_resources[] = {
556 .start = OMAP34XX_SEC_AES_BASE,
557 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
558 .flags = IORESOURCE_MEM,
561 .start = OMAP34XX_DMA_AES2_TX,
562 .flags = IORESOURCE_DMA,
565 .start = OMAP34XX_DMA_AES2_RX,
566 .flags = IORESOURCE_DMA,
569 static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
571 #define omap3_aes_resources NULL
572 #define omap3_aes_resources_sz 0
575 static struct platform_device aes_device = {
580 static void omap_init_aes(void)
582 if (cpu_is_omap24xx()) {
583 aes_device.resource = omap2_aes_resources;
584 aes_device.num_resources = omap2_aes_resources_sz;
585 } else if (cpu_is_omap34xx()) {
586 aes_device.resource = omap3_aes_resources;
587 aes_device.num_resources = omap3_aes_resources_sz;
589 pr_err("%s: platform not supported\n", __func__);
592 platform_device_register(&aes_device);
596 static inline void omap_init_aes(void) { }
599 /*-------------------------------------------------------------------------*/
601 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
602 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
603 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
604 static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
607 static struct resource omap_vout_resource[2] = {
611 static struct platform_device omap_vout_device = {
613 .num_resources = ARRAY_SIZE(omap_vout_resource),
614 .resource = &omap_vout_resource[0],
617 static void omap_init_vout(void)
619 if (platform_device_register(&omap_vout_device) < 0)
620 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
623 static inline void omap_init_vout(void) {}
626 /*-------------------------------------------------------------------------*/
628 static int __init omap2_init_devices(void)
631 * please keep these calls, and their implementations above,
632 * in alphabetical order so they're easier to sort through.
636 omap_init_hdmi_audio();
638 /* If dtb is there, the devices will be created dynamically */
639 if (!of_have_populated_dt()) {
652 arch_initcall(omap2_init_devices);
654 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
655 static int __init omap_init_wdt(void)
658 struct platform_device *pdev;
659 struct omap_hwmod *oh;
660 char *oh_name = "wd_timer2";
661 char *dev_name = "omap_wdt";
663 if (!cpu_class_is_omap2() || of_have_populated_dt())
666 oh = omap_hwmod_lookup(oh_name);
668 pr_err("Could not look up wd_timer%d hwmod\n", id);
672 pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0);
673 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
677 subsys_initcall(omap_init_wdt);