blob: d8a0cc3b9d2c0c88eea556f5b5fb5c9ce16120cf [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>
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"
Lokesh Vutlad5e7c862012-10-15 14:03:51 -070039#include "dma.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
Kevin Hilman3528c582011-07-21 13:48:45 -070068 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharan0abcf612011-02-08 14:10:45 +053069}
70postcore_initcall(omap3_l3_init);
71
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
Kevin Hilman3528c582011-07-21 13:48:45 -0700102 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharana4dc6162011-03-09 16:00:29 +0530103}
104postcore_initcall(omap4_l3_init);
105
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{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300232 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300233 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
234
Laurent Pincharta11f6702009-12-14 08:09:07 -0300235 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700236}
Tony Lindgren828c7072009-03-23 18:23:49 -0700237
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200238#else /* !CONFIG_IOMMU_API */
239
240int omap3_init_camera(struct isp_platform_data *pdata)
241{
242 return 0;
243}
244
245#endif
246
Tony Lindgren1dbae812005-11-10 14:26:51 +0000247static inline void omap_init_camera(void)
248{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300249#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
250 if (cpu_is_omap24xx())
251 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000252#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300253}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000254
Syed Rafiuddin59556762010-12-27 05:51:45 +0000255int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700256 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000257{
Kevin Hilman3528c582011-07-21 13:48:45 -0700258 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000259 struct omap_hwmod *oh;
260 struct omap4_keypad_platform_data *keypad_data;
261 unsigned int id = -1;
262 char *oh_name = "kbd";
263 char *name = "omap4-keypad";
264
265 oh = omap_hwmod_lookup(oh_name);
266 if (!oh) {
267 pr_err("Could not look up %s\n", oh_name);
268 return -ENODEV;
269 }
270
271 keypad_data = sdp4430_keypad_data;
272
Kevin Hilman3528c582011-07-21 13:48:45 -0700273 pdev = omap_device_build(name, id, oh, keypad_data,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700274 sizeof(struct omap4_keypad_platform_data));
Syed Rafiuddin59556762010-12-27 05:51:45 +0000275
Kevin Hilman3528c582011-07-21 13:48:45 -0700276 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300277 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000278 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700279 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000280 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700281 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000282
283 return 0;
284}
285
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700286#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800287static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800288{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800289 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700290 struct platform_device *pdev;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800291
292 oh = omap_hwmod_lookup("mailbox");
293 if (!oh) {
294 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700295 return;
296 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800297
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700298 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700299 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
300 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800301}
302#else
303static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700304#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800305
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100306static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100307
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000308#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
309
310static struct platform_device omap_pcm = {
311 .name = "omap-pcm-audio",
312 .id = -1,
313};
314
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000315static void omap_init_audio(void)
316{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000317 platform_device_register(&omap_pcm);
318}
319
320#else
321static inline void omap_init_audio(void) {}
322#endif
323
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600324#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
325 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
326
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800327static void __init omap_init_mcpdm(void)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600328{
329 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200330 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600331
332 oh = omap_hwmod_lookup("mcpdm");
333 if (!oh) {
334 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
335 return;
336 }
337
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700338 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200339 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600340}
341#else
342static inline void omap_init_mcpdm(void) {}
343#endif
344
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800345#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
346 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
347
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800348static void __init omap_init_dmic(void)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800349{
350 struct omap_hwmod *oh;
351 struct platform_device *pdev;
352
353 oh = omap_hwmod_lookup("dmic");
354 if (!oh) {
Sebastien Guiriec49c58e82012-10-16 11:19:17 -0700355 pr_err("Could not look up dmic hw_mod\n");
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800356 return;
357 }
358
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700359 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800360 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
361}
362#else
363static inline void omap_init_dmic(void) {}
364#endif
365
Ricardo Neri5eeec212012-05-09 14:19:14 -0700366#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
367 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
368
369static struct platform_device omap_hdmi_audio = {
370 .name = "omap-hdmi-audio",
371 .id = -1,
372};
373
374static void __init omap_init_hdmi_audio(void)
375{
376 struct omap_hwmod *oh;
377 struct platform_device *pdev;
378
379 oh = omap_hwmod_lookup("dss_hdmi");
380 if (!oh) {
381 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
382 return;
383 }
384
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700385 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0, 0);
Ricardo Neri5eeec212012-05-09 14:19:14 -0700386 WARN(IS_ERR(pdev),
387 "Can't build omap_device for omap-hdmi-audio-dai.\n");
388
389 platform_device_register(&omap_hdmi_audio);
390}
391#else
392static inline void omap_init_hdmi_audio(void) {}
393#endif
394
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300395#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700396
Arnd Bergmann22037472012-08-24 15:21:06 +0200397#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700398
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800399static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700400{
Kevin Hilman3528c582011-07-21 13:48:45 -0700401 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530402 char *name = "omap2_mcspi";
403 struct omap2_mcspi_platform_config *pdata;
404 static int spi_num;
405 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700406
Charulatha V1a5d8192011-02-02 17:52:14 +0530407 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
408 if (!pdata) {
409 pr_err("Memory allocation for McSPI device failed\n");
410 return -ENOMEM;
411 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700412
Charulatha V1a5d8192011-02-02 17:52:14 +0530413 pdata->num_cs = mcspi_attrib->num_chipselect;
414 switch (oh->class->rev) {
415 case OMAP2_MCSPI_REV:
416 case OMAP3_MCSPI_REV:
417 pdata->regs_offset = 0;
418 break;
419 case OMAP4_MCSPI_REV:
420 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
421 break;
422 default:
423 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100424 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530425 return -EINVAL;
426 }
427
428 spi_num++;
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700429 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -0700430 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530431 name, oh->name);
432 kfree(pdata);
433 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700434}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700435
436static void omap_init_mcspi(void)
437{
Charulatha V1a5d8192011-02-02 17:52:14 +0530438 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700439}
440
441#else
442static inline void omap_init_mcspi(void) {}
443#endif
444
Paul Walmsley4848d462012-09-23 17:28:27 -0600445/**
446 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
447 *
448 * Bind the RNG hwmod to the RNG omap_device. No return value.
449 */
450static void omap_init_rng(void)
451{
452 struct omap_hwmod *oh;
453 struct platform_device *pdev;
454
455 oh = omap_hwmod_lookup("rng");
456 if (!oh)
457 return;
458
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700459 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
Paul Walmsley4848d462012-09-23 17:28:27 -0600460 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
461}
Will Deacon88341332010-04-09 13:54:43 +0100462
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800463#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
464
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000465#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800466static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300467 {
468 .start = OMAP24XX_SEC_SHA1MD5_BASE,
469 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
470 .flags = IORESOURCE_MEM,
471 },
472 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700473 .start = 51 + OMAP_INTC_START,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300474 .flags = IORESOURCE_IRQ,
475 }
476};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800477static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
478#else
479#define omap2_sham_resources NULL
480#define omap2_sham_resources_sz 0
481#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300482
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000483#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800484static struct resource omap3_sham_resources[] = {
485 {
486 .start = OMAP34XX_SEC_SHA1MD5_BASE,
487 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
488 .flags = IORESOURCE_MEM,
489 },
490 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700491 .start = 49 + OMAP_INTC_START,
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800492 .flags = IORESOURCE_IRQ,
493 },
494 {
495 .start = OMAP34XX_DMA_SHA1MD5_RX,
496 .flags = IORESOURCE_DMA,
497 }
498};
499static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
500#else
501#define omap3_sham_resources NULL
502#define omap3_sham_resources_sz 0
503#endif
504
505static struct platform_device sham_device = {
506 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300507 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300508};
509
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800510static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300511{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800512 if (cpu_is_omap24xx()) {
513 sham_device.resource = omap2_sham_resources;
514 sham_device.num_resources = omap2_sham_resources_sz;
515 } else if (cpu_is_omap34xx()) {
516 sham_device.resource = omap3_sham_resources;
517 sham_device.num_resources = omap3_sham_resources_sz;
518 } else {
519 pr_err("%s: platform not supported\n", __func__);
520 return;
521 }
522 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300523}
524#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800525static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300526#endif
527
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800528#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
529
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000530#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800531static struct resource omap2_aes_resources[] = {
532 {
533 .start = OMAP24XX_SEC_AES_BASE,
534 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
535 .flags = IORESOURCE_MEM,
536 },
537 {
538 .start = OMAP24XX_DMA_AES_TX,
539 .flags = IORESOURCE_DMA,
540 },
541 {
542 .start = OMAP24XX_DMA_AES_RX,
543 .flags = IORESOURCE_DMA,
544 }
545};
546static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
547#else
548#define omap2_aes_resources NULL
549#define omap2_aes_resources_sz 0
550#endif
551
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000552#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800553static struct resource omap3_aes_resources[] = {
554 {
555 .start = OMAP34XX_SEC_AES_BASE,
556 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
557 .flags = IORESOURCE_MEM,
558 },
559 {
560 .start = OMAP34XX_DMA_AES2_TX,
561 .flags = IORESOURCE_DMA,
562 },
563 {
564 .start = OMAP34XX_DMA_AES2_RX,
565 .flags = IORESOURCE_DMA,
566 }
567};
568static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
569#else
570#define omap3_aes_resources NULL
571#define omap3_aes_resources_sz 0
572#endif
573
574static struct platform_device aes_device = {
575 .name = "omap-aes",
576 .id = -1,
577};
578
579static void omap_init_aes(void)
580{
581 if (cpu_is_omap24xx()) {
582 aes_device.resource = omap2_aes_resources;
583 aes_device.num_resources = omap2_aes_resources_sz;
584 } else if (cpu_is_omap34xx()) {
585 aes_device.resource = omap3_aes_resources;
586 aes_device.num_resources = omap3_aes_resources_sz;
587 } else {
588 pr_err("%s: platform not supported\n", __func__);
589 return;
590 }
591 platform_device_register(&aes_device);
592}
593
594#else
595static inline void omap_init_aes(void) { }
596#endif
597
Tony Lindgrend8874662008-12-10 17:37:16 -0800598/*-------------------------------------------------------------------------*/
599
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700600#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
601 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
602#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
603static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
604};
605#else
606static struct resource omap_vout_resource[2] = {
607};
608#endif
609
610static struct platform_device omap_vout_device = {
611 .name = "omap_vout",
612 .num_resources = ARRAY_SIZE(omap_vout_resource),
613 .resource = &omap_vout_resource[0],
614 .id = -1,
615};
616static void omap_init_vout(void)
617{
618 if (platform_device_register(&omap_vout_device) < 0)
619 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
620}
621#else
622static inline void omap_init_vout(void) {}
623#endif
624
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530625#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
626static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
627{
628 int cnt = 0;
629
630 while (ocp2scp_dev->drv_name != NULL) {
631 cnt++;
632 ocp2scp_dev++;
633 }
634
635 return cnt;
636}
637
Tony Lindgrene407ee02013-01-21 10:17:03 -0800638static void __init omap_init_ocp2scp(void)
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530639{
640 struct omap_hwmod *oh;
641 struct platform_device *pdev;
642 int bus_id = -1, dev_cnt = 0, i;
643 struct omap_ocp2scp_dev *ocp2scp_dev;
644 const char *oh_name, *name;
645 struct omap_ocp2scp_platform_data *pdata;
646
647 if (!cpu_is_omap44xx())
648 return;
649
650 oh_name = "ocp2scp_usb_phy";
651 name = "omap-ocp2scp";
652
653 oh = omap_hwmod_lookup(oh_name);
654 if (!oh) {
655 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
656 oh_name);
657 return;
658 }
659
660 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
661 if (!pdata) {
662 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
663 return;
664 }
665
666 ocp2scp_dev = oh->dev_attr;
667 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
668
669 if (!dev_cnt) {
670 pr_err("%s: No devices connected to ocp2scp\n", __func__);
671 kfree(pdata);
672 return;
673 }
674
675 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
676 * dev_cnt, GFP_KERNEL);
677 if (!pdata->devices) {
678 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
679 kfree(pdata);
680 return;
681 }
682
683 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
684 pdata->devices[i] = ocp2scp_dev;
685
686 pdata->dev_cnt = dev_cnt;
687
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -0700688 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata));
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530689 if (IS_ERR(pdev)) {
690 pr_err("Could not build omap_device for %s %s\n",
691 name, oh_name);
692 kfree(pdata->devices);
693 kfree(pdata);
694 return;
695 }
696}
697#else
698static inline void omap_init_ocp2scp(void) { }
699#endif
700
Tony Lindgren1dbae812005-11-10 14:26:51 +0000701/*-------------------------------------------------------------------------*/
702
703static int __init omap2_init_devices(void)
704{
Matt Porter484202f2012-09-17 16:26:11 -0700705 /* Enable dummy states for those platforms without pinctrl support */
706 if (!of_have_populated_dt())
707 pinctrl_provide_dummies();
708
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700709 /*
710 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000711 * in alphabetical order so they're easier to sort through.
712 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000713 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700714 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700715 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800716 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100717 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300718 if (!of_have_populated_dt()) {
719 omap_init_dmic();
Peter Ujfalusi4b21ffc2012-05-02 15:23:19 +0300720 omap_init_mcpdm();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100721 omap_init_mcspi();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300722 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100723 omap_init_sti();
Paul Walmsley4848d462012-09-23 17:28:27 -0600724 omap_init_rng();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800725 omap_init_sham();
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800726 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700727 omap_init_vout();
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530728 omap_init_ocp2scp();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000729
730 return 0;
731}
732arch_initcall(omap2_init_devices);