blob: 58e1d201732e89d6c8b8ea570ceeb6a856d3d91d [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>
Felipe Balbi0f1142a2012-03-16 22:47:48 -070020#include <linux/platform_data/omap4-keypad.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000021
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/hardware.h>
Will Deacon88341332010-04-09 13:54:43 +010023#include <mach/irqs.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000024#include <asm/mach-types.h>
25#include <asm/mach/map.h>
Will Deacon88341332010-04-09 13:54:43 +010026#include <asm/pmu.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000027
Tony Lindgrence491cf2009-10-20 09:40:47 -070028#include <plat/tc.h>
29#include <plat/board.h>
Jarkko Nikulaa09f73f2010-10-04 15:04:53 +030030#include <plat/mcbsp.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070031#include <plat/mmc.h>
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +080032#include <plat/dma.h>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053033#include <plat/omap_hwmod.h>
34#include <plat/omap_device.h>
Syed Rafiuddin59556762010-12-27 05:51:45 +000035#include <plat/omap4-keypad.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000036
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"
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{
46 int l;
47 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
58 l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
59
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{
76 int l, i;
77 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 */
89 if (!(cpu_is_omap44xx()))
90 return -ENODEV;
91
92 for (i = 0; i < L3_MODULES; i++) {
93 l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
94
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 {
118 .start = INT_24XX_CAM_IRQ,
119 .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
133#include <plat/iommu.h>
134
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 {
207 .start = INT_34XX_CAM_IRQ,
208 .flags = IORESOURCE_IRQ,
209 }
210};
211
212static struct platform_device omap3isp_device = {
213 .name = "omap3isp",
214 .id = -1,
215 .num_resources = ARRAY_SIZE(omap3isp_resources),
216 .resource = omap3isp_resources,
217};
218
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300219static struct omap_iommu_arch_data omap3_isp_iommu = {
220 .name = "isp",
221};
222
Laurent Pincharta11f6702009-12-14 08:09:07 -0300223int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700224{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300225 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300226 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
227
Laurent Pincharta11f6702009-12-14 08:09:07 -0300228 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700229}
Tony Lindgren828c7072009-03-23 18:23:49 -0700230
Ohad Ben-Cohen1a51a0c2012-01-11 15:28:11 +0200231#else /* !CONFIG_IOMMU_API */
232
233int omap3_init_camera(struct isp_platform_data *pdata)
234{
235 return 0;
236}
237
238#endif
239
Tony Lindgren1dbae812005-11-10 14:26:51 +0000240static inline void omap_init_camera(void)
241{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300242#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
243 if (cpu_is_omap24xx())
244 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000245#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300246}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000247
Syed Rafiuddin59556762010-12-27 05:51:45 +0000248int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700249 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000250{
Kevin Hilman3528c582011-07-21 13:48:45 -0700251 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000252 struct omap_hwmod *oh;
253 struct omap4_keypad_platform_data *keypad_data;
254 unsigned int id = -1;
255 char *oh_name = "kbd";
256 char *name = "omap4-keypad";
257
258 oh = omap_hwmod_lookup(oh_name);
259 if (!oh) {
260 pr_err("Could not look up %s\n", oh_name);
261 return -ENODEV;
262 }
263
264 keypad_data = sdp4430_keypad_data;
265
Kevin Hilman3528c582011-07-21 13:48:45 -0700266 pdev = omap_device_build(name, id, oh, keypad_data,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200267 sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000268
Kevin Hilman3528c582011-07-21 13:48:45 -0700269 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300270 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000271 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700272 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000273 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700274 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000275
276 return 0;
277}
278
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700279#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800280static inline void omap_init_mbox(void)
281{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800282 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700283 struct platform_device *pdev;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800284
285 oh = omap_hwmod_lookup("mailbox");
286 if (!oh) {
287 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700288 return;
289 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800290
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200291 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700292 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
293 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800294}
295#else
296static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700297#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800298
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100299static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100300
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000301#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
302
303static struct platform_device omap_pcm = {
304 .name = "omap-pcm-audio",
305 .id = -1,
306};
307
308/*
309 * OMAP2420 has 2 McBSP ports
310 * OMAP2430 has 5 McBSP ports
311 * OMAP3 has 5 McBSP ports
312 * OMAP4 has 4 McBSP ports
313 */
314OMAP_MCBSP_PLATFORM_DEVICE(1);
315OMAP_MCBSP_PLATFORM_DEVICE(2);
316OMAP_MCBSP_PLATFORM_DEVICE(3);
317OMAP_MCBSP_PLATFORM_DEVICE(4);
318OMAP_MCBSP_PLATFORM_DEVICE(5);
319
320static void omap_init_audio(void)
321{
322 platform_device_register(&omap_mcbsp1);
323 platform_device_register(&omap_mcbsp2);
324 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
325 platform_device_register(&omap_mcbsp3);
326 platform_device_register(&omap_mcbsp4);
327 }
328 if (cpu_is_omap243x() || cpu_is_omap34xx())
329 platform_device_register(&omap_mcbsp5);
330
331 platform_device_register(&omap_pcm);
332}
333
334#else
335static inline void omap_init_audio(void) {}
336#endif
337
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600338#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
339 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
340
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600341static void omap_init_mcpdm(void)
342{
343 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200344 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600345
346 oh = omap_hwmod_lookup("mcpdm");
347 if (!oh) {
348 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
349 return;
350 }
351
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200352 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0, NULL, 0, 0);
353 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600354}
355#else
356static inline void omap_init_mcpdm(void) {}
357#endif
358
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800359#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
360 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
361
362static void omap_init_dmic(void)
363{
364 struct omap_hwmod *oh;
365 struct platform_device *pdev;
366
367 oh = omap_hwmod_lookup("dmic");
368 if (!oh) {
369 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
370 return;
371 }
372
373 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0, NULL, 0, 0);
374 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
375}
376#else
377static inline void omap_init_dmic(void) {}
378#endif
379
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300380#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700381
Tony Lindgrence491cf2009-10-20 09:40:47 -0700382#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700383
Charulatha V1a5d8192011-02-02 17:52:14 +0530384static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700385{
Kevin Hilman3528c582011-07-21 13:48:45 -0700386 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530387 char *name = "omap2_mcspi";
388 struct omap2_mcspi_platform_config *pdata;
389 static int spi_num;
390 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700391
Charulatha V1a5d8192011-02-02 17:52:14 +0530392 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
393 if (!pdata) {
394 pr_err("Memory allocation for McSPI device failed\n");
395 return -ENOMEM;
396 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700397
Charulatha V1a5d8192011-02-02 17:52:14 +0530398 pdata->num_cs = mcspi_attrib->num_chipselect;
399 switch (oh->class->rev) {
400 case OMAP2_MCSPI_REV:
401 case OMAP3_MCSPI_REV:
402 pdata->regs_offset = 0;
403 break;
404 case OMAP4_MCSPI_REV:
405 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
406 break;
407 default:
408 pr_err("Invalid McSPI Revision value\n");
Julia Lawalle0feca892011-12-23 18:39:31 +0100409 kfree(pdata);
Charulatha V1a5d8192011-02-02 17:52:14 +0530410 return -EINVAL;
411 }
412
413 spi_num++;
Kevin Hilman3528c582011-07-21 13:48:45 -0700414 pdev = omap_device_build(name, spi_num, oh, pdata,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200415 sizeof(*pdata), NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700416 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530417 name, oh->name);
418 kfree(pdata);
419 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700420}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700421
422static void omap_init_mcspi(void)
423{
Charulatha V1a5d8192011-02-02 17:52:14 +0530424 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700425}
426
427#else
428static inline void omap_init_mcspi(void) {}
429#endif
430
Will Deacon88341332010-04-09 13:54:43 +0100431static struct resource omap2_pmu_resource = {
432 .start = 3,
433 .end = 3,
434 .flags = IORESOURCE_IRQ,
435};
436
437static struct resource omap3_pmu_resource = {
438 .start = INT_34XX_BENCH_MPU_EMUL,
439 .end = INT_34XX_BENCH_MPU_EMUL,
440 .flags = IORESOURCE_IRQ,
441};
442
443static struct platform_device omap_pmu_device = {
444 .name = "arm-pmu",
445 .id = ARM_PMU_DEVICE_CPU,
446 .num_resources = 1,
447};
448
449static void omap_init_pmu(void)
450{
451 if (cpu_is_omap24xx())
452 omap_pmu_device.resource = &omap2_pmu_resource;
453 else if (cpu_is_omap34xx())
454 omap_pmu_device.resource = &omap3_pmu_resource;
455 else
456 return;
457
458 platform_device_register(&omap_pmu_device);
459}
460
461
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800462#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
463
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000464#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800465static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300466 {
467 .start = OMAP24XX_SEC_SHA1MD5_BASE,
468 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
469 .flags = IORESOURCE_MEM,
470 },
471 {
472 .start = INT_24XX_SHA1MD5,
473 .flags = IORESOURCE_IRQ,
474 }
475};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800476static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
477#else
478#define omap2_sham_resources NULL
479#define omap2_sham_resources_sz 0
480#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300481
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000482#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800483static struct resource omap3_sham_resources[] = {
484 {
485 .start = OMAP34XX_SEC_SHA1MD5_BASE,
486 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
487 .flags = IORESOURCE_MEM,
488 },
489 {
490 .start = INT_34XX_SHA1MD52_IRQ,
491 .flags = IORESOURCE_IRQ,
492 },
493 {
494 .start = OMAP34XX_DMA_SHA1MD5_RX,
495 .flags = IORESOURCE_DMA,
496 }
497};
498static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
499#else
500#define omap3_sham_resources NULL
501#define omap3_sham_resources_sz 0
502#endif
503
504static struct platform_device sham_device = {
505 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300506 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300507};
508
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800509static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300510{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800511 if (cpu_is_omap24xx()) {
512 sham_device.resource = omap2_sham_resources;
513 sham_device.num_resources = omap2_sham_resources_sz;
514 } else if (cpu_is_omap34xx()) {
515 sham_device.resource = omap3_sham_resources;
516 sham_device.num_resources = omap3_sham_resources_sz;
517 } else {
518 pr_err("%s: platform not supported\n", __func__);
519 return;
520 }
521 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300522}
523#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800524static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300525#endif
526
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800527#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
528
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000529#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800530static struct resource omap2_aes_resources[] = {
531 {
532 .start = OMAP24XX_SEC_AES_BASE,
533 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
534 .flags = IORESOURCE_MEM,
535 },
536 {
537 .start = OMAP24XX_DMA_AES_TX,
538 .flags = IORESOURCE_DMA,
539 },
540 {
541 .start = OMAP24XX_DMA_AES_RX,
542 .flags = IORESOURCE_DMA,
543 }
544};
545static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
546#else
547#define omap2_aes_resources NULL
548#define omap2_aes_resources_sz 0
549#endif
550
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000551#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800552static struct resource omap3_aes_resources[] = {
553 {
554 .start = OMAP34XX_SEC_AES_BASE,
555 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
556 .flags = IORESOURCE_MEM,
557 },
558 {
559 .start = OMAP34XX_DMA_AES2_TX,
560 .flags = IORESOURCE_DMA,
561 },
562 {
563 .start = OMAP34XX_DMA_AES2_RX,
564 .flags = IORESOURCE_DMA,
565 }
566};
567static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
568#else
569#define omap3_aes_resources NULL
570#define omap3_aes_resources_sz 0
571#endif
572
573static struct platform_device aes_device = {
574 .name = "omap-aes",
575 .id = -1,
576};
577
578static void omap_init_aes(void)
579{
580 if (cpu_is_omap24xx()) {
581 aes_device.resource = omap2_aes_resources;
582 aes_device.num_resources = omap2_aes_resources_sz;
583 } else if (cpu_is_omap34xx()) {
584 aes_device.resource = omap3_aes_resources;
585 aes_device.num_resources = omap3_aes_resources_sz;
586 } else {
587 pr_err("%s: platform not supported\n", __func__);
588 return;
589 }
590 platform_device_register(&aes_device);
591}
592
593#else
594static inline void omap_init_aes(void) { }
595#endif
596
Tony Lindgrend8874662008-12-10 17:37:16 -0800597/*-------------------------------------------------------------------------*/
598
Anand Gadiyare08016d2011-03-01 13:12:55 -0800599#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
Kevin Hilman917fa282008-12-10 17:37:17 -0800600
Anand Gadiyare08016d2011-03-01 13:12:55 -0800601static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
602 *mmc_controller)
Tony Lindgrend8874662008-12-10 17:37:16 -0800603{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000604 if ((mmc_controller->slots[0].switch_pin > 0) && \
605 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
606 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
607 OMAP_PIN_INPUT_PULLUP);
608 if ((mmc_controller->slots[0].gpio_wp > 0) && \
609 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
610 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
611 OMAP_PIN_INPUT_PULLUP);
612
Anand Gadiyare08016d2011-03-01 13:12:55 -0800613 omap_mux_init_signal("sdmmc_cmd", 0);
614 omap_mux_init_signal("sdmmc_clki", 0);
615 omap_mux_init_signal("sdmmc_clko", 0);
616 omap_mux_init_signal("sdmmc_dat0", 0);
617 omap_mux_init_signal("sdmmc_dat_dir0", 0);
618 omap_mux_init_signal("sdmmc_cmd_dir", 0);
619 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
620 omap_mux_init_signal("sdmmc_dat1", 0);
621 omap_mux_init_signal("sdmmc_dat2", 0);
622 omap_mux_init_signal("sdmmc_dat3", 0);
623 omap_mux_init_signal("sdmmc_dat_dir1", 0);
624 omap_mux_init_signal("sdmmc_dat_dir2", 0);
625 omap_mux_init_signal("sdmmc_dat_dir3", 0);
Tony Lindgrend8874662008-12-10 17:37:16 -0800626 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700627
Anand Gadiyare08016d2011-03-01 13:12:55 -0800628 /*
629 * Use internal loop-back in MMC/SDIO Module Input Clock
630 * selection
631 */
632 if (mmc_controller->slots[0].internal_clock) {
633 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
634 v |= (1 << 24);
635 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700636 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800637}
638
Anand Gadiyare08016d2011-03-01 13:12:55 -0800639void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
Tony Lindgrend8874662008-12-10 17:37:16 -0800640{
Anand Gadiyare08016d2011-03-01 13:12:55 -0800641 char *name = "mmci-omap";
Tony Lindgrend8874662008-12-10 17:37:16 -0800642
Anand Gadiyare08016d2011-03-01 13:12:55 -0800643 if (!mmc_data[0]) {
644 pr_err("%s fails: Incomplete platform data\n", __func__);
645 return;
646 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800647
Anand Gadiyare08016d2011-03-01 13:12:55 -0800648 omap242x_mmc_mux(mmc_data[0]);
649 omap_mmc_add(name, 0, OMAP2_MMC1_BASE, OMAP2420_MMC_SIZE,
650 INT_24XX_MMC_IRQ, mmc_data[0]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800651}
652
653#endif
654
655/*-------------------------------------------------------------------------*/
656
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300657#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
Tony Lindgren59b479e2011-01-27 16:39:40 -0800658#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300659#define OMAP_HDQ_BASE 0x480B2000
660#endif
661static struct resource omap_hdq_resources[] = {
662 {
663 .start = OMAP_HDQ_BASE,
664 .end = OMAP_HDQ_BASE + 0x1C,
665 .flags = IORESOURCE_MEM,
666 },
667 {
668 .start = INT_24XX_HDQ_IRQ,
669 .flags = IORESOURCE_IRQ,
670 },
671};
672static struct platform_device omap_hdq_dev = {
673 .name = "omap_hdq",
674 .id = 0,
675 .dev = {
676 .platform_data = NULL,
677 },
678 .num_resources = ARRAY_SIZE(omap_hdq_resources),
679 .resource = omap_hdq_resources,
680};
681static inline void omap_hdq_init(void)
682{
683 (void) platform_device_register(&omap_hdq_dev);
684}
685#else
686static inline void omap_hdq_init(void) {}
687#endif
688
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700689/*---------------------------------------------------------------------------*/
690
691#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
692 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
693#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
694static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
695};
696#else
697static struct resource omap_vout_resource[2] = {
698};
699#endif
700
701static struct platform_device omap_vout_device = {
702 .name = "omap_vout",
703 .num_resources = ARRAY_SIZE(omap_vout_resource),
704 .resource = &omap_vout_resource[0],
705 .id = -1,
706};
707static void omap_init_vout(void)
708{
709 if (platform_device_register(&omap_vout_device) < 0)
710 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
711}
712#else
713static inline void omap_init_vout(void) {}
714#endif
715
Tony Lindgren1dbae812005-11-10 14:26:51 +0000716/*-------------------------------------------------------------------------*/
717
718static int __init omap2_init_devices(void)
719{
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700720 /*
721 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000722 * in alphabetical order so they're easier to sort through.
723 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000724 omap_init_audio();
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600725 omap_init_mcpdm();
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800726 omap_init_dmic();
Tony Lindgren828c7072009-03-23 18:23:49 -0700727 omap_init_camera();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800728 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700729 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100730 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300731 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100732 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800733 omap_init_sham();
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800734 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700735 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000736
737 return 0;
738}
739arch_initcall(omap2_init_devices);
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530740
741#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530742static int __init omap_init_wdt(void)
743{
744 int id = -1;
Kevin Hilman3528c582011-07-21 13:48:45 -0700745 struct platform_device *pdev;
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530746 struct omap_hwmod *oh;
747 char *oh_name = "wd_timer2";
748 char *dev_name = "omap_wdt";
749
750 if (!cpu_class_is_omap2())
751 return 0;
752
753 oh = omap_hwmod_lookup(oh_name);
754 if (!oh) {
755 pr_err("Could not look up wd_timer%d hwmod\n", id);
756 return -EINVAL;
757 }
758
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200759 pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700760 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530761 dev_name, oh->name);
762 return 0;
763}
764subsys_initcall(omap_init_wdt);
765#endif