blob: b6cc233214d75fee1bcf37ab47a68e692cd4b33d [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
Kevin Hilman3528c582011-07-21 13:48:45 -070065 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
sricharan0abcf612011-02-08 14:10:45 +053066 NULL, 0, 0);
67
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}
72postcore_initcall(omap3_l3_init);
73
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
Kevin Hilman3528c582011-07-21 13:48:45 -0700100 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
sricharana4dc6162011-03-09 16:00:29 +0530101 0, NULL, 0, 0);
102
Kevin Hilman3528c582011-07-21 13:48:45 -0700103 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
sricharana4dc6162011-03-09 16:00:29 +0530104
Kevin Hilman3528c582011-07-21 13:48:45 -0700105 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
sricharana4dc6162011-03-09 16:00:29 +0530106}
107postcore_initcall(omap4_l3_init);
108
Tony Lindgren828c7072009-03-23 18:23:49 -0700109#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800110
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300111static struct resource omap2cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800112 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700113 .start = OMAP24XX_CAMERA_BASE,
114 .end = OMAP24XX_CAMERA_BASE + 0xfff,
115 .flags = IORESOURCE_MEM,
116 },
117 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700118 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700119 .flags = IORESOURCE_IRQ,
120 }
121};
122
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300123static struct platform_device omap2cam_device = {
Tony Lindgren828c7072009-03-23 18:23:49 -0700124 .name = "omap24xxcam",
125 .id = -1,
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300126 .num_resources = ARRAY_SIZE(omap2cam_resources),
127 .resource = omap2cam_resources,
Tony Lindgren828c7072009-03-23 18:23:49 -0700128};
Laurent Pincharta11f6702009-12-14 08:09:07 -0300129#endif
Tony Lindgren828c7072009-03-23 18:23:49 -0700130
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200131#if defined(CONFIG_IOMMU_API)
132
Tony Lindgren2ab7c842012-11-02 12:24:14 -0700133#include <linux/platform_data/iommu-omap.h>
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200134
Tony Lindgren828c7072009-03-23 18:23:49 -0700135static struct resource omap3isp_resources[] = {
136 {
137 .start = OMAP3430_ISP_BASE,
138 .end = OMAP3430_ISP_END,
139 .flags = IORESOURCE_MEM,
140 },
141 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700142 .start = OMAP3430_ISP_CCP2_BASE,
143 .end = OMAP3430_ISP_CCP2_END,
144 .flags = IORESOURCE_MEM,
145 },
146 {
147 .start = OMAP3430_ISP_CCDC_BASE,
148 .end = OMAP3430_ISP_CCDC_END,
149 .flags = IORESOURCE_MEM,
150 },
151 {
152 .start = OMAP3430_ISP_HIST_BASE,
153 .end = OMAP3430_ISP_HIST_END,
154 .flags = IORESOURCE_MEM,
155 },
156 {
157 .start = OMAP3430_ISP_H3A_BASE,
158 .end = OMAP3430_ISP_H3A_END,
159 .flags = IORESOURCE_MEM,
160 },
161 {
162 .start = OMAP3430_ISP_PREV_BASE,
163 .end = OMAP3430_ISP_PREV_END,
164 .flags = IORESOURCE_MEM,
165 },
166 {
167 .start = OMAP3430_ISP_RESZ_BASE,
168 .end = OMAP3430_ISP_RESZ_END,
169 .flags = IORESOURCE_MEM,
170 },
171 {
172 .start = OMAP3430_ISP_SBL_BASE,
173 .end = OMAP3430_ISP_SBL_END,
174 .flags = IORESOURCE_MEM,
175 },
176 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300177 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
178 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700179 .flags = IORESOURCE_MEM,
180 },
181 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300182 .start = OMAP3430_ISP_CSIPHY2_BASE,
183 .end = OMAP3430_ISP_CSIPHY2_END,
184 .flags = IORESOURCE_MEM,
185 },
186 {
187 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
188 .end = OMAP3630_ISP_CSI2A_REGS2_END,
189 .flags = IORESOURCE_MEM,
190 },
191 {
192 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
193 .end = OMAP3630_ISP_CSI2C_REGS1_END,
194 .flags = IORESOURCE_MEM,
195 },
196 {
197 .start = OMAP3630_ISP_CSIPHY1_BASE,
198 .end = OMAP3630_ISP_CSIPHY1_END,
199 .flags = IORESOURCE_MEM,
200 },
201 {
202 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
203 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700204 .flags = IORESOURCE_MEM,
205 },
206 {
Sakari Ailusc19d19e2012-10-14 07:31:48 -0300207 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
208 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
209 .flags = IORESOURCE_MEM,
210 },
211 {
212 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
213 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
214 .flags = IORESOURCE_MEM,
215 },
216 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700217 .start = 24 + OMAP_INTC_START,
Tony Lindgren828c7072009-03-23 18:23:49 -0700218 .flags = IORESOURCE_IRQ,
219 }
220};
221
222static struct platform_device omap3isp_device = {
223 .name = "omap3isp",
224 .id = -1,
225 .num_resources = ARRAY_SIZE(omap3isp_resources),
226 .resource = omap3isp_resources,
227};
228
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300229static struct omap_iommu_arch_data omap3_isp_iommu = {
Omar Ramirez Luna72b15b62012-11-19 19:05:50 -0600230 .name = "mmu_isp",
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300231};
232
Laurent Pincharta11f6702009-12-14 08:09:07 -0300233int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700234{
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
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +0530258#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
259static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
260 .type = 1,
261};
262
263struct resource omap4_control_usb_res[] = {
264 {
265 .name = "control_dev_conf",
266 .start = 0x4a002300,
267 .end = 0x4a002303,
268 .flags = IORESOURCE_MEM,
269 },
270 {
271 .name = "otghs_control",
272 .start = 0x4a00233c,
273 .end = 0x4a00233f,
274 .flags = IORESOURCE_MEM,
275 },
276};
277
278static struct platform_device omap4_control_usb = {
279 .name = "omap-control-usb",
280 .id = -1,
281 .dev = {
282 .platform_data = &omap4_control_usb_pdata,
283 },
284 .num_resources = 2,
285 .resource = omap4_control_usb_res,
286};
287
288static inline void __init omap_init_control_usb(void)
289{
290 if (!cpu_is_omap44xx())
291 return;
292
293 if (platform_device_register(&omap4_control_usb))
294 pr_err("Error registering omap_control_usb device\n");
295}
296
297#else
298static inline void omap_init_control_usb(void) { }
299#endif /* CONFIG_OMAP_CONTROL_USB */
300
Syed Rafiuddin59556762010-12-27 05:51:45 +0000301int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700302 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000303{
Kevin Hilman3528c582011-07-21 13:48:45 -0700304 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000305 struct omap_hwmod *oh;
306 struct omap4_keypad_platform_data *keypad_data;
307 unsigned int id = -1;
308 char *oh_name = "kbd";
309 char *name = "omap4-keypad";
310
311 oh = omap_hwmod_lookup(oh_name);
312 if (!oh) {
313 pr_err("Could not look up %s\n", oh_name);
314 return -ENODEV;
315 }
316
317 keypad_data = sdp4430_keypad_data;
318
Kevin Hilman3528c582011-07-21 13:48:45 -0700319 pdev = omap_device_build(name, id, oh, keypad_data,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200320 sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000321
Kevin Hilman3528c582011-07-21 13:48:45 -0700322 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300323 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000324 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700325 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000326 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700327 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000328
329 return 0;
330}
331
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700332#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800333static inline void __init omap_init_mbox(void)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800334{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800335 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700336 struct platform_device *pdev;
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 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800343
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200344 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700345 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
346 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800347}
348#else
349static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700350#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800351
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100352static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100353
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000354#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
355
356static struct platform_device omap_pcm = {
357 .name = "omap-pcm-audio",
358 .id = -1,
359};
360
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000361static void omap_init_audio(void)
362{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000363 platform_device_register(&omap_pcm);
364}
365
366#else
367static inline void omap_init_audio(void) {}
368#endif
369
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600370#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
371 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
372
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800373static void __init omap_init_mcpdm(void)
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600374{
375 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200376 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600377
378 oh = omap_hwmod_lookup("mcpdm");
379 if (!oh) {
380 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
381 return;
382 }
383
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200384 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0, NULL, 0, 0);
385 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600386}
387#else
388static inline void omap_init_mcpdm(void) {}
389#endif
390
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800391#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
392 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
393
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800394static void __init omap_init_dmic(void)
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800395{
396 struct omap_hwmod *oh;
397 struct platform_device *pdev;
398
399 oh = omap_hwmod_lookup("dmic");
400 if (!oh) {
Sebastien Guiriec49c58e82012-10-16 11:19:17 -0700401 pr_err("Could not look up dmic hw_mod\n");
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800402 return;
403 }
404
405 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0, NULL, 0, 0);
406 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
407}
408#else
409static inline void omap_init_dmic(void) {}
410#endif
411
Ricardo Neri5eeec212012-05-09 14:19:14 -0700412#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
413 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
414
415static struct platform_device omap_hdmi_audio = {
416 .name = "omap-hdmi-audio",
417 .id = -1,
418};
419
420static void __init omap_init_hdmi_audio(void)
421{
422 struct omap_hwmod *oh;
423 struct platform_device *pdev;
424
425 oh = omap_hwmod_lookup("dss_hdmi");
426 if (!oh) {
427 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
428 return;
429 }
430
431 pdev = omap_device_build("omap-hdmi-audio-dai",
432 -1, oh, NULL, 0, NULL, 0, 0);
433 WARN(IS_ERR(pdev),
434 "Can't build omap_device for omap-hdmi-audio-dai.\n");
435
436 platform_device_register(&omap_hdmi_audio);
437}
438#else
439static inline void omap_init_hdmi_audio(void) {}
440#endif
441
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300442#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700443
Arnd Bergmann22037472012-08-24 15:21:06 +0200444#include <linux/platform_data/spi-omap2-mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700445
Kevin Hilman9cf793f2012-02-20 09:43:30 -0800446static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700447{
Kevin Hilman3528c582011-07-21 13:48:45 -0700448 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530449 char *name = "omap2_mcspi";
450 struct omap2_mcspi_platform_config *pdata;
451 static int spi_num;
452 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700453
Charulatha V1a5d8192011-02-02 17:52:14 +0530454 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
455 if (!pdata) {
456 pr_err("Memory allocation for McSPI device failed\n");
457 return -ENOMEM;
458 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700459
Charulatha V1a5d8192011-02-02 17:52:14 +0530460 pdata->num_cs = mcspi_attrib->num_chipselect;
461 switch (oh->class->rev) {
462 case OMAP2_MCSPI_REV:
463 case OMAP3_MCSPI_REV:
464 pdata->regs_offset = 0;
465 break;
466 case OMAP4_MCSPI_REV:
467 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
468 break;
469 default:
470 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100471 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530472 return -EINVAL;
473 }
474
475 spi_num++;
Kevin Hilman3528c582011-07-21 13:48:45 -0700476 pdev = omap_device_build(name, spi_num, oh, pdata,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200477 sizeof(*pdata), NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700478 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530479 name, oh->name);
480 kfree(pdata);
481 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700482}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700483
484static void omap_init_mcspi(void)
485{
Charulatha V1a5d8192011-02-02 17:52:14 +0530486 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700487}
488
489#else
490static inline void omap_init_mcspi(void) {}
491#endif
492
Paul Walmsley4848d462012-09-23 17:28:27 -0600493/**
494 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
495 *
496 * Bind the RNG hwmod to the RNG omap_device. No return value.
497 */
498static void omap_init_rng(void)
499{
500 struct omap_hwmod *oh;
501 struct platform_device *pdev;
502
503 oh = omap_hwmod_lookup("rng");
504 if (!oh)
505 return;
506
507 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0, NULL, 0, 0);
508 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
509}
Will Deacon88341332010-04-09 13:54:43 +0100510
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800511#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
512
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000513#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800514static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300515 {
516 .start = OMAP24XX_SEC_SHA1MD5_BASE,
517 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
518 .flags = IORESOURCE_MEM,
519 },
520 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700521 .start = 51 + OMAP_INTC_START,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300522 .flags = IORESOURCE_IRQ,
523 }
524};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800525static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
526#else
527#define omap2_sham_resources NULL
528#define omap2_sham_resources_sz 0
529#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300530
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000531#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800532static struct resource omap3_sham_resources[] = {
533 {
534 .start = OMAP34XX_SEC_SHA1MD5_BASE,
535 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
536 .flags = IORESOURCE_MEM,
537 },
538 {
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700539 .start = 49 + OMAP_INTC_START,
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800540 .flags = IORESOURCE_IRQ,
541 },
542 {
543 .start = OMAP34XX_DMA_SHA1MD5_RX,
544 .flags = IORESOURCE_DMA,
545 }
546};
547static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
548#else
549#define omap3_sham_resources NULL
550#define omap3_sham_resources_sz 0
551#endif
552
553static struct platform_device sham_device = {
554 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300555 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300556};
557
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800558static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300559{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800560 if (cpu_is_omap24xx()) {
561 sham_device.resource = omap2_sham_resources;
562 sham_device.num_resources = omap2_sham_resources_sz;
563 } else if (cpu_is_omap34xx()) {
564 sham_device.resource = omap3_sham_resources;
565 sham_device.num_resources = omap3_sham_resources_sz;
566 } else {
567 pr_err("%s: platform not supported\n", __func__);
568 return;
569 }
570 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300571}
572#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800573static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300574#endif
575
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800576#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
577
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000578#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800579static struct resource omap2_aes_resources[] = {
580 {
581 .start = OMAP24XX_SEC_AES_BASE,
582 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
583 .flags = IORESOURCE_MEM,
584 },
585 {
586 .start = OMAP24XX_DMA_AES_TX,
587 .flags = IORESOURCE_DMA,
588 },
589 {
590 .start = OMAP24XX_DMA_AES_RX,
591 .flags = IORESOURCE_DMA,
592 }
593};
594static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
595#else
596#define omap2_aes_resources NULL
597#define omap2_aes_resources_sz 0
598#endif
599
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000600#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800601static struct resource omap3_aes_resources[] = {
602 {
603 .start = OMAP34XX_SEC_AES_BASE,
604 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
605 .flags = IORESOURCE_MEM,
606 },
607 {
608 .start = OMAP34XX_DMA_AES2_TX,
609 .flags = IORESOURCE_DMA,
610 },
611 {
612 .start = OMAP34XX_DMA_AES2_RX,
613 .flags = IORESOURCE_DMA,
614 }
615};
616static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
617#else
618#define omap3_aes_resources NULL
619#define omap3_aes_resources_sz 0
620#endif
621
622static struct platform_device aes_device = {
623 .name = "omap-aes",
624 .id = -1,
625};
626
627static void omap_init_aes(void)
628{
629 if (cpu_is_omap24xx()) {
630 aes_device.resource = omap2_aes_resources;
631 aes_device.num_resources = omap2_aes_resources_sz;
632 } else if (cpu_is_omap34xx()) {
633 aes_device.resource = omap3_aes_resources;
634 aes_device.num_resources = omap3_aes_resources_sz;
635 } else {
636 pr_err("%s: platform not supported\n", __func__);
637 return;
638 }
639 platform_device_register(&aes_device);
640}
641
642#else
643static inline void omap_init_aes(void) { }
644#endif
645
Tony Lindgrend8874662008-12-10 17:37:16 -0800646/*-------------------------------------------------------------------------*/
647
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700648#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
649 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
650#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
651static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
652};
653#else
654static struct resource omap_vout_resource[2] = {
655};
656#endif
657
658static struct platform_device omap_vout_device = {
659 .name = "omap_vout",
660 .num_resources = ARRAY_SIZE(omap_vout_resource),
661 .resource = &omap_vout_resource[0],
662 .id = -1,
663};
664static void omap_init_vout(void)
665{
666 if (platform_device_register(&omap_vout_device) < 0)
667 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
668}
669#else
670static inline void omap_init_vout(void) {}
671#endif
672
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530673#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
674static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
675{
676 int cnt = 0;
677
678 while (ocp2scp_dev->drv_name != NULL) {
679 cnt++;
680 ocp2scp_dev++;
681 }
682
683 return cnt;
684}
685
Tony Lindgrene407ee02013-01-21 10:17:03 -0800686static void __init omap_init_ocp2scp(void)
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530687{
688 struct omap_hwmod *oh;
689 struct platform_device *pdev;
690 int bus_id = -1, dev_cnt = 0, i;
691 struct omap_ocp2scp_dev *ocp2scp_dev;
692 const char *oh_name, *name;
693 struct omap_ocp2scp_platform_data *pdata;
694
695 if (!cpu_is_omap44xx())
696 return;
697
698 oh_name = "ocp2scp_usb_phy";
699 name = "omap-ocp2scp";
700
701 oh = omap_hwmod_lookup(oh_name);
702 if (!oh) {
703 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
704 oh_name);
705 return;
706 }
707
708 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
709 if (!pdata) {
710 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
711 return;
712 }
713
714 ocp2scp_dev = oh->dev_attr;
715 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
716
717 if (!dev_cnt) {
718 pr_err("%s: No devices connected to ocp2scp\n", __func__);
719 kfree(pdata);
720 return;
721 }
722
723 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
724 * dev_cnt, GFP_KERNEL);
725 if (!pdata->devices) {
726 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
727 kfree(pdata);
728 return;
729 }
730
731 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
732 pdata->devices[i] = ocp2scp_dev;
733
734 pdata->dev_cnt = dev_cnt;
735
736 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata), NULL,
737 0, false);
738 if (IS_ERR(pdev)) {
739 pr_err("Could not build omap_device for %s %s\n",
740 name, oh_name);
741 kfree(pdata->devices);
742 kfree(pdata);
743 return;
744 }
745}
746#else
747static inline void omap_init_ocp2scp(void) { }
748#endif
749
Tony Lindgren1dbae812005-11-10 14:26:51 +0000750/*-------------------------------------------------------------------------*/
751
752static int __init omap2_init_devices(void)
753{
Matt Porter484202f2012-09-17 16:26:11 -0700754 /* Enable dummy states for those platforms without pinctrl support */
755 if (!of_have_populated_dt())
756 pinctrl_provide_dummies();
757
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700758 /*
759 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000760 * in alphabetical order so they're easier to sort through.
761 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000762 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700763 omap_init_camera();
Ricardo Neri5eeec212012-05-09 14:19:14 -0700764 omap_init_hdmi_audio();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800765 omap_init_mbox();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100766 /* If dtb is there, the devices will be created dynamically */
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300767 if (!of_have_populated_dt()) {
Kishon Vijay Abraham I36273352013-02-06 18:58:48 +0530768 omap_init_control_usb();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300769 omap_init_dmic();
Peter Ujfalusi4b21ffc2012-05-02 15:23:19 +0300770 omap_init_mcpdm();
Benoit Coussonefcf1e52012-01-20 14:15:58 +0100771 omap_init_mcspi();
Peter Ujfalusi259bd6c2012-05-02 15:23:18 +0300772 }
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100773 omap_init_sti();
Paul Walmsley4848d462012-09-23 17:28:27 -0600774 omap_init_rng();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800775 omap_init_sham();
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800776 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700777 omap_init_vout();
Kishon Vijay Abraham I459bc972012-10-27 19:05:56 +0530778 omap_init_ocp2scp();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000779
780 return 0;
781}
782arch_initcall(omap2_init_devices);