blob: 3ae9d0a477b69b3d432df4cd736b517992b458e2 [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>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070029#include <plat/mmc.h>
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +080030#include <plat/dma.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000031
Tony Lindgren4896e392009-12-11 16:16:32 -080032#include "mux.h"
33
Tony Lindgren828c7072009-03-23 18:23:49 -070034#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae92006-12-07 13:58:10 -080035
Tony Lindgren828c7072009-03-23 18:23:49 -070036static struct resource cam_resources[] = {
Tony Lindgrenc40fae92006-12-07 13:58:10 -080037 {
Tony Lindgren828c7072009-03-23 18:23:49 -070038 .start = OMAP24XX_CAMERA_BASE,
39 .end = OMAP24XX_CAMERA_BASE + 0xfff,
40 .flags = IORESOURCE_MEM,
41 },
42 {
43 .start = INT_24XX_CAM_IRQ,
44 .flags = IORESOURCE_IRQ,
45 }
46};
47
48static struct platform_device omap_cam_device = {
49 .name = "omap24xxcam",
50 .id = -1,
51 .num_resources = ARRAY_SIZE(cam_resources),
52 .resource = cam_resources,
53};
54
55static inline void omap_init_camera(void)
56{
57 platform_device_register(&omap_cam_device);
58}
59
60#elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
61
62static struct resource omap3isp_resources[] = {
63 {
64 .start = OMAP3430_ISP_BASE,
65 .end = OMAP3430_ISP_END,
66 .flags = IORESOURCE_MEM,
67 },
68 {
69 .start = OMAP3430_ISP_CBUFF_BASE,
70 .end = OMAP3430_ISP_CBUFF_END,
71 .flags = IORESOURCE_MEM,
72 },
73 {
74 .start = OMAP3430_ISP_CCP2_BASE,
75 .end = OMAP3430_ISP_CCP2_END,
76 .flags = IORESOURCE_MEM,
77 },
78 {
79 .start = OMAP3430_ISP_CCDC_BASE,
80 .end = OMAP3430_ISP_CCDC_END,
81 .flags = IORESOURCE_MEM,
82 },
83 {
84 .start = OMAP3430_ISP_HIST_BASE,
85 .end = OMAP3430_ISP_HIST_END,
86 .flags = IORESOURCE_MEM,
87 },
88 {
89 .start = OMAP3430_ISP_H3A_BASE,
90 .end = OMAP3430_ISP_H3A_END,
91 .flags = IORESOURCE_MEM,
92 },
93 {
94 .start = OMAP3430_ISP_PREV_BASE,
95 .end = OMAP3430_ISP_PREV_END,
96 .flags = IORESOURCE_MEM,
97 },
98 {
99 .start = OMAP3430_ISP_RESZ_BASE,
100 .end = OMAP3430_ISP_RESZ_END,
101 .flags = IORESOURCE_MEM,
102 },
103 {
104 .start = OMAP3430_ISP_SBL_BASE,
105 .end = OMAP3430_ISP_SBL_END,
106 .flags = IORESOURCE_MEM,
107 },
108 {
109 .start = OMAP3430_ISP_CSI2A_BASE,
110 .end = OMAP3430_ISP_CSI2A_END,
111 .flags = IORESOURCE_MEM,
112 },
113 {
114 .start = OMAP3430_ISP_CSI2PHY_BASE,
115 .end = OMAP3430_ISP_CSI2PHY_END,
116 .flags = IORESOURCE_MEM,
117 },
118 {
119 .start = INT_34XX_CAM_IRQ,
120 .flags = IORESOURCE_IRQ,
121 }
122};
123
124static struct platform_device omap3isp_device = {
125 .name = "omap3isp",
126 .id = -1,
127 .num_resources = ARRAY_SIZE(omap3isp_resources),
128 .resource = omap3isp_resources,
129};
130
131static inline void omap_init_camera(void)
132{
133 platform_device_register(&omap3isp_device);
134}
135#else
136static inline void omap_init_camera(void)
137{
138}
139#endif
140
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700141#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800142
C A Subramaniam454bf342009-11-22 10:11:18 -0800143#define MBOX_REG_SIZE 0x120
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700144
C A Subramaniam454bf342009-11-22 10:11:18 -0800145#ifdef CONFIG_ARCH_OMAP2
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800146static struct resource omap2_mbox_resources[] = {
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800147 {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700148 .start = OMAP24XX_MAILBOX_BASE,
149 .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800150 .flags = IORESOURCE_MEM,
151 },
152 {
153 .start = INT_24XX_MAIL_U0_MPU,
154 .flags = IORESOURCE_IRQ,
155 },
156 {
157 .start = INT_24XX_MAIL_U3_MPU,
158 .flags = IORESOURCE_IRQ,
159 },
160};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800161static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
162#else
163#define omap2_mbox_resources NULL
164#define omap2_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800165#endif
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800166
C A Subramaniam454bf342009-11-22 10:11:18 -0800167#ifdef CONFIG_ARCH_OMAP3
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800168static struct resource omap3_mbox_resources[] = {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700169 {
170 .start = OMAP34XX_MAILBOX_BASE,
171 .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
172 .flags = IORESOURCE_MEM,
173 },
174 {
175 .start = INT_24XX_MAIL_U0_MPU,
176 .flags = IORESOURCE_IRQ,
177 },
178};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800179static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
180#else
181#define omap3_mbox_resources NULL
182#define omap3_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800183#endif
184
185#ifdef CONFIG_ARCH_OMAP4
186
187#define OMAP4_MBOX_REG_SIZE 0x130
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800188static struct resource omap4_mbox_resources[] = {
C A Subramaniam454bf342009-11-22 10:11:18 -0800189 {
190 .start = OMAP44XX_MAILBOX_BASE,
191 .end = OMAP44XX_MAILBOX_BASE +
192 OMAP4_MBOX_REG_SIZE - 1,
193 .flags = IORESOURCE_MEM,
194 },
195 {
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530196 .start = OMAP44XX_IRQ_MAIL_U0,
C A Subramaniam454bf342009-11-22 10:11:18 -0800197 .flags = IORESOURCE_IRQ,
198 },
199};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800200static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
201#else
202#define omap4_mbox_resources NULL
203#define omap4_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800204#endif
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700205
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800206static struct platform_device mbox_device = {
Hiroshi DOYUda8cfe02009-03-23 18:07:25 -0700207 .name = "omap2-mailbox",
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800208 .id = -1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800209};
210
211static inline void omap_init_mbox(void)
212{
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800213 if (cpu_is_omap24xx()) {
214 mbox_device.resource = omap2_mbox_resources;
215 mbox_device.num_resources = omap2_mbox_resources_sz;
216 } else if (cpu_is_omap34xx()) {
217 mbox_device.resource = omap3_mbox_resources;
218 mbox_device.num_resources = omap3_mbox_resources_sz;
219 } else if (cpu_is_omap44xx()) {
220 mbox_device.resource = omap4_mbox_resources;
221 mbox_device.num_resources = omap4_mbox_resources_sz;
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700222 } else {
223 pr_err("%s: platform not supported\n", __func__);
224 return;
225 }
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800226 platform_device_register(&mbox_device);
227}
228#else
229static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700230#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800231
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100232#if defined(CONFIG_OMAP_STI)
233
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300234#if defined(CONFIG_ARCH_OMAP2)
235
236#define OMAP2_STI_BASE 0x48068000
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100237#define OMAP2_STI_CHANNEL_BASE 0x54000000
238#define OMAP2_STI_IRQ 4
239
240static struct resource sti_resources[] = {
241 {
242 .start = OMAP2_STI_BASE,
243 .end = OMAP2_STI_BASE + 0x7ff,
244 .flags = IORESOURCE_MEM,
245 },
246 {
247 .start = OMAP2_STI_CHANNEL_BASE,
248 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
249 .flags = IORESOURCE_MEM,
250 },
251 {
252 .start = OMAP2_STI_IRQ,
253 .flags = IORESOURCE_IRQ,
254 }
255};
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300256#elif defined(CONFIG_ARCH_OMAP3)
257
258#define OMAP3_SDTI_BASE 0x54500000
259#define OMAP3_SDTI_CHANNEL_BASE 0x54600000
260
261static struct resource sti_resources[] = {
262 {
263 .start = OMAP3_SDTI_BASE,
264 .end = OMAP3_SDTI_BASE + 0xFFF,
265 .flags = IORESOURCE_MEM,
266 },
267 {
268 .start = OMAP3_SDTI_CHANNEL_BASE,
269 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
270 .flags = IORESOURCE_MEM,
271 }
272};
273
274#endif
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100275
276static struct platform_device sti_device = {
277 .name = "sti",
278 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100279 .num_resources = ARRAY_SIZE(sti_resources),
280 .resource = sti_resources,
281};
282
283static inline void omap_init_sti(void)
284{
285 platform_device_register(&sti_device);
286}
287#else
288static inline void omap_init_sti(void) {}
289#endif
290
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300291#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700292
Tony Lindgrence491cf2009-10-20 09:40:47 -0700293#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700294
295#define OMAP2_MCSPI1_BASE 0x48098000
296#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300297#define OMAP2_MCSPI3_BASE 0x480b8000
298#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700299
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700300#define OMAP4_MCSPI1_BASE 0x48098100
301#define OMAP4_MCSPI2_BASE 0x4809a100
302#define OMAP4_MCSPI3_BASE 0x480b8100
303#define OMAP4_MCSPI4_BASE 0x480ba100
304
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700305static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700306 .num_cs = 4,
307};
308
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800309static struct resource omap2_mcspi1_resources[] = {
310 {
311 .start = OMAP2_MCSPI1_BASE,
312 .end = OMAP2_MCSPI1_BASE + 0xff,
313 .flags = IORESOURCE_MEM,
314 },
315};
316
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300317static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700318 .name = "omap2_mcspi",
319 .id = 1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800320 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
321 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700322 .dev = {
323 .platform_data = &omap2_mcspi1_config,
324 },
325};
326
327static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700328 .num_cs = 2,
329};
330
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800331static struct resource omap2_mcspi2_resources[] = {
332 {
333 .start = OMAP2_MCSPI2_BASE,
334 .end = OMAP2_MCSPI2_BASE + 0xff,
335 .flags = IORESOURCE_MEM,
336 },
337};
338
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300339static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700340 .name = "omap2_mcspi",
341 .id = 2,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800342 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
343 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700344 .dev = {
345 .platform_data = &omap2_mcspi2_config,
346 },
347};
348
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700349#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
350 defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300351static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
352 .num_cs = 2,
353};
354
355static struct resource omap2_mcspi3_resources[] = {
356 {
357 .start = OMAP2_MCSPI3_BASE,
358 .end = OMAP2_MCSPI3_BASE + 0xff,
359 .flags = IORESOURCE_MEM,
360 },
361};
362
363static struct platform_device omap2_mcspi3 = {
364 .name = "omap2_mcspi",
365 .id = 3,
366 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
367 .resource = omap2_mcspi3_resources,
368 .dev = {
369 .platform_data = &omap2_mcspi3_config,
370 },
371};
372#endif
373
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700374#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300375static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
376 .num_cs = 1,
377};
378
379static struct resource omap2_mcspi4_resources[] = {
380 {
381 .start = OMAP2_MCSPI4_BASE,
382 .end = OMAP2_MCSPI4_BASE + 0xff,
383 .flags = IORESOURCE_MEM,
384 },
385};
386
387static struct platform_device omap2_mcspi4 = {
388 .name = "omap2_mcspi",
389 .id = 4,
390 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
391 .resource = omap2_mcspi4_resources,
392 .dev = {
393 .platform_data = &omap2_mcspi4_config,
394 },
395};
396#endif
397
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700398#ifdef CONFIG_ARCH_OMAP4
399static inline void omap4_mcspi_fixup(void)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700400{
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700401 omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
402 omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
403 omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
404 omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
405 omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
406 omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
407 omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
408 omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
409}
410#else
411static inline void omap4_mcspi_fixup(void)
412{
413}
414#endif
415
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700416#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
417 defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700418static inline void omap2_mcspi3_init(void)
419{
420 platform_device_register(&omap2_mcspi3);
421}
422#else
423static inline void omap2_mcspi3_init(void)
424{
425}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300426#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700427
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700428#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700429static inline void omap2_mcspi4_init(void)
430{
431 platform_device_register(&omap2_mcspi4);
432}
433#else
434static inline void omap2_mcspi4_init(void)
435{
436}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300437#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700438
439static void omap_init_mcspi(void)
440{
441 if (cpu_is_omap44xx())
442 omap4_mcspi_fixup();
443
444 platform_device_register(&omap2_mcspi1);
445 platform_device_register(&omap2_mcspi2);
446
447 if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
448 omap2_mcspi3_init();
449
450 if (cpu_is_omap343x() || cpu_is_omap44xx())
451 omap2_mcspi4_init();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700452}
453
454#else
455static inline void omap_init_mcspi(void) {}
456#endif
457
Will Deacon88341332010-04-09 13:54:43 +0100458static struct resource omap2_pmu_resource = {
459 .start = 3,
460 .end = 3,
461 .flags = IORESOURCE_IRQ,
462};
463
464static struct resource omap3_pmu_resource = {
465 .start = INT_34XX_BENCH_MPU_EMUL,
466 .end = INT_34XX_BENCH_MPU_EMUL,
467 .flags = IORESOURCE_IRQ,
468};
469
470static struct platform_device omap_pmu_device = {
471 .name = "arm-pmu",
472 .id = ARM_PMU_DEVICE_CPU,
473 .num_resources = 1,
474};
475
476static void omap_init_pmu(void)
477{
478 if (cpu_is_omap24xx())
479 omap_pmu_device.resource = &omap2_pmu_resource;
480 else if (cpu_is_omap34xx())
481 omap_pmu_device.resource = &omap3_pmu_resource;
482 else
483 return;
484
485 platform_device_register(&omap_pmu_device);
486}
487
488
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800489#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
490
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000491#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800492static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300493 {
494 .start = OMAP24XX_SEC_SHA1MD5_BASE,
495 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
496 .flags = IORESOURCE_MEM,
497 },
498 {
499 .start = INT_24XX_SHA1MD5,
500 .flags = IORESOURCE_IRQ,
501 }
502};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800503static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
504#else
505#define omap2_sham_resources NULL
506#define omap2_sham_resources_sz 0
507#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300508
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000509#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800510static struct resource omap3_sham_resources[] = {
511 {
512 .start = OMAP34XX_SEC_SHA1MD5_BASE,
513 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
514 .flags = IORESOURCE_MEM,
515 },
516 {
517 .start = INT_34XX_SHA1MD52_IRQ,
518 .flags = IORESOURCE_IRQ,
519 },
520 {
521 .start = OMAP34XX_DMA_SHA1MD5_RX,
522 .flags = IORESOURCE_DMA,
523 }
524};
525static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
526#else
527#define omap3_sham_resources NULL
528#define omap3_sham_resources_sz 0
529#endif
530
531static struct platform_device sham_device = {
532 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300533 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300534};
535
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800536static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300537{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800538 if (cpu_is_omap24xx()) {
539 sham_device.resource = omap2_sham_resources;
540 sham_device.num_resources = omap2_sham_resources_sz;
541 } else if (cpu_is_omap34xx()) {
542 sham_device.resource = omap3_sham_resources;
543 sham_device.num_resources = omap3_sham_resources_sz;
544 } else {
545 pr_err("%s: platform not supported\n", __func__);
546 return;
547 }
548 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300549}
550#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800551static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300552#endif
553
Tony Lindgrend8874662008-12-10 17:37:16 -0800554/*-------------------------------------------------------------------------*/
555
kishore kadiyala82cf8182009-09-22 16:45:25 -0700556#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Kevin Hilman917fa282008-12-10 17:37:17 -0800557
558#define MMCHS_SYSCONFIG 0x0010
559#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
560#define MMCHS_SYSSTATUS 0x0014
561#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
562
563static struct platform_device dummy_pdev = {
564 .dev = {
565 .bus = &platform_bus_type,
566 },
567};
568
569/**
570 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
571 *
572 * Ensure that each MMC controller is fully reset. Controllers
573 * left in an unknown state (by bootloader) may prevent retention
574 * or OFF-mode. This is especially important in cases where the
575 * MMC driver is not enabled, _or_ built as a module.
576 *
577 * In order for reset to work, interface, functional and debounce
578 * clocks must be enabled. The debounce clock comes from func_32k_clk
579 * and is not under SW control, so we only enable i- and f-clocks.
580 **/
581static void __init omap_hsmmc_reset(void)
582{
Tony Lindgren4323e9f2010-02-12 12:26:48 -0800583 u32 i, nr_controllers;
584
585 if (cpu_is_omap242x())
586 return;
587
588 nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
kishore kadiyala82cf8182009-09-22 16:45:25 -0700589 (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
Kevin Hilman917fa282008-12-10 17:37:17 -0800590
591 for (i = 0; i < nr_controllers; i++) {
592 u32 v, base = 0;
593 struct clk *iclk, *fclk;
594 struct device *dev = &dummy_pdev.dev;
595
596 switch (i) {
597 case 0:
598 base = OMAP2_MMC1_BASE;
599 break;
600 case 1:
601 base = OMAP2_MMC2_BASE;
602 break;
603 case 2:
604 base = OMAP3_MMC3_BASE;
605 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700606 case 3:
607 if (!cpu_is_omap44xx())
608 return;
609 base = OMAP4_MMC4_BASE;
610 break;
611 case 4:
612 if (!cpu_is_omap44xx())
613 return;
614 base = OMAP4_MMC5_BASE;
615 break;
Kevin Hilman917fa282008-12-10 17:37:17 -0800616 }
617
kishore kadiyala82cf8182009-09-22 16:45:25 -0700618 if (cpu_is_omap44xx())
619 base += OMAP4_MMC_REG_OFFSET;
620
Kevin Hilman917fa282008-12-10 17:37:17 -0800621 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000622 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000623 iclk = clk_get(dev, "ick");
Kevin Hilman917fa282008-12-10 17:37:17 -0800624 if (iclk && clk_enable(iclk))
625 iclk = NULL;
626
Russell King6f7607c2009-01-28 10:22:50 +0000627 fclk = clk_get(dev, "fck");
Kevin Hilman917fa282008-12-10 17:37:17 -0800628 if (fclk && clk_enable(fclk))
629 fclk = NULL;
630
631 if (!iclk || !fclk) {
632 printk(KERN_WARNING
633 "%s: Unable to enable clocks for MMC%d, "
634 "cannot reset.\n", __func__, i);
635 break;
636 }
637
638 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
639 v = omap_readl(base + MMCHS_SYSSTATUS);
640 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
641 MMCHS_SYSSTATUS_RESETDONE))
642 cpu_relax();
643
644 if (fclk) {
645 clk_disable(fclk);
646 clk_put(fclk);
647 }
648 if (iclk) {
649 clk_disable(iclk);
650 clk_put(iclk);
651 }
652 }
653}
654#else
655static inline void omap_hsmmc_reset(void) {}
656#endif
657
Tony Lindgrend8874662008-12-10 17:37:16 -0800658#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
659 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
660
661static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
662 int controller_nr)
663{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000664 if ((mmc_controller->slots[0].switch_pin > 0) && \
665 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
666 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
667 OMAP_PIN_INPUT_PULLUP);
668 if ((mmc_controller->slots[0].gpio_wp > 0) && \
669 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
670 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
671 OMAP_PIN_INPUT_PULLUP);
672
Tony Lindgrend8874662008-12-10 17:37:16 -0800673 if (cpu_is_omap2420() && controller_nr == 0) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300674 omap_mux_init_signal("sdmmc_cmd", 0);
675 omap_mux_init_signal("sdmmc_clki", 0);
676 omap_mux_init_signal("sdmmc_clko", 0);
677 omap_mux_init_signal("sdmmc_dat0", 0);
678 omap_mux_init_signal("sdmmc_dat_dir0", 0);
679 omap_mux_init_signal("sdmmc_cmd_dir", 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800680 if (mmc_controller->slots[0].wires == 4) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300681 omap_mux_init_signal("sdmmc_dat1", 0);
682 omap_mux_init_signal("sdmmc_dat2", 0);
683 omap_mux_init_signal("sdmmc_dat3", 0);
684 omap_mux_init_signal("sdmmc_dat_dir1", 0);
685 omap_mux_init_signal("sdmmc_dat_dir2", 0);
686 omap_mux_init_signal("sdmmc_dat_dir3", 0);
Tony Lindgrend8874662008-12-10 17:37:16 -0800687 }
688
689 /*
690 * Use internal loop-back in MMC/SDIO Module Input Clock
691 * selection
692 */
693 if (mmc_controller->slots[0].internal_clock) {
694 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
695 v |= (1 << 24);
696 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
697 }
698 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700699
Madhu4596d142009-11-22 10:11:06 -0800700 if (cpu_is_omap34xx()) {
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700701 if (controller_nr == 0) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800702 omap_mux_init_signal("sdmmc1_clk",
703 OMAP_PIN_INPUT_PULLUP);
704 omap_mux_init_signal("sdmmc1_cmd",
705 OMAP_PIN_INPUT_PULLUP);
706 omap_mux_init_signal("sdmmc1_dat0",
707 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700708 if (mmc_controller->slots[0].wires == 4 ||
709 mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800710 omap_mux_init_signal("sdmmc1_dat1",
711 OMAP_PIN_INPUT_PULLUP);
712 omap_mux_init_signal("sdmmc1_dat2",
713 OMAP_PIN_INPUT_PULLUP);
714 omap_mux_init_signal("sdmmc1_dat3",
715 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700716 }
717 if (mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800718 omap_mux_init_signal("sdmmc1_dat4",
719 OMAP_PIN_INPUT_PULLUP);
720 omap_mux_init_signal("sdmmc1_dat5",
721 OMAP_PIN_INPUT_PULLUP);
722 omap_mux_init_signal("sdmmc1_dat6",
723 OMAP_PIN_INPUT_PULLUP);
724 omap_mux_init_signal("sdmmc1_dat7",
725 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700726 }
727 }
728 if (controller_nr == 1) {
729 /* MMC2 */
Tony Lindgren4896e392009-12-11 16:16:32 -0800730 omap_mux_init_signal("sdmmc2_clk",
731 OMAP_PIN_INPUT_PULLUP);
732 omap_mux_init_signal("sdmmc2_cmd",
733 OMAP_PIN_INPUT_PULLUP);
734 omap_mux_init_signal("sdmmc2_dat0",
735 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700736
737 /*
738 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
739 * in the board-*.c files
740 */
741 if (mmc_controller->slots[0].wires == 4 ||
742 mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800743 omap_mux_init_signal("sdmmc2_dat1",
744 OMAP_PIN_INPUT_PULLUP);
745 omap_mux_init_signal("sdmmc2_dat2",
746 OMAP_PIN_INPUT_PULLUP);
747 omap_mux_init_signal("sdmmc2_dat3",
748 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700749 }
Madhu46792322009-11-22 10:11:08 -0800750 if (mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800751 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
752 OMAP_PIN_INPUT_PULLUP);
753 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
754 OMAP_PIN_INPUT_PULLUP);
755 omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
756 OMAP_PIN_INPUT_PULLUP);
757 omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
758 OMAP_PIN_INPUT_PULLUP);
Madhu46792322009-11-22 10:11:08 -0800759 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700760 }
761
762 /*
763 * For MMC3 the pins need to be muxed in the board-*.c files
764 */
765 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800766}
767
768void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
769 int nr_controllers)
770{
771 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800772 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800773
774 for (i = 0; i < nr_controllers; i++) {
775 unsigned long base, size;
776 unsigned int irq = 0;
777
778 if (!mmc_data[i])
779 continue;
780
781 omap2_mmc_mux(mmc_data[i], i);
782
783 switch (i) {
784 case 0:
785 base = OMAP2_MMC1_BASE;
786 irq = INT_24XX_MMC_IRQ;
787 break;
788 case 1:
789 base = OMAP2_MMC2_BASE;
790 irq = INT_24XX_MMC2_IRQ;
791 break;
792 case 2:
kishore kadiyala82cf8182009-09-22 16:45:25 -0700793 if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
Tony Lindgrend8874662008-12-10 17:37:16 -0800794 return;
795 base = OMAP3_MMC3_BASE;
796 irq = INT_34XX_MMC3_IRQ;
797 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700798 case 3:
799 if (!cpu_is_omap44xx())
800 return;
801 base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530802 irq = OMAP44XX_IRQ_MMC4;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700803 break;
804 case 4:
805 if (!cpu_is_omap44xx())
806 return;
807 base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
kishore kadiyala9df76b72010-04-21 18:19:37 +0000808 irq = OMAP44XX_IRQ_MMC5;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700809 break;
Tony Lindgrend8874662008-12-10 17:37:16 -0800810 default:
811 continue;
812 }
813
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800814 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800815 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800816 name = "mmci-omap";
kishore kadiyala82cf8182009-09-22 16:45:25 -0700817 } else if (cpu_is_omap44xx()) {
818 if (i < 3) {
819 base += OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530820 irq += OMAP44XX_IRQ_GIC_START;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700821 }
822 size = OMAP4_HSMMC_SIZE;
823 name = "mmci-omap-hs";
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800824 } else {
kishore kadiyala82cf8182009-09-22 16:45:25 -0700825 size = OMAP3_HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800826 name = "mmci-omap-hs";
827 }
828 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800829 };
830}
831
832#endif
833
834/*-------------------------------------------------------------------------*/
835
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300836#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
837#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
838#define OMAP_HDQ_BASE 0x480B2000
839#endif
840static struct resource omap_hdq_resources[] = {
841 {
842 .start = OMAP_HDQ_BASE,
843 .end = OMAP_HDQ_BASE + 0x1C,
844 .flags = IORESOURCE_MEM,
845 },
846 {
847 .start = INT_24XX_HDQ_IRQ,
848 .flags = IORESOURCE_IRQ,
849 },
850};
851static struct platform_device omap_hdq_dev = {
852 .name = "omap_hdq",
853 .id = 0,
854 .dev = {
855 .platform_data = NULL,
856 },
857 .num_resources = ARRAY_SIZE(omap_hdq_resources),
858 .resource = omap_hdq_resources,
859};
860static inline void omap_hdq_init(void)
861{
862 (void) platform_device_register(&omap_hdq_dev);
863}
864#else
865static inline void omap_hdq_init(void) {}
866#endif
867
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700868/*---------------------------------------------------------------------------*/
869
870#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
871 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
872#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
873static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
874};
875#else
876static struct resource omap_vout_resource[2] = {
877};
878#endif
879
880static struct platform_device omap_vout_device = {
881 .name = "omap_vout",
882 .num_resources = ARRAY_SIZE(omap_vout_resource),
883 .resource = &omap_vout_resource[0],
884 .id = -1,
885};
886static void omap_init_vout(void)
887{
888 if (platform_device_register(&omap_vout_device) < 0)
889 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
890}
891#else
892static inline void omap_init_vout(void) {}
893#endif
894
Tony Lindgren1dbae812005-11-10 14:26:51 +0000895/*-------------------------------------------------------------------------*/
896
897static int __init omap2_init_devices(void)
898{
899 /* please keep these calls, and their implementations above,
900 * in alphabetical order so they're easier to sort through.
901 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800902 omap_hsmmc_reset();
Tony Lindgren828c7072009-03-23 18:23:49 -0700903 omap_init_camera();
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800904 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700905 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100906 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300907 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100908 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800909 omap_init_sham();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700910 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000911
912 return 0;
913}
914arch_initcall(omap2_init_devices);