blob: 8075f5868c38820383dbdbb7ab9daca344e4684a [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 Lindgren646e3ed2008-10-06 15:49:36 +030028#include <mach/eac.h>
Tony Lindgrend8874662008-12-10 17:37:16 -080029#include <mach/mmc.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000030
Tony Lindgrenc40fae952006-12-07 13:58:10 -080031#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
32#define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
33
34static struct resource mbox_resources[] = {
35 {
36 .start = OMAP2_MBOX_BASE,
37 .end = OMAP2_MBOX_BASE + 0x11f,
38 .flags = IORESOURCE_MEM,
39 },
40 {
41 .start = INT_24XX_MAIL_U0_MPU,
42 .flags = IORESOURCE_IRQ,
43 },
44 {
45 .start = INT_24XX_MAIL_U3_MPU,
46 .flags = IORESOURCE_IRQ,
47 },
48};
49
50static struct platform_device mbox_device = {
51 .name = "mailbox",
52 .id = -1,
53 .num_resources = ARRAY_SIZE(mbox_resources),
54 .resource = mbox_resources,
55};
56
57static inline void omap_init_mbox(void)
58{
59 platform_device_register(&mbox_device);
60}
61#else
62static inline void omap_init_mbox(void) { }
63#endif
64
Tony Lindgren9b6553c2006-04-02 17:46:30 +010065#if defined(CONFIG_OMAP_STI)
66
Tony Lindgren646e3ed2008-10-06 15:49:36 +030067#if defined(CONFIG_ARCH_OMAP2)
68
69#define OMAP2_STI_BASE 0x48068000
Tony Lindgren9b6553c2006-04-02 17:46:30 +010070#define OMAP2_STI_CHANNEL_BASE 0x54000000
71#define OMAP2_STI_IRQ 4
72
73static struct resource sti_resources[] = {
74 {
75 .start = OMAP2_STI_BASE,
76 .end = OMAP2_STI_BASE + 0x7ff,
77 .flags = IORESOURCE_MEM,
78 },
79 {
80 .start = OMAP2_STI_CHANNEL_BASE,
81 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
82 .flags = IORESOURCE_MEM,
83 },
84 {
85 .start = OMAP2_STI_IRQ,
86 .flags = IORESOURCE_IRQ,
87 }
88};
Tony Lindgren646e3ed2008-10-06 15:49:36 +030089#elif defined(CONFIG_ARCH_OMAP3)
90
91#define OMAP3_SDTI_BASE 0x54500000
92#define OMAP3_SDTI_CHANNEL_BASE 0x54600000
93
94static struct resource sti_resources[] = {
95 {
96 .start = OMAP3_SDTI_BASE,
97 .end = OMAP3_SDTI_BASE + 0xFFF,
98 .flags = IORESOURCE_MEM,
99 },
100 {
101 .start = OMAP3_SDTI_CHANNEL_BASE,
102 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
103 .flags = IORESOURCE_MEM,
104 }
105};
106
107#endif
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100108
109static struct platform_device sti_device = {
110 .name = "sti",
111 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100112 .num_resources = ARRAY_SIZE(sti_resources),
113 .resource = sti_resources,
114};
115
116static inline void omap_init_sti(void)
117{
118 platform_device_register(&sti_device);
119}
120#else
121static inline void omap_init_sti(void) {}
122#endif
123
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300124#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700125
Russell Kinga09e64f2008-08-05 16:14:15 +0100126#include <mach/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700127
128#define OMAP2_MCSPI1_BASE 0x48098000
129#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300130#define OMAP2_MCSPI3_BASE 0x480b8000
131#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700132
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700133static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700134 .num_cs = 4,
135};
136
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800137static struct resource omap2_mcspi1_resources[] = {
138 {
139 .start = OMAP2_MCSPI1_BASE,
140 .end = OMAP2_MCSPI1_BASE + 0xff,
141 .flags = IORESOURCE_MEM,
142 },
143};
144
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300145static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700146 .name = "omap2_mcspi",
147 .id = 1,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800148 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
149 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700150 .dev = {
151 .platform_data = &omap2_mcspi1_config,
152 },
153};
154
155static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700156 .num_cs = 2,
157};
158
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800159static struct resource omap2_mcspi2_resources[] = {
160 {
161 .start = OMAP2_MCSPI2_BASE,
162 .end = OMAP2_MCSPI2_BASE + 0xff,
163 .flags = IORESOURCE_MEM,
164 },
165};
166
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300167static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700168 .name = "omap2_mcspi",
169 .id = 2,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800170 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
171 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700172 .dev = {
173 .platform_data = &omap2_mcspi2_config,
174 },
175};
176
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300177#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
178static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
179 .num_cs = 2,
180};
181
182static struct resource omap2_mcspi3_resources[] = {
183 {
184 .start = OMAP2_MCSPI3_BASE,
185 .end = OMAP2_MCSPI3_BASE + 0xff,
186 .flags = IORESOURCE_MEM,
187 },
188};
189
190static struct platform_device omap2_mcspi3 = {
191 .name = "omap2_mcspi",
192 .id = 3,
193 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
194 .resource = omap2_mcspi3_resources,
195 .dev = {
196 .platform_data = &omap2_mcspi3_config,
197 },
198};
199#endif
200
201#ifdef CONFIG_ARCH_OMAP3
202static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
203 .num_cs = 1,
204};
205
206static struct resource omap2_mcspi4_resources[] = {
207 {
208 .start = OMAP2_MCSPI4_BASE,
209 .end = OMAP2_MCSPI4_BASE + 0xff,
210 .flags = IORESOURCE_MEM,
211 },
212};
213
214static struct platform_device omap2_mcspi4 = {
215 .name = "omap2_mcspi",
216 .id = 4,
217 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
218 .resource = omap2_mcspi4_resources,
219 .dev = {
220 .platform_data = &omap2_mcspi4_config,
221 },
222};
223#endif
224
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700225static void omap_init_mcspi(void)
226{
227 platform_device_register(&omap2_mcspi1);
228 platform_device_register(&omap2_mcspi2);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300229#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
230 platform_device_register(&omap2_mcspi3);
231#endif
232#ifdef CONFIG_ARCH_OMAP3
233 platform_device_register(&omap2_mcspi4);
234#endif
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700235}
236
237#else
238static inline void omap_init_mcspi(void) {}
239#endif
240
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300241#ifdef CONFIG_SND_OMAP24XX_EAC
242
243#define OMAP2_EAC_BASE 0x48090000
244
245static struct resource omap2_eac_resources[] = {
246 {
247 .start = OMAP2_EAC_BASE,
248 .end = OMAP2_EAC_BASE + 0x109,
249 .flags = IORESOURCE_MEM,
250 },
251};
252
253static struct platform_device omap2_eac_device = {
254 .name = "omap24xx-eac",
255 .id = -1,
256 .num_resources = ARRAY_SIZE(omap2_eac_resources),
257 .resource = omap2_eac_resources,
258 .dev = {
259 .platform_data = NULL,
260 },
261};
262
263void omap_init_eac(struct eac_platform_data *pdata)
264{
265 omap2_eac_device.dev.platform_data = pdata;
266 platform_device_register(&omap2_eac_device);
267}
268
269#else
270void omap_init_eac(struct eac_platform_data *pdata) {}
271#endif
272
273#ifdef CONFIG_OMAP_SHA1_MD5
274static struct resource sha1_md5_resources[] = {
275 {
276 .start = OMAP24XX_SEC_SHA1MD5_BASE,
277 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
278 .flags = IORESOURCE_MEM,
279 },
280 {
281 .start = INT_24XX_SHA1MD5,
282 .flags = IORESOURCE_IRQ,
283 }
284};
285
286static struct platform_device sha1_md5_device = {
287 .name = "OMAP SHA1/MD5",
288 .id = -1,
289 .num_resources = ARRAY_SIZE(sha1_md5_resources),
290 .resource = sha1_md5_resources,
291};
292
293static void omap_init_sha1_md5(void)
294{
295 platform_device_register(&sha1_md5_device);
296}
297#else
298static inline void omap_init_sha1_md5(void) { }
299#endif
300
Tony Lindgrend8874662008-12-10 17:37:16 -0800301/*-------------------------------------------------------------------------*/
302
Kevin Hilman917fa282008-12-10 17:37:17 -0800303#ifdef CONFIG_ARCH_OMAP3
304
305#define MMCHS_SYSCONFIG 0x0010
306#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
307#define MMCHS_SYSSTATUS 0x0014
308#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
309
310static struct platform_device dummy_pdev = {
311 .dev = {
312 .bus = &platform_bus_type,
313 },
314};
315
316/**
317 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
318 *
319 * Ensure that each MMC controller is fully reset. Controllers
320 * left in an unknown state (by bootloader) may prevent retention
321 * or OFF-mode. This is especially important in cases where the
322 * MMC driver is not enabled, _or_ built as a module.
323 *
324 * In order for reset to work, interface, functional and debounce
325 * clocks must be enabled. The debounce clock comes from func_32k_clk
326 * and is not under SW control, so we only enable i- and f-clocks.
327 **/
328static void __init omap_hsmmc_reset(void)
329{
330 u32 i, nr_controllers = cpu_is_omap34xx() ? OMAP34XX_NR_MMC :
331 OMAP24XX_NR_MMC;
332
333 for (i = 0; i < nr_controllers; i++) {
334 u32 v, base = 0;
335 struct clk *iclk, *fclk;
336 struct device *dev = &dummy_pdev.dev;
337
338 switch (i) {
339 case 0:
340 base = OMAP2_MMC1_BASE;
341 break;
342 case 1:
343 base = OMAP2_MMC2_BASE;
344 break;
345 case 2:
346 base = OMAP3_MMC3_BASE;
347 break;
348 }
349
350 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000351 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000352 iclk = clk_get(dev, "ick");
Kevin Hilman917fa282008-12-10 17:37:17 -0800353 if (iclk && clk_enable(iclk))
354 iclk = NULL;
355
Russell King6f7607c2009-01-28 10:22:50 +0000356 fclk = clk_get(dev, "fck");
Kevin Hilman917fa282008-12-10 17:37:17 -0800357 if (fclk && clk_enable(fclk))
358 fclk = NULL;
359
360 if (!iclk || !fclk) {
361 printk(KERN_WARNING
362 "%s: Unable to enable clocks for MMC%d, "
363 "cannot reset.\n", __func__, i);
364 break;
365 }
366
367 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
368 v = omap_readl(base + MMCHS_SYSSTATUS);
369 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
370 MMCHS_SYSSTATUS_RESETDONE))
371 cpu_relax();
372
373 if (fclk) {
374 clk_disable(fclk);
375 clk_put(fclk);
376 }
377 if (iclk) {
378 clk_disable(iclk);
379 clk_put(iclk);
380 }
381 }
382}
383#else
384static inline void omap_hsmmc_reset(void) {}
385#endif
386
Tony Lindgrend8874662008-12-10 17:37:16 -0800387#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
388 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
389
390static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
391 int controller_nr)
392{
393 if (cpu_is_omap2420() && controller_nr == 0) {
394 omap_cfg_reg(H18_24XX_MMC_CMD);
395 omap_cfg_reg(H15_24XX_MMC_CLKI);
396 omap_cfg_reg(G19_24XX_MMC_CLKO);
397 omap_cfg_reg(F20_24XX_MMC_DAT0);
398 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
399 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800400 if (mmc_controller->slots[0].wires == 4) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800401 omap_cfg_reg(H14_24XX_MMC_DAT1);
402 omap_cfg_reg(E19_24XX_MMC_DAT2);
403 omap_cfg_reg(D19_24XX_MMC_DAT3);
404 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
405 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
406 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
407 }
408
409 /*
410 * Use internal loop-back in MMC/SDIO Module Input Clock
411 * selection
412 */
413 if (mmc_controller->slots[0].internal_clock) {
414 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
415 v |= (1 << 24);
416 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
417 }
418 }
419}
420
421void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
422 int nr_controllers)
423{
424 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800425 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800426
427 for (i = 0; i < nr_controllers; i++) {
428 unsigned long base, size;
429 unsigned int irq = 0;
430
431 if (!mmc_data[i])
432 continue;
433
434 omap2_mmc_mux(mmc_data[i], i);
435
436 switch (i) {
437 case 0:
438 base = OMAP2_MMC1_BASE;
439 irq = INT_24XX_MMC_IRQ;
440 break;
441 case 1:
442 base = OMAP2_MMC2_BASE;
443 irq = INT_24XX_MMC2_IRQ;
444 break;
445 case 2:
446 if (!cpu_is_omap34xx())
447 return;
448 base = OMAP3_MMC3_BASE;
449 irq = INT_34XX_MMC3_IRQ;
450 break;
451 default:
452 continue;
453 }
454
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800455 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800456 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800457 name = "mmci-omap";
458 } else {
Tony Lindgrend8874662008-12-10 17:37:16 -0800459 size = HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800460 name = "mmci-omap-hs";
461 }
462 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800463 };
464}
465
466#endif
467
468/*-------------------------------------------------------------------------*/
469
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300470#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
471#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
472#define OMAP_HDQ_BASE 0x480B2000
473#endif
474static struct resource omap_hdq_resources[] = {
475 {
476 .start = OMAP_HDQ_BASE,
477 .end = OMAP_HDQ_BASE + 0x1C,
478 .flags = IORESOURCE_MEM,
479 },
480 {
481 .start = INT_24XX_HDQ_IRQ,
482 .flags = IORESOURCE_IRQ,
483 },
484};
485static struct platform_device omap_hdq_dev = {
486 .name = "omap_hdq",
487 .id = 0,
488 .dev = {
489 .platform_data = NULL,
490 },
491 .num_resources = ARRAY_SIZE(omap_hdq_resources),
492 .resource = omap_hdq_resources,
493};
494static inline void omap_hdq_init(void)
495{
496 (void) platform_device_register(&omap_hdq_dev);
497}
498#else
499static inline void omap_hdq_init(void) {}
500#endif
501
Tony Lindgren1dbae812005-11-10 14:26:51 +0000502/*-------------------------------------------------------------------------*/
503
504static int __init omap2_init_devices(void)
505{
506 /* please keep these calls, and their implementations above,
507 * in alphabetical order so they're easier to sort through.
508 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800509 omap_hsmmc_reset();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800510 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700511 omap_init_mcspi();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300512 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100513 omap_init_sti();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300514 omap_init_sha1_md5();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000515
516 return 0;
517}
518arch_initcall(omap2_init_devices);