blob: 512ae4696a6c319b3875c4ae4286387210a5d352 [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 */
11
Tony Lindgren1dbae812005-11-10 14:26:51 +000012#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010016#include <linux/io.h>
Kevin Hilman917fa282008-12-10 17:37:17 -080017#include <linux/clk.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000018
Russell Kinga09e64f2008-08-05 16:14:15 +010019#include <mach/hardware.h>
Will Deacon88341332010-04-09 13:54:43 +010020#include <mach/irqs.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000021#include <asm/mach-types.h>
22#include <asm/mach/map.h>
Will Deacon88341332010-04-09 13:54:43 +010023#include <asm/pmu.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000024
Tony Lindgrence491cf2009-10-20 09:40:47 -070025#include <plat/control.h>
26#include <plat/tc.h>
27#include <plat/board.h>
Jarkko Nikulaa09f73f2010-10-04 15:04:53 +030028#include <plat/mcbsp.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070030#include <plat/mmc.h>
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +080031#include <plat/dma.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000032
Tony Lindgren4896e392009-12-11 16:16:32 -080033#include "mux.h"
34
Tony Lindgren828c7072009-03-23 18:23:49 -070035#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -080036
Tony Lindgren828c7072009-03-23 18:23:49 -070037static struct resource cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -080038 {
Tony Lindgren828c7072009-03-23 18:23:49 -070039 .start = OMAP24XX_CAMERA_BASE,
40 .end = OMAP24XX_CAMERA_BASE + 0xfff,
41 .flags = IORESOURCE_MEM,
42 },
43 {
44 .start = INT_24XX_CAM_IRQ,
45 .flags = IORESOURCE_IRQ,
46 }
47};
48
49static struct platform_device omap_cam_device = {
50 .name = "omap24xxcam",
51 .id = -1,
52 .num_resources = ARRAY_SIZE(cam_resources),
53 .resource = cam_resources,
54};
55
56static inline void omap_init_camera(void)
57{
58 platform_device_register(&omap_cam_device);
59}
60
61#elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
62
63static struct resource omap3isp_resources[] = {
64 {
65 .start = OMAP3430_ISP_BASE,
66 .end = OMAP3430_ISP_END,
67 .flags = IORESOURCE_MEM,
68 },
69 {
70 .start = OMAP3430_ISP_CBUFF_BASE,
71 .end = OMAP3430_ISP_CBUFF_END,
72 .flags = IORESOURCE_MEM,
73 },
74 {
75 .start = OMAP3430_ISP_CCP2_BASE,
76 .end = OMAP3430_ISP_CCP2_END,
77 .flags = IORESOURCE_MEM,
78 },
79 {
80 .start = OMAP3430_ISP_CCDC_BASE,
81 .end = OMAP3430_ISP_CCDC_END,
82 .flags = IORESOURCE_MEM,
83 },
84 {
85 .start = OMAP3430_ISP_HIST_BASE,
86 .end = OMAP3430_ISP_HIST_END,
87 .flags = IORESOURCE_MEM,
88 },
89 {
90 .start = OMAP3430_ISP_H3A_BASE,
91 .end = OMAP3430_ISP_H3A_END,
92 .flags = IORESOURCE_MEM,
93 },
94 {
95 .start = OMAP3430_ISP_PREV_BASE,
96 .end = OMAP3430_ISP_PREV_END,
97 .flags = IORESOURCE_MEM,
98 },
99 {
100 .start = OMAP3430_ISP_RESZ_BASE,
101 .end = OMAP3430_ISP_RESZ_END,
102 .flags = IORESOURCE_MEM,
103 },
104 {
105 .start = OMAP3430_ISP_SBL_BASE,
106 .end = OMAP3430_ISP_SBL_END,
107 .flags = IORESOURCE_MEM,
108 },
109 {
110 .start = OMAP3430_ISP_CSI2A_BASE,
111 .end = OMAP3430_ISP_CSI2A_END,
112 .flags = IORESOURCE_MEM,
113 },
114 {
115 .start = OMAP3430_ISP_CSI2PHY_BASE,
116 .end = OMAP3430_ISP_CSI2PHY_END,
117 .flags = IORESOURCE_MEM,
118 },
119 {
120 .start = INT_34XX_CAM_IRQ,
121 .flags = IORESOURCE_IRQ,
122 }
123};
124
125static struct platform_device omap3isp_device = {
126 .name = "omap3isp",
127 .id = -1,
128 .num_resources = ARRAY_SIZE(omap3isp_resources),
129 .resource = omap3isp_resources,
130};
131
132static inline void omap_init_camera(void)
133{
134 platform_device_register(&omap3isp_device);
135}
136#else
137static inline void omap_init_camera(void)
138{
139}
140#endif
141
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700142#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800143
C A Subramaniam454bf342009-11-22 10:11:18 -0800144#define MBOX_REG_SIZE 0x120
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700145
C A Subramaniam454bf342009-11-22 10:11:18 -0800146#ifdef CONFIG_ARCH_OMAP2
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800147static struct resource omap2_mbox_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800148 {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700149 .start = OMAP24XX_MAILBOX_BASE,
150 .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800151 .flags = IORESOURCE_MEM,
152 },
153 {
154 .start = INT_24XX_MAIL_U0_MPU,
155 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000156 .name = "dsp",
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800157 },
158 {
159 .start = INT_24XX_MAIL_U3_MPU,
160 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000161 .name = "iva",
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800162 },
163};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800164static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
165#else
166#define omap2_mbox_resources NULL
167#define omap2_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800168#endif
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800169
C A Subramaniam454bf342009-11-22 10:11:18 -0800170#ifdef CONFIG_ARCH_OMAP3
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800171static struct resource omap3_mbox_resources[] = {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700172 {
173 .start = OMAP34XX_MAILBOX_BASE,
174 .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
175 .flags = IORESOURCE_MEM,
176 },
177 {
178 .start = INT_24XX_MAIL_U0_MPU,
179 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000180 .name = "dsp",
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700181 },
182};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800183static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
184#else
185#define omap3_mbox_resources NULL
186#define omap3_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800187#endif
188
189#ifdef CONFIG_ARCH_OMAP4
190
191#define OMAP4_MBOX_REG_SIZE 0x130
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800192static struct resource omap4_mbox_resources[] = {
C A Subramaniam454bf342009-11-22 10:11:18 -0800193 {
194 .start = OMAP44XX_MAILBOX_BASE,
195 .end = OMAP44XX_MAILBOX_BASE +
196 OMAP4_MBOX_REG_SIZE - 1,
197 .flags = IORESOURCE_MEM,
198 },
199 {
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530200 .start = OMAP44XX_IRQ_MAIL_U0,
C A Subramaniam454bf342009-11-22 10:11:18 -0800201 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000202 .name = "mbox",
C A Subramaniam454bf342009-11-22 10:11:18 -0800203 },
204};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800205static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
206#else
207#define omap4_mbox_resources NULL
208#define omap4_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800209#endif
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700210
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800211static struct platform_device mbox_device = {
Felipe Contrerasd7427092010-06-11 15:51:48 +0000212 .name = "omap-mailbox",
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800213 .id = -1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800214};
215
216static inline void omap_init_mbox(void)
217{
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800218 if (cpu_is_omap24xx()) {
219 mbox_device.resource = omap2_mbox_resources;
220 mbox_device.num_resources = omap2_mbox_resources_sz;
221 } else if (cpu_is_omap34xx()) {
222 mbox_device.resource = omap3_mbox_resources;
223 mbox_device.num_resources = omap3_mbox_resources_sz;
224 } else if (cpu_is_omap44xx()) {
225 mbox_device.resource = omap4_mbox_resources;
226 mbox_device.num_resources = omap4_mbox_resources_sz;
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700227 } else {
228 pr_err("%s: platform not supported\n", __func__);
229 return;
230 }
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800231 platform_device_register(&mbox_device);
232}
233#else
234static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700235#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800236
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100237static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100238
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000239#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
240
241static struct platform_device omap_pcm = {
242 .name = "omap-pcm-audio",
243 .id = -1,
244};
245
246/*
247 * OMAP2420 has 2 McBSP ports
248 * OMAP2430 has 5 McBSP ports
249 * OMAP3 has 5 McBSP ports
250 * OMAP4 has 4 McBSP ports
251 */
252OMAP_MCBSP_PLATFORM_DEVICE(1);
253OMAP_MCBSP_PLATFORM_DEVICE(2);
254OMAP_MCBSP_PLATFORM_DEVICE(3);
255OMAP_MCBSP_PLATFORM_DEVICE(4);
256OMAP_MCBSP_PLATFORM_DEVICE(5);
257
258static void omap_init_audio(void)
259{
260 platform_device_register(&omap_mcbsp1);
261 platform_device_register(&omap_mcbsp2);
262 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
263 platform_device_register(&omap_mcbsp3);
264 platform_device_register(&omap_mcbsp4);
265 }
266 if (cpu_is_omap243x() || cpu_is_omap34xx())
267 platform_device_register(&omap_mcbsp5);
268
269 platform_device_register(&omap_pcm);
270}
271
272#else
273static inline void omap_init_audio(void) {}
274#endif
275
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300276#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700277
Tony Lindgrence491cf2009-10-20 09:40:47 -0700278#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700279
280#define OMAP2_MCSPI1_BASE 0x48098000
281#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300282#define OMAP2_MCSPI3_BASE 0x480b8000
283#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700284
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700285#define OMAP4_MCSPI1_BASE 0x48098100
286#define OMAP4_MCSPI2_BASE 0x4809a100
287#define OMAP4_MCSPI3_BASE 0x480b8100
288#define OMAP4_MCSPI4_BASE 0x480ba100
289
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700290static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700291 .num_cs = 4,
292};
293
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800294static struct resource omap2_mcspi1_resources[] = {
295 {
296 .start = OMAP2_MCSPI1_BASE,
297 .end = OMAP2_MCSPI1_BASE + 0xff,
298 .flags = IORESOURCE_MEM,
299 },
300};
301
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300302static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700303 .name = "omap2_mcspi",
304 .id = 1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800305 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
306 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700307 .dev = {
308 .platform_data = &omap2_mcspi1_config,
309 },
310};
311
312static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700313 .num_cs = 2,
314};
315
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800316static struct resource omap2_mcspi2_resources[] = {
317 {
318 .start = OMAP2_MCSPI2_BASE,
319 .end = OMAP2_MCSPI2_BASE + 0xff,
320 .flags = IORESOURCE_MEM,
321 },
322};
323
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300324static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700325 .name = "omap2_mcspi",
326 .id = 2,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800327 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
328 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700329 .dev = {
330 .platform_data = &omap2_mcspi2_config,
331 },
332};
333
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700334#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
335 defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300336static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
337 .num_cs = 2,
338};
339
340static struct resource omap2_mcspi3_resources[] = {
341 {
342 .start = OMAP2_MCSPI3_BASE,
343 .end = OMAP2_MCSPI3_BASE + 0xff,
344 .flags = IORESOURCE_MEM,
345 },
346};
347
348static struct platform_device omap2_mcspi3 = {
349 .name = "omap2_mcspi",
350 .id = 3,
351 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
352 .resource = omap2_mcspi3_resources,
353 .dev = {
354 .platform_data = &omap2_mcspi3_config,
355 },
356};
357#endif
358
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700359#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300360static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
361 .num_cs = 1,
362};
363
364static struct resource omap2_mcspi4_resources[] = {
365 {
366 .start = OMAP2_MCSPI4_BASE,
367 .end = OMAP2_MCSPI4_BASE + 0xff,
368 .flags = IORESOURCE_MEM,
369 },
370};
371
372static struct platform_device omap2_mcspi4 = {
373 .name = "omap2_mcspi",
374 .id = 4,
375 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
376 .resource = omap2_mcspi4_resources,
377 .dev = {
378 .platform_data = &omap2_mcspi4_config,
379 },
380};
381#endif
382
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700383#ifdef CONFIG_ARCH_OMAP4
384static inline void omap4_mcspi_fixup(void)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700385{
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700386 omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
387 omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
388 omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
389 omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
390 omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
391 omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
392 omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
393 omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
394}
395#else
396static inline void omap4_mcspi_fixup(void)
397{
398}
399#endif
400
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700401#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
402 defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700403static inline void omap2_mcspi3_init(void)
404{
405 platform_device_register(&omap2_mcspi3);
406}
407#else
408static inline void omap2_mcspi3_init(void)
409{
410}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300411#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700412
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700413#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700414static inline void omap2_mcspi4_init(void)
415{
416 platform_device_register(&omap2_mcspi4);
417}
418#else
419static inline void omap2_mcspi4_init(void)
420{
421}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300422#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700423
424static void omap_init_mcspi(void)
425{
426 if (cpu_is_omap44xx())
427 omap4_mcspi_fixup();
428
429 platform_device_register(&omap2_mcspi1);
430 platform_device_register(&omap2_mcspi2);
431
432 if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
433 omap2_mcspi3_init();
434
435 if (cpu_is_omap343x() || cpu_is_omap44xx())
436 omap2_mcspi4_init();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700437}
438
439#else
440static inline void omap_init_mcspi(void) {}
441#endif
442
Will Deacon88341332010-04-09 13:54:43 +0100443static struct resource omap2_pmu_resource = {
444 .start = 3,
445 .end = 3,
446 .flags = IORESOURCE_IRQ,
447};
448
449static struct resource omap3_pmu_resource = {
450 .start = INT_34XX_BENCH_MPU_EMUL,
451 .end = INT_34XX_BENCH_MPU_EMUL,
452 .flags = IORESOURCE_IRQ,
453};
454
455static struct platform_device omap_pmu_device = {
456 .name = "arm-pmu",
457 .id = ARM_PMU_DEVICE_CPU,
458 .num_resources = 1,
459};
460
461static void omap_init_pmu(void)
462{
463 if (cpu_is_omap24xx())
464 omap_pmu_device.resource = &omap2_pmu_resource;
465 else if (cpu_is_omap34xx())
466 omap_pmu_device.resource = &omap3_pmu_resource;
467 else
468 return;
469
470 platform_device_register(&omap_pmu_device);
471}
472
473
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800474#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
475
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000476#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800477static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300478 {
479 .start = OMAP24XX_SEC_SHA1MD5_BASE,
480 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
481 .flags = IORESOURCE_MEM,
482 },
483 {
484 .start = INT_24XX_SHA1MD5,
485 .flags = IORESOURCE_IRQ,
486 }
487};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800488static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
489#else
490#define omap2_sham_resources NULL
491#define omap2_sham_resources_sz 0
492#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300493
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000494#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800495static struct resource omap3_sham_resources[] = {
496 {
497 .start = OMAP34XX_SEC_SHA1MD5_BASE,
498 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
499 .flags = IORESOURCE_MEM,
500 },
501 {
502 .start = INT_34XX_SHA1MD52_IRQ,
503 .flags = IORESOURCE_IRQ,
504 },
505 {
506 .start = OMAP34XX_DMA_SHA1MD5_RX,
507 .flags = IORESOURCE_DMA,
508 }
509};
510static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
511#else
512#define omap3_sham_resources NULL
513#define omap3_sham_resources_sz 0
514#endif
515
516static struct platform_device sham_device = {
517 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300518 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300519};
520
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800521static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300522{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800523 if (cpu_is_omap24xx()) {
524 sham_device.resource = omap2_sham_resources;
525 sham_device.num_resources = omap2_sham_resources_sz;
526 } else if (cpu_is_omap34xx()) {
527 sham_device.resource = omap3_sham_resources;
528 sham_device.num_resources = omap3_sham_resources_sz;
529 } else {
530 pr_err("%s: platform not supported\n", __func__);
531 return;
532 }
533 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300534}
535#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800536static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300537#endif
538
Tony Lindgrend8874662008-12-10 17:37:16 -0800539/*-------------------------------------------------------------------------*/
540
kishore kadiyala82cf8182009-09-22 16:45:25 -0700541#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Kevin Hilman917fa282008-12-10 17:37:17 -0800542
543#define MMCHS_SYSCONFIG 0x0010
544#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
545#define MMCHS_SYSSTATUS 0x0014
546#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
547
548static struct platform_device dummy_pdev = {
549 .dev = {
550 .bus = &platform_bus_type,
551 },
552};
553
554/**
555 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
556 *
557 * Ensure that each MMC controller is fully reset. Controllers
558 * left in an unknown state (by bootloader) may prevent retention
559 * or OFF-mode. This is especially important in cases where the
560 * MMC driver is not enabled, _or_ built as a module.
561 *
562 * In order for reset to work, interface, functional and debounce
563 * clocks must be enabled. The debounce clock comes from func_32k_clk
564 * and is not under SW control, so we only enable i- and f-clocks.
565 **/
566static void __init omap_hsmmc_reset(void)
567{
Tony Lindgren4323e9f2010-02-12 12:26:48 -0800568 u32 i, nr_controllers;
569
570 if (cpu_is_omap242x())
571 return;
572
573 nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
kishore kadiyala82cf8182009-09-22 16:45:25 -0700574 (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
Kevin Hilman917fa282008-12-10 17:37:17 -0800575
576 for (i = 0; i < nr_controllers; i++) {
577 u32 v, base = 0;
578 struct clk *iclk, *fclk;
579 struct device *dev = &dummy_pdev.dev;
580
581 switch (i) {
582 case 0:
583 base = OMAP2_MMC1_BASE;
584 break;
585 case 1:
586 base = OMAP2_MMC2_BASE;
587 break;
588 case 2:
589 base = OMAP3_MMC3_BASE;
590 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700591 case 3:
592 if (!cpu_is_omap44xx())
593 return;
594 base = OMAP4_MMC4_BASE;
595 break;
596 case 4:
597 if (!cpu_is_omap44xx())
598 return;
599 base = OMAP4_MMC5_BASE;
600 break;
Kevin Hilman917fa282008-12-10 17:37:17 -0800601 }
602
kishore kadiyala82cf8182009-09-22 16:45:25 -0700603 if (cpu_is_omap44xx())
604 base += OMAP4_MMC_REG_OFFSET;
605
Kevin Hilman917fa282008-12-10 17:37:17 -0800606 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000607 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000608 iclk = clk_get(dev, "ick");
Kevin Hilman917fa282008-12-10 17:37:17 -0800609 if (iclk && clk_enable(iclk))
610 iclk = NULL;
611
Russell King6f7607c2009-01-28 10:22:50 +0000612 fclk = clk_get(dev, "fck");
Kevin Hilman917fa282008-12-10 17:37:17 -0800613 if (fclk && clk_enable(fclk))
614 fclk = NULL;
615
616 if (!iclk || !fclk) {
617 printk(KERN_WARNING
618 "%s: Unable to enable clocks for MMC%d, "
619 "cannot reset.\n", __func__, i);
620 break;
621 }
622
623 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
624 v = omap_readl(base + MMCHS_SYSSTATUS);
625 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
626 MMCHS_SYSSTATUS_RESETDONE))
627 cpu_relax();
628
629 if (fclk) {
630 clk_disable(fclk);
631 clk_put(fclk);
632 }
633 if (iclk) {
634 clk_disable(iclk);
635 clk_put(iclk);
636 }
637 }
638}
639#else
640static inline void omap_hsmmc_reset(void) {}
641#endif
642
Tony Lindgrend8874662008-12-10 17:37:16 -0800643#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
644 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
645
646static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
647 int controller_nr)
648{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000649 if ((mmc_controller->slots[0].switch_pin > 0) && \
650 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
651 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
652 OMAP_PIN_INPUT_PULLUP);
653 if ((mmc_controller->slots[0].gpio_wp > 0) && \
654 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
655 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
656 OMAP_PIN_INPUT_PULLUP);
657
Tony Lindgrend8874662008-12-10 17:37:16 -0800658 if (cpu_is_omap2420() && controller_nr == 0) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300659 omap_mux_init_signal("sdmmc_cmd", 0);
660 omap_mux_init_signal("sdmmc_clki", 0);
661 omap_mux_init_signal("sdmmc_clko", 0);
662 omap_mux_init_signal("sdmmc_dat0", 0);
663 omap_mux_init_signal("sdmmc_dat_dir0", 0);
664 omap_mux_init_signal("sdmmc_cmd_dir", 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800665 if (mmc_controller->slots[0].wires == 4) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300666 omap_mux_init_signal("sdmmc_dat1", 0);
667 omap_mux_init_signal("sdmmc_dat2", 0);
668 omap_mux_init_signal("sdmmc_dat3", 0);
669 omap_mux_init_signal("sdmmc_dat_dir1", 0);
670 omap_mux_init_signal("sdmmc_dat_dir2", 0);
671 omap_mux_init_signal("sdmmc_dat_dir3", 0);
Tony Lindgrend8874662008-12-10 17:37:16 -0800672 }
673
674 /*
675 * Use internal loop-back in MMC/SDIO Module Input Clock
676 * selection
677 */
678 if (mmc_controller->slots[0].internal_clock) {
679 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
680 v |= (1 << 24);
681 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
682 }
683 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700684
Madhu4596d142009-11-22 10:11:06 -0800685 if (cpu_is_omap34xx()) {
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700686 if (controller_nr == 0) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800687 omap_mux_init_signal("sdmmc1_clk",
688 OMAP_PIN_INPUT_PULLUP);
689 omap_mux_init_signal("sdmmc1_cmd",
690 OMAP_PIN_INPUT_PULLUP);
691 omap_mux_init_signal("sdmmc1_dat0",
692 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700693 if (mmc_controller->slots[0].wires == 4 ||
694 mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800695 omap_mux_init_signal("sdmmc1_dat1",
696 OMAP_PIN_INPUT_PULLUP);
697 omap_mux_init_signal("sdmmc1_dat2",
698 OMAP_PIN_INPUT_PULLUP);
699 omap_mux_init_signal("sdmmc1_dat3",
700 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700701 }
702 if (mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800703 omap_mux_init_signal("sdmmc1_dat4",
704 OMAP_PIN_INPUT_PULLUP);
705 omap_mux_init_signal("sdmmc1_dat5",
706 OMAP_PIN_INPUT_PULLUP);
707 omap_mux_init_signal("sdmmc1_dat6",
708 OMAP_PIN_INPUT_PULLUP);
709 omap_mux_init_signal("sdmmc1_dat7",
710 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700711 }
712 }
713 if (controller_nr == 1) {
714 /* MMC2 */
Tony Lindgren4896e392009-12-11 16:16:32 -0800715 omap_mux_init_signal("sdmmc2_clk",
716 OMAP_PIN_INPUT_PULLUP);
717 omap_mux_init_signal("sdmmc2_cmd",
718 OMAP_PIN_INPUT_PULLUP);
719 omap_mux_init_signal("sdmmc2_dat0",
720 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700721
722 /*
723 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
724 * in the board-*.c files
725 */
726 if (mmc_controller->slots[0].wires == 4 ||
727 mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800728 omap_mux_init_signal("sdmmc2_dat1",
729 OMAP_PIN_INPUT_PULLUP);
730 omap_mux_init_signal("sdmmc2_dat2",
731 OMAP_PIN_INPUT_PULLUP);
732 omap_mux_init_signal("sdmmc2_dat3",
733 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700734 }
Madhu46792322009-11-22 10:11:08 -0800735 if (mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800736 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
737 OMAP_PIN_INPUT_PULLUP);
738 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
739 OMAP_PIN_INPUT_PULLUP);
740 omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
741 OMAP_PIN_INPUT_PULLUP);
742 omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
743 OMAP_PIN_INPUT_PULLUP);
Madhu46792322009-11-22 10:11:08 -0800744 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700745 }
746
747 /*
748 * For MMC3 the pins need to be muxed in the board-*.c files
749 */
750 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800751}
752
753void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
754 int nr_controllers)
755{
756 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800757 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800758
759 for (i = 0; i < nr_controllers; i++) {
760 unsigned long base, size;
761 unsigned int irq = 0;
762
763 if (!mmc_data[i])
764 continue;
765
766 omap2_mmc_mux(mmc_data[i], i);
767
768 switch (i) {
769 case 0:
770 base = OMAP2_MMC1_BASE;
771 irq = INT_24XX_MMC_IRQ;
772 break;
773 case 1:
774 base = OMAP2_MMC2_BASE;
775 irq = INT_24XX_MMC2_IRQ;
776 break;
777 case 2:
kishore kadiyala82cf8182009-09-22 16:45:25 -0700778 if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
Tony Lindgrend8874662008-12-10 17:37:16 -0800779 return;
780 base = OMAP3_MMC3_BASE;
781 irq = INT_34XX_MMC3_IRQ;
782 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700783 case 3:
784 if (!cpu_is_omap44xx())
785 return;
786 base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530787 irq = OMAP44XX_IRQ_MMC4;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700788 break;
789 case 4:
790 if (!cpu_is_omap44xx())
791 return;
792 base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
kishore kadiyala9df76b72010-04-21 18:19:37 +0000793 irq = OMAP44XX_IRQ_MMC5;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700794 break;
Tony Lindgrend8874662008-12-10 17:37:16 -0800795 default:
796 continue;
797 }
798
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800799 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800800 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800801 name = "mmci-omap";
kishore kadiyala82cf8182009-09-22 16:45:25 -0700802 } else if (cpu_is_omap44xx()) {
803 if (i < 3) {
804 base += OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530805 irq += OMAP44XX_IRQ_GIC_START;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700806 }
807 size = OMAP4_HSMMC_SIZE;
808 name = "mmci-omap-hs";
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800809 } else {
kishore kadiyala82cf8182009-09-22 16:45:25 -0700810 size = OMAP3_HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800811 name = "mmci-omap-hs";
812 }
813 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800814 };
815}
816
817#endif
818
819/*-------------------------------------------------------------------------*/
820
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300821#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
822#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
823#define OMAP_HDQ_BASE 0x480B2000
824#endif
825static struct resource omap_hdq_resources[] = {
826 {
827 .start = OMAP_HDQ_BASE,
828 .end = OMAP_HDQ_BASE + 0x1C,
829 .flags = IORESOURCE_MEM,
830 },
831 {
832 .start = INT_24XX_HDQ_IRQ,
833 .flags = IORESOURCE_IRQ,
834 },
835};
836static struct platform_device omap_hdq_dev = {
837 .name = "omap_hdq",
838 .id = 0,
839 .dev = {
840 .platform_data = NULL,
841 },
842 .num_resources = ARRAY_SIZE(omap_hdq_resources),
843 .resource = omap_hdq_resources,
844};
845static inline void omap_hdq_init(void)
846{
847 (void) platform_device_register(&omap_hdq_dev);
848}
849#else
850static inline void omap_hdq_init(void) {}
851#endif
852
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700853/*---------------------------------------------------------------------------*/
854
855#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
856 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
857#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
858static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
859};
860#else
861static struct resource omap_vout_resource[2] = {
862};
863#endif
864
865static struct platform_device omap_vout_device = {
866 .name = "omap_vout",
867 .num_resources = ARRAY_SIZE(omap_vout_resource),
868 .resource = &omap_vout_resource[0],
869 .id = -1,
870};
871static void omap_init_vout(void)
872{
873 if (platform_device_register(&omap_vout_device) < 0)
874 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
875}
876#else
877static inline void omap_init_vout(void) {}
878#endif
879
Tony Lindgren1dbae812005-11-10 14:26:51 +0000880/*-------------------------------------------------------------------------*/
881
882static int __init omap2_init_devices(void)
883{
884 /* please keep these calls, and their implementations above,
885 * in alphabetical order so they're easier to sort through.
886 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800887 omap_hsmmc_reset();
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000888 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700889 omap_init_camera();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800890 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700891 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100892 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300893 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100894 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800895 omap_init_sham();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700896 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000897
898 return 0;
899}
900arch_initcall(omap2_init_devices);