blob: 92009a4c6c8680f0d5d083e2643fb1f64cc4f227 [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>
Tony Lindgren1dbae812005-11-10 14:26:51 +000020#include <asm/mach-types.h>
21#include <asm/mach/map.h>
22
Tony Lindgren90c62bf2008-12-10 17:37:17 -080023#include <mach/control.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/tc.h>
25#include <mach/board.h>
26#include <mach/mux.h>
27#include <mach/gpio.h>
Tony Lindgrend8874662008-12-10 17:37:16 -080028#include <mach/mmc.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000029
Tony Lindgren828c7072009-03-23 18:23:49 -070030#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -080031
Tony Lindgren828c7072009-03-23 18:23:49 -070032static struct resource cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -080033 {
Tony Lindgren828c7072009-03-23 18:23:49 -070034 .start = OMAP24XX_CAMERA_BASE,
35 .end = OMAP24XX_CAMERA_BASE + 0xfff,
36 .flags = IORESOURCE_MEM,
37 },
38 {
39 .start = INT_24XX_CAM_IRQ,
40 .flags = IORESOURCE_IRQ,
41 }
42};
43
44static struct platform_device omap_cam_device = {
45 .name = "omap24xxcam",
46 .id = -1,
47 .num_resources = ARRAY_SIZE(cam_resources),
48 .resource = cam_resources,
49};
50
51static inline void omap_init_camera(void)
52{
53 platform_device_register(&omap_cam_device);
54}
55
56#elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
57
58static struct resource omap3isp_resources[] = {
59 {
60 .start = OMAP3430_ISP_BASE,
61 .end = OMAP3430_ISP_END,
62 .flags = IORESOURCE_MEM,
63 },
64 {
65 .start = OMAP3430_ISP_CBUFF_BASE,
66 .end = OMAP3430_ISP_CBUFF_END,
67 .flags = IORESOURCE_MEM,
68 },
69 {
70 .start = OMAP3430_ISP_CCP2_BASE,
71 .end = OMAP3430_ISP_CCP2_END,
72 .flags = IORESOURCE_MEM,
73 },
74 {
75 .start = OMAP3430_ISP_CCDC_BASE,
76 .end = OMAP3430_ISP_CCDC_END,
77 .flags = IORESOURCE_MEM,
78 },
79 {
80 .start = OMAP3430_ISP_HIST_BASE,
81 .end = OMAP3430_ISP_HIST_END,
82 .flags = IORESOURCE_MEM,
83 },
84 {
85 .start = OMAP3430_ISP_H3A_BASE,
86 .end = OMAP3430_ISP_H3A_END,
87 .flags = IORESOURCE_MEM,
88 },
89 {
90 .start = OMAP3430_ISP_PREV_BASE,
91 .end = OMAP3430_ISP_PREV_END,
92 .flags = IORESOURCE_MEM,
93 },
94 {
95 .start = OMAP3430_ISP_RESZ_BASE,
96 .end = OMAP3430_ISP_RESZ_END,
97 .flags = IORESOURCE_MEM,
98 },
99 {
100 .start = OMAP3430_ISP_SBL_BASE,
101 .end = OMAP3430_ISP_SBL_END,
102 .flags = IORESOURCE_MEM,
103 },
104 {
105 .start = OMAP3430_ISP_CSI2A_BASE,
106 .end = OMAP3430_ISP_CSI2A_END,
107 .flags = IORESOURCE_MEM,
108 },
109 {
110 .start = OMAP3430_ISP_CSI2PHY_BASE,
111 .end = OMAP3430_ISP_CSI2PHY_END,
112 .flags = IORESOURCE_MEM,
113 },
114 {
115 .start = INT_34XX_CAM_IRQ,
116 .flags = IORESOURCE_IRQ,
117 }
118};
119
120static struct platform_device omap3isp_device = {
121 .name = "omap3isp",
122 .id = -1,
123 .num_resources = ARRAY_SIZE(omap3isp_resources),
124 .resource = omap3isp_resources,
125};
126
127static inline void omap_init_camera(void)
128{
129 platform_device_register(&omap3isp_device);
130}
131#else
132static inline void omap_init_camera(void)
133{
134}
135#endif
136
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700137#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800138
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700139#define MBOX_REG_SIZE 0x120
140
141static struct resource omap2_mbox_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800142 {
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700143 .start = OMAP24XX_MAILBOX_BASE,
144 .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800145 .flags = IORESOURCE_MEM,
146 },
147 {
148 .start = INT_24XX_MAIL_U0_MPU,
149 .flags = IORESOURCE_IRQ,
150 },
151 {
152 .start = INT_24XX_MAIL_U3_MPU,
153 .flags = IORESOURCE_IRQ,
154 },
155};
156
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700157static struct resource omap3_mbox_resources[] = {
158 {
159 .start = OMAP34XX_MAILBOX_BASE,
160 .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
161 .flags = IORESOURCE_MEM,
162 },
163 {
164 .start = INT_24XX_MAIL_U0_MPU,
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800169static struct platform_device mbox_device = {
Hiroshi DOYUda8cfe02009-03-23 18:07:25 -0700170 .name = "omap2-mailbox",
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800171 .id = -1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800172};
173
174static inline void omap_init_mbox(void)
175{
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700176 if (cpu_is_omap2420()) {
177 mbox_device.num_resources = ARRAY_SIZE(omap2_mbox_resources);
178 mbox_device.resource = omap2_mbox_resources;
179 } else if (cpu_is_omap3430()) {
180 mbox_device.num_resources = ARRAY_SIZE(omap3_mbox_resources);
181 mbox_device.resource = omap3_mbox_resources;
182 } else {
183 pr_err("%s: platform not supported\n", __func__);
184 return;
185 }
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800186 platform_device_register(&mbox_device);
187}
188#else
189static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700190#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800191
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100192#if defined(CONFIG_OMAP_STI)
193
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300194#if defined(CONFIG_ARCH_OMAP2)
195
196#define OMAP2_STI_BASE 0x48068000
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100197#define OMAP2_STI_CHANNEL_BASE 0x54000000
198#define OMAP2_STI_IRQ 4
199
200static struct resource sti_resources[] = {
201 {
202 .start = OMAP2_STI_BASE,
203 .end = OMAP2_STI_BASE + 0x7ff,
204 .flags = IORESOURCE_MEM,
205 },
206 {
207 .start = OMAP2_STI_CHANNEL_BASE,
208 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
209 .flags = IORESOURCE_MEM,
210 },
211 {
212 .start = OMAP2_STI_IRQ,
213 .flags = IORESOURCE_IRQ,
214 }
215};
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300216#elif defined(CONFIG_ARCH_OMAP3)
217
218#define OMAP3_SDTI_BASE 0x54500000
219#define OMAP3_SDTI_CHANNEL_BASE 0x54600000
220
221static struct resource sti_resources[] = {
222 {
223 .start = OMAP3_SDTI_BASE,
224 .end = OMAP3_SDTI_BASE + 0xFFF,
225 .flags = IORESOURCE_MEM,
226 },
227 {
228 .start = OMAP3_SDTI_CHANNEL_BASE,
229 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
230 .flags = IORESOURCE_MEM,
231 }
232};
233
234#endif
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100235
236static struct platform_device sti_device = {
237 .name = "sti",
238 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100239 .num_resources = ARRAY_SIZE(sti_resources),
240 .resource = sti_resources,
241};
242
243static inline void omap_init_sti(void)
244{
245 platform_device_register(&sti_device);
246}
247#else
248static inline void omap_init_sti(void) {}
249#endif
250
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300251#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700252
Russell Kinga09e64f2008-08-05 16:14:15 +0100253#include <mach/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700254
255#define OMAP2_MCSPI1_BASE 0x48098000
256#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300257#define OMAP2_MCSPI3_BASE 0x480b8000
258#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700259
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700260static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700261 .num_cs = 4,
262};
263
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800264static struct resource omap2_mcspi1_resources[] = {
265 {
266 .start = OMAP2_MCSPI1_BASE,
267 .end = OMAP2_MCSPI1_BASE + 0xff,
268 .flags = IORESOURCE_MEM,
269 },
270};
271
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300272static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700273 .name = "omap2_mcspi",
274 .id = 1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800275 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
276 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700277 .dev = {
278 .platform_data = &omap2_mcspi1_config,
279 },
280};
281
282static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700283 .num_cs = 2,
284};
285
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800286static struct resource omap2_mcspi2_resources[] = {
287 {
288 .start = OMAP2_MCSPI2_BASE,
289 .end = OMAP2_MCSPI2_BASE + 0xff,
290 .flags = IORESOURCE_MEM,
291 },
292};
293
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300294static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700295 .name = "omap2_mcspi",
296 .id = 2,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800297 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
298 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700299 .dev = {
300 .platform_data = &omap2_mcspi2_config,
301 },
302};
303
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300304#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
305static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
306 .num_cs = 2,
307};
308
309static struct resource omap2_mcspi3_resources[] = {
310 {
311 .start = OMAP2_MCSPI3_BASE,
312 .end = OMAP2_MCSPI3_BASE + 0xff,
313 .flags = IORESOURCE_MEM,
314 },
315};
316
317static struct platform_device omap2_mcspi3 = {
318 .name = "omap2_mcspi",
319 .id = 3,
320 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
321 .resource = omap2_mcspi3_resources,
322 .dev = {
323 .platform_data = &omap2_mcspi3_config,
324 },
325};
326#endif
327
328#ifdef CONFIG_ARCH_OMAP3
329static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
330 .num_cs = 1,
331};
332
333static struct resource omap2_mcspi4_resources[] = {
334 {
335 .start = OMAP2_MCSPI4_BASE,
336 .end = OMAP2_MCSPI4_BASE + 0xff,
337 .flags = IORESOURCE_MEM,
338 },
339};
340
341static struct platform_device omap2_mcspi4 = {
342 .name = "omap2_mcspi",
343 .id = 4,
344 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
345 .resource = omap2_mcspi4_resources,
346 .dev = {
347 .platform_data = &omap2_mcspi4_config,
348 },
349};
350#endif
351
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700352static void omap_init_mcspi(void)
353{
354 platform_device_register(&omap2_mcspi1);
355 platform_device_register(&omap2_mcspi2);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300356#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
Jarkko Nikulac8a799b2009-05-12 11:20:02 -0700357 if (cpu_is_omap2430() || cpu_is_omap343x())
358 platform_device_register(&omap2_mcspi3);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300359#endif
360#ifdef CONFIG_ARCH_OMAP3
Jarkko Nikulac8a799b2009-05-12 11:20:02 -0700361 if (cpu_is_omap343x())
362 platform_device_register(&omap2_mcspi4);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300363#endif
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700364}
365
366#else
367static inline void omap_init_mcspi(void) {}
368#endif
369
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300370#ifdef CONFIG_OMAP_SHA1_MD5
371static struct resource sha1_md5_resources[] = {
372 {
373 .start = OMAP24XX_SEC_SHA1MD5_BASE,
374 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
375 .flags = IORESOURCE_MEM,
376 },
377 {
378 .start = INT_24XX_SHA1MD5,
379 .flags = IORESOURCE_IRQ,
380 }
381};
382
383static struct platform_device sha1_md5_device = {
384 .name = "OMAP SHA1/MD5",
385 .id = -1,
386 .num_resources = ARRAY_SIZE(sha1_md5_resources),
387 .resource = sha1_md5_resources,
388};
389
390static void omap_init_sha1_md5(void)
391{
392 platform_device_register(&sha1_md5_device);
393}
394#else
395static inline void omap_init_sha1_md5(void) { }
396#endif
397
Tony Lindgrend8874662008-12-10 17:37:16 -0800398/*-------------------------------------------------------------------------*/
399
kishore kadiyala82cf8182009-09-22 16:45:25 -0700400#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Kevin Hilman917fa282008-12-10 17:37:17 -0800401
402#define MMCHS_SYSCONFIG 0x0010
403#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
404#define MMCHS_SYSSTATUS 0x0014
405#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
406
407static struct platform_device dummy_pdev = {
408 .dev = {
409 .bus = &platform_bus_type,
410 },
411};
412
413/**
414 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
415 *
416 * Ensure that each MMC controller is fully reset. Controllers
417 * left in an unknown state (by bootloader) may prevent retention
418 * or OFF-mode. This is especially important in cases where the
419 * MMC driver is not enabled, _or_ built as a module.
420 *
421 * In order for reset to work, interface, functional and debounce
422 * clocks must be enabled. The debounce clock comes from func_32k_clk
423 * and is not under SW control, so we only enable i- and f-clocks.
424 **/
425static void __init omap_hsmmc_reset(void)
426{
kishore kadiyala82cf8182009-09-22 16:45:25 -0700427 u32 i, nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
428 (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
Kevin Hilman917fa282008-12-10 17:37:17 -0800429
430 for (i = 0; i < nr_controllers; i++) {
431 u32 v, base = 0;
432 struct clk *iclk, *fclk;
433 struct device *dev = &dummy_pdev.dev;
434
435 switch (i) {
436 case 0:
437 base = OMAP2_MMC1_BASE;
438 break;
439 case 1:
440 base = OMAP2_MMC2_BASE;
441 break;
442 case 2:
443 base = OMAP3_MMC3_BASE;
444 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700445 case 3:
446 if (!cpu_is_omap44xx())
447 return;
448 base = OMAP4_MMC4_BASE;
449 break;
450 case 4:
451 if (!cpu_is_omap44xx())
452 return;
453 base = OMAP4_MMC5_BASE;
454 break;
Kevin Hilman917fa282008-12-10 17:37:17 -0800455 }
456
kishore kadiyala82cf8182009-09-22 16:45:25 -0700457 if (cpu_is_omap44xx())
458 base += OMAP4_MMC_REG_OFFSET;
459
Kevin Hilman917fa282008-12-10 17:37:17 -0800460 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000461 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000462 iclk = clk_get(dev, "ick");
Kevin Hilman917fa282008-12-10 17:37:17 -0800463 if (iclk && clk_enable(iclk))
464 iclk = NULL;
465
Russell King6f7607c2009-01-28 10:22:50 +0000466 fclk = clk_get(dev, "fck");
Kevin Hilman917fa282008-12-10 17:37:17 -0800467 if (fclk && clk_enable(fclk))
468 fclk = NULL;
469
470 if (!iclk || !fclk) {
471 printk(KERN_WARNING
472 "%s: Unable to enable clocks for MMC%d, "
473 "cannot reset.\n", __func__, i);
474 break;
475 }
476
477 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
478 v = omap_readl(base + MMCHS_SYSSTATUS);
479 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
480 MMCHS_SYSSTATUS_RESETDONE))
481 cpu_relax();
482
483 if (fclk) {
484 clk_disable(fclk);
485 clk_put(fclk);
486 }
487 if (iclk) {
488 clk_disable(iclk);
489 clk_put(iclk);
490 }
491 }
492}
493#else
494static inline void omap_hsmmc_reset(void) {}
495#endif
496
Tony Lindgrend8874662008-12-10 17:37:16 -0800497#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
498 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
499
500static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
501 int controller_nr)
502{
503 if (cpu_is_omap2420() && controller_nr == 0) {
504 omap_cfg_reg(H18_24XX_MMC_CMD);
505 omap_cfg_reg(H15_24XX_MMC_CLKI);
506 omap_cfg_reg(G19_24XX_MMC_CLKO);
507 omap_cfg_reg(F20_24XX_MMC_DAT0);
508 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
509 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800510 if (mmc_controller->slots[0].wires == 4) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800511 omap_cfg_reg(H14_24XX_MMC_DAT1);
512 omap_cfg_reg(E19_24XX_MMC_DAT2);
513 omap_cfg_reg(D19_24XX_MMC_DAT3);
514 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
515 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
516 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
517 }
518
519 /*
520 * Use internal loop-back in MMC/SDIO Module Input Clock
521 * selection
522 */
523 if (mmc_controller->slots[0].internal_clock) {
524 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
525 v |= (1 << 24);
526 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
527 }
528 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700529
530 if (cpu_is_omap3430()) {
531 if (controller_nr == 0) {
532 omap_cfg_reg(N28_3430_MMC1_CLK);
533 omap_cfg_reg(M27_3430_MMC1_CMD);
534 omap_cfg_reg(N27_3430_MMC1_DAT0);
535 if (mmc_controller->slots[0].wires == 4 ||
536 mmc_controller->slots[0].wires == 8) {
537 omap_cfg_reg(N26_3430_MMC1_DAT1);
538 omap_cfg_reg(N25_3430_MMC1_DAT2);
539 omap_cfg_reg(P28_3430_MMC1_DAT3);
540 }
541 if (mmc_controller->slots[0].wires == 8) {
542 omap_cfg_reg(P27_3430_MMC1_DAT4);
543 omap_cfg_reg(P26_3430_MMC1_DAT5);
544 omap_cfg_reg(R27_3430_MMC1_DAT6);
545 omap_cfg_reg(R25_3430_MMC1_DAT7);
546 }
547 }
548 if (controller_nr == 1) {
549 /* MMC2 */
550 omap_cfg_reg(AE2_3430_MMC2_CLK);
551 omap_cfg_reg(AG5_3430_MMC2_CMD);
552 omap_cfg_reg(AH5_3430_MMC2_DAT0);
553
554 /*
555 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
556 * in the board-*.c files
557 */
558 if (mmc_controller->slots[0].wires == 4 ||
559 mmc_controller->slots[0].wires == 8) {
560 omap_cfg_reg(AH4_3430_MMC2_DAT1);
561 omap_cfg_reg(AG4_3430_MMC2_DAT2);
562 omap_cfg_reg(AF4_3430_MMC2_DAT3);
563 }
564 }
565
566 /*
567 * For MMC3 the pins need to be muxed in the board-*.c files
568 */
569 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800570}
571
572void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
573 int nr_controllers)
574{
575 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800576 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800577
578 for (i = 0; i < nr_controllers; i++) {
579 unsigned long base, size;
580 unsigned int irq = 0;
581
582 if (!mmc_data[i])
583 continue;
584
585 omap2_mmc_mux(mmc_data[i], i);
586
587 switch (i) {
588 case 0:
589 base = OMAP2_MMC1_BASE;
590 irq = INT_24XX_MMC_IRQ;
591 break;
592 case 1:
593 base = OMAP2_MMC2_BASE;
594 irq = INT_24XX_MMC2_IRQ;
595 break;
596 case 2:
kishore kadiyala82cf8182009-09-22 16:45:25 -0700597 if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
Tony Lindgrend8874662008-12-10 17:37:16 -0800598 return;
599 base = OMAP3_MMC3_BASE;
600 irq = INT_34XX_MMC3_IRQ;
601 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700602 case 3:
603 if (!cpu_is_omap44xx())
604 return;
605 base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
606 irq = INT_44XX_MMC4_IRQ;
607 break;
608 case 4:
609 if (!cpu_is_omap44xx())
610 return;
611 base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
612 irq = INT_44XX_MMC5_IRQ;
613 break;
Tony Lindgrend8874662008-12-10 17:37:16 -0800614 default:
615 continue;
616 }
617
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800618 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800619 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800620 name = "mmci-omap";
kishore kadiyala82cf8182009-09-22 16:45:25 -0700621 } else if (cpu_is_omap44xx()) {
622 if (i < 3) {
623 base += OMAP4_MMC_REG_OFFSET;
624 irq += IRQ_GIC_START;
625 }
626 size = OMAP4_HSMMC_SIZE;
627 name = "mmci-omap-hs";
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800628 } else {
kishore kadiyala82cf8182009-09-22 16:45:25 -0700629 size = OMAP3_HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800630 name = "mmci-omap-hs";
631 }
632 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800633 };
634}
635
636#endif
637
638/*-------------------------------------------------------------------------*/
639
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300640#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
641#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
642#define OMAP_HDQ_BASE 0x480B2000
643#endif
644static struct resource omap_hdq_resources[] = {
645 {
646 .start = OMAP_HDQ_BASE,
647 .end = OMAP_HDQ_BASE + 0x1C,
648 .flags = IORESOURCE_MEM,
649 },
650 {
651 .start = INT_24XX_HDQ_IRQ,
652 .flags = IORESOURCE_IRQ,
653 },
654};
655static struct platform_device omap_hdq_dev = {
656 .name = "omap_hdq",
657 .id = 0,
658 .dev = {
659 .platform_data = NULL,
660 },
661 .num_resources = ARRAY_SIZE(omap_hdq_resources),
662 .resource = omap_hdq_resources,
663};
664static inline void omap_hdq_init(void)
665{
666 (void) platform_device_register(&omap_hdq_dev);
667}
668#else
669static inline void omap_hdq_init(void) {}
670#endif
671
Tony Lindgren1dbae812005-11-10 14:26:51 +0000672/*-------------------------------------------------------------------------*/
673
674static int __init omap2_init_devices(void)
675{
676 /* please keep these calls, and their implementations above,
677 * in alphabetical order so they're easier to sort through.
678 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800679 omap_hsmmc_reset();
Tony Lindgren828c7072009-03-23 18:23:49 -0700680 omap_init_camera();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800681 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700682 omap_init_mcspi();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300683 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100684 omap_init_sti();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300685 omap_init_sha1_md5();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000686
687 return 0;
688}
689arch_initcall(omap2_init_devices);