blob: 072893a7d1362901130ea9be2d25323649875970 [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>
28#include <plat/mux.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,
156 },
157 {
158 .start = INT_24XX_MAIL_U3_MPU,
159 .flags = IORESOURCE_IRQ,
160 },
161};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800162static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
163#else
164#define omap2_mbox_resources NULL
165#define omap2_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800166#endif
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800167
C A Subramaniam454bf342009-11-22 10:11:18 -0800168#ifdef CONFIG_ARCH_OMAP3
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800169static struct resource omap3_mbox_resources[] = {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700170 {
171 .start = OMAP34XX_MAILBOX_BASE,
172 .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
173 .flags = IORESOURCE_MEM,
174 },
175 {
176 .start = INT_24XX_MAIL_U0_MPU,
177 .flags = IORESOURCE_IRQ,
178 },
179};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800180static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
181#else
182#define omap3_mbox_resources NULL
183#define omap3_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800184#endif
185
186#ifdef CONFIG_ARCH_OMAP4
187
188#define OMAP4_MBOX_REG_SIZE 0x130
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800189static struct resource omap4_mbox_resources[] = {
C A Subramaniam454bf342009-11-22 10:11:18 -0800190 {
191 .start = OMAP44XX_MAILBOX_BASE,
192 .end = OMAP44XX_MAILBOX_BASE +
193 OMAP4_MBOX_REG_SIZE - 1,
194 .flags = IORESOURCE_MEM,
195 },
196 {
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530197 .start = OMAP44XX_IRQ_MAIL_U0,
C A Subramaniam454bf342009-11-22 10:11:18 -0800198 .flags = IORESOURCE_IRQ,
199 },
200};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800201static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
202#else
203#define omap4_mbox_resources NULL
204#define omap4_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800205#endif
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700206
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800207static struct platform_device mbox_device = {
Hiroshi DOYUda8cfe02009-03-23 18:07:25 -0700208 .name = "omap2-mailbox",
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800209 .id = -1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800210};
211
212static inline void omap_init_mbox(void)
213{
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800214 if (cpu_is_omap24xx()) {
215 mbox_device.resource = omap2_mbox_resources;
216 mbox_device.num_resources = omap2_mbox_resources_sz;
217 } else if (cpu_is_omap34xx()) {
218 mbox_device.resource = omap3_mbox_resources;
219 mbox_device.num_resources = omap3_mbox_resources_sz;
220 } else if (cpu_is_omap44xx()) {
221 mbox_device.resource = omap4_mbox_resources;
222 mbox_device.num_resources = omap4_mbox_resources_sz;
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700223 } else {
224 pr_err("%s: platform not supported\n", __func__);
225 return;
226 }
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800227 platform_device_register(&mbox_device);
228}
229#else
230static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700231#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800232
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100233#if defined(CONFIG_OMAP_STI)
234
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300235#if defined(CONFIG_ARCH_OMAP2)
236
237#define OMAP2_STI_BASE 0x48068000
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100238#define OMAP2_STI_CHANNEL_BASE 0x54000000
239#define OMAP2_STI_IRQ 4
240
241static struct resource sti_resources[] = {
242 {
243 .start = OMAP2_STI_BASE,
244 .end = OMAP2_STI_BASE + 0x7ff,
245 .flags = IORESOURCE_MEM,
246 },
247 {
248 .start = OMAP2_STI_CHANNEL_BASE,
249 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
250 .flags = IORESOURCE_MEM,
251 },
252 {
253 .start = OMAP2_STI_IRQ,
254 .flags = IORESOURCE_IRQ,
255 }
256};
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300257#elif defined(CONFIG_ARCH_OMAP3)
258
259#define OMAP3_SDTI_BASE 0x54500000
260#define OMAP3_SDTI_CHANNEL_BASE 0x54600000
261
262static struct resource sti_resources[] = {
263 {
264 .start = OMAP3_SDTI_BASE,
265 .end = OMAP3_SDTI_BASE + 0xFFF,
266 .flags = IORESOURCE_MEM,
267 },
268 {
269 .start = OMAP3_SDTI_CHANNEL_BASE,
270 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
271 .flags = IORESOURCE_MEM,
272 }
273};
274
275#endif
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100276
277static struct platform_device sti_device = {
278 .name = "sti",
279 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100280 .num_resources = ARRAY_SIZE(sti_resources),
281 .resource = sti_resources,
282};
283
284static inline void omap_init_sti(void)
285{
286 platform_device_register(&sti_device);
287}
288#else
289static inline void omap_init_sti(void) {}
290#endif
291
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300292#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700293
Tony Lindgrence491cf2009-10-20 09:40:47 -0700294#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700295
296#define OMAP2_MCSPI1_BASE 0x48098000
297#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300298#define OMAP2_MCSPI3_BASE 0x480b8000
299#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700300
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700301#define OMAP4_MCSPI1_BASE 0x48098100
302#define OMAP4_MCSPI2_BASE 0x4809a100
303#define OMAP4_MCSPI3_BASE 0x480b8100
304#define OMAP4_MCSPI4_BASE 0x480ba100
305
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700306static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700307 .num_cs = 4,
308};
309
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800310static struct resource omap2_mcspi1_resources[] = {
311 {
312 .start = OMAP2_MCSPI1_BASE,
313 .end = OMAP2_MCSPI1_BASE + 0xff,
314 .flags = IORESOURCE_MEM,
315 },
316};
317
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300318static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700319 .name = "omap2_mcspi",
320 .id = 1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800321 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
322 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700323 .dev = {
324 .platform_data = &omap2_mcspi1_config,
325 },
326};
327
328static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700329 .num_cs = 2,
330};
331
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800332static struct resource omap2_mcspi2_resources[] = {
333 {
334 .start = OMAP2_MCSPI2_BASE,
335 .end = OMAP2_MCSPI2_BASE + 0xff,
336 .flags = IORESOURCE_MEM,
337 },
338};
339
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300340static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700341 .name = "omap2_mcspi",
342 .id = 2,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800343 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
344 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700345 .dev = {
346 .platform_data = &omap2_mcspi2_config,
347 },
348};
349
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700350#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
351 defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300352static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
353 .num_cs = 2,
354};
355
356static struct resource omap2_mcspi3_resources[] = {
357 {
358 .start = OMAP2_MCSPI3_BASE,
359 .end = OMAP2_MCSPI3_BASE + 0xff,
360 .flags = IORESOURCE_MEM,
361 },
362};
363
364static struct platform_device omap2_mcspi3 = {
365 .name = "omap2_mcspi",
366 .id = 3,
367 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
368 .resource = omap2_mcspi3_resources,
369 .dev = {
370 .platform_data = &omap2_mcspi3_config,
371 },
372};
373#endif
374
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700375#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300376static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
377 .num_cs = 1,
378};
379
380static struct resource omap2_mcspi4_resources[] = {
381 {
382 .start = OMAP2_MCSPI4_BASE,
383 .end = OMAP2_MCSPI4_BASE + 0xff,
384 .flags = IORESOURCE_MEM,
385 },
386};
387
388static struct platform_device omap2_mcspi4 = {
389 .name = "omap2_mcspi",
390 .id = 4,
391 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
392 .resource = omap2_mcspi4_resources,
393 .dev = {
394 .platform_data = &omap2_mcspi4_config,
395 },
396};
397#endif
398
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700399#ifdef CONFIG_ARCH_OMAP4
400static inline void omap4_mcspi_fixup(void)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700401{
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700402 omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
403 omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
404 omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
405 omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
406 omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
407 omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
408 omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
409 omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
410}
411#else
412static inline void omap4_mcspi_fixup(void)
413{
414}
415#endif
416
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700417#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
418 defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700419static inline void omap2_mcspi3_init(void)
420{
421 platform_device_register(&omap2_mcspi3);
422}
423#else
424static inline void omap2_mcspi3_init(void)
425{
426}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300427#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700428
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700429#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700430static inline void omap2_mcspi4_init(void)
431{
432 platform_device_register(&omap2_mcspi4);
433}
434#else
435static inline void omap2_mcspi4_init(void)
436{
437}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300438#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700439
440static void omap_init_mcspi(void)
441{
442 if (cpu_is_omap44xx())
443 omap4_mcspi_fixup();
444
445 platform_device_register(&omap2_mcspi1);
446 platform_device_register(&omap2_mcspi2);
447
448 if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
449 omap2_mcspi3_init();
450
451 if (cpu_is_omap343x() || cpu_is_omap44xx())
452 omap2_mcspi4_init();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700453}
454
455#else
456static inline void omap_init_mcspi(void) {}
457#endif
458
Will Deacon88341332010-04-09 13:54:43 +0100459static struct resource omap2_pmu_resource = {
460 .start = 3,
461 .end = 3,
462 .flags = IORESOURCE_IRQ,
463};
464
465static struct resource omap3_pmu_resource = {
466 .start = INT_34XX_BENCH_MPU_EMUL,
467 .end = INT_34XX_BENCH_MPU_EMUL,
468 .flags = IORESOURCE_IRQ,
469};
470
471static struct platform_device omap_pmu_device = {
472 .name = "arm-pmu",
473 .id = ARM_PMU_DEVICE_CPU,
474 .num_resources = 1,
475};
476
477static void omap_init_pmu(void)
478{
479 if (cpu_is_omap24xx())
480 omap_pmu_device.resource = &omap2_pmu_resource;
481 else if (cpu_is_omap34xx())
482 omap_pmu_device.resource = &omap3_pmu_resource;
483 else
484 return;
485
486 platform_device_register(&omap_pmu_device);
487}
488
489
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800490#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
491
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000492#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800493static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300494 {
495 .start = OMAP24XX_SEC_SHA1MD5_BASE,
496 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
497 .flags = IORESOURCE_MEM,
498 },
499 {
500 .start = INT_24XX_SHA1MD5,
501 .flags = IORESOURCE_IRQ,
502 }
503};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800504static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
505#else
506#define omap2_sham_resources NULL
507#define omap2_sham_resources_sz 0
508#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300509
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000510#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800511static struct resource omap3_sham_resources[] = {
512 {
513 .start = OMAP34XX_SEC_SHA1MD5_BASE,
514 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
515 .flags = IORESOURCE_MEM,
516 },
517 {
518 .start = INT_34XX_SHA1MD52_IRQ,
519 .flags = IORESOURCE_IRQ,
520 },
521 {
522 .start = OMAP34XX_DMA_SHA1MD5_RX,
523 .flags = IORESOURCE_DMA,
524 }
525};
526static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
527#else
528#define omap3_sham_resources NULL
529#define omap3_sham_resources_sz 0
530#endif
531
532static struct platform_device sham_device = {
533 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300534 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300535};
536
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800537static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300538{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800539 if (cpu_is_omap24xx()) {
540 sham_device.resource = omap2_sham_resources;
541 sham_device.num_resources = omap2_sham_resources_sz;
542 } else if (cpu_is_omap34xx()) {
543 sham_device.resource = omap3_sham_resources;
544 sham_device.num_resources = omap3_sham_resources_sz;
545 } else {
546 pr_err("%s: platform not supported\n", __func__);
547 return;
548 }
549 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300550}
551#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800552static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300553#endif
554
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800555#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
556
557#ifdef CONFIG_ARCH_OMAP24XX
558static struct resource omap2_aes_resources[] = {
559 {
560 .start = OMAP24XX_SEC_AES_BASE,
561 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
562 .flags = IORESOURCE_MEM,
563 },
564 {
565 .start = OMAP24XX_DMA_AES_TX,
566 .flags = IORESOURCE_DMA,
567 },
568 {
569 .start = OMAP24XX_DMA_AES_RX,
570 .flags = IORESOURCE_DMA,
571 }
572};
573static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
574#else
575#define omap2_aes_resources NULL
576#define omap2_aes_resources_sz 0
577#endif
578
579#ifdef CONFIG_ARCH_OMAP34XX
580static struct resource omap3_aes_resources[] = {
581 {
582 .start = OMAP34XX_SEC_AES_BASE,
583 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
584 .flags = IORESOURCE_MEM,
585 },
586 {
587 .start = OMAP34XX_DMA_AES2_TX,
588 .flags = IORESOURCE_DMA,
589 },
590 {
591 .start = OMAP34XX_DMA_AES2_RX,
592 .flags = IORESOURCE_DMA,
593 }
594};
595static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
596#else
597#define omap3_aes_resources NULL
598#define omap3_aes_resources_sz 0
599#endif
600
601static struct platform_device aes_device = {
602 .name = "omap-aes",
603 .id = -1,
604};
605
606static void omap_init_aes(void)
607{
608 if (cpu_is_omap24xx()) {
609 aes_device.resource = omap2_aes_resources;
610 aes_device.num_resources = omap2_aes_resources_sz;
611 } else if (cpu_is_omap34xx()) {
612 aes_device.resource = omap3_aes_resources;
613 aes_device.num_resources = omap3_aes_resources_sz;
614 } else {
615 pr_err("%s: platform not supported\n", __func__);
616 return;
617 }
618 platform_device_register(&aes_device);
619}
620
621#else
622static inline void omap_init_aes(void) { }
623#endif
624
Tony Lindgrend8874662008-12-10 17:37:16 -0800625/*-------------------------------------------------------------------------*/
626
kishore kadiyala82cf8182009-09-22 16:45:25 -0700627#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Kevin Hilman917fa282008-12-10 17:37:17 -0800628
629#define MMCHS_SYSCONFIG 0x0010
630#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
631#define MMCHS_SYSSTATUS 0x0014
632#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
633
634static struct platform_device dummy_pdev = {
635 .dev = {
636 .bus = &platform_bus_type,
637 },
638};
639
640/**
641 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
642 *
643 * Ensure that each MMC controller is fully reset. Controllers
644 * left in an unknown state (by bootloader) may prevent retention
645 * or OFF-mode. This is especially important in cases where the
646 * MMC driver is not enabled, _or_ built as a module.
647 *
648 * In order for reset to work, interface, functional and debounce
649 * clocks must be enabled. The debounce clock comes from func_32k_clk
650 * and is not under SW control, so we only enable i- and f-clocks.
651 **/
652static void __init omap_hsmmc_reset(void)
653{
Tony Lindgren4323e9f2010-02-12 12:26:48 -0800654 u32 i, nr_controllers;
655
656 if (cpu_is_omap242x())
657 return;
658
659 nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
kishore kadiyala82cf8182009-09-22 16:45:25 -0700660 (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
Kevin Hilman917fa282008-12-10 17:37:17 -0800661
662 for (i = 0; i < nr_controllers; i++) {
663 u32 v, base = 0;
664 struct clk *iclk, *fclk;
665 struct device *dev = &dummy_pdev.dev;
666
667 switch (i) {
668 case 0:
669 base = OMAP2_MMC1_BASE;
670 break;
671 case 1:
672 base = OMAP2_MMC2_BASE;
673 break;
674 case 2:
675 base = OMAP3_MMC3_BASE;
676 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700677 case 3:
678 if (!cpu_is_omap44xx())
679 return;
680 base = OMAP4_MMC4_BASE;
681 break;
682 case 4:
683 if (!cpu_is_omap44xx())
684 return;
685 base = OMAP4_MMC5_BASE;
686 break;
Kevin Hilman917fa282008-12-10 17:37:17 -0800687 }
688
kishore kadiyala82cf8182009-09-22 16:45:25 -0700689 if (cpu_is_omap44xx())
690 base += OMAP4_MMC_REG_OFFSET;
691
Kevin Hilman917fa282008-12-10 17:37:17 -0800692 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000693 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000694 iclk = clk_get(dev, "ick");
Kevin Hilman917fa282008-12-10 17:37:17 -0800695 if (iclk && clk_enable(iclk))
696 iclk = NULL;
697
Russell King6f7607c2009-01-28 10:22:50 +0000698 fclk = clk_get(dev, "fck");
Kevin Hilman917fa282008-12-10 17:37:17 -0800699 if (fclk && clk_enable(fclk))
700 fclk = NULL;
701
702 if (!iclk || !fclk) {
703 printk(KERN_WARNING
704 "%s: Unable to enable clocks for MMC%d, "
705 "cannot reset.\n", __func__, i);
706 break;
707 }
708
709 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
710 v = omap_readl(base + MMCHS_SYSSTATUS);
711 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
712 MMCHS_SYSSTATUS_RESETDONE))
713 cpu_relax();
714
715 if (fclk) {
716 clk_disable(fclk);
717 clk_put(fclk);
718 }
719 if (iclk) {
720 clk_disable(iclk);
721 clk_put(iclk);
722 }
723 }
724}
725#else
726static inline void omap_hsmmc_reset(void) {}
727#endif
728
Tony Lindgrend8874662008-12-10 17:37:16 -0800729#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
730 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
731
732static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
733 int controller_nr)
734{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000735 if ((mmc_controller->slots[0].switch_pin > 0) && \
736 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
737 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
738 OMAP_PIN_INPUT_PULLUP);
739 if ((mmc_controller->slots[0].gpio_wp > 0) && \
740 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
741 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
742 OMAP_PIN_INPUT_PULLUP);
743
Tony Lindgrend8874662008-12-10 17:37:16 -0800744 if (cpu_is_omap2420() && controller_nr == 0) {
745 omap_cfg_reg(H18_24XX_MMC_CMD);
746 omap_cfg_reg(H15_24XX_MMC_CLKI);
747 omap_cfg_reg(G19_24XX_MMC_CLKO);
748 omap_cfg_reg(F20_24XX_MMC_DAT0);
749 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
750 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800751 if (mmc_controller->slots[0].wires == 4) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800752 omap_cfg_reg(H14_24XX_MMC_DAT1);
753 omap_cfg_reg(E19_24XX_MMC_DAT2);
754 omap_cfg_reg(D19_24XX_MMC_DAT3);
755 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
756 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
757 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
758 }
759
760 /*
761 * Use internal loop-back in MMC/SDIO Module Input Clock
762 * selection
763 */
764 if (mmc_controller->slots[0].internal_clock) {
765 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
766 v |= (1 << 24);
767 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
768 }
769 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700770
Madhu4596d142009-11-22 10:11:06 -0800771 if (cpu_is_omap34xx()) {
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700772 if (controller_nr == 0) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800773 omap_mux_init_signal("sdmmc1_clk",
774 OMAP_PIN_INPUT_PULLUP);
775 omap_mux_init_signal("sdmmc1_cmd",
776 OMAP_PIN_INPUT_PULLUP);
777 omap_mux_init_signal("sdmmc1_dat0",
778 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700779 if (mmc_controller->slots[0].wires == 4 ||
780 mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800781 omap_mux_init_signal("sdmmc1_dat1",
782 OMAP_PIN_INPUT_PULLUP);
783 omap_mux_init_signal("sdmmc1_dat2",
784 OMAP_PIN_INPUT_PULLUP);
785 omap_mux_init_signal("sdmmc1_dat3",
786 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700787 }
788 if (mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800789 omap_mux_init_signal("sdmmc1_dat4",
790 OMAP_PIN_INPUT_PULLUP);
791 omap_mux_init_signal("sdmmc1_dat5",
792 OMAP_PIN_INPUT_PULLUP);
793 omap_mux_init_signal("sdmmc1_dat6",
794 OMAP_PIN_INPUT_PULLUP);
795 omap_mux_init_signal("sdmmc1_dat7",
796 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700797 }
798 }
799 if (controller_nr == 1) {
800 /* MMC2 */
Tony Lindgren4896e392009-12-11 16:16:32 -0800801 omap_mux_init_signal("sdmmc2_clk",
802 OMAP_PIN_INPUT_PULLUP);
803 omap_mux_init_signal("sdmmc2_cmd",
804 OMAP_PIN_INPUT_PULLUP);
805 omap_mux_init_signal("sdmmc2_dat0",
806 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700807
808 /*
809 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
810 * in the board-*.c files
811 */
812 if (mmc_controller->slots[0].wires == 4 ||
813 mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800814 omap_mux_init_signal("sdmmc2_dat1",
815 OMAP_PIN_INPUT_PULLUP);
816 omap_mux_init_signal("sdmmc2_dat2",
817 OMAP_PIN_INPUT_PULLUP);
818 omap_mux_init_signal("sdmmc2_dat3",
819 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700820 }
Madhu46792322009-11-22 10:11:08 -0800821 if (mmc_controller->slots[0].wires == 8) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800822 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
823 OMAP_PIN_INPUT_PULLUP);
824 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
825 OMAP_PIN_INPUT_PULLUP);
826 omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
827 OMAP_PIN_INPUT_PULLUP);
828 omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
829 OMAP_PIN_INPUT_PULLUP);
Madhu46792322009-11-22 10:11:08 -0800830 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700831 }
832
833 /*
834 * For MMC3 the pins need to be muxed in the board-*.c files
835 */
836 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800837}
838
839void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
840 int nr_controllers)
841{
842 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800843 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800844
845 for (i = 0; i < nr_controllers; i++) {
846 unsigned long base, size;
847 unsigned int irq = 0;
848
849 if (!mmc_data[i])
850 continue;
851
852 omap2_mmc_mux(mmc_data[i], i);
853
854 switch (i) {
855 case 0:
856 base = OMAP2_MMC1_BASE;
857 irq = INT_24XX_MMC_IRQ;
858 break;
859 case 1:
860 base = OMAP2_MMC2_BASE;
861 irq = INT_24XX_MMC2_IRQ;
862 break;
863 case 2:
kishore kadiyala82cf8182009-09-22 16:45:25 -0700864 if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
Tony Lindgrend8874662008-12-10 17:37:16 -0800865 return;
866 base = OMAP3_MMC3_BASE;
867 irq = INT_34XX_MMC3_IRQ;
868 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700869 case 3:
870 if (!cpu_is_omap44xx())
871 return;
872 base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530873 irq = OMAP44XX_IRQ_MMC4;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700874 break;
875 case 4:
876 if (!cpu_is_omap44xx())
877 return;
878 base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
kishore kadiyala9df76b72010-04-21 18:19:37 +0000879 irq = OMAP44XX_IRQ_MMC5;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700880 break;
Tony Lindgrend8874662008-12-10 17:37:16 -0800881 default:
882 continue;
883 }
884
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800885 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800886 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800887 name = "mmci-omap";
kishore kadiyala82cf8182009-09-22 16:45:25 -0700888 } else if (cpu_is_omap44xx()) {
889 if (i < 3) {
890 base += OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530891 irq += OMAP44XX_IRQ_GIC_START;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700892 }
893 size = OMAP4_HSMMC_SIZE;
894 name = "mmci-omap-hs";
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800895 } else {
kishore kadiyala82cf8182009-09-22 16:45:25 -0700896 size = OMAP3_HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800897 name = "mmci-omap-hs";
898 }
899 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800900 };
901}
902
903#endif
904
905/*-------------------------------------------------------------------------*/
906
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300907#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
908#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
909#define OMAP_HDQ_BASE 0x480B2000
910#endif
911static struct resource omap_hdq_resources[] = {
912 {
913 .start = OMAP_HDQ_BASE,
914 .end = OMAP_HDQ_BASE + 0x1C,
915 .flags = IORESOURCE_MEM,
916 },
917 {
918 .start = INT_24XX_HDQ_IRQ,
919 .flags = IORESOURCE_IRQ,
920 },
921};
922static struct platform_device omap_hdq_dev = {
923 .name = "omap_hdq",
924 .id = 0,
925 .dev = {
926 .platform_data = NULL,
927 },
928 .num_resources = ARRAY_SIZE(omap_hdq_resources),
929 .resource = omap_hdq_resources,
930};
931static inline void omap_hdq_init(void)
932{
933 (void) platform_device_register(&omap_hdq_dev);
934}
935#else
936static inline void omap_hdq_init(void) {}
937#endif
938
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700939/*---------------------------------------------------------------------------*/
940
941#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
942 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
943#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
944static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
945};
946#else
947static struct resource omap_vout_resource[2] = {
948};
949#endif
950
951static struct platform_device omap_vout_device = {
952 .name = "omap_vout",
953 .num_resources = ARRAY_SIZE(omap_vout_resource),
954 .resource = &omap_vout_resource[0],
955 .id = -1,
956};
957static void omap_init_vout(void)
958{
959 if (platform_device_register(&omap_vout_device) < 0)
960 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
961}
962#else
963static inline void omap_init_vout(void) {}
964#endif
965
Tony Lindgren1dbae812005-11-10 14:26:51 +0000966/*-------------------------------------------------------------------------*/
967
968static int __init omap2_init_devices(void)
969{
970 /* please keep these calls, and their implementations above,
971 * in alphabetical order so they're easier to sort through.
972 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800973 omap_hsmmc_reset();
Tony Lindgren828c7072009-03-23 18:23:49 -0700974 omap_init_camera();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800975 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700976 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100977 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300978 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100979 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800980 omap_init_sham();
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800981 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700982 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000983
984 return 0;
985}
986arch_initcall(omap2_init_devices);