blob: e58609b312c7091b5589314fbb4b457b457ccb0f [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>
Suman Annab8a7cf82013-01-28 17:21:58 -060022#include <linux/platform_data/mailbox-omap.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000023
Tony Lindgren1dbae812005-11-10 14:26:51 +000024#include <asm/mach-types.h>
25#include <asm/mach/map.h>
26
Tony Lindgren45c3eb72012-11-30 08:41:50 -080027#include <linux/omap-dma.h>
Tony Lindgren2a296c82012-10-02 17:41:35 -070028
Tony Lindgrenee0839c2012-02-24 10:34:35 -080029#include "iomap.h"
Tony Lindgren2a296c82012-10-02 17:41:35 -070030#include "omap_hwmod.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070031#include "omap_device.h"
Tony Lindgren0e701562012-09-20 11:42:20 -070032#include "omap4-keypad.h"
Tony Lindgren1dbae812005-11-10 14:26:51 +000033
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -070034#include "soc.h"
35#include "common.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080036#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060037#include "control.h"
Laurent Pincharta11f6702009-12-14 08:09:07 -030038#include "devices.h"
Archit Taneja576e5bd2013-09-16 12:48:31 +053039#include "display.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080040
sricharan0abcf612011-02-08 14:10:45 +053041#define L3_MODULES_MAX_LEN 12
sricharana4dc6162011-03-09 16:00:29 +053042#define L3_MODULES 3
sricharan0abcf612011-02-08 14:10:45 +053043
44static int __init omap3_l3_init(void)
45{
sricharan0abcf612011-02-08 14:10:45 +053046 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -070047 struct platform_device *pdev;
sricharan0abcf612011-02-08 14:10:45 +053048 char oh_name[L3_MODULES_MAX_LEN];
49
50 /*
51 * To avoid code running on other OMAPs in
52 * multi-omap builds
53 */
54 if (!(cpu_is_omap34xx()))
55 return -ENODEV;
56
Paul Walmsleyeeb37112012-04-13 06:34:32 -060057 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
sricharan0abcf612011-02-08 14:10:45 +053058
59 oh = omap_hwmod_lookup(oh_name);
60
61 if (!oh)
62 pr_err("could not look up %s\n", oh_name);
63
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070064 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
sricharan0abcf612011-02-08 14:10:45 +053065
Kevin Hilman3528c582011-07-21 13:48:45 -070066 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharan0abcf612011-02-08 14:10:45 +053067
Thomas Meyer12616742013-06-01 11:44:44 +020068 return PTR_RET(pdev);
sricharan0abcf612011-02-08 14:10:45 +053069}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -080070omap_postcore_initcall(omap3_l3_init);
sricharan0abcf612011-02-08 14:10:45 +053071
sricharana4dc6162011-03-09 16:00:29 +053072static int __init omap4_l3_init(void)
73{
Paul Walmsleyeeb37112012-04-13 06:34:32 -060074 int i;
sricharana4dc6162011-03-09 16:00:29 +053075 struct omap_hwmod *oh[3];
Kevin Hilman3528c582011-07-21 13:48:45 -070076 struct platform_device *pdev;
sricharana4dc6162011-03-09 16:00:29 +053077 char oh_name[L3_MODULES_MAX_LEN];
78
Benoit Coussonad8dfac2011-08-12 13:48:47 +020079 /* If dtb is there, the devices will be created dynamically */
80 if (of_have_populated_dt())
81 return -ENODEV;
82
sricharana4dc6162011-03-09 16:00:29 +053083 /*
84 * To avoid code running on other OMAPs in
85 * multi-omap builds
86 */
R Sricharane17933c2011-11-04 15:52:59 +053087 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
sricharana4dc6162011-03-09 16:00:29 +053088 return -ENODEV;
89
90 for (i = 0; i < L3_MODULES; i++) {
Paul Walmsleyeeb37112012-04-13 06:34:32 -060091 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
sricharana4dc6162011-03-09 16:00:29 +053092
93 oh[i] = omap_hwmod_lookup(oh_name);
94 if (!(oh[i]))
95 pr_err("could not look up %s\n", oh_name);
96 }
97
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070098 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
sricharana4dc6162011-03-09 16:00:29 +053099
Kevin Hilman3528c582011-07-21 13:48:45 -0700100 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharana4dc6162011-03-09 16:00:29 +0530101
Thomas Meyer12616742013-06-01 11:44:44 +0200102 return PTR_RET(pdev);
sricharana4dc6162011-03-09 16:00:29 +0530103}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800104omap_postcore_initcall(omap4_l3_init);
sricharana4dc6162011-03-09 16:00:29 +0530105
Tony Lindgren828c7072009-03-23 18:23:49 -0700106#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800107
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300108static struct resource omap2cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800109 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700110 .start = OMAP24XX_CAMERA_BASE,
111 .end = OMAP24XX_CAMERA_BASE + 0xfff,
112 .flags = IORESOURCE_MEM,
113 },
114 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700115 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700116 .flags = IORESOURCE_IRQ,
117 }
118};
119
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300120static struct platform_device omap2cam_device = {
Tony Lindgren828c7072009-03-23 18:23:49 -0700121 .name = "omap24xxcam",
122 .id = -1,
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300123 .num_resources = ARRAY_SIZE(omap2cam_resources),
124 .resource = omap2cam_resources,
Tony Lindgren828c7072009-03-23 18:23:49 -0700125};
Laurent Pincharta11f6702009-12-14 08:09:07 -0300126#endif
Tony Lindgren828c7072009-03-23 18:23:49 -0700127
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200128#if defined(CONFIG_IOMMU_API)
129
Tony Lindgren2ab7c842012-11-02 12:24:14 -0700130#include <linux/platform_data/iommu-omap.h>
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200131
Tony Lindgren828c7072009-03-23 18:23:49 -0700132static struct resource omap3isp_resources[] = {
133 {
134 .start = OMAP3430_ISP_BASE,
135 .end = OMAP3430_ISP_END,
136 .flags = IORESOURCE_MEM,
137 },
138 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700139 .start = OMAP3430_ISP_CCP2_BASE,
140 .end = OMAP3430_ISP_CCP2_END,
141 .flags = IORESOURCE_MEM,
142 },
143 {
144 .start = OMAP3430_ISP_CCDC_BASE,
145 .end = OMAP3430_ISP_CCDC_END,
146 .flags = IORESOURCE_MEM,
147 },
148 {
149 .start = OMAP3430_ISP_HIST_BASE,
150 .end = OMAP3430_ISP_HIST_END,
151 .flags = IORESOURCE_MEM,
152 },
153 {
154 .start = OMAP3430_ISP_H3A_BASE,
155 .end = OMAP3430_ISP_H3A_END,
156 .flags = IORESOURCE_MEM,
157 },
158 {
159 .start = OMAP3430_ISP_PREV_BASE,
160 .end = OMAP3430_ISP_PREV_END,
161 .flags = IORESOURCE_MEM,
162 },
163 {
164 .start = OMAP3430_ISP_RESZ_BASE,
165 .end = OMAP3430_ISP_RESZ_END,
166 .flags = IORESOURCE_MEM,
167 },
168 {
169 .start = OMAP3430_ISP_SBL_BASE,
170 .end = OMAP3430_ISP_SBL_END,
171 .flags = IORESOURCE_MEM,
172 },
173 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300174 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
175 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700176 .flags = IORESOURCE_MEM,
177 },
178 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300179 .start = OMAP3430_ISP_CSIPHY2_BASE,
180 .end = OMAP3430_ISP_CSIPHY2_END,
181 .flags = IORESOURCE_MEM,
182 },
183 {
184 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
185 .end = OMAP3630_ISP_CSI2A_REGS2_END,
186 .flags = IORESOURCE_MEM,
187 },
188 {
189 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
190 .end = OMAP3630_ISP_CSI2C_REGS1_END,
191 .flags = IORESOURCE_MEM,
192 },
193 {
194 .start = OMAP3630_ISP_CSIPHY1_BASE,
195 .end = OMAP3630_ISP_CSIPHY1_END,
196 .flags = IORESOURCE_MEM,
197 },
198 {
199 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
200 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700201 .flags = IORESOURCE_MEM,
202 },
203 {
Sakari Ailusc19d19e2012-10-14 07:31:48 -0300204 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
205 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
206 .flags = IORESOURCE_MEM,
207 },
208 {
209 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
210 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
211 .flags = IORESOURCE_MEM,
212 },
213 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700214 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700215 .flags = IORESOURCE_IRQ,
216 }
217};
218
219static struct platform_device omap3isp_device = {
220 .name = "omap3isp",
221 .id = -1,
222 .num_resources = ARRAY_SIZE(omap3isp_resources),
223 .resource = omap3isp_resources,
224};
225
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300226static struct omap_iommu_arch_data omap3_isp_iommu = {
Omar Ramirez Luna72b15b62012-11-19 19:05:50 -0600227 .name = "mmu_isp",
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300228};
229
Laurent Pincharta11f6702009-12-14 08:09:07 -0300230int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700231{
Suman Anna0ac4f032014-03-05 18:24:12 -0600232 if (of_have_populated_dt())
233 omap3_isp_iommu.name = "480bd400.mmu";
234
Laurent Pincharta11f6702009-12-14 08:09:07 -0300235 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300236 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
237
Laurent Pincharta11f6702009-12-14 08:09:07 -0300238 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700239}
Tony Lindgren828c7072009-03-23 18:23:49 -0700240
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200241#else /* !CONFIG_IOMMU_API */
242
243int omap3_init_camera(struct isp_platform_data *pdata)
244{
245 return 0;
246}
247
248#endif
249
Tony Lindgren1dbae812005-11-10 14:26:51 +0000250static inline void omap_init_camera(void)
251{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300252#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
253 if (cpu_is_omap24xx())
254 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000255#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300256}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000257
Syed Rafiuddin59556762010-12-27 05:51:45 +0000258int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700259 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000260{
Kevin Hilman3528c582011-07-21 13:48:45 -0700261 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000262 struct omap_hwmod *oh;
263 struct omap4_keypad_platform_data *keypad_data;
264 unsigned int id = -1;
265 char *oh_name = "kbd";
266 char *name = "omap4-keypad";
267
268 oh = omap_hwmod_lookup(oh_name);
269 if (!oh) {
270 pr_err("Could not look up %s\n", oh_name);
271 return -ENODEV;
272 }
273
274 keypad_data = sdp4430_keypad_data;
275
Kevin Hilman3528c582011-07-21 13:48:45 -0700276 pdev = omap_device_build(name, id, oh, keypad_data,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700277 sizeof(struct omap4_keypad_platform_data));
Syed Rafiuddin59556762010-12-27 05:51:45 +0000278
Kevin Hilman3528c582011-07-21 13:48:45 -0700279 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300280 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000281 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700282 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000283 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700284 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000285
286 return 0;
287}
288
Suman Annac869c752013-03-12 17:55:29 -0500289#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800290static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800291{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800292 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700293 struct platform_device *pdev;
Suman Annab8a7cf82013-01-28 17:21:58 -0600294 struct omap_mbox_pdata *pdata;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800295
296 oh = omap_hwmod_lookup("mailbox");
297 if (!oh) {
298 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700299 return;
300 }
Suman Annab8a7cf82013-01-28 17:21:58 -0600301 if (!oh->dev_attr) {
302 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
303 return;
304 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800305
Suman Annab8a7cf82013-01-28 17:21:58 -0600306 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
307 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700308 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
309 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800310}
311#else
312static inline void omap_init_mbox(void) { }
Suman Annac869c752013-03-12 17:55:29 -0500313#endif /* CONFIG_OMAP2PLUS_MBOX */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800314
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100315static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100316
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000317#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
318
319static struct platform_device omap_pcm = {
320 .name = "omap-pcm-audio",
321 .id = -1,
322};
323
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000324static void omap_init_audio(void)
325{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000326 platform_device_register(&omap_pcm);
327}
328
329#else
330static inline void omap_init_audio(void) {}
331#endif
332
Ricardo Neri5eeec212012-05-09 14:19:14 -0700333#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
334 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
335
336static struct platform_device omap_hdmi_audio = {
337 .name = "omap-hdmi-audio",
338 .id = -1,
339};
340
341static void __init omap_init_hdmi_audio(void)
342{
343 struct omap_hwmod *oh;
344 struct platform_device *pdev;
345
346 oh = omap_hwmod_lookup("dss_hdmi");
Peter Ujfalusi7252db52013-06-11 10:32:00 +0200347 if (!oh)
Ricardo Neri5eeec212012-05-09 14:19:14 -0700348 return;
Ricardo Neri5eeec212012-05-09 14:19:14 -0700349
Paul Walmsley6efc3fe2013-02-12 03:58:35 +0000350 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
Ricardo Neri5eeec212012-05-09 14:19:14 -0700351 WARN(IS_ERR(pdev),
352 "Can't build omap_device for omap-hdmi-audio-dai.\n");
353
354 platform_device_register(&omap_hdmi_audio);
355}
356#else
357static inline void omap_init_hdmi_audio(void) {}
358#endif
359
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300360#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700361
Arnd Bergmann22037472012-08-24 15:21:06 +0200362#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700363
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800364static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700365{
Kevin Hilman3528c582011-07-21 13:48:45 -0700366 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530367 char *name = "omap2_mcspi";
368 struct omap2_mcspi_platform_config *pdata;
369 static int spi_num;
370 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700371
Charulatha V1a5d8192011-02-02 17:52:14 +0530372 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
373 if (!pdata) {
374 pr_err("Memory allocation for McSPI device failed\n");
375 return -ENOMEM;
376 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700377
Charulatha V1a5d8192011-02-02 17:52:14 +0530378 pdata->num_cs = mcspi_attrib->num_chipselect;
379 switch (oh->class->rev) {
380 case OMAP2_MCSPI_REV:
381 case OMAP3_MCSPI_REV:
382 pdata->regs_offset = 0;
383 break;
384 case OMAP4_MCSPI_REV:
385 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
386 break;
387 default:
388 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100389 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530390 return -EINVAL;
391 }
392
393 spi_num++;
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700394 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700395 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530396 name, oh->name);
397 kfree(pdata);
398 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700399}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700400
401static void omap_init_mcspi(void)
402{
Charulatha V1a5d8192011-02-02 17:52:14 +0530403 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700404}
405
406#else
407static inline void omap_init_mcspi(void) {}
408#endif
409
Paul Walmsley4848d462012-09-23 17:28:27 -0600410/**
411 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
412 *
413 * Bind the RNG hwmod to the RNG omap_device. No return value.
414 */
415static void omap_init_rng(void)
416{
417 struct omap_hwmod *oh;
418 struct platform_device *pdev;
419
420 oh = omap_hwmod_lookup("rng");
421 if (!oh)
422 return;
423
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700424 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
Paul Walmsley4848d462012-09-23 17:28:27 -0600425 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
426}
Will Deacon88341332010-04-09 13:54:43 +0100427
Mark A. Greer26f88e62013-03-18 10:06:32 -0600428static void __init omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300429{
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600430 struct omap_hwmod *oh;
431 struct platform_device *pdev;
Mark A. Greere569e992013-03-30 15:49:19 -0600432
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600433 oh = omap_hwmod_lookup("sham");
434 if (!oh)
435 return;
Mark A. Greere569e992013-03-30 15:49:19 -0600436
Mark A. Greer8c7bb572013-03-18 10:06:33 -0600437 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
438 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300439}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300440
Mark A. Greer14ae5562012-12-21 09:28:10 -0700441static void __init omap_init_aes(void)
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800442{
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700443 struct omap_hwmod *oh;
444 struct platform_device *pdev;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700445
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700446 oh = omap_hwmod_lookup("aes");
447 if (!oh)
448 return;
Mark A. Greer660ffd62012-12-21 09:28:09 -0700449
Mark A. Greer77e2fd82012-12-21 09:28:11 -0700450 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
451 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800452}
453
Tony Lindgrend8874662008-12-10 17:37:16 -0800454/*-------------------------------------------------------------------------*/
455
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700456#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
457 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
458#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
459static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
460};
461#else
462static struct resource omap_vout_resource[2] = {
463};
464#endif
465
466static struct platform_device omap_vout_device = {
467 .name = "omap_vout",
468 .num_resources = ARRAY_SIZE(omap_vout_resource),
469 .resource = &omap_vout_resource[0],
470 .id = -1,
471};
Archit Taneja576e5bd2013-09-16 12:48:31 +0530472
473int __init omap_init_vout(void)
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700474{
Archit Taneja576e5bd2013-09-16 12:48:31 +0530475 return platform_device_register(&omap_vout_device);
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700476}
477#else
Archit Taneja576e5bd2013-09-16 12:48:31 +0530478int __init omap_init_vout(void) { return 0; }
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700479#endif
480
Tony Lindgren1dbae812005-11-10 14:26:51 +0000481/*-------------------------------------------------------------------------*/
482
483static int __init omap2_init_devices(void)
484{
Matt Porter484202f2012-09-17 16:26:11 -0700485 /* Enable dummy states for those platforms without pinctrl support */
486 if (!of_have_populated_dt())
487 pinctrl_provide_dummies();
488
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700489 /*
490 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000491 * in alphabetical order so they're easier to sort through.
492 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000493 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700494 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700495 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800496 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100497 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300498 if (!of_have_populated_dt()) {
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100499 omap_init_mcspi();
Mark A. Greer114d7a82013-03-18 10:06:33 -0600500 omap_init_sham();
Mark A. Greer53335ac2012-12-21 09:28:12 -0700501 omap_init_aes();
Lokesh Vutla674ee082013-08-05 20:17:22 +0530502 omap_init_rng();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300503 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100504 omap_init_sti();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000505
506 return 0;
507}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -0800508omap_arch_initcall(omap2_init_devices);