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/pinctrl/machine.h>
21 #include <linux/platform_data/omap4-keypad.h>
22 #include <linux/platform_data/mailbox-omap.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/map.h>
27 #include <linux/omap-dma.h>
30 #include "omap_hwmod.h"
31 #include "omap_device.h"
32 #include "omap4-keypad.h"
40 #define L3_MODULES_MAX_LEN 12
43 static int __init omap3_l3_init(void)
45 struct omap_hwmod *oh;
46 struct platform_device *pdev;
47 char oh_name[L3_MODULES_MAX_LEN];
50 * To avoid code running on other OMAPs in
53 if (!(cpu_is_omap34xx()))
56 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 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
65 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
69 omap_postcore_initcall(omap3_l3_init);
71 static int __init omap4_l3_init(void)
74 struct omap_hwmod *oh[3];
75 struct platform_device *pdev;
76 char oh_name[L3_MODULES_MAX_LEN];
78 /* If dtb is there, the devices will be created dynamically */
79 if (of_have_populated_dt())
83 * To avoid code running on other OMAPs in
86 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
89 for (i = 0; i < L3_MODULES; i++) {
90 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
92 oh[i] = omap_hwmod_lookup(oh_name);
94 pr_err("could not look up %s\n", oh_name);
97 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
99 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
101 return PTR_RET(pdev);
103 omap_postcore_initcall(omap4_l3_init);
105 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
107 static struct resource omap2cam_resources[] = {
109 .start = OMAP24XX_CAMERA_BASE,
110 .end = OMAP24XX_CAMERA_BASE + 0xfff,
111 .flags = IORESOURCE_MEM,
114 .start = 24 + OMAP_INTC_START,
115 .flags = IORESOURCE_IRQ,
119 static struct platform_device omap2cam_device = {
120 .name = "omap24xxcam",
122 .num_resources = ARRAY_SIZE(omap2cam_resources),
123 .resource = omap2cam_resources,
127 #if defined(CONFIG_IOMMU_API)
129 #include <linux/platform_data/iommu-omap.h>
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 = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
204 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
205 .flags = IORESOURCE_MEM,
208 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
209 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
210 .flags = IORESOURCE_MEM,
213 .start = 24 + OMAP_INTC_START,
214 .flags = IORESOURCE_IRQ,
218 static struct platform_device omap3isp_device = {
221 .num_resources = ARRAY_SIZE(omap3isp_resources),
222 .resource = omap3isp_resources,
225 static struct omap_iommu_arch_data omap3_isp_iommu = {
229 int omap3_init_camera(struct isp_platform_data *pdata)
231 omap3isp_device.dev.platform_data = pdata;
232 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
234 return platform_device_register(&omap3isp_device);
237 #else /* !CONFIG_IOMMU_API */
239 int omap3_init_camera(struct isp_platform_data *pdata)
246 static inline void omap_init_camera(void)
248 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
249 if (cpu_is_omap24xx())
250 platform_device_register(&omap2cam_device);
254 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
255 *sdp4430_keypad_data, struct omap_board_data *bdata)
257 struct platform_device *pdev;
258 struct omap_hwmod *oh;
259 struct omap4_keypad_platform_data *keypad_data;
260 unsigned int id = -1;
261 char *oh_name = "kbd";
262 char *name = "omap4-keypad";
264 oh = omap_hwmod_lookup(oh_name);
266 pr_err("Could not look up %s\n", oh_name);
270 keypad_data = sdp4430_keypad_data;
272 pdev = omap_device_build(name, id, oh, keypad_data,
273 sizeof(struct omap4_keypad_platform_data));
276 WARN(1, "Can't build omap_device for %s:%s.\n",
278 return PTR_ERR(pdev);
280 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
285 #if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
286 static inline void __init omap_init_mbox(void)
288 struct omap_hwmod *oh;
289 struct platform_device *pdev;
290 struct omap_mbox_pdata *pdata;
292 oh = omap_hwmod_lookup("mailbox");
294 pr_err("%s: unable to find hwmod\n", __func__);
298 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
302 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
303 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
304 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
305 __func__, PTR_ERR(pdev));
308 static inline void omap_init_mbox(void) { }
309 #endif /* CONFIG_OMAP2PLUS_MBOX */
311 static inline void omap_init_sti(void) {}
313 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
315 static struct platform_device omap_pcm = {
316 .name = "omap-pcm-audio",
320 static void omap_init_audio(void)
322 platform_device_register(&omap_pcm);
326 static inline void omap_init_audio(void) {}
329 #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
330 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
332 static struct platform_device omap_hdmi_audio = {
333 .name = "omap-hdmi-audio",
337 static void __init omap_init_hdmi_audio(void)
339 struct omap_hwmod *oh;
340 struct platform_device *pdev;
342 oh = omap_hwmod_lookup("dss_hdmi");
346 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
348 "Can't build omap_device for omap-hdmi-audio-dai.\n");
350 platform_device_register(&omap_hdmi_audio);
353 static inline void omap_init_hdmi_audio(void) {}
356 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
358 #include <linux/platform_data/spi-omap2-mcspi.h>
360 static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
362 struct platform_device *pdev;
363 char *name = "omap2_mcspi";
364 struct omap2_mcspi_platform_config *pdata;
366 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
368 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
370 pr_err("Memory allocation for McSPI device failed\n");
374 pdata->num_cs = mcspi_attrib->num_chipselect;
375 switch (oh->class->rev) {
376 case OMAP2_MCSPI_REV:
377 case OMAP3_MCSPI_REV:
378 pdata->regs_offset = 0;
380 case OMAP4_MCSPI_REV:
381 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
384 pr_err("Invalid McSPI Revision value\n");
390 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
391 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
397 static void omap_init_mcspi(void)
399 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
403 static inline void omap_init_mcspi(void) {}
407 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
409 * Bind the RNG hwmod to the RNG omap_device. No return value.
411 static void omap_init_rng(void)
413 struct omap_hwmod *oh;
414 struct platform_device *pdev;
416 oh = omap_hwmod_lookup("rng");
420 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
421 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
424 static void __init omap_init_sham(void)
426 struct omap_hwmod *oh;
427 struct platform_device *pdev;
429 oh = omap_hwmod_lookup("sham");
433 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
434 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
437 static void __init omap_init_aes(void)
439 struct omap_hwmod *oh;
440 struct platform_device *pdev;
442 oh = omap_hwmod_lookup("aes");
446 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
447 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
450 /*-------------------------------------------------------------------------*/
452 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
453 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
454 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
455 static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
458 static struct resource omap_vout_resource[2] = {
462 static struct platform_device omap_vout_device = {
464 .num_resources = ARRAY_SIZE(omap_vout_resource),
465 .resource = &omap_vout_resource[0],
468 static void omap_init_vout(void)
470 if (platform_device_register(&omap_vout_device) < 0)
471 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
474 static inline void omap_init_vout(void) {}
477 /*-------------------------------------------------------------------------*/
479 static int __init omap2_init_devices(void)
481 /* Enable dummy states for those platforms without pinctrl support */
482 if (!of_have_populated_dt())
483 pinctrl_provide_dummies();
486 * please keep these calls, and their implementations above,
487 * in alphabetical order so they're easier to sort through.
491 omap_init_hdmi_audio();
493 /* If dtb is there, the devices will be created dynamically */
494 if (!of_have_populated_dt()) {
505 omap_arch_initcall(omap2_init_devices);