blob: 73762accd128bf63f35f3d51535d02ff50ab373d [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>
Suman Annab8a7cf82013-01-28 17:21:58 -060023#include <linux/platform_data/mailbox-omap.h>
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +053024#include <linux/usb/omap_control_usb.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000025
Tony Lindgren1dbae812005-11-10 14:26:51 +000026#include <asm/mach-types.h>
27#include <asm/mach/map.h>
28
Tony Lindgren45c3eb72012-11-30 08:41:50 -080029#include <linux/omap-dma.h>
Tony Lindgren2a296c82012-10-02 17:41:35 -070030
Tony Lindgrenee0839c2012-02-24 10:34:35 -080031#include "iomap.h"
Tony Lindgren2a296c82012-10-02 17:41:35 -070032#include "omap_hwmod.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070033#include "omap_device.h"
Tony Lindgren0e701562012-09-20 11:42:20 -070034#include "omap4-keypad.h"
Tony Lindgren1dbae812005-11-10 14:26:51 +000035
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070036#include "soc.h"
37#include "common.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080038#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060039#include "control.h"
Laurent Pincharta11f6702009-12-14 08:09:07 -030040#include "devices.h"
Lokesh Vutlad5e7c862012-10-15 14:03:51 -070041#include "dma.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080042
sricharan0abcf612011-02-08 14:10:45 +053043#define L3_MODULES_MAX_LEN 12
sricharana4dc6162011-03-09 16:00:29 +053044#define L3_MODULES 3
sricharan0abcf612011-02-08 14:10:45 +053045
46static int __init omap3_l3_init(void)
47{
sricharan0abcf612011-02-08 14:10:45 +053048 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -070049 struct platform_device *pdev;
sricharan0abcf612011-02-08 14:10:45 +053050 char oh_name[L3_MODULES_MAX_LEN];
51
52 /*
53 * To avoid code running on other OMAPs in
54 * multi-omap builds
55 */
56 if (!(cpu_is_omap34xx()))
57 return -ENODEV;
58
Paul Walmsleyeeb37112012-04-13 06:34:32 -060059 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
sricharan0abcf612011-02-08 14:10:45 +053060
61 oh = omap_hwmod_lookup(oh_name);
62
63 if (!oh)
64 pr_err("could not look up %s\n", oh_name);
65
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070066 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
sricharan0abcf612011-02-08 14:10:45 +053067
Kevin Hilman3528c582011-07-21 13:48:45 -070068 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharan0abcf612011-02-08 14:10:45 +053069
Kevin Hilman3528c582011-07-21 13:48:45 -070070 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharan0abcf612011-02-08 14:10:45 +053071}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -080072omap_postcore_initcall(omap3_l3_init);
sricharan0abcf612011-02-08 14:10:45 +053073
sricharana4dc6162011-03-09 16:00:29 +053074static int __init omap4_l3_init(void)
75{
Paul Walmsleyeeb37112012-04-13 06:34:32 -060076 int i;
sricharana4dc6162011-03-09 16:00:29 +053077 struct omap_hwmod *oh[3];
Kevin Hilman3528c582011-07-21 13:48:45 -070078 struct platform_device *pdev;
sricharana4dc6162011-03-09 16:00:29 +053079 char oh_name[L3_MODULES_MAX_LEN];
80
Benoit Coussonad8dfac2011-08-12 13:48:47 +020081 /* If dtb is there, the devices will be created dynamically */
82 if (of_have_populated_dt())
83 return -ENODEV;
84
sricharana4dc6162011-03-09 16:00:29 +053085 /*
86 * To avoid code running on other OMAPs in
87 * multi-omap builds
88 */
R Sricharane17933c2011-11-04 15:52:59 +053089 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
sricharana4dc6162011-03-09 16:00:29 +053090 return -ENODEV;
91
92 for (i = 0; i < L3_MODULES; i++) {
Paul Walmsleyeeb37112012-04-13 06:34:32 -060093 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
sricharana4dc6162011-03-09 16:00:29 +053094
95 oh[i] = omap_hwmod_lookup(oh_name);
96 if (!(oh[i]))
97 pr_err("could not look up %s\n", oh_name);
98 }
99
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700100 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
sricharana4dc6162011-03-09 16:00:29 +0530101
Kevin Hilman3528c582011-07-21 13:48:45 -0700102 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharana4dc6162011-03-09 16:00:29 +0530103
Kevin Hilman3528c582011-07-21 13:48:45 -0700104 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharana4dc6162011-03-09 16:00:29 +0530105}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -0800106omap_postcore_initcall(omap4_l3_init);
sricharana4dc6162011-03-09 16:00:29 +0530107
Tony Lindgren828c7072009-03-23 18:23:49 -0700108#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800109
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300110static struct resource omap2cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800111 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700112 .start = OMAP24XX_CAMERA_BASE,
113 .end = OMAP24XX_CAMERA_BASE + 0xfff,
114 .flags = IORESOURCE_MEM,
115 },
116 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700117 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700118 .flags = IORESOURCE_IRQ,
119 }
120};
121
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300122static struct platform_device omap2cam_device = {
Tony Lindgren828c7072009-03-23 18:23:49 -0700123 .name = "omap24xxcam",
124 .id = -1,
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300125 .num_resources = ARRAY_SIZE(omap2cam_resources),
126 .resource = omap2cam_resources,
Tony Lindgren828c7072009-03-23 18:23:49 -0700127};
Laurent Pincharta11f6702009-12-14 08:09:07 -0300128#endif
Tony Lindgren828c7072009-03-23 18:23:49 -0700129
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200130#if defined(CONFIG_IOMMU_API)
131
Tony Lindgren2ab7c842012-11-02 12:24:14 -0700132#include <linux/platform_data/iommu-omap.h>
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200133
Tony Lindgren828c7072009-03-23 18:23:49 -0700134static struct resource omap3isp_resources[] = {
135 {
136 .start = OMAP3430_ISP_BASE,
137 .end = OMAP3430_ISP_END,
138 .flags = IORESOURCE_MEM,
139 },
140 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700141 .start = OMAP3430_ISP_CCP2_BASE,
142 .end = OMAP3430_ISP_CCP2_END,
143 .flags = IORESOURCE_MEM,
144 },
145 {
146 .start = OMAP3430_ISP_CCDC_BASE,
147 .end = OMAP3430_ISP_CCDC_END,
148 .flags = IORESOURCE_MEM,
149 },
150 {
151 .start = OMAP3430_ISP_HIST_BASE,
152 .end = OMAP3430_ISP_HIST_END,
153 .flags = IORESOURCE_MEM,
154 },
155 {
156 .start = OMAP3430_ISP_H3A_BASE,
157 .end = OMAP3430_ISP_H3A_END,
158 .flags = IORESOURCE_MEM,
159 },
160 {
161 .start = OMAP3430_ISP_PREV_BASE,
162 .end = OMAP3430_ISP_PREV_END,
163 .flags = IORESOURCE_MEM,
164 },
165 {
166 .start = OMAP3430_ISP_RESZ_BASE,
167 .end = OMAP3430_ISP_RESZ_END,
168 .flags = IORESOURCE_MEM,
169 },
170 {
171 .start = OMAP3430_ISP_SBL_BASE,
172 .end = OMAP3430_ISP_SBL_END,
173 .flags = IORESOURCE_MEM,
174 },
175 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300176 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
177 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700178 .flags = IORESOURCE_MEM,
179 },
180 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300181 .start = OMAP3430_ISP_CSIPHY2_BASE,
182 .end = OMAP3430_ISP_CSIPHY2_END,
183 .flags = IORESOURCE_MEM,
184 },
185 {
186 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
187 .end = OMAP3630_ISP_CSI2A_REGS2_END,
188 .flags = IORESOURCE_MEM,
189 },
190 {
191 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
192 .end = OMAP3630_ISP_CSI2C_REGS1_END,
193 .flags = IORESOURCE_MEM,
194 },
195 {
196 .start = OMAP3630_ISP_CSIPHY1_BASE,
197 .end = OMAP3630_ISP_CSIPHY1_END,
198 .flags = IORESOURCE_MEM,
199 },
200 {
201 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
202 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700203 .flags = IORESOURCE_MEM,
204 },
205 {
Sakari Ailusc19d19e2012-10-14 07:31:48 -0300206 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
207 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
208 .flags = IORESOURCE_MEM,
209 },
210 {
211 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
212 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
213 .flags = IORESOURCE_MEM,
214 },
215 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700216 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700217 .flags = IORESOURCE_IRQ,
218 }
219};
220
221static struct platform_device omap3isp_device = {
222 .name = "omap3isp",
223 .id = -1,
224 .num_resources = ARRAY_SIZE(omap3isp_resources),
225 .resource = omap3isp_resources,
226};
227
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300228static struct omap_iommu_arch_data omap3_isp_iommu = {
Omar Ramirez Luna72b15b62012-11-19 19:05:50 -0600229 .name = "mmu_isp",
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300230};
231
Laurent Pincharta11f6702009-12-14 08:09:07 -0300232int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700233{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300234 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300235 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
236
Laurent Pincharta11f6702009-12-14 08:09:07 -0300237 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700238}
Tony Lindgren828c7072009-03-23 18:23:49 -0700239
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200240#else /* !CONFIG_IOMMU_API */
241
242int omap3_init_camera(struct isp_platform_data *pdata)
243{
244 return 0;
245}
246
247#endif
248
Tony Lindgren1dbae812005-11-10 14:26:51 +0000249static inline void omap_init_camera(void)
250{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300251#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
252 if (cpu_is_omap24xx())
253 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000254#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300255}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000256
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +0530257#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
258static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
259 .type = 1,
260};
261
262struct resource omap4_control_usb_res[] = {
263 {
264 .name = "control_dev_conf",
265 .start = 0x4a002300,
266 .end = 0x4a002303,
267 .flags = IORESOURCE_MEM,
268 },
269 {
270 .name = "otghs_control",
271 .start = 0x4a00233c,
272 .end = 0x4a00233f,
273 .flags = IORESOURCE_MEM,
274 },
275};
276
277static struct platform_device omap4_control_usb = {
278 .name = "omap-control-usb",
279 .id = -1,
280 .dev = {
281 .platform_data = &omap4_control_usb_pdata,
282 },
283 .num_resources = 2,
284 .resource = omap4_control_usb_res,
285};
286
287static inline void __init omap_init_control_usb(void)
288{
289 if (!cpu_is_omap44xx())
290 return;
291
292 if (platform_device_register(&omap4_control_usb))
293 pr_err("Error registering omap_control_usb device\n");
294}
295
296#else
297static inline void omap_init_control_usb(void) { }
298#endif /* CONFIG_OMAP_CONTROL_USB */
299
Syed Rafiuddin59556762010-12-27 05:51:45 +0000300int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700301 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000302{
Kevin Hilman3528c582011-07-21 13:48:45 -0700303 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000304 struct omap_hwmod *oh;
305 struct omap4_keypad_platform_data *keypad_data;
306 unsigned int id = -1;
307 char *oh_name = "kbd";
308 char *name = "omap4-keypad";
309
310 oh = omap_hwmod_lookup(oh_name);
311 if (!oh) {
312 pr_err("Could not look up %s\n", oh_name);
313 return -ENODEV;
314 }
315
316 keypad_data = sdp4430_keypad_data;
317
Kevin Hilman3528c582011-07-21 13:48:45 -0700318 pdev = omap_device_build(name, id, oh, keypad_data,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700319 sizeof(struct omap4_keypad_platform_data));
Syed Rafiuddin59556762010-12-27 05:51:45 +0000320
Kevin Hilman3528c582011-07-21 13:48:45 -0700321 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300322 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000323 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700324 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000325 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700326 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000327
328 return 0;
329}
330
Suman Annac869c752013-03-12 17:55:29 -0500331#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800332static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800333{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800334 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700335 struct platform_device *pdev;
Suman Annab8a7cf82013-01-28 17:21:58 -0600336 struct omap_mbox_pdata *pdata;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800337
338 oh = omap_hwmod_lookup("mailbox");
339 if (!oh) {
340 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700341 return;
342 }
Suman Annab8a7cf82013-01-28 17:21:58 -0600343 if (!oh->dev_attr) {
344 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
345 return;
346 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800347
Suman Annab8a7cf82013-01-28 17:21:58 -0600348 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
349 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700350 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
351 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800352}
353#else
354static inline void omap_init_mbox(void) { }
Suman Annac869c752013-03-12 17:55:29 -0500355#endif /* CONFIG_OMAP2PLUS_MBOX */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800356
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100357static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100358
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000359#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
360
361static struct platform_device omap_pcm = {
362 .name = "omap-pcm-audio",
363 .id = -1,
364};
365
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000366static void omap_init_audio(void)
367{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000368 platform_device_register(&omap_pcm);
369}
370
371#else
372static inline void omap_init_audio(void) {}
373#endif
374
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600375#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
376 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
377
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800378static void __init omap_init_mcpdm(void)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600379{
380 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200381 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600382
383 oh = omap_hwmod_lookup("mcpdm");
384 if (!oh) {
385 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
386 return;
387 }
388
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700389 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200390 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600391}
392#else
393static inline void omap_init_mcpdm(void) {}
394#endif
395
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800396#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
397 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
398
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800399static void __init omap_init_dmic(void)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800400{
401 struct omap_hwmod *oh;
402 struct platform_device *pdev;
403
404 oh = omap_hwmod_lookup("dmic");
405 if (!oh) {
Sebastien Guiriec49c58e82012-10-16 11:19:17 -0700406 pr_err("Could not look up dmic hw_mod\n");
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800407 return;
408 }
409
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700410 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800411 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
412}
413#else
414static inline void omap_init_dmic(void) {}
415#endif
416
Ricardo Neri5eeec212012-05-09 14:19:14 -0700417#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
418 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
419
420static struct platform_device omap_hdmi_audio = {
421 .name = "omap-hdmi-audio",
422 .id = -1,
423};
424
425static void __init omap_init_hdmi_audio(void)
426{
427 struct omap_hwmod *oh;
428 struct platform_device *pdev;
429
430 oh = omap_hwmod_lookup("dss_hdmi");
431 if (!oh) {
432 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
433 return;
434 }
435
Paul Walmsley6efc3fe2013-02-12 03:58:35 +0000436 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
Ricardo Neri5eeec212012-05-09 14:19:14 -0700437 WARN(IS_ERR(pdev),
438 "Can't build omap_device for omap-hdmi-audio-dai.\n");
439
440 platform_device_register(&omap_hdmi_audio);
441}
442#else
443static inline void omap_init_hdmi_audio(void) {}
444#endif
445
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300446#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700447
Arnd Bergmann22037472012-08-24 15:21:06 +0200448#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700449
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800450static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700451{
Kevin Hilman3528c582011-07-21 13:48:45 -0700452 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530453 char *name = "omap2_mcspi";
454 struct omap2_mcspi_platform_config *pdata;
455 static int spi_num;
456 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700457
Charulatha V1a5d8192011-02-02 17:52:14 +0530458 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
459 if (!pdata) {
460 pr_err("Memory allocation for McSPI device failed\n");
461 return -ENOMEM;
462 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700463
Charulatha V1a5d8192011-02-02 17:52:14 +0530464 pdata->num_cs = mcspi_attrib->num_chipselect;
465 switch (oh->class->rev) {
466 case OMAP2_MCSPI_REV:
467 case OMAP3_MCSPI_REV:
468 pdata->regs_offset = 0;
469 break;
470 case OMAP4_MCSPI_REV:
471 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
472 break;
473 default:
474 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100475 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530476 return -EINVAL;
477 }
478
479 spi_num++;
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700480 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700481 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530482 name, oh->name);
483 kfree(pdata);
484 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700485}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700486
487static void omap_init_mcspi(void)
488{
Charulatha V1a5d8192011-02-02 17:52:14 +0530489 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700490}
491
492#else
493static inline void omap_init_mcspi(void) {}
494#endif
495
Paul Walmsley4848d462012-09-23 17:28:27 -0600496/**
497 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
498 *
499 * Bind the RNG hwmod to the RNG omap_device. No return value.
500 */
501static void omap_init_rng(void)
502{
503 struct omap_hwmod *oh;
504 struct platform_device *pdev;
505
506 oh = omap_hwmod_lookup("rng");
507 if (!oh)
508 return;
509
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700510 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
Paul Walmsley4848d462012-09-23 17:28:27 -0600511 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
512}
Will Deacon88341332010-04-09 13:54:43 +0100513
Mark A. Greer26f88e62013-03-18 10:06:32 -0600514static void __init omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300515{
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600516 struct omap_hwmod *oh;
517 struct platform_device *pdev;
Mark A. Greere569e992013-03-30 15:49:19 -0600518
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600519 oh = omap_hwmod_lookup("sham");
520 if (!oh)
521 return;
Mark A. Greere569e992013-03-30 15:49:19 -0600522
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600523 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
524 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300525}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300526
Mark A. Greer14ae5562012-12-21 09:28:10 -0700527static void __init omap_init_aes(void)
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800528{
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700529 struct omap_hwmod *oh;
530 struct platform_device *pdev;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700531
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700532 oh = omap_hwmod_lookup("aes");
533 if (!oh)
534 return;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700535
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700536 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
537 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800538}
539
Tony Lindgrend8874662008-12-10 17:37:16 -0800540/*-------------------------------------------------------------------------*/
541
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700542#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
543 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
544#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
545static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
546};
547#else
548static struct resource omap_vout_resource[2] = {
549};
550#endif
551
552static struct platform_device omap_vout_device = {
553 .name = "omap_vout",
554 .num_resources = ARRAY_SIZE(omap_vout_resource),
555 .resource = &omap_vout_resource[0],
556 .id = -1,
557};
558static void omap_init_vout(void)
559{
560 if (platform_device_register(&omap_vout_device) < 0)
561 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
562}
563#else
564static inline void omap_init_vout(void) {}
565#endif
566
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530567#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
568static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
569{
570 int cnt = 0;
571
572 while (ocp2scp_dev->drv_name != NULL) {
573 cnt++;
574 ocp2scp_dev++;
575 }
576
577 return cnt;
578}
579
Tony Lindgrene407ee02013-01-21 10:17:03 -0800580static void __init omap_init_ocp2scp(void)
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530581{
582 struct omap_hwmod *oh;
583 struct platform_device *pdev;
584 int bus_id = -1, dev_cnt = 0, i;
585 struct omap_ocp2scp_dev *ocp2scp_dev;
586 const char *oh_name, *name;
587 struct omap_ocp2scp_platform_data *pdata;
588
589 if (!cpu_is_omap44xx())
590 return;
591
592 oh_name = "ocp2scp_usb_phy";
593 name = "omap-ocp2scp";
594
595 oh = omap_hwmod_lookup(oh_name);
596 if (!oh) {
597 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
598 oh_name);
599 return;
600 }
601
602 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
603 if (!pdata) {
604 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
605 return;
606 }
607
608 ocp2scp_dev = oh->dev_attr;
609 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
610
611 if (!dev_cnt) {
612 pr_err("%s: No devices connected to ocp2scp\n", __func__);
613 kfree(pdata);
614 return;
615 }
616
617 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
618 * dev_cnt, GFP_KERNEL);
619 if (!pdata->devices) {
620 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
621 kfree(pdata);
622 return;
623 }
624
625 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
626 pdata->devices[i] = ocp2scp_dev;
627
628 pdata->dev_cnt = dev_cnt;
629
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700630 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata));
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530631 if (IS_ERR(pdev)) {
632 pr_err("Could not build omap_device for %s %s\n",
633 name, oh_name);
634 kfree(pdata->devices);
635 kfree(pdata);
636 return;
637 }
638}
639#else
640static inline void omap_init_ocp2scp(void) { }
641#endif
642
Tony Lindgren1dbae812005-11-10 14:26:51 +0000643/*-------------------------------------------------------------------------*/
644
645static int __init omap2_init_devices(void)
646{
Matt Porter484202f2012-09-17 16:26:11 -0700647 /* Enable dummy states for those platforms without pinctrl support */
648 if (!of_have_populated_dt())
649 pinctrl_provide_dummies();
650
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700651 /*
652 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000653 * in alphabetical order so they're easier to sort through.
654 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000655 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700656 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700657 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800658 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100659 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300660 if (!of_have_populated_dt()) {
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +0530661 omap_init_control_usb();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300662 omap_init_dmic();
Peter Ujfalusi4b21ffc2012-05-02 15:23:19 +0300663 omap_init_mcpdm();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100664 omap_init_mcspi();
Mark A. Greer114d7a82013-03-18 10:06:33 -0600665 omap_init_sham();
Mark A. Greer53335ac2012-12-21 09:28:12 -0700666 omap_init_aes();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300667 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100668 omap_init_sti();
Paul Walmsley4848d462012-09-23 17:28:27 -0600669 omap_init_rng();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700670 omap_init_vout();
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530671 omap_init_ocp2scp();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000672
673 return 0;
674}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -0800675omap_arch_initcall(omap2_init_devices);