blob: daa0ff65f59941e24eadc5908e543a79f8d97f55 [file] [log] [blame]
Tony Lindgren1dbae812005-11-10 14:26:51 +00001/*
2 * linux/arch/arm/mach-omap2/devices.c
3 *
4 * OMAP2 platform device setup/initialization
5 *
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.
10 */
Russell King2f8163b2011-07-26 10:53:52 +010011#include <linux/gpio.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000012#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010015#include <linux/io.h>
Kevin Hilman917fa282008-12-10 17:37:17 -080016#include <linux/clk.h>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053017#include <linux/err.h>
Charulatha V1a5d8192011-02-02 17:52:14 +053018#include <linux/slab.h>
Benoit Coussonad8dfac2011-08-12 13:48:47 +020019#include <linux/of.h>
Matt Porter484202f2012-09-17 16:26:11 -070020#include <linux/pinctrl/machine.h>
Felipe Balbi0f1142a2012-03-16 22:47:48 -070021#include <linux/platform_data/omap4-keypad.h>
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +053022#include <linux/platform_data/omap_ocp2scp.h>
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +053023#include <linux/usb/omap_control_usb.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000024
Tony Lindgren1dbae812005-11-10 14:26:51 +000025#include <asm/mach-types.h>
26#include <asm/mach/map.h>
27
Tony Lindgren45c3eb72012-11-30 08:41:50 -080028#include <linux/omap-dma.h>
Tony Lindgren2a296c82012-10-02 17:41:35 -070029
Tony Lindgrenee0839c2012-02-24 10:34:35 -080030#include "iomap.h"
Tony Lindgren2a296c82012-10-02 17:41:35 -070031#include "omap_hwmod.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070032#include "omap_device.h"
Tony Lindgren0e701562012-09-20 11:42:20 -070033#include "omap4-keypad.h"
Tony Lindgren1dbae812005-11-10 14:26:51 +000034
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070035#include "soc.h"
36#include "common.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080037#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060038#include "control.h"
Laurent Pincharta11f6702009-12-14 08:09:07 -030039#include "devices.h"
Lokesh Vutlad5e7c862012-10-15 14:03:51 -070040#include "dma.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080041
sricharan0abcf612011-02-08 14:10:45 +053042#define L3_MODULES_MAX_LEN 12
sricharana4dc6162011-03-09 16:00:29 +053043#define L3_MODULES 3
sricharan0abcf612011-02-08 14:10:45 +053044
45static int __init omap3_l3_init(void)
46{
sricharan0abcf612011-02-08 14:10:45 +053047 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -070048 struct platform_device *pdev;
sricharan0abcf612011-02-08 14:10:45 +053049 char oh_name[L3_MODULES_MAX_LEN];
50
51 /*
52 * To avoid code running on other OMAPs in
53 * multi-omap builds
54 */
55 if (!(cpu_is_omap34xx()))
56 return -ENODEV;
57
Paul Walmsleyeeb37112012-04-13 06:34:32 -060058 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
sricharan0abcf612011-02-08 14:10:45 +053059
60 oh = omap_hwmod_lookup(oh_name);
61
62 if (!oh)
63 pr_err("could not look up %s\n", oh_name);
64
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070065 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
sricharan0abcf612011-02-08 14:10:45 +053066
Kevin Hilman3528c582011-07-21 13:48:45 -070067 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharan0abcf612011-02-08 14:10:45 +053068
Kevin Hilman3528c582011-07-21 13:48:45 -070069 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharan0abcf612011-02-08 14:10:45 +053070}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -080071omap_postcore_initcall(omap3_l3_init);
sricharan0abcf612011-02-08 14:10:45 +053072
sricharana4dc6162011-03-09 16:00:29 +053073static int __init omap4_l3_init(void)
74{
Paul Walmsleyeeb37112012-04-13 06:34:32 -060075 int i;
sricharana4dc6162011-03-09 16:00:29 +053076 struct omap_hwmod *oh[3];
Kevin Hilman3528c582011-07-21 13:48:45 -070077 struct platform_device *pdev;
sricharana4dc6162011-03-09 16:00:29 +053078 char oh_name[L3_MODULES_MAX_LEN];
79
Benoit Coussonad8dfac2011-08-12 13:48:47 +020080 /* If dtb is there, the devices will be created dynamically */
81 if (of_have_populated_dt())
82 return -ENODEV;
83
sricharana4dc6162011-03-09 16:00:29 +053084 /*
85 * To avoid code running on other OMAPs in
86 * multi-omap builds
87 */
R Sricharane17933c2011-11-04 15:52:59 +053088 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
sricharana4dc6162011-03-09 16:00:29 +053089 return -ENODEV;
90
91 for (i = 0; i < L3_MODULES; i++) {
Paul Walmsleyeeb37112012-04-13 06:34:32 -060092 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
sricharana4dc6162011-03-09 16:00:29 +053093
94 oh[i] = omap_hwmod_lookup(oh_name);
95 if (!(oh[i]))
96 pr_err("could not look up %s\n", oh_name);
97 }
98
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070099 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
sricharana4dc6162011-03-09 16:00:29 +0530100
Kevin Hilman3528c582011-07-21 13:48:45 -0700101 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharana4dc6162011-03-09 16:00:29 +0530102
Kevin Hilman3528c582011-07-21 13:48:45 -0700103 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharana4dc6162011-03-09 16:00:29 +0530104}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800105omap_postcore_initcall(omap4_l3_init);
sricharana4dc6162011-03-09 16:00:29 +0530106
Tony Lindgren828c7072009-03-23 18:23:49 -0700107#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800108
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300109static struct resource omap2cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800110 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700111 .start = OMAP24XX_CAMERA_BASE,
112 .end = OMAP24XX_CAMERA_BASE + 0xfff,
113 .flags = IORESOURCE_MEM,
114 },
115 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700116 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700117 .flags = IORESOURCE_IRQ,
118 }
119};
120
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300121static struct platform_device omap2cam_device = {
Tony Lindgren828c7072009-03-23 18:23:49 -0700122 .name = "omap24xxcam",
123 .id = -1,
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300124 .num_resources = ARRAY_SIZE(omap2cam_resources),
125 .resource = omap2cam_resources,
Tony Lindgren828c7072009-03-23 18:23:49 -0700126};
Laurent Pincharta11f6702009-12-14 08:09:07 -0300127#endif
Tony Lindgren828c7072009-03-23 18:23:49 -0700128
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200129#if defined(CONFIG_IOMMU_API)
130
Tony Lindgren2ab7c842012-11-02 12:24:14 -0700131#include <linux/platform_data/iommu-omap.h>
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200132
Tony Lindgren828c7072009-03-23 18:23:49 -0700133static struct resource omap3isp_resources[] = {
134 {
135 .start = OMAP3430_ISP_BASE,
136 .end = OMAP3430_ISP_END,
137 .flags = IORESOURCE_MEM,
138 },
139 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700140 .start = OMAP3430_ISP_CCP2_BASE,
141 .end = OMAP3430_ISP_CCP2_END,
142 .flags = IORESOURCE_MEM,
143 },
144 {
145 .start = OMAP3430_ISP_CCDC_BASE,
146 .end = OMAP3430_ISP_CCDC_END,
147 .flags = IORESOURCE_MEM,
148 },
149 {
150 .start = OMAP3430_ISP_HIST_BASE,
151 .end = OMAP3430_ISP_HIST_END,
152 .flags = IORESOURCE_MEM,
153 },
154 {
155 .start = OMAP3430_ISP_H3A_BASE,
156 .end = OMAP3430_ISP_H3A_END,
157 .flags = IORESOURCE_MEM,
158 },
159 {
160 .start = OMAP3430_ISP_PREV_BASE,
161 .end = OMAP3430_ISP_PREV_END,
162 .flags = IORESOURCE_MEM,
163 },
164 {
165 .start = OMAP3430_ISP_RESZ_BASE,
166 .end = OMAP3430_ISP_RESZ_END,
167 .flags = IORESOURCE_MEM,
168 },
169 {
170 .start = OMAP3430_ISP_SBL_BASE,
171 .end = OMAP3430_ISP_SBL_END,
172 .flags = IORESOURCE_MEM,
173 },
174 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300175 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
176 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700177 .flags = IORESOURCE_MEM,
178 },
179 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300180 .start = OMAP3430_ISP_CSIPHY2_BASE,
181 .end = OMAP3430_ISP_CSIPHY2_END,
182 .flags = IORESOURCE_MEM,
183 },
184 {
185 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
186 .end = OMAP3630_ISP_CSI2A_REGS2_END,
187 .flags = IORESOURCE_MEM,
188 },
189 {
190 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
191 .end = OMAP3630_ISP_CSI2C_REGS1_END,
192 .flags = IORESOURCE_MEM,
193 },
194 {
195 .start = OMAP3630_ISP_CSIPHY1_BASE,
196 .end = OMAP3630_ISP_CSIPHY1_END,
197 .flags = IORESOURCE_MEM,
198 },
199 {
200 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
201 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700202 .flags = IORESOURCE_MEM,
203 },
204 {
Sakari Ailusc19d19e2012-10-14 07:31:48 -0300205 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
206 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
207 .flags = IORESOURCE_MEM,
208 },
209 {
210 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
211 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
212 .flags = IORESOURCE_MEM,
213 },
214 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700215 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700216 .flags = IORESOURCE_IRQ,
217 }
218};
219
220static struct platform_device omap3isp_device = {
221 .name = "omap3isp",
222 .id = -1,
223 .num_resources = ARRAY_SIZE(omap3isp_resources),
224 .resource = omap3isp_resources,
225};
226
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300227static struct omap_iommu_arch_data omap3_isp_iommu = {
Omar Ramirez Luna72b15b62012-11-19 19:05:50 -0600228 .name = "mmu_isp",
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300229};
230
Laurent Pincharta11f6702009-12-14 08:09:07 -0300231int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700232{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300233 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300234 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
235
Laurent Pincharta11f6702009-12-14 08:09:07 -0300236 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700237}
Tony Lindgren828c7072009-03-23 18:23:49 -0700238
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200239#else /* !CONFIG_IOMMU_API */
240
241int omap3_init_camera(struct isp_platform_data *pdata)
242{
243 return 0;
244}
245
246#endif
247
Tony Lindgren1dbae812005-11-10 14:26:51 +0000248static inline void omap_init_camera(void)
249{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300250#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
251 if (cpu_is_omap24xx())
252 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000253#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300254}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000255
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +0530256#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
257static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
258 .type = 1,
259};
260
261struct resource omap4_control_usb_res[] = {
262 {
263 .name = "control_dev_conf",
264 .start = 0x4a002300,
265 .end = 0x4a002303,
266 .flags = IORESOURCE_MEM,
267 },
268 {
269 .name = "otghs_control",
270 .start = 0x4a00233c,
271 .end = 0x4a00233f,
272 .flags = IORESOURCE_MEM,
273 },
274};
275
276static struct platform_device omap4_control_usb = {
277 .name = "omap-control-usb",
278 .id = -1,
279 .dev = {
280 .platform_data = &omap4_control_usb_pdata,
281 },
282 .num_resources = 2,
283 .resource = omap4_control_usb_res,
284};
285
286static inline void __init omap_init_control_usb(void)
287{
288 if (!cpu_is_omap44xx())
289 return;
290
291 if (platform_device_register(&omap4_control_usb))
292 pr_err("Error registering omap_control_usb device\n");
293}
294
295#else
296static inline void omap_init_control_usb(void) { }
297#endif /* CONFIG_OMAP_CONTROL_USB */
298
Syed Rafiuddin59556762010-12-27 05:51:45 +0000299int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700300 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000301{
Kevin Hilman3528c582011-07-21 13:48:45 -0700302 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000303 struct omap_hwmod *oh;
304 struct omap4_keypad_platform_data *keypad_data;
305 unsigned int id = -1;
306 char *oh_name = "kbd";
307 char *name = "omap4-keypad";
308
309 oh = omap_hwmod_lookup(oh_name);
310 if (!oh) {
311 pr_err("Could not look up %s\n", oh_name);
312 return -ENODEV;
313 }
314
315 keypad_data = sdp4430_keypad_data;
316
Kevin Hilman3528c582011-07-21 13:48:45 -0700317 pdev = omap_device_build(name, id, oh, keypad_data,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700318 sizeof(struct omap4_keypad_platform_data));
Syed Rafiuddin59556762010-12-27 05:51:45 +0000319
Kevin Hilman3528c582011-07-21 13:48:45 -0700320 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300321 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000322 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700323 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000324 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700325 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000326
327 return 0;
328}
329
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700330#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800331static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800332{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800333 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700334 struct platform_device *pdev;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800335
336 oh = omap_hwmod_lookup("mailbox");
337 if (!oh) {
338 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700339 return;
340 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800341
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700342 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700343 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
344 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800345}
346#else
347static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700348#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800349
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100350static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100351
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000352#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
353
354static struct platform_device omap_pcm = {
355 .name = "omap-pcm-audio",
356 .id = -1,
357};
358
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000359static void omap_init_audio(void)
360{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000361 platform_device_register(&omap_pcm);
362}
363
364#else
365static inline void omap_init_audio(void) {}
366#endif
367
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600368#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
369 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
370
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800371static void __init omap_init_mcpdm(void)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600372{
373 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200374 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600375
376 oh = omap_hwmod_lookup("mcpdm");
Peter Ujfalusi5fe0a122013-06-11 10:31:58 +0200377 if (!oh)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600378 return;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600379
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700380 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200381 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600382}
383#else
384static inline void omap_init_mcpdm(void) {}
385#endif
386
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800387#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
388 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
389
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800390static void __init omap_init_dmic(void)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800391{
392 struct omap_hwmod *oh;
393 struct platform_device *pdev;
394
395 oh = omap_hwmod_lookup("dmic");
Peter Ujfalusi6d931cf2013-06-11 10:31:59 +0200396 if (!oh)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800397 return;
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800398
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700399 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800400 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
401}
402#else
403static inline void omap_init_dmic(void) {}
404#endif
405
Ricardo Neri5eeec212012-05-09 14:19:14 -0700406#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
407 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
408
409static struct platform_device omap_hdmi_audio = {
410 .name = "omap-hdmi-audio",
411 .id = -1,
412};
413
414static void __init omap_init_hdmi_audio(void)
415{
416 struct omap_hwmod *oh;
417 struct platform_device *pdev;
418
419 oh = omap_hwmod_lookup("dss_hdmi");
Peter Ujfalusi7252db52013-06-11 10:32:00 +0200420 if (!oh)
Ricardo Neri5eeec212012-05-09 14:19:14 -0700421 return;
Ricardo Neri5eeec212012-05-09 14:19:14 -0700422
Paul Walmsley6efc3fe2013-02-12 03:58:35 +0000423 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
Ricardo Neri5eeec212012-05-09 14:19:14 -0700424 WARN(IS_ERR(pdev),
425 "Can't build omap_device for omap-hdmi-audio-dai.\n");
426
427 platform_device_register(&omap_hdmi_audio);
428}
429#else
430static inline void omap_init_hdmi_audio(void) {}
431#endif
432
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300433#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700434
Arnd Bergmann22037472012-08-24 15:21:06 +0200435#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700436
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800437static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700438{
Kevin Hilman3528c582011-07-21 13:48:45 -0700439 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530440 char *name = "omap2_mcspi";
441 struct omap2_mcspi_platform_config *pdata;
442 static int spi_num;
443 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700444
Charulatha V1a5d8192011-02-02 17:52:14 +0530445 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
446 if (!pdata) {
447 pr_err("Memory allocation for McSPI device failed\n");
448 return -ENOMEM;
449 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700450
Charulatha V1a5d8192011-02-02 17:52:14 +0530451 pdata->num_cs = mcspi_attrib->num_chipselect;
452 switch (oh->class->rev) {
453 case OMAP2_MCSPI_REV:
454 case OMAP3_MCSPI_REV:
455 pdata->regs_offset = 0;
456 break;
457 case OMAP4_MCSPI_REV:
458 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
459 break;
460 default:
461 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100462 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530463 return -EINVAL;
464 }
465
466 spi_num++;
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700467 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700468 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530469 name, oh->name);
470 kfree(pdata);
471 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700472}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700473
474static void omap_init_mcspi(void)
475{
Charulatha V1a5d8192011-02-02 17:52:14 +0530476 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700477}
478
479#else
480static inline void omap_init_mcspi(void) {}
481#endif
482
Paul Walmsley4848d462012-09-23 17:28:27 -0600483/**
484 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
485 *
486 * Bind the RNG hwmod to the RNG omap_device. No return value.
487 */
488static void omap_init_rng(void)
489{
490 struct omap_hwmod *oh;
491 struct platform_device *pdev;
492
493 oh = omap_hwmod_lookup("rng");
494 if (!oh)
495 return;
496
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700497 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
Paul Walmsley4848d462012-09-23 17:28:27 -0600498 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
499}
Will Deacon88341332010-04-09 13:54:43 +0100500
Mark A. Greer26f88e62013-03-18 10:06:32 -0600501static void __init omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300502{
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600503 struct omap_hwmod *oh;
504 struct platform_device *pdev;
Mark A. Greere569e992013-03-30 15:49:19 -0600505
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600506 oh = omap_hwmod_lookup("sham");
507 if (!oh)
508 return;
Mark A. Greere569e992013-03-30 15:49:19 -0600509
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600510 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
511 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300512}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300513
Mark A. Greer14ae5562012-12-21 09:28:10 -0700514static void __init omap_init_aes(void)
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800515{
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700516 struct omap_hwmod *oh;
517 struct platform_device *pdev;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700518
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700519 oh = omap_hwmod_lookup("aes");
520 if (!oh)
521 return;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700522
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700523 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
524 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800525}
526
Tony Lindgrend8874662008-12-10 17:37:16 -0800527/*-------------------------------------------------------------------------*/
528
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700529#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
530 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
531#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
532static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
533};
534#else
535static struct resource omap_vout_resource[2] = {
536};
537#endif
538
539static struct platform_device omap_vout_device = {
540 .name = "omap_vout",
541 .num_resources = ARRAY_SIZE(omap_vout_resource),
542 .resource = &omap_vout_resource[0],
543 .id = -1,
544};
545static void omap_init_vout(void)
546{
547 if (platform_device_register(&omap_vout_device) < 0)
548 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
549}
550#else
551static inline void omap_init_vout(void) {}
552#endif
553
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530554#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
555static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
556{
557 int cnt = 0;
558
559 while (ocp2scp_dev->drv_name != NULL) {
560 cnt++;
561 ocp2scp_dev++;
562 }
563
564 return cnt;
565}
566
Tony Lindgrene407ee02013-01-21 10:17:03 -0800567static void __init omap_init_ocp2scp(void)
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530568{
569 struct omap_hwmod *oh;
570 struct platform_device *pdev;
571 int bus_id = -1, dev_cnt = 0, i;
572 struct omap_ocp2scp_dev *ocp2scp_dev;
573 const char *oh_name, *name;
574 struct omap_ocp2scp_platform_data *pdata;
575
576 if (!cpu_is_omap44xx())
577 return;
578
579 oh_name = "ocp2scp_usb_phy";
580 name = "omap-ocp2scp";
581
582 oh = omap_hwmod_lookup(oh_name);
583 if (!oh) {
584 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
585 oh_name);
586 return;
587 }
588
589 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
590 if (!pdata) {
591 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
592 return;
593 }
594
595 ocp2scp_dev = oh->dev_attr;
596 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
597
598 if (!dev_cnt) {
599 pr_err("%s: No devices connected to ocp2scp\n", __func__);
600 kfree(pdata);
601 return;
602 }
603
604 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
605 * dev_cnt, GFP_KERNEL);
606 if (!pdata->devices) {
607 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
608 kfree(pdata);
609 return;
610 }
611
612 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
613 pdata->devices[i] = ocp2scp_dev;
614
615 pdata->dev_cnt = dev_cnt;
616
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700617 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata));
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530618 if (IS_ERR(pdev)) {
619 pr_err("Could not build omap_device for %s %s\n",
620 name, oh_name);
621 kfree(pdata->devices);
622 kfree(pdata);
623 return;
624 }
625}
626#else
627static inline void omap_init_ocp2scp(void) { }
628#endif
629
Tony Lindgren1dbae812005-11-10 14:26:51 +0000630/*-------------------------------------------------------------------------*/
631
632static int __init omap2_init_devices(void)
633{
Matt Porter484202f2012-09-17 16:26:11 -0700634 /* Enable dummy states for those platforms without pinctrl support */
635 if (!of_have_populated_dt())
636 pinctrl_provide_dummies();
637
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700638 /*
639 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000640 * in alphabetical order so they're easier to sort through.
641 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000642 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700643 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700644 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800645 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100646 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300647 if (!of_have_populated_dt()) {
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +0530648 omap_init_control_usb();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300649 omap_init_dmic();
Peter Ujfalusi4b21ffc2012-05-02 15:23:19 +0300650 omap_init_mcpdm();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100651 omap_init_mcspi();
Mark A. Greer114d7a82013-03-18 10:06:33 -0600652 omap_init_sham();
Mark A. Greer53335ac2012-12-21 09:28:12 -0700653 omap_init_aes();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300654 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100655 omap_init_sti();
Paul Walmsley4848d462012-09-23 17:28:27 -0600656 omap_init_rng();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700657 omap_init_vout();
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530658 omap_init_ocp2scp();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000659
660 return 0;
661}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800662omap_arch_initcall(omap2_init_devices);