2 * linux/arch/arm/mach-omap2/devices.c
4 * OMAP2 platform device setup/initialization
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.
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
17 #include <linux/clk.h>
19 #include <mach/hardware.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/map.h>
23 #include <mach/control.h>
25 #include <mach/board.h>
27 #include <mach/gpio.h>
31 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
32 #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
34 static struct resource mbox_resources
[] = {
36 .start
= OMAP2_MBOX_BASE
,
37 .end
= OMAP2_MBOX_BASE
+ 0x11f,
38 .flags
= IORESOURCE_MEM
,
41 .start
= INT_24XX_MAIL_U0_MPU
,
42 .flags
= IORESOURCE_IRQ
,
45 .start
= INT_24XX_MAIL_U3_MPU
,
46 .flags
= IORESOURCE_IRQ
,
50 static struct platform_device mbox_device
= {
53 .num_resources
= ARRAY_SIZE(mbox_resources
),
54 .resource
= mbox_resources
,
57 static inline void omap_init_mbox(void)
59 platform_device_register(&mbox_device
);
62 static inline void omap_init_mbox(void) { }
65 #if defined(CONFIG_OMAP_STI)
67 #if defined(CONFIG_ARCH_OMAP2)
69 #define OMAP2_STI_BASE 0x48068000
70 #define OMAP2_STI_CHANNEL_BASE 0x54000000
71 #define OMAP2_STI_IRQ 4
73 static struct resource sti_resources
[] = {
75 .start
= OMAP2_STI_BASE
,
76 .end
= OMAP2_STI_BASE
+ 0x7ff,
77 .flags
= IORESOURCE_MEM
,
80 .start
= OMAP2_STI_CHANNEL_BASE
,
81 .end
= OMAP2_STI_CHANNEL_BASE
+ SZ_64K
- 1,
82 .flags
= IORESOURCE_MEM
,
85 .start
= OMAP2_STI_IRQ
,
86 .flags
= IORESOURCE_IRQ
,
89 #elif defined(CONFIG_ARCH_OMAP3)
91 #define OMAP3_SDTI_BASE 0x54500000
92 #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
94 static struct resource sti_resources
[] = {
96 .start
= OMAP3_SDTI_BASE
,
97 .end
= OMAP3_SDTI_BASE
+ 0xFFF,
98 .flags
= IORESOURCE_MEM
,
101 .start
= OMAP3_SDTI_CHANNEL_BASE
,
102 .end
= OMAP3_SDTI_CHANNEL_BASE
+ SZ_1M
- 1,
103 .flags
= IORESOURCE_MEM
,
109 static struct platform_device sti_device
= {
112 .num_resources
= ARRAY_SIZE(sti_resources
),
113 .resource
= sti_resources
,
116 static inline void omap_init_sti(void)
118 platform_device_register(&sti_device
);
121 static inline void omap_init_sti(void) {}
124 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
126 #include <mach/mcspi.h>
128 #define OMAP2_MCSPI1_BASE 0x48098000
129 #define OMAP2_MCSPI2_BASE 0x4809a000
130 #define OMAP2_MCSPI3_BASE 0x480b8000
131 #define OMAP2_MCSPI4_BASE 0x480ba000
133 static struct omap2_mcspi_platform_config omap2_mcspi1_config
= {
137 static struct resource omap2_mcspi1_resources
[] = {
139 .start
= OMAP2_MCSPI1_BASE
,
140 .end
= OMAP2_MCSPI1_BASE
+ 0xff,
141 .flags
= IORESOURCE_MEM
,
145 static struct platform_device omap2_mcspi1
= {
146 .name
= "omap2_mcspi",
148 .num_resources
= ARRAY_SIZE(omap2_mcspi1_resources
),
149 .resource
= omap2_mcspi1_resources
,
151 .platform_data
= &omap2_mcspi1_config
,
155 static struct omap2_mcspi_platform_config omap2_mcspi2_config
= {
159 static struct resource omap2_mcspi2_resources
[] = {
161 .start
= OMAP2_MCSPI2_BASE
,
162 .end
= OMAP2_MCSPI2_BASE
+ 0xff,
163 .flags
= IORESOURCE_MEM
,
167 static struct platform_device omap2_mcspi2
= {
168 .name
= "omap2_mcspi",
170 .num_resources
= ARRAY_SIZE(omap2_mcspi2_resources
),
171 .resource
= omap2_mcspi2_resources
,
173 .platform_data
= &omap2_mcspi2_config
,
177 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
178 static struct omap2_mcspi_platform_config omap2_mcspi3_config
= {
182 static struct resource omap2_mcspi3_resources
[] = {
184 .start
= OMAP2_MCSPI3_BASE
,
185 .end
= OMAP2_MCSPI3_BASE
+ 0xff,
186 .flags
= IORESOURCE_MEM
,
190 static struct platform_device omap2_mcspi3
= {
191 .name
= "omap2_mcspi",
193 .num_resources
= ARRAY_SIZE(omap2_mcspi3_resources
),
194 .resource
= omap2_mcspi3_resources
,
196 .platform_data
= &omap2_mcspi3_config
,
201 #ifdef CONFIG_ARCH_OMAP3
202 static struct omap2_mcspi_platform_config omap2_mcspi4_config
= {
206 static struct resource omap2_mcspi4_resources
[] = {
208 .start
= OMAP2_MCSPI4_BASE
,
209 .end
= OMAP2_MCSPI4_BASE
+ 0xff,
210 .flags
= IORESOURCE_MEM
,
214 static struct platform_device omap2_mcspi4
= {
215 .name
= "omap2_mcspi",
217 .num_resources
= ARRAY_SIZE(omap2_mcspi4_resources
),
218 .resource
= omap2_mcspi4_resources
,
220 .platform_data
= &omap2_mcspi4_config
,
225 static void omap_init_mcspi(void)
227 platform_device_register(&omap2_mcspi1
);
228 platform_device_register(&omap2_mcspi2
);
229 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
230 platform_device_register(&omap2_mcspi3
);
232 #ifdef CONFIG_ARCH_OMAP3
233 platform_device_register(&omap2_mcspi4
);
238 static inline void omap_init_mcspi(void) {}
241 #ifdef CONFIG_SND_OMAP24XX_EAC
243 #define OMAP2_EAC_BASE 0x48090000
245 static struct resource omap2_eac_resources
[] = {
247 .start
= OMAP2_EAC_BASE
,
248 .end
= OMAP2_EAC_BASE
+ 0x109,
249 .flags
= IORESOURCE_MEM
,
253 static struct platform_device omap2_eac_device
= {
254 .name
= "omap24xx-eac",
256 .num_resources
= ARRAY_SIZE(omap2_eac_resources
),
257 .resource
= omap2_eac_resources
,
259 .platform_data
= NULL
,
263 void omap_init_eac(struct eac_platform_data
*pdata
)
265 omap2_eac_device
.dev
.platform_data
= pdata
;
266 platform_device_register(&omap2_eac_device
);
270 void omap_init_eac(struct eac_platform_data
*pdata
) {}
273 #ifdef CONFIG_OMAP_SHA1_MD5
274 static struct resource sha1_md5_resources
[] = {
276 .start
= OMAP24XX_SEC_SHA1MD5_BASE
,
277 .end
= OMAP24XX_SEC_SHA1MD5_BASE
+ 0x64,
278 .flags
= IORESOURCE_MEM
,
281 .start
= INT_24XX_SHA1MD5
,
282 .flags
= IORESOURCE_IRQ
,
286 static struct platform_device sha1_md5_device
= {
287 .name
= "OMAP SHA1/MD5",
289 .num_resources
= ARRAY_SIZE(sha1_md5_resources
),
290 .resource
= sha1_md5_resources
,
293 static void omap_init_sha1_md5(void)
295 platform_device_register(&sha1_md5_device
);
298 static inline void omap_init_sha1_md5(void) { }
301 /*-------------------------------------------------------------------------*/
303 #ifdef CONFIG_ARCH_OMAP3
305 #define MMCHS_SYSCONFIG 0x0010
306 #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
307 #define MMCHS_SYSSTATUS 0x0014
308 #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
310 static struct platform_device dummy_pdev
= {
312 .bus
= &platform_bus_type
,
317 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
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.
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.
328 static void __init
omap_hsmmc_reset(void)
330 u32 i
, nr_controllers
= cpu_is_omap34xx() ? OMAP34XX_NR_MMC
:
333 for (i
= 0; i
< nr_controllers
; i
++) {
335 struct clk
*iclk
, *fclk
;
336 struct device
*dev
= &dummy_pdev
.dev
;
340 base
= OMAP2_MMC1_BASE
;
343 base
= OMAP2_MMC2_BASE
;
346 base
= OMAP3_MMC3_BASE
;
351 iclk
= clk_get(dev
, "mmchs_ick");
352 if (iclk
&& clk_enable(iclk
))
355 fclk
= clk_get(dev
, "mmchs_fck");
356 if (fclk
&& clk_enable(fclk
))
359 if (!iclk
|| !fclk
) {
361 "%s: Unable to enable clocks for MMC%d, "
362 "cannot reset.\n", __func__
, i
);
366 omap_writel(MMCHS_SYSCONFIG_SWRESET
, base
+ MMCHS_SYSCONFIG
);
367 v
= omap_readl(base
+ MMCHS_SYSSTATUS
);
368 while (!(omap_readl(base
+ MMCHS_SYSSTATUS
) &
369 MMCHS_SYSSTATUS_RESETDONE
))
383 static inline void omap_hsmmc_reset(void) {}
386 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
387 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
389 static inline void omap2_mmc_mux(struct omap_mmc_platform_data
*mmc_controller
,
392 if (cpu_is_omap2420() && controller_nr
== 0) {
393 omap_cfg_reg(H18_24XX_MMC_CMD
);
394 omap_cfg_reg(H15_24XX_MMC_CLKI
);
395 omap_cfg_reg(G19_24XX_MMC_CLKO
);
396 omap_cfg_reg(F20_24XX_MMC_DAT0
);
397 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0
);
398 omap_cfg_reg(G18_24XX_MMC_CMD_DIR
);
399 if (mmc_controller
->slots
[0].wires
== 4) {
400 omap_cfg_reg(H14_24XX_MMC_DAT1
);
401 omap_cfg_reg(E19_24XX_MMC_DAT2
);
402 omap_cfg_reg(D19_24XX_MMC_DAT3
);
403 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1
);
404 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2
);
405 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3
);
409 * Use internal loop-back in MMC/SDIO Module Input Clock
412 if (mmc_controller
->slots
[0].internal_clock
) {
413 u32 v
= omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0
);
415 omap_ctrl_writel(v
, OMAP2_CONTROL_DEVCONF0
);
420 void __init
omap2_init_mmc(struct omap_mmc_platform_data
**mmc_data
,
425 for (i
= 0; i
< nr_controllers
; i
++) {
426 unsigned long base
, size
;
427 unsigned int irq
= 0;
432 omap2_mmc_mux(mmc_data
[i
], i
);
436 base
= OMAP2_MMC1_BASE
;
437 irq
= INT_24XX_MMC_IRQ
;
440 base
= OMAP2_MMC2_BASE
;
441 irq
= INT_24XX_MMC2_IRQ
;
444 if (!cpu_is_omap34xx())
446 base
= OMAP3_MMC3_BASE
;
447 irq
= INT_34XX_MMC3_IRQ
;
453 if (cpu_is_omap2420())
454 size
= OMAP2420_MMC_SIZE
;
458 omap_mmc_add(i
, base
, size
, irq
, mmc_data
[i
]);
464 /*-------------------------------------------------------------------------*/
466 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
467 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
468 #define OMAP_HDQ_BASE 0x480B2000
470 static struct resource omap_hdq_resources
[] = {
472 .start
= OMAP_HDQ_BASE
,
473 .end
= OMAP_HDQ_BASE
+ 0x1C,
474 .flags
= IORESOURCE_MEM
,
477 .start
= INT_24XX_HDQ_IRQ
,
478 .flags
= IORESOURCE_IRQ
,
481 static struct platform_device omap_hdq_dev
= {
485 .platform_data
= NULL
,
487 .num_resources
= ARRAY_SIZE(omap_hdq_resources
),
488 .resource
= omap_hdq_resources
,
490 static inline void omap_hdq_init(void)
492 (void) platform_device_register(&omap_hdq_dev
);
495 static inline void omap_hdq_init(void) {}
498 /*-------------------------------------------------------------------------*/
500 static int __init
omap2_init_devices(void)
502 /* please keep these calls, and their implementations above,
503 * in alphabetical order so they're easier to sort through.
510 omap_init_sha1_md5();
514 arch_initcall(omap2_init_devices
);