blob: 8ccdfcf2942c4c056dcb8a181d16e4a3cb4489f1 [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>
Tony Lindgren1dbae812005-11-10 14:26:51 +000017
Russell Kinga09e64f2008-08-05 16:14:15 +010018#include <mach/hardware.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000019#include <asm/mach-types.h>
20#include <asm/mach/map.h>
21
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/tc.h>
23#include <mach/board.h>
24#include <mach/mux.h>
25#include <mach/gpio.h>
Tony Lindgren646e3ed2008-10-06 15:49:36 +030026#include <mach/eac.h>
Tony Lindgrend8874662008-12-10 17:37:16 -080027#include <mach/mmc.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000028
Tony Lindgrenc40fae92006-12-07 13:58:10 -080029#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
30#define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
31
32static struct resource mbox_resources[] = {
33 {
34 .start = OMAP2_MBOX_BASE,
35 .end = OMAP2_MBOX_BASE + 0x11f,
36 .flags = IORESOURCE_MEM,
37 },
38 {
39 .start = INT_24XX_MAIL_U0_MPU,
40 .flags = IORESOURCE_IRQ,
41 },
42 {
43 .start = INT_24XX_MAIL_U3_MPU,
44 .flags = IORESOURCE_IRQ,
45 },
46};
47
48static struct platform_device mbox_device = {
49 .name = "mailbox",
50 .id = -1,
51 .num_resources = ARRAY_SIZE(mbox_resources),
52 .resource = mbox_resources,
53};
54
55static inline void omap_init_mbox(void)
56{
57 platform_device_register(&mbox_device);
58}
59#else
60static inline void omap_init_mbox(void) { }
61#endif
62
Tony Lindgren9b6553c2006-04-02 17:46:30 +010063#if defined(CONFIG_OMAP_STI)
64
Tony Lindgren646e3ed2008-10-06 15:49:36 +030065#if defined(CONFIG_ARCH_OMAP2)
66
67#define OMAP2_STI_BASE 0x48068000
Tony Lindgren9b6553c2006-04-02 17:46:30 +010068#define OMAP2_STI_CHANNEL_BASE 0x54000000
69#define OMAP2_STI_IRQ 4
70
71static struct resource sti_resources[] = {
72 {
73 .start = OMAP2_STI_BASE,
74 .end = OMAP2_STI_BASE + 0x7ff,
75 .flags = IORESOURCE_MEM,
76 },
77 {
78 .start = OMAP2_STI_CHANNEL_BASE,
79 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
80 .flags = IORESOURCE_MEM,
81 },
82 {
83 .start = OMAP2_STI_IRQ,
84 .flags = IORESOURCE_IRQ,
85 }
86};
Tony Lindgren646e3ed2008-10-06 15:49:36 +030087#elif defined(CONFIG_ARCH_OMAP3)
88
89#define OMAP3_SDTI_BASE 0x54500000
90#define OMAP3_SDTI_CHANNEL_BASE 0x54600000
91
92static struct resource sti_resources[] = {
93 {
94 .start = OMAP3_SDTI_BASE,
95 .end = OMAP3_SDTI_BASE + 0xFFF,
96 .flags = IORESOURCE_MEM,
97 },
98 {
99 .start = OMAP3_SDTI_CHANNEL_BASE,
100 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
101 .flags = IORESOURCE_MEM,
102 }
103};
104
105#endif
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100106
107static struct platform_device sti_device = {
108 .name = "sti",
109 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100110 .num_resources = ARRAY_SIZE(sti_resources),
111 .resource = sti_resources,
112};
113
114static inline void omap_init_sti(void)
115{
116 platform_device_register(&sti_device);
117}
118#else
119static inline void omap_init_sti(void) {}
120#endif
121
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300122#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700123
Russell Kinga09e64f2008-08-05 16:14:15 +0100124#include <mach/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700125
126#define OMAP2_MCSPI1_BASE 0x48098000
127#define OMAP2_MCSPI2_BASE 0x4809a000
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300128#define OMAP2_MCSPI3_BASE 0x480b8000
129#define OMAP2_MCSPI4_BASE 0x480ba000
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700130
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700131static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700132 .num_cs = 4,
133};
134
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800135static struct resource omap2_mcspi1_resources[] = {
136 {
137 .start = OMAP2_MCSPI1_BASE,
138 .end = OMAP2_MCSPI1_BASE + 0xff,
139 .flags = IORESOURCE_MEM,
140 },
141};
142
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300143static struct platform_device omap2_mcspi1 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700144 .name = "omap2_mcspi",
145 .id = 1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800146 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
147 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700148 .dev = {
149 .platform_data = &omap2_mcspi1_config,
150 },
151};
152
153static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700154 .num_cs = 2,
155};
156
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800157static struct resource omap2_mcspi2_resources[] = {
158 {
159 .start = OMAP2_MCSPI2_BASE,
160 .end = OMAP2_MCSPI2_BASE + 0xff,
161 .flags = IORESOURCE_MEM,
162 },
163};
164
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300165static struct platform_device omap2_mcspi2 = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700166 .name = "omap2_mcspi",
167 .id = 2,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800168 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
169 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700170 .dev = {
171 .platform_data = &omap2_mcspi2_config,
172 },
173};
174
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300175#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
176static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
177 .num_cs = 2,
178};
179
180static struct resource omap2_mcspi3_resources[] = {
181 {
182 .start = OMAP2_MCSPI3_BASE,
183 .end = OMAP2_MCSPI3_BASE + 0xff,
184 .flags = IORESOURCE_MEM,
185 },
186};
187
188static struct platform_device omap2_mcspi3 = {
189 .name = "omap2_mcspi",
190 .id = 3,
191 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
192 .resource = omap2_mcspi3_resources,
193 .dev = {
194 .platform_data = &omap2_mcspi3_config,
195 },
196};
197#endif
198
199#ifdef CONFIG_ARCH_OMAP3
200static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
201 .num_cs = 1,
202};
203
204static struct resource omap2_mcspi4_resources[] = {
205 {
206 .start = OMAP2_MCSPI4_BASE,
207 .end = OMAP2_MCSPI4_BASE + 0xff,
208 .flags = IORESOURCE_MEM,
209 },
210};
211
212static struct platform_device omap2_mcspi4 = {
213 .name = "omap2_mcspi",
214 .id = 4,
215 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
216 .resource = omap2_mcspi4_resources,
217 .dev = {
218 .platform_data = &omap2_mcspi4_config,
219 },
220};
221#endif
222
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700223static void omap_init_mcspi(void)
224{
225 platform_device_register(&omap2_mcspi1);
226 platform_device_register(&omap2_mcspi2);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300227#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
228 platform_device_register(&omap2_mcspi3);
229#endif
230#ifdef CONFIG_ARCH_OMAP3
231 platform_device_register(&omap2_mcspi4);
232#endif
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700233}
234
235#else
236static inline void omap_init_mcspi(void) {}
237#endif
238
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300239#ifdef CONFIG_SND_OMAP24XX_EAC
240
241#define OMAP2_EAC_BASE 0x48090000
242
243static struct resource omap2_eac_resources[] = {
244 {
245 .start = OMAP2_EAC_BASE,
246 .end = OMAP2_EAC_BASE + 0x109,
247 .flags = IORESOURCE_MEM,
248 },
249};
250
251static struct platform_device omap2_eac_device = {
252 .name = "omap24xx-eac",
253 .id = -1,
254 .num_resources = ARRAY_SIZE(omap2_eac_resources),
255 .resource = omap2_eac_resources,
256 .dev = {
257 .platform_data = NULL,
258 },
259};
260
261void omap_init_eac(struct eac_platform_data *pdata)
262{
263 omap2_eac_device.dev.platform_data = pdata;
264 platform_device_register(&omap2_eac_device);
265}
266
267#else
268void omap_init_eac(struct eac_platform_data *pdata) {}
269#endif
270
271#ifdef CONFIG_OMAP_SHA1_MD5
272static struct resource sha1_md5_resources[] = {
273 {
274 .start = OMAP24XX_SEC_SHA1MD5_BASE,
275 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
276 .flags = IORESOURCE_MEM,
277 },
278 {
279 .start = INT_24XX_SHA1MD5,
280 .flags = IORESOURCE_IRQ,
281 }
282};
283
284static struct platform_device sha1_md5_device = {
285 .name = "OMAP SHA1/MD5",
286 .id = -1,
287 .num_resources = ARRAY_SIZE(sha1_md5_resources),
288 .resource = sha1_md5_resources,
289};
290
291static void omap_init_sha1_md5(void)
292{
293 platform_device_register(&sha1_md5_device);
294}
295#else
296static inline void omap_init_sha1_md5(void) { }
297#endif
298
Tony Lindgrend8874662008-12-10 17:37:16 -0800299/*-------------------------------------------------------------------------*/
300
301#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
302 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
303
304static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
305 int controller_nr)
306{
307 if (cpu_is_omap2420() && controller_nr == 0) {
308 omap_cfg_reg(H18_24XX_MMC_CMD);
309 omap_cfg_reg(H15_24XX_MMC_CLKI);
310 omap_cfg_reg(G19_24XX_MMC_CLKO);
311 omap_cfg_reg(F20_24XX_MMC_DAT0);
312 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
313 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
314 if (mmc_controller->slots[0].wire4) {
315 omap_cfg_reg(H14_24XX_MMC_DAT1);
316 omap_cfg_reg(E19_24XX_MMC_DAT2);
317 omap_cfg_reg(D19_24XX_MMC_DAT3);
318 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
319 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
320 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
321 }
322
323 /*
324 * Use internal loop-back in MMC/SDIO Module Input Clock
325 * selection
326 */
327 if (mmc_controller->slots[0].internal_clock) {
328 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
329 v |= (1 << 24);
330 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
331 }
332 }
333}
334
335void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
336 int nr_controllers)
337{
338 int i;
339
340 for (i = 0; i < nr_controllers; i++) {
341 unsigned long base, size;
342 unsigned int irq = 0;
343
344 if (!mmc_data[i])
345 continue;
346
347 omap2_mmc_mux(mmc_data[i], i);
348
349 switch (i) {
350 case 0:
351 base = OMAP2_MMC1_BASE;
352 irq = INT_24XX_MMC_IRQ;
353 break;
354 case 1:
355 base = OMAP2_MMC2_BASE;
356 irq = INT_24XX_MMC2_IRQ;
357 break;
358 case 2:
359 if (!cpu_is_omap34xx())
360 return;
361 base = OMAP3_MMC3_BASE;
362 irq = INT_34XX_MMC3_IRQ;
363 break;
364 default:
365 continue;
366 }
367
368 if (cpu_is_omap2420())
369 size = OMAP2420_MMC_SIZE;
370 else
371 size = HSMMC_SIZE;
372
373 omap_mmc_add(i, base, size, irq, mmc_data[i]);
374 };
375}
376
377#endif
378
379/*-------------------------------------------------------------------------*/
380
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300381#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
382#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
383#define OMAP_HDQ_BASE 0x480B2000
384#endif
385static struct resource omap_hdq_resources[] = {
386 {
387 .start = OMAP_HDQ_BASE,
388 .end = OMAP_HDQ_BASE + 0x1C,
389 .flags = IORESOURCE_MEM,
390 },
391 {
392 .start = INT_24XX_HDQ_IRQ,
393 .flags = IORESOURCE_IRQ,
394 },
395};
396static struct platform_device omap_hdq_dev = {
397 .name = "omap_hdq",
398 .id = 0,
399 .dev = {
400 .platform_data = NULL,
401 },
402 .num_resources = ARRAY_SIZE(omap_hdq_resources),
403 .resource = omap_hdq_resources,
404};
405static inline void omap_hdq_init(void)
406{
407 (void) platform_device_register(&omap_hdq_dev);
408}
409#else
410static inline void omap_hdq_init(void) {}
411#endif
412
Tony Lindgren1dbae812005-11-10 14:26:51 +0000413/*-------------------------------------------------------------------------*/
414
415static int __init omap2_init_devices(void)
416{
417 /* please keep these calls, and their implementations above,
418 * in alphabetical order so they're easier to sort through.
419 */
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800420 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700421 omap_init_mcspi();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300422 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100423 omap_init_sti();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300424 omap_init_sha1_md5();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000425
426 return 0;
427}
428arch_initcall(omap2_init_devices);