blob: 46dfd1ae8f71a6001f90ecdcea237103f906dcc4 [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>
Tony Lindgren1dbae812005-11-10 14:26:51 +000020
Russell Kinga09e64f2008-08-05 16:14:15 +010021#include <mach/hardware.h>
Will Deacon88341332010-04-09 13:54:43 +010022#include <mach/irqs.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000023#include <asm/mach-types.h>
24#include <asm/mach/map.h>
Will Deacon88341332010-04-09 13:54:43 +010025#include <asm/pmu.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000026
Tony Lindgrence491cf2009-10-20 09:40:47 -070027#include <plat/tc.h>
28#include <plat/board.h>
Jarkko Nikulaa09f73f2010-10-04 15:04:53 +030029#include <plat/mcbsp.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070030#include <plat/mmc.h>
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +030031#include <plat/iommu.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
131static struct resource omap3isp_resources[] = {
132 {
133 .start = OMAP3430_ISP_BASE,
134 .end = OMAP3430_ISP_END,
135 .flags = IORESOURCE_MEM,
136 },
137 {
Tony Lindgren828c7072009-03-23 18:23:49 -0700138 .start = OMAP3430_ISP_CCP2_BASE,
139 .end = OMAP3430_ISP_CCP2_END,
140 .flags = IORESOURCE_MEM,
141 },
142 {
143 .start = OMAP3430_ISP_CCDC_BASE,
144 .end = OMAP3430_ISP_CCDC_END,
145 .flags = IORESOURCE_MEM,
146 },
147 {
148 .start = OMAP3430_ISP_HIST_BASE,
149 .end = OMAP3430_ISP_HIST_END,
150 .flags = IORESOURCE_MEM,
151 },
152 {
153 .start = OMAP3430_ISP_H3A_BASE,
154 .end = OMAP3430_ISP_H3A_END,
155 .flags = IORESOURCE_MEM,
156 },
157 {
158 .start = OMAP3430_ISP_PREV_BASE,
159 .end = OMAP3430_ISP_PREV_END,
160 .flags = IORESOURCE_MEM,
161 },
162 {
163 .start = OMAP3430_ISP_RESZ_BASE,
164 .end = OMAP3430_ISP_RESZ_END,
165 .flags = IORESOURCE_MEM,
166 },
167 {
168 .start = OMAP3430_ISP_SBL_BASE,
169 .end = OMAP3430_ISP_SBL_END,
170 .flags = IORESOURCE_MEM,
171 },
172 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300173 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
174 .end = OMAP3430_ISP_CSI2A_REGS1_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700175 .flags = IORESOURCE_MEM,
176 },
177 {
Tuukka Toivonen6817a692010-02-02 11:17:33 -0300178 .start = OMAP3430_ISP_CSIPHY2_BASE,
179 .end = OMAP3430_ISP_CSIPHY2_END,
180 .flags = IORESOURCE_MEM,
181 },
182 {
183 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
184 .end = OMAP3630_ISP_CSI2A_REGS2_END,
185 .flags = IORESOURCE_MEM,
186 },
187 {
188 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
189 .end = OMAP3630_ISP_CSI2C_REGS1_END,
190 .flags = IORESOURCE_MEM,
191 },
192 {
193 .start = OMAP3630_ISP_CSIPHY1_BASE,
194 .end = OMAP3630_ISP_CSIPHY1_END,
195 .flags = IORESOURCE_MEM,
196 },
197 {
198 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
199 .end = OMAP3630_ISP_CSI2C_REGS2_END,
Tony Lindgren828c7072009-03-23 18:23:49 -0700200 .flags = IORESOURCE_MEM,
201 },
202 {
203 .start = INT_34XX_CAM_IRQ,
204 .flags = IORESOURCE_IRQ,
205 }
206};
207
208static struct platform_device omap3isp_device = {
209 .name = "omap3isp",
210 .id = -1,
211 .num_resources = ARRAY_SIZE(omap3isp_resources),
212 .resource = omap3isp_resources,
213};
214
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300215static struct omap_iommu_arch_data omap3_isp_iommu = {
216 .name = "isp",
217};
218
Laurent Pincharta11f6702009-12-14 08:09:07 -0300219int omap3_init_camera(struct isp_platform_data *pdata)
Tony Lindgren828c7072009-03-23 18:23:49 -0700220{
Laurent Pincharta11f6702009-12-14 08:09:07 -0300221 omap3isp_device.dev.platform_data = pdata;
Ohad Ben-Cohenc8eaab32011-09-23 16:44:57 +0300222 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
223
Laurent Pincharta11f6702009-12-14 08:09:07 -0300224 return platform_device_register(&omap3isp_device);
Tony Lindgren828c7072009-03-23 18:23:49 -0700225}
Tony Lindgren828c7072009-03-23 18:23:49 -0700226
Tony Lindgren1dbae812005-11-10 14:26:51 +0000227static inline void omap_init_camera(void)
228{
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300229#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
230 if (cpu_is_omap24xx())
231 platform_device_register(&omap2cam_device);
Tony Lindgren1dbae812005-11-10 14:26:51 +0000232#endif
Sergio Aguirrecfe2cde2010-11-15 11:29:54 -0300233}
Tony Lindgren1dbae812005-11-10 14:26:51 +0000234
Syed Rafiuddin59556762010-12-27 05:51:45 +0000235int __init omap4_keyboard_init(struct omap4_keypad_platform_data
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700236 *sdp4430_keypad_data, struct omap_board_data *bdata)
Syed Rafiuddin59556762010-12-27 05:51:45 +0000237{
Kevin Hilman3528c582011-07-21 13:48:45 -0700238 struct platform_device *pdev;
Syed Rafiuddin59556762010-12-27 05:51:45 +0000239 struct omap_hwmod *oh;
240 struct omap4_keypad_platform_data *keypad_data;
241 unsigned int id = -1;
242 char *oh_name = "kbd";
243 char *name = "omap4-keypad";
244
245 oh = omap_hwmod_lookup(oh_name);
246 if (!oh) {
247 pr_err("Could not look up %s\n", oh_name);
248 return -ENODEV;
249 }
250
251 keypad_data = sdp4430_keypad_data;
252
Kevin Hilman3528c582011-07-21 13:48:45 -0700253 pdev = omap_device_build(name, id, oh, keypad_data,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200254 sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000255
Kevin Hilman3528c582011-07-21 13:48:45 -0700256 if (IS_ERR(pdev)) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300257 WARN(1, "Can't build omap_device for %s:%s.\n",
Syed Rafiuddin59556762010-12-27 05:51:45 +0000258 name, oh->name);
Kevin Hilman3528c582011-07-21 13:48:45 -0700259 return PTR_ERR(pdev);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000260 }
Shubhrajyoti Dattaf67df6c2011-07-05 03:38:24 -0700261 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
Syed Rafiuddin59556762010-12-27 05:51:45 +0000262
263 return 0;
264}
265
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700266#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800267static inline void omap_init_mbox(void)
268{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800269 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -0700270 struct platform_device *pdev;
Felipe Contreras69dbf852011-02-24 12:51:33 -0800271
272 oh = omap_hwmod_lookup("mailbox");
273 if (!oh) {
274 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700275 return;
276 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800277
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200278 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700279 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
280 __func__, PTR_ERR(pdev));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800281}
282#else
283static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700284#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800285
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100286static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100287
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000288#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
289
290static struct platform_device omap_pcm = {
291 .name = "omap-pcm-audio",
292 .id = -1,
293};
294
295/*
296 * OMAP2420 has 2 McBSP ports
297 * OMAP2430 has 5 McBSP ports
298 * OMAP3 has 5 McBSP ports
299 * OMAP4 has 4 McBSP ports
300 */
301OMAP_MCBSP_PLATFORM_DEVICE(1);
302OMAP_MCBSP_PLATFORM_DEVICE(2);
303OMAP_MCBSP_PLATFORM_DEVICE(3);
304OMAP_MCBSP_PLATFORM_DEVICE(4);
305OMAP_MCBSP_PLATFORM_DEVICE(5);
306
307static void omap_init_audio(void)
308{
309 platform_device_register(&omap_mcbsp1);
310 platform_device_register(&omap_mcbsp2);
311 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
312 platform_device_register(&omap_mcbsp3);
313 platform_device_register(&omap_mcbsp4);
314 }
315 if (cpu_is_omap243x() || cpu_is_omap34xx())
316 platform_device_register(&omap_mcbsp5);
317
318 platform_device_register(&omap_pcm);
319}
320
321#else
322static inline void omap_init_audio(void) {}
323#endif
324
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600325#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
326 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
327
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600328static void omap_init_mcpdm(void)
329{
330 struct omap_hwmod *oh;
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200331 struct platform_device *pdev;
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600332
333 oh = omap_hwmod_lookup("mcpdm");
334 if (!oh) {
335 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
336 return;
337 }
338
Peter Ujfalusi927dbbb2011-11-03 10:41:22 +0200339 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0, NULL, 0, 0);
340 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600341}
342#else
343static inline void omap_init_mcpdm(void) {}
344#endif
345
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800346#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
347 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
348
349static void omap_init_dmic(void)
350{
351 struct omap_hwmod *oh;
352 struct platform_device *pdev;
353
354 oh = omap_hwmod_lookup("dmic");
355 if (!oh) {
356 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
357 return;
358 }
359
360 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0, NULL, 0, 0);
361 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
362}
363#else
364static inline void omap_init_dmic(void) {}
365#endif
366
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300367#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700368
Tony Lindgrence491cf2009-10-20 09:40:47 -0700369#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700370
Charulatha V1a5d8192011-02-02 17:52:14 +0530371static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700372{
Kevin Hilman3528c582011-07-21 13:48:45 -0700373 struct platform_device *pdev;
Charulatha V1a5d8192011-02-02 17:52:14 +0530374 char *name = "omap2_mcspi";
375 struct omap2_mcspi_platform_config *pdata;
376 static int spi_num;
377 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700378
Charulatha V1a5d8192011-02-02 17:52:14 +0530379 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
380 if (!pdata) {
381 pr_err("Memory allocation for McSPI device failed\n");
382 return -ENOMEM;
383 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700384
Charulatha V1a5d8192011-02-02 17:52:14 +0530385 pdata->num_cs = mcspi_attrib->num_chipselect;
386 switch (oh->class->rev) {
387 case OMAP2_MCSPI_REV:
388 case OMAP3_MCSPI_REV:
389 pdata->regs_offset = 0;
390 break;
391 case OMAP4_MCSPI_REV:
392 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
393 break;
394 default:
395 pr_err("Invalid McSPI Revision value\n");
396 return -EINVAL;
397 }
398
399 spi_num++;
Kevin Hilman3528c582011-07-21 13:48:45 -0700400 pdev = omap_device_build(name, spi_num, oh, pdata,
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200401 sizeof(*pdata), NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700402 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
Charulatha V1a5d8192011-02-02 17:52:14 +0530403 name, oh->name);
404 kfree(pdata);
405 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700406}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700407
408static void omap_init_mcspi(void)
409{
Charulatha V1a5d8192011-02-02 17:52:14 +0530410 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700411}
412
413#else
414static inline void omap_init_mcspi(void) {}
415#endif
416
Will Deacon88341332010-04-09 13:54:43 +0100417static struct resource omap2_pmu_resource = {
418 .start = 3,
419 .end = 3,
420 .flags = IORESOURCE_IRQ,
421};
422
423static struct resource omap3_pmu_resource = {
424 .start = INT_34XX_BENCH_MPU_EMUL,
425 .end = INT_34XX_BENCH_MPU_EMUL,
426 .flags = IORESOURCE_IRQ,
427};
428
429static struct platform_device omap_pmu_device = {
430 .name = "arm-pmu",
431 .id = ARM_PMU_DEVICE_CPU,
432 .num_resources = 1,
433};
434
435static void omap_init_pmu(void)
436{
437 if (cpu_is_omap24xx())
438 omap_pmu_device.resource = &omap2_pmu_resource;
439 else if (cpu_is_omap34xx())
440 omap_pmu_device.resource = &omap3_pmu_resource;
441 else
442 return;
443
444 platform_device_register(&omap_pmu_device);
445}
446
447
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800448#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
449
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000450#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800451static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300452 {
453 .start = OMAP24XX_SEC_SHA1MD5_BASE,
454 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
455 .flags = IORESOURCE_MEM,
456 },
457 {
458 .start = INT_24XX_SHA1MD5,
459 .flags = IORESOURCE_IRQ,
460 }
461};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800462static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
463#else
464#define omap2_sham_resources NULL
465#define omap2_sham_resources_sz 0
466#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300467
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000468#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800469static struct resource omap3_sham_resources[] = {
470 {
471 .start = OMAP34XX_SEC_SHA1MD5_BASE,
472 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
473 .flags = IORESOURCE_MEM,
474 },
475 {
476 .start = INT_34XX_SHA1MD52_IRQ,
477 .flags = IORESOURCE_IRQ,
478 },
479 {
480 .start = OMAP34XX_DMA_SHA1MD5_RX,
481 .flags = IORESOURCE_DMA,
482 }
483};
484static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
485#else
486#define omap3_sham_resources NULL
487#define omap3_sham_resources_sz 0
488#endif
489
490static struct platform_device sham_device = {
491 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300492 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300493};
494
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800495static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300496{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800497 if (cpu_is_omap24xx()) {
498 sham_device.resource = omap2_sham_resources;
499 sham_device.num_resources = omap2_sham_resources_sz;
500 } else if (cpu_is_omap34xx()) {
501 sham_device.resource = omap3_sham_resources;
502 sham_device.num_resources = omap3_sham_resources_sz;
503 } else {
504 pr_err("%s: platform not supported\n", __func__);
505 return;
506 }
507 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300508}
509#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800510static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300511#endif
512
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800513#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
514
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000515#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800516static struct resource omap2_aes_resources[] = {
517 {
518 .start = OMAP24XX_SEC_AES_BASE,
519 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
520 .flags = IORESOURCE_MEM,
521 },
522 {
523 .start = OMAP24XX_DMA_AES_TX,
524 .flags = IORESOURCE_DMA,
525 },
526 {
527 .start = OMAP24XX_DMA_AES_RX,
528 .flags = IORESOURCE_DMA,
529 }
530};
531static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
532#else
533#define omap2_aes_resources NULL
534#define omap2_aes_resources_sz 0
535#endif
536
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000537#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800538static struct resource omap3_aes_resources[] = {
539 {
540 .start = OMAP34XX_SEC_AES_BASE,
541 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
542 .flags = IORESOURCE_MEM,
543 },
544 {
545 .start = OMAP34XX_DMA_AES2_TX,
546 .flags = IORESOURCE_DMA,
547 },
548 {
549 .start = OMAP34XX_DMA_AES2_RX,
550 .flags = IORESOURCE_DMA,
551 }
552};
553static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
554#else
555#define omap3_aes_resources NULL
556#define omap3_aes_resources_sz 0
557#endif
558
559static struct platform_device aes_device = {
560 .name = "omap-aes",
561 .id = -1,
562};
563
564static void omap_init_aes(void)
565{
566 if (cpu_is_omap24xx()) {
567 aes_device.resource = omap2_aes_resources;
568 aes_device.num_resources = omap2_aes_resources_sz;
569 } else if (cpu_is_omap34xx()) {
570 aes_device.resource = omap3_aes_resources;
571 aes_device.num_resources = omap3_aes_resources_sz;
572 } else {
573 pr_err("%s: platform not supported\n", __func__);
574 return;
575 }
576 platform_device_register(&aes_device);
577}
578
579#else
580static inline void omap_init_aes(void) { }
581#endif
582
Tony Lindgrend8874662008-12-10 17:37:16 -0800583/*-------------------------------------------------------------------------*/
584
Anand Gadiyare08016d2011-03-01 13:12:55 -0800585#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
Kevin Hilman917fa282008-12-10 17:37:17 -0800586
Anand Gadiyare08016d2011-03-01 13:12:55 -0800587static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
588 *mmc_controller)
Tony Lindgrend8874662008-12-10 17:37:16 -0800589{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000590 if ((mmc_controller->slots[0].switch_pin > 0) && \
591 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
592 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
593 OMAP_PIN_INPUT_PULLUP);
594 if ((mmc_controller->slots[0].gpio_wp > 0) && \
595 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
596 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
597 OMAP_PIN_INPUT_PULLUP);
598
Anand Gadiyare08016d2011-03-01 13:12:55 -0800599 omap_mux_init_signal("sdmmc_cmd", 0);
600 omap_mux_init_signal("sdmmc_clki", 0);
601 omap_mux_init_signal("sdmmc_clko", 0);
602 omap_mux_init_signal("sdmmc_dat0", 0);
603 omap_mux_init_signal("sdmmc_dat_dir0", 0);
604 omap_mux_init_signal("sdmmc_cmd_dir", 0);
605 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
606 omap_mux_init_signal("sdmmc_dat1", 0);
607 omap_mux_init_signal("sdmmc_dat2", 0);
608 omap_mux_init_signal("sdmmc_dat3", 0);
609 omap_mux_init_signal("sdmmc_dat_dir1", 0);
610 omap_mux_init_signal("sdmmc_dat_dir2", 0);
611 omap_mux_init_signal("sdmmc_dat_dir3", 0);
Tony Lindgrend8874662008-12-10 17:37:16 -0800612 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700613
Anand Gadiyare08016d2011-03-01 13:12:55 -0800614 /*
615 * Use internal loop-back in MMC/SDIO Module Input Clock
616 * selection
617 */
618 if (mmc_controller->slots[0].internal_clock) {
619 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
620 v |= (1 << 24);
621 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700622 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800623}
624
Anand Gadiyare08016d2011-03-01 13:12:55 -0800625void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
Tony Lindgrend8874662008-12-10 17:37:16 -0800626{
Anand Gadiyare08016d2011-03-01 13:12:55 -0800627 char *name = "mmci-omap";
Tony Lindgrend8874662008-12-10 17:37:16 -0800628
Anand Gadiyare08016d2011-03-01 13:12:55 -0800629 if (!mmc_data[0]) {
630 pr_err("%s fails: Incomplete platform data\n", __func__);
631 return;
632 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800633
Anand Gadiyare08016d2011-03-01 13:12:55 -0800634 omap242x_mmc_mux(mmc_data[0]);
635 omap_mmc_add(name, 0, OMAP2_MMC1_BASE, OMAP2420_MMC_SIZE,
636 INT_24XX_MMC_IRQ, mmc_data[0]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800637}
638
639#endif
640
641/*-------------------------------------------------------------------------*/
642
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300643#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
Tony Lindgren59b479e2011-01-27 16:39:40 -0800644#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300645#define OMAP_HDQ_BASE 0x480B2000
646#endif
647static struct resource omap_hdq_resources[] = {
648 {
649 .start = OMAP_HDQ_BASE,
650 .end = OMAP_HDQ_BASE + 0x1C,
651 .flags = IORESOURCE_MEM,
652 },
653 {
654 .start = INT_24XX_HDQ_IRQ,
655 .flags = IORESOURCE_IRQ,
656 },
657};
658static struct platform_device omap_hdq_dev = {
659 .name = "omap_hdq",
660 .id = 0,
661 .dev = {
662 .platform_data = NULL,
663 },
664 .num_resources = ARRAY_SIZE(omap_hdq_resources),
665 .resource = omap_hdq_resources,
666};
667static inline void omap_hdq_init(void)
668{
669 (void) platform_device_register(&omap_hdq_dev);
670}
671#else
672static inline void omap_hdq_init(void) {}
673#endif
674
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700675/*---------------------------------------------------------------------------*/
676
677#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
678 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
679#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
680static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
681};
682#else
683static struct resource omap_vout_resource[2] = {
684};
685#endif
686
687static struct platform_device omap_vout_device = {
688 .name = "omap_vout",
689 .num_resources = ARRAY_SIZE(omap_vout_resource),
690 .resource = &omap_vout_resource[0],
691 .id = -1,
692};
693static void omap_init_vout(void)
694{
695 if (platform_device_register(&omap_vout_device) < 0)
696 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
697}
698#else
699static inline void omap_init_vout(void) {}
700#endif
701
Tony Lindgren1dbae812005-11-10 14:26:51 +0000702/*-------------------------------------------------------------------------*/
703
704static int __init omap2_init_devices(void)
705{
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700706 /*
707 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000708 * in alphabetical order so they're easier to sort through.
709 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000710 omap_init_audio();
Peter Ujfalusid231f5c2011-02-12 22:28:56 -0600711 omap_init_mcpdm();
Peter Ujfaluside9eb092011-12-13 10:48:54 -0800712 omap_init_dmic();
Tony Lindgren828c7072009-03-23 18:23:49 -0700713 omap_init_camera();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800714 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700715 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100716 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300717 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100718 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800719 omap_init_sham();
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800720 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700721 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000722
723 return 0;
724}
725arch_initcall(omap2_init_devices);
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530726
727#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530728static int __init omap_init_wdt(void)
729{
730 int id = -1;
Kevin Hilman3528c582011-07-21 13:48:45 -0700731 struct platform_device *pdev;
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530732 struct omap_hwmod *oh;
733 char *oh_name = "wd_timer2";
734 char *dev_name = "omap_wdt";
735
736 if (!cpu_class_is_omap2())
737 return 0;
738
739 oh = omap_hwmod_lookup(oh_name);
740 if (!oh) {
741 pr_err("Could not look up wd_timer%d hwmod\n", id);
742 return -EINVAL;
743 }
744
Benoit Coussonf718e2c2011-08-10 15:30:09 +0200745 pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0);
Kevin Hilman3528c582011-07-21 13:48:45 -0700746 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530747 dev_name, oh->name);
748 return 0;
749}
750subsys_initcall(omap_init_wdt);
751#endif