blob: 8e2f0aa310b5809a32b7bfe94daf21f096c1b6e5 [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>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053018#include <linux/err.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000019
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/hardware.h>
Will Deacon88341332010-04-09 13:54:43 +010021#include <mach/irqs.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000022#include <asm/mach-types.h>
23#include <asm/mach/map.h>
Will Deacon88341332010-04-09 13:54:43 +010024#include <asm/pmu.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000025
Tony Lindgrence491cf2009-10-20 09:40:47 -070026#include <plat/control.h>
27#include <plat/tc.h>
28#include <plat/board.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>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053032#include <plat/omap_hwmod.h>
33#include <plat/omap_device.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000034
Tony Lindgren4896e392009-12-11 16:16:32 -080035#include "mux.h"
36
Tony Lindgren828c7072009-03-23 18:23:49 -070037#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae92006-12-07 13:58:10 -080038
Tony Lindgren828c7072009-03-23 18:23:49 -070039static struct resource cam_resources[] = {
Tony Lindgrenc40fae92006-12-07 13:58:10 -080040 {
Tony Lindgren828c7072009-03-23 18:23:49 -070041 .start = OMAP24XX_CAMERA_BASE,
42 .end = OMAP24XX_CAMERA_BASE + 0xfff,
43 .flags = IORESOURCE_MEM,
44 },
45 {
46 .start = INT_24XX_CAM_IRQ,
47 .flags = IORESOURCE_IRQ,
48 }
49};
50
51static struct platform_device omap_cam_device = {
52 .name = "omap24xxcam",
53 .id = -1,
54 .num_resources = ARRAY_SIZE(cam_resources),
55 .resource = cam_resources,
56};
57
58static inline void omap_init_camera(void)
59{
60 platform_device_register(&omap_cam_device);
61}
62
63#elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
64
65static struct resource omap3isp_resources[] = {
66 {
67 .start = OMAP3430_ISP_BASE,
68 .end = OMAP3430_ISP_END,
69 .flags = IORESOURCE_MEM,
70 },
71 {
72 .start = OMAP3430_ISP_CBUFF_BASE,
73 .end = OMAP3430_ISP_CBUFF_END,
74 .flags = IORESOURCE_MEM,
75 },
76 {
77 .start = OMAP3430_ISP_CCP2_BASE,
78 .end = OMAP3430_ISP_CCP2_END,
79 .flags = IORESOURCE_MEM,
80 },
81 {
82 .start = OMAP3430_ISP_CCDC_BASE,
83 .end = OMAP3430_ISP_CCDC_END,
84 .flags = IORESOURCE_MEM,
85 },
86 {
87 .start = OMAP3430_ISP_HIST_BASE,
88 .end = OMAP3430_ISP_HIST_END,
89 .flags = IORESOURCE_MEM,
90 },
91 {
92 .start = OMAP3430_ISP_H3A_BASE,
93 .end = OMAP3430_ISP_H3A_END,
94 .flags = IORESOURCE_MEM,
95 },
96 {
97 .start = OMAP3430_ISP_PREV_BASE,
98 .end = OMAP3430_ISP_PREV_END,
99 .flags = IORESOURCE_MEM,
100 },
101 {
102 .start = OMAP3430_ISP_RESZ_BASE,
103 .end = OMAP3430_ISP_RESZ_END,
104 .flags = IORESOURCE_MEM,
105 },
106 {
107 .start = OMAP3430_ISP_SBL_BASE,
108 .end = OMAP3430_ISP_SBL_END,
109 .flags = IORESOURCE_MEM,
110 },
111 {
112 .start = OMAP3430_ISP_CSI2A_BASE,
113 .end = OMAP3430_ISP_CSI2A_END,
114 .flags = IORESOURCE_MEM,
115 },
116 {
117 .start = OMAP3430_ISP_CSI2PHY_BASE,
118 .end = OMAP3430_ISP_CSI2PHY_END,
119 .flags = IORESOURCE_MEM,
120 },
121 {
122 .start = INT_34XX_CAM_IRQ,
123 .flags = IORESOURCE_IRQ,
124 }
125};
126
127static struct platform_device omap3isp_device = {
128 .name = "omap3isp",
129 .id = -1,
130 .num_resources = ARRAY_SIZE(omap3isp_resources),
131 .resource = omap3isp_resources,
132};
133
134static inline void omap_init_camera(void)
135{
136 platform_device_register(&omap3isp_device);
137}
138#else
139static inline void omap_init_camera(void)
140{
141}
142#endif
143
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700144#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800145
C A Subramaniam454bf342009-11-22 10:11:18 -0800146#define MBOX_REG_SIZE 0x120
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700147
C A Subramaniam454bf342009-11-22 10:11:18 -0800148#ifdef CONFIG_ARCH_OMAP2
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800149static struct resource omap2_mbox_resources[] = {
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800150 {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700151 .start = OMAP24XX_MAILBOX_BASE,
152 .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800153 .flags = IORESOURCE_MEM,
154 },
155 {
156 .start = INT_24XX_MAIL_U0_MPU,
157 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000158 .name = "dsp",
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800159 },
160 {
161 .start = INT_24XX_MAIL_U3_MPU,
162 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000163 .name = "iva",
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800164 },
165};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800166static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
167#else
168#define omap2_mbox_resources NULL
169#define omap2_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800170#endif
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800171
C A Subramaniam454bf342009-11-22 10:11:18 -0800172#ifdef CONFIG_ARCH_OMAP3
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800173static struct resource omap3_mbox_resources[] = {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700174 {
175 .start = OMAP34XX_MAILBOX_BASE,
176 .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
177 .flags = IORESOURCE_MEM,
178 },
179 {
180 .start = INT_24XX_MAIL_U0_MPU,
181 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000182 .name = "dsp",
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700183 },
184};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800185static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
186#else
187#define omap3_mbox_resources NULL
188#define omap3_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800189#endif
190
191#ifdef CONFIG_ARCH_OMAP4
192
193#define OMAP4_MBOX_REG_SIZE 0x130
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800194static struct resource omap4_mbox_resources[] = {
C A Subramaniam454bf342009-11-22 10:11:18 -0800195 {
196 .start = OMAP44XX_MAILBOX_BASE,
197 .end = OMAP44XX_MAILBOX_BASE +
198 OMAP4_MBOX_REG_SIZE - 1,
199 .flags = IORESOURCE_MEM,
200 },
201 {
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530202 .start = OMAP44XX_IRQ_MAIL_U0,
C A Subramaniam454bf342009-11-22 10:11:18 -0800203 .flags = IORESOURCE_IRQ,
Felipe Contreras1f2c4df2010-06-11 15:51:44 +0000204 .name = "mbox",
C A Subramaniam454bf342009-11-22 10:11:18 -0800205 },
206};
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800207static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
208#else
209#define omap4_mbox_resources NULL
210#define omap4_mbox_resources_sz 0
C A Subramaniam454bf342009-11-22 10:11:18 -0800211#endif
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700212
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800213static struct platform_device mbox_device = {
Felipe Contrerasd7427092010-06-11 15:51:48 +0000214 .name = "omap-mailbox",
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800215 .id = -1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800216};
217
218static inline void omap_init_mbox(void)
219{
Tony Lindgrend10f2b62010-02-12 12:26:47 -0800220 if (cpu_is_omap24xx()) {
221 mbox_device.resource = omap2_mbox_resources;
222 mbox_device.num_resources = omap2_mbox_resources_sz;
223 } else if (cpu_is_omap34xx()) {
224 mbox_device.resource = omap3_mbox_resources;
225 mbox_device.num_resources = omap3_mbox_resources_sz;
226 } else if (cpu_is_omap44xx()) {
227 mbox_device.resource = omap4_mbox_resources;
228 mbox_device.num_resources = omap4_mbox_resources_sz;
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700229 } else {
230 pr_err("%s: platform not supported\n", __func__);
231 return;
232 }
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800233 platform_device_register(&mbox_device);
234}
235#else
236static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700237#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800238
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100239static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100240
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300241#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700242
Tony Lindgrence491cf2009-10-20 09:40:47 -0700243#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700244
245#define OMAP2_MCSPI1_BASE 0x48098000
246#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300247#define OMAP2_MCSPI3_BASE 0x480b8000
248#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700249
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700250#define OMAP4_MCSPI1_BASE 0x48098100
251#define OMAP4_MCSPI2_BASE 0x4809a100
252#define OMAP4_MCSPI3_BASE 0x480b8100
253#define OMAP4_MCSPI4_BASE 0x480ba100
254
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700255static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700256 .num_cs = 4,
257};
258
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800259static struct resource omap2_mcspi1_resources[] = {
260 {
261 .start = OMAP2_MCSPI1_BASE,
262 .end = OMAP2_MCSPI1_BASE + 0xff,
263 .flags = IORESOURCE_MEM,
264 },
265};
266
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300267static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700268 .name = "omap2_mcspi",
269 .id = 1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800270 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
271 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700272 .dev = {
273 .platform_data = &omap2_mcspi1_config,
274 },
275};
276
277static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700278 .num_cs = 2,
279};
280
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800281static struct resource omap2_mcspi2_resources[] = {
282 {
283 .start = OMAP2_MCSPI2_BASE,
284 .end = OMAP2_MCSPI2_BASE + 0xff,
285 .flags = IORESOURCE_MEM,
286 },
287};
288
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300289static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700290 .name = "omap2_mcspi",
291 .id = 2,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800292 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
293 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700294 .dev = {
295 .platform_data = &omap2_mcspi2_config,
296 },
297};
298
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700299#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
300 defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300301static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
302 .num_cs = 2,
303};
304
305static struct resource omap2_mcspi3_resources[] = {
306 {
307 .start = OMAP2_MCSPI3_BASE,
308 .end = OMAP2_MCSPI3_BASE + 0xff,
309 .flags = IORESOURCE_MEM,
310 },
311};
312
313static struct platform_device omap2_mcspi3 = {
314 .name = "omap2_mcspi",
315 .id = 3,
316 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
317 .resource = omap2_mcspi3_resources,
318 .dev = {
319 .platform_data = &omap2_mcspi3_config,
320 },
321};
322#endif
323
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700324#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300325static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
326 .num_cs = 1,
327};
328
329static struct resource omap2_mcspi4_resources[] = {
330 {
331 .start = OMAP2_MCSPI4_BASE,
332 .end = OMAP2_MCSPI4_BASE + 0xff,
333 .flags = IORESOURCE_MEM,
334 },
335};
336
337static struct platform_device omap2_mcspi4 = {
338 .name = "omap2_mcspi",
339 .id = 4,
340 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
341 .resource = omap2_mcspi4_resources,
342 .dev = {
343 .platform_data = &omap2_mcspi4_config,
344 },
345};
346#endif
347
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700348#ifdef CONFIG_ARCH_OMAP4
349static inline void omap4_mcspi_fixup(void)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700350{
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700351 omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
352 omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
353 omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
354 omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
355 omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
356 omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
357 omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
358 omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
359}
360#else
361static inline void omap4_mcspi_fixup(void)
362{
363}
364#endif
365
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700366#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
367 defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700368static inline void omap2_mcspi3_init(void)
369{
370 platform_device_register(&omap2_mcspi3);
371}
372#else
373static inline void omap2_mcspi3_init(void)
374{
375}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300376#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700377
Syed Rafiuddin7869c0b2009-09-22 16:46:18 -0700378#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700379static inline void omap2_mcspi4_init(void)
380{
381 platform_device_register(&omap2_mcspi4);
382}
383#else
384static inline void omap2_mcspi4_init(void)
385{
386}
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300387#endif
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700388
389static void omap_init_mcspi(void)
390{
391 if (cpu_is_omap44xx())
392 omap4_mcspi_fixup();
393
394 platform_device_register(&omap2_mcspi1);
395 platform_device_register(&omap2_mcspi2);
396
397 if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
398 omap2_mcspi3_init();
399
400 if (cpu_is_omap343x() || cpu_is_omap44xx())
401 omap2_mcspi4_init();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700402}
403
404#else
405static inline void omap_init_mcspi(void) {}
406#endif
407
Will Deacon88341332010-04-09 13:54:43 +0100408static struct resource omap2_pmu_resource = {
409 .start = 3,
410 .end = 3,
411 .flags = IORESOURCE_IRQ,
412};
413
414static struct resource omap3_pmu_resource = {
415 .start = INT_34XX_BENCH_MPU_EMUL,
416 .end = INT_34XX_BENCH_MPU_EMUL,
417 .flags = IORESOURCE_IRQ,
418};
419
420static struct platform_device omap_pmu_device = {
421 .name = "arm-pmu",
422 .id = ARM_PMU_DEVICE_CPU,
423 .num_resources = 1,
424};
425
426static void omap_init_pmu(void)
427{
428 if (cpu_is_omap24xx())
429 omap_pmu_device.resource = &omap2_pmu_resource;
430 else if (cpu_is_omap34xx())
431 omap_pmu_device.resource = &omap3_pmu_resource;
432 else
433 return;
434
435 platform_device_register(&omap_pmu_device);
436}
437
438
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800439#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
440
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000441#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800442static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300443 {
444 .start = OMAP24XX_SEC_SHA1MD5_BASE,
445 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
446 .flags = IORESOURCE_MEM,
447 },
448 {
449 .start = INT_24XX_SHA1MD5,
450 .flags = IORESOURCE_IRQ,
451 }
452};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800453static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
454#else
455#define omap2_sham_resources NULL
456#define omap2_sham_resources_sz 0
457#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300458
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000459#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800460static struct resource omap3_sham_resources[] = {
461 {
462 .start = OMAP34XX_SEC_SHA1MD5_BASE,
463 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
464 .flags = IORESOURCE_MEM,
465 },
466 {
467 .start = INT_34XX_SHA1MD52_IRQ,
468 .flags = IORESOURCE_IRQ,
469 },
470 {
471 .start = OMAP34XX_DMA_SHA1MD5_RX,
472 .flags = IORESOURCE_DMA,
473 }
474};
475static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
476#else
477#define omap3_sham_resources NULL
478#define omap3_sham_resources_sz 0
479#endif
480
481static struct platform_device sham_device = {
482 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300483 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300484};
485
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800486static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300487{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800488 if (cpu_is_omap24xx()) {
489 sham_device.resource = omap2_sham_resources;
490 sham_device.num_resources = omap2_sham_resources_sz;
491 } else if (cpu_is_omap34xx()) {
492 sham_device.resource = omap3_sham_resources;
493 sham_device.num_resources = omap3_sham_resources_sz;
494 } else {
495 pr_err("%s: platform not supported\n", __func__);
496 return;
497 }
498 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300499}
500#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800501static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300502#endif
503
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000504#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
505
506#ifdef CONFIG_ARCH_OMAP2
507static struct resource omap2_aes_resources[] = {
508 {
509 .start = OMAP24XX_SEC_AES_BASE,
510 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
511 .flags = IORESOURCE_MEM,
512 },
513 {
514 .start = OMAP24XX_DMA_AES_TX,
515 .flags = IORESOURCE_DMA,
516 },
517 {
518 .start = OMAP24XX_DMA_AES_RX,
519 .flags = IORESOURCE_DMA,
520 }
521};
522static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
523#else
524#define omap2_aes_resources NULL
525#define omap2_aes_resources_sz 0
526#endif
527
528#ifdef CONFIG_ARCH_OMAP3
529static struct resource omap3_aes_resources[] = {
530 {
531 .start = OMAP34XX_SEC_AES_BASE,
532 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
533 .flags = IORESOURCE_MEM,
534 },
535 {
536 .start = OMAP34XX_DMA_AES2_TX,
537 .flags = IORESOURCE_DMA,
538 },
539 {
540 .start = OMAP34XX_DMA_AES2_RX,
541 .flags = IORESOURCE_DMA,
542 }
543};
544static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
545#else
546#define omap3_aes_resources NULL
547#define omap3_aes_resources_sz 0
548#endif
549
550static struct platform_device aes_device = {
551 .name = "omap-aes",
552 .id = -1,
553};
554
555static void omap_init_aes(void)
556{
557 if (cpu_is_omap24xx()) {
558 aes_device.resource = omap2_aes_resources;
559 aes_device.num_resources = omap2_aes_resources_sz;
560 } else if (cpu_is_omap34xx()) {
561 aes_device.resource = omap3_aes_resources;
562 aes_device.num_resources = omap3_aes_resources_sz;
563 } else {
564 pr_err("%s: platform not supported\n", __func__);
565 return;
566 }
567 platform_device_register(&aes_device);
568}
569
570#else
571static inline void omap_init_aes(void) { }
572#endif
573
Tony Lindgrend8874662008-12-10 17:37:16 -0800574/*-------------------------------------------------------------------------*/
575
kishore kadiyala82cf8182009-09-22 16:45:25 -0700576#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Kevin Hilman917fa282008-12-10 17:37:17 -0800577
578#define MMCHS_SYSCONFIG 0x0010
579#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
580#define MMCHS_SYSSTATUS 0x0014
581#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
582
583static struct platform_device dummy_pdev = {
584 .dev = {
585 .bus = &platform_bus_type,
586 },
587};
588
589/**
590 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
591 *
592 * Ensure that each MMC controller is fully reset. Controllers
593 * left in an unknown state (by bootloader) may prevent retention
594 * or OFF-mode. This is especially important in cases where the
595 * MMC driver is not enabled, _or_ built as a module.
596 *
597 * In order for reset to work, interface, functional and debounce
598 * clocks must be enabled. The debounce clock comes from func_32k_clk
599 * and is not under SW control, so we only enable i- and f-clocks.
600 **/
601static void __init omap_hsmmc_reset(void)
602{
Tony Lindgren4323e9f2010-02-12 12:26:48 -0800603 u32 i, nr_controllers;
604
605 if (cpu_is_omap242x())
606 return;
607
608 nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
kishore kadiyala82cf8182009-09-22 16:45:25 -0700609 (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
Kevin Hilman917fa282008-12-10 17:37:17 -0800610
611 for (i = 0; i < nr_controllers; i++) {
612 u32 v, base = 0;
613 struct clk *iclk, *fclk;
614 struct device *dev = &dummy_pdev.dev;
615
616 switch (i) {
617 case 0:
618 base = OMAP2_MMC1_BASE;
619 break;
620 case 1:
621 base = OMAP2_MMC2_BASE;
622 break;
623 case 2:
624 base = OMAP3_MMC3_BASE;
625 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700626 case 3:
627 if (!cpu_is_omap44xx())
628 return;
629 base = OMAP4_MMC4_BASE;
630 break;
631 case 4:
632 if (!cpu_is_omap44xx())
633 return;
634 base = OMAP4_MMC5_BASE;
635 break;
Kevin Hilman917fa282008-12-10 17:37:17 -0800636 }
637
kishore kadiyala82cf8182009-09-22 16:45:25 -0700638 if (cpu_is_omap44xx())
639 base += OMAP4_MMC_REG_OFFSET;
640
Kevin Hilman917fa282008-12-10 17:37:17 -0800641 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000642 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000643 iclk = clk_get(dev, "ick");
Kevin Hilman917fa282008-12-10 17:37:17 -0800644 if (iclk && clk_enable(iclk))
645 iclk = NULL;
646
Russell King6f7607c2009-01-28 10:22:50 +0000647 fclk = clk_get(dev, "fck");
Kevin Hilman917fa282008-12-10 17:37:17 -0800648 if (fclk && clk_enable(fclk))
649 fclk = NULL;
650
651 if (!iclk || !fclk) {
652 printk(KERN_WARNING
653 "%s: Unable to enable clocks for MMC%d, "
654 "cannot reset.\n", __func__, i);
655 break;
656 }
657
658 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
659 v = omap_readl(base + MMCHS_SYSSTATUS);
660 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
661 MMCHS_SYSSTATUS_RESETDONE))
662 cpu_relax();
663
664 if (fclk) {
665 clk_disable(fclk);
666 clk_put(fclk);
667 }
668 if (iclk) {
669 clk_disable(iclk);
670 clk_put(iclk);
671 }
672 }
673}
674#else
675static inline void omap_hsmmc_reset(void) {}
676#endif
677
Tony Lindgrend8874662008-12-10 17:37:16 -0800678#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
679 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
680
681static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
682 int controller_nr)
683{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000684 if ((mmc_controller->slots[0].switch_pin > 0) && \
685 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
686 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
687 OMAP_PIN_INPUT_PULLUP);
688 if ((mmc_controller->slots[0].gpio_wp > 0) && \
689 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
690 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
691 OMAP_PIN_INPUT_PULLUP);
692
Tony Lindgrend8874662008-12-10 17:37:16 -0800693 if (cpu_is_omap2420() && controller_nr == 0) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300694 omap_mux_init_signal("sdmmc_cmd", 0);
695 omap_mux_init_signal("sdmmc_clki", 0);
696 omap_mux_init_signal("sdmmc_clko", 0);
697 omap_mux_init_signal("sdmmc_dat0", 0);
698 omap_mux_init_signal("sdmmc_dat_dir0", 0);
699 omap_mux_init_signal("sdmmc_cmd_dir", 0);
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000700 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300701 omap_mux_init_signal("sdmmc_dat1", 0);
702 omap_mux_init_signal("sdmmc_dat2", 0);
703 omap_mux_init_signal("sdmmc_dat3", 0);
704 omap_mux_init_signal("sdmmc_dat_dir1", 0);
705 omap_mux_init_signal("sdmmc_dat_dir2", 0);
706 omap_mux_init_signal("sdmmc_dat_dir3", 0);
Tony Lindgrend8874662008-12-10 17:37:16 -0800707 }
708
709 /*
710 * Use internal loop-back in MMC/SDIO Module Input Clock
711 * selection
712 */
713 if (mmc_controller->slots[0].internal_clock) {
714 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
715 v |= (1 << 24);
716 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
717 }
718 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700719
Madhu4596d142009-11-22 10:11:06 -0800720 if (cpu_is_omap34xx()) {
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700721 if (controller_nr == 0) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800722 omap_mux_init_signal("sdmmc1_clk",
723 OMAP_PIN_INPUT_PULLUP);
724 omap_mux_init_signal("sdmmc1_cmd",
725 OMAP_PIN_INPUT_PULLUP);
726 omap_mux_init_signal("sdmmc1_dat0",
727 OMAP_PIN_INPUT_PULLUP);
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000728 if (mmc_controller->slots[0].caps &
729 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800730 omap_mux_init_signal("sdmmc1_dat1",
731 OMAP_PIN_INPUT_PULLUP);
732 omap_mux_init_signal("sdmmc1_dat2",
733 OMAP_PIN_INPUT_PULLUP);
734 omap_mux_init_signal("sdmmc1_dat3",
735 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700736 }
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000737 if (mmc_controller->slots[0].caps &
738 MMC_CAP_8_BIT_DATA) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800739 omap_mux_init_signal("sdmmc1_dat4",
740 OMAP_PIN_INPUT_PULLUP);
741 omap_mux_init_signal("sdmmc1_dat5",
742 OMAP_PIN_INPUT_PULLUP);
743 omap_mux_init_signal("sdmmc1_dat6",
744 OMAP_PIN_INPUT_PULLUP);
745 omap_mux_init_signal("sdmmc1_dat7",
746 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700747 }
748 }
749 if (controller_nr == 1) {
750 /* MMC2 */
Tony Lindgren4896e392009-12-11 16:16:32 -0800751 omap_mux_init_signal("sdmmc2_clk",
752 OMAP_PIN_INPUT_PULLUP);
753 omap_mux_init_signal("sdmmc2_cmd",
754 OMAP_PIN_INPUT_PULLUP);
755 omap_mux_init_signal("sdmmc2_dat0",
756 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700757
758 /*
759 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
760 * in the board-*.c files
761 */
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000762 if (mmc_controller->slots[0].caps &
763 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800764 omap_mux_init_signal("sdmmc2_dat1",
765 OMAP_PIN_INPUT_PULLUP);
766 omap_mux_init_signal("sdmmc2_dat2",
767 OMAP_PIN_INPUT_PULLUP);
768 omap_mux_init_signal("sdmmc2_dat3",
769 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700770 }
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000771 if (mmc_controller->slots[0].caps &
772 MMC_CAP_8_BIT_DATA) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800773 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
774 OMAP_PIN_INPUT_PULLUP);
775 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
776 OMAP_PIN_INPUT_PULLUP);
777 omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
778 OMAP_PIN_INPUT_PULLUP);
779 omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
780 OMAP_PIN_INPUT_PULLUP);
Madhu46792322009-11-22 10:11:08 -0800781 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700782 }
783
784 /*
785 * For MMC3 the pins need to be muxed in the board-*.c files
786 */
787 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800788}
789
790void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
791 int nr_controllers)
792{
793 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800794 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800795
796 for (i = 0; i < nr_controllers; i++) {
797 unsigned long base, size;
798 unsigned int irq = 0;
799
800 if (!mmc_data[i])
801 continue;
802
803 omap2_mmc_mux(mmc_data[i], i);
804
805 switch (i) {
806 case 0:
807 base = OMAP2_MMC1_BASE;
808 irq = INT_24XX_MMC_IRQ;
809 break;
810 case 1:
811 base = OMAP2_MMC2_BASE;
812 irq = INT_24XX_MMC2_IRQ;
813 break;
814 case 2:
kishore kadiyala82cf8182009-09-22 16:45:25 -0700815 if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
Tony Lindgrend8874662008-12-10 17:37:16 -0800816 return;
817 base = OMAP3_MMC3_BASE;
818 irq = INT_34XX_MMC3_IRQ;
819 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700820 case 3:
821 if (!cpu_is_omap44xx())
822 return;
823 base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530824 irq = OMAP44XX_IRQ_MMC4;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700825 break;
826 case 4:
827 if (!cpu_is_omap44xx())
828 return;
829 base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
kishore kadiyala9df76b72010-04-21 18:19:37 +0000830 irq = OMAP44XX_IRQ_MMC5;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700831 break;
Tony Lindgrend8874662008-12-10 17:37:16 -0800832 default:
833 continue;
834 }
835
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800836 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800837 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800838 name = "mmci-omap";
kishore kadiyala82cf8182009-09-22 16:45:25 -0700839 } else if (cpu_is_omap44xx()) {
840 if (i < 3) {
841 base += OMAP4_MMC_REG_OFFSET;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530842 irq += OMAP44XX_IRQ_GIC_START;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700843 }
844 size = OMAP4_HSMMC_SIZE;
845 name = "mmci-omap-hs";
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800846 } else {
kishore kadiyala82cf8182009-09-22 16:45:25 -0700847 size = OMAP3_HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800848 name = "mmci-omap-hs";
849 }
850 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800851 };
852}
853
854#endif
855
856/*-------------------------------------------------------------------------*/
857
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300858#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
859#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
860#define OMAP_HDQ_BASE 0x480B2000
861#endif
862static struct resource omap_hdq_resources[] = {
863 {
864 .start = OMAP_HDQ_BASE,
865 .end = OMAP_HDQ_BASE + 0x1C,
866 .flags = IORESOURCE_MEM,
867 },
868 {
869 .start = INT_24XX_HDQ_IRQ,
870 .flags = IORESOURCE_IRQ,
871 },
872};
873static struct platform_device omap_hdq_dev = {
874 .name = "omap_hdq",
875 .id = 0,
876 .dev = {
877 .platform_data = NULL,
878 },
879 .num_resources = ARRAY_SIZE(omap_hdq_resources),
880 .resource = omap_hdq_resources,
881};
882static inline void omap_hdq_init(void)
883{
884 (void) platform_device_register(&omap_hdq_dev);
885}
886#else
887static inline void omap_hdq_init(void) {}
888#endif
889
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700890/*---------------------------------------------------------------------------*/
891
892#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
893 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
894#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
895static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
896};
897#else
898static struct resource omap_vout_resource[2] = {
899};
900#endif
901
902static struct platform_device omap_vout_device = {
903 .name = "omap_vout",
904 .num_resources = ARRAY_SIZE(omap_vout_resource),
905 .resource = &omap_vout_resource[0],
906 .id = -1,
907};
908static void omap_init_vout(void)
909{
910 if (platform_device_register(&omap_vout_device) < 0)
911 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
912}
913#else
914static inline void omap_init_vout(void) {}
915#endif
916
Tony Lindgren1dbae812005-11-10 14:26:51 +0000917/*-------------------------------------------------------------------------*/
918
919static int __init omap2_init_devices(void)
920{
921 /* please keep these calls, and their implementations above,
922 * in alphabetical order so they're easier to sort through.
923 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800924 omap_hsmmc_reset();
Tony Lindgren828c7072009-03-23 18:23:49 -0700925 omap_init_camera();
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800926 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700927 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100928 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300929 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100930 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800931 omap_init_sham();
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000932 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700933 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000934
935 return 0;
936}
937arch_initcall(omap2_init_devices);
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530938
939#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
940struct omap_device_pm_latency omap_wdt_latency[] = {
941 [0] = {
942 .deactivate_func = omap_device_idle_hwmods,
943 .activate_func = omap_device_enable_hwmods,
944 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
945 },
946};
947
948static int __init omap_init_wdt(void)
949{
950 int id = -1;
951 struct omap_device *od;
952 struct omap_hwmod *oh;
953 char *oh_name = "wd_timer2";
954 char *dev_name = "omap_wdt";
955
956 if (!cpu_class_is_omap2())
957 return 0;
958
959 oh = omap_hwmod_lookup(oh_name);
960 if (!oh) {
961 pr_err("Could not look up wd_timer%d hwmod\n", id);
962 return -EINVAL;
963 }
964
965 od = omap_device_build(dev_name, id, oh, NULL, 0,
966 omap_wdt_latency,
967 ARRAY_SIZE(omap_wdt_latency), 0);
968 WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
969 dev_name, oh->name);
970 return 0;
971}
972subsys_initcall(omap_init_wdt);
973#endif