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_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
33 static struct resource cam_resources[] = {
35 .start = OMAP24XX_CAMERA_BASE,
36 .end = OMAP24XX_CAMERA_BASE + 0xfff,
37 .flags = IORESOURCE_MEM,
40 .start = INT_24XX_CAM_IRQ,
41 .flags = IORESOURCE_IRQ,
45 static struct platform_device omap_cam_device = {
46 .name = "omap24xxcam",
48 .num_resources = ARRAY_SIZE(cam_resources),
49 .resource = cam_resources,
52 static inline void omap_init_camera(void)
54 platform_device_register(&omap_cam_device);
57 #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
59 static struct resource cam_resources[] = {
61 .start = OMAP34XX_CAMERA_BASE,
62 .end = OMAP34XX_CAMERA_BASE + 0x1B70,
63 .flags = IORESOURCE_MEM,
66 .start = INT_34XX_CAM_IRQ,
67 .flags = IORESOURCE_IRQ,
71 static struct platform_device omap_cam_device = {
72 .name = "omap34xxcam",
74 .num_resources = ARRAY_SIZE(cam_resources),
75 .resource = cam_resources,
78 static inline void omap_init_camera(void)
80 platform_device_register(&omap_cam_device);
83 static inline void omap_init_camera(void)
88 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
89 #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
91 static struct resource mbox_resources[] = {
93 .start = OMAP2_MBOX_BASE,
94 .end = OMAP2_MBOX_BASE + 0x11f,
95 .flags = IORESOURCE_MEM,
98 .start = INT_24XX_MAIL_U0_MPU,
99 .flags = IORESOURCE_IRQ,
102 .start = INT_24XX_MAIL_U3_MPU,
103 .flags = IORESOURCE_IRQ,
107 static struct platform_device mbox_device = {
110 .num_resources = ARRAY_SIZE(mbox_resources),
111 .resource = mbox_resources,
114 static inline void omap_init_mbox(void)
116 platform_device_register(&mbox_device);
119 static inline void omap_init_mbox(void) { }
122 #if defined(CONFIG_OMAP_STI)
124 #if defined(CONFIG_ARCH_OMAP2)
126 #define OMAP2_STI_BASE 0x48068000
127 #define OMAP2_STI_CHANNEL_BASE 0x54000000
128 #define OMAP2_STI_IRQ 4
130 static struct resource sti_resources[] = {
132 .start = OMAP2_STI_BASE,
133 .end = OMAP2_STI_BASE + 0x7ff,
134 .flags = IORESOURCE_MEM,
137 .start = OMAP2_STI_CHANNEL_BASE,
138 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
139 .flags = IORESOURCE_MEM,
142 .start = OMAP2_STI_IRQ,
143 .flags = IORESOURCE_IRQ,
146 #elif defined(CONFIG_ARCH_OMAP3)
148 #define OMAP3_SDTI_BASE 0x54500000
149 #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
151 static struct resource sti_resources[] = {
153 .start = OMAP3_SDTI_BASE,
154 .end = OMAP3_SDTI_BASE + 0xFFF,
155 .flags = IORESOURCE_MEM,
158 .start = OMAP3_SDTI_CHANNEL_BASE,
159 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
160 .flags = IORESOURCE_MEM,
166 static struct platform_device sti_device = {
169 .num_resources = ARRAY_SIZE(sti_resources),
170 .resource = sti_resources,
173 static inline void omap_init_sti(void)
175 platform_device_register(&sti_device);
178 static inline void omap_init_sti(void) {}
181 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
183 #include <mach/mcspi.h>
185 #define OMAP2_MCSPI1_BASE 0x48098000
186 #define OMAP2_MCSPI2_BASE 0x4809a000
187 #define OMAP2_MCSPI3_BASE 0x480b8000
188 #define OMAP2_MCSPI4_BASE 0x480ba000
190 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
194 static struct resource omap2_mcspi1_resources[] = {
196 .start = OMAP2_MCSPI1_BASE,
197 .end = OMAP2_MCSPI1_BASE + 0xff,
198 .flags = IORESOURCE_MEM,
202 static struct platform_device omap2_mcspi1 = {
203 .name = "omap2_mcspi",
205 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
206 .resource = omap2_mcspi1_resources,
208 .platform_data = &omap2_mcspi1_config,
212 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
216 static struct resource omap2_mcspi2_resources[] = {
218 .start = OMAP2_MCSPI2_BASE,
219 .end = OMAP2_MCSPI2_BASE + 0xff,
220 .flags = IORESOURCE_MEM,
224 static struct platform_device omap2_mcspi2 = {
225 .name = "omap2_mcspi",
227 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
228 .resource = omap2_mcspi2_resources,
230 .platform_data = &omap2_mcspi2_config,
234 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
235 static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
239 static struct resource omap2_mcspi3_resources[] = {
241 .start = OMAP2_MCSPI3_BASE,
242 .end = OMAP2_MCSPI3_BASE + 0xff,
243 .flags = IORESOURCE_MEM,
247 static struct platform_device omap2_mcspi3 = {
248 .name = "omap2_mcspi",
250 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
251 .resource = omap2_mcspi3_resources,
253 .platform_data = &omap2_mcspi3_config,
258 #ifdef CONFIG_ARCH_OMAP3
259 static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
263 static struct resource omap2_mcspi4_resources[] = {
265 .start = OMAP2_MCSPI4_BASE,
266 .end = OMAP2_MCSPI4_BASE + 0xff,
267 .flags = IORESOURCE_MEM,
271 static struct platform_device omap2_mcspi4 = {
272 .name = "omap2_mcspi",
274 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
275 .resource = omap2_mcspi4_resources,
277 .platform_data = &omap2_mcspi4_config,
282 static void omap_init_mcspi(void)
284 platform_device_register(&omap2_mcspi1);
285 platform_device_register(&omap2_mcspi2);
286 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
287 if (cpu_is_omap2430() || cpu_is_omap343x())
288 platform_device_register(&omap2_mcspi3);
290 #ifdef CONFIG_ARCH_OMAP3
291 if (cpu_is_omap343x())
292 platform_device_register(&omap2_mcspi4);
297 static inline void omap_init_mcspi(void) {}
300 #ifdef CONFIG_SND_OMAP24XX_EAC
302 #define OMAP2_EAC_BASE (L4_24XX_BASE + 0x90000)
304 static struct resource omap2_eac_resources[] = {
306 .start = OMAP2_EAC_BASE,
307 .end = OMAP2_EAC_BASE + 0xfff,
308 .flags = IORESOURCE_MEM,
312 static struct platform_device omap2_eac_device = {
313 .name = "omap24xx-eac",
315 .num_resources = ARRAY_SIZE(omap2_eac_resources),
316 .resource = omap2_eac_resources,
318 .platform_data = NULL,
322 void omap_init_eac(struct eac_platform_data *pdata)
324 omap2_eac_device.dev.platform_data = pdata;
325 platform_device_register(&omap2_eac_device);
329 void omap_init_eac(struct eac_platform_data *pdata) {}
332 #ifdef CONFIG_OMAP_SHA1_MD5
333 static struct resource sha1_md5_resources[] = {
335 .start = OMAP24XX_SEC_SHA1MD5_BASE,
336 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
337 .flags = IORESOURCE_MEM,
340 .start = INT_24XX_SHA1MD5,
341 .flags = IORESOURCE_IRQ,
345 static struct platform_device sha1_md5_device = {
346 .name = "OMAP SHA1/MD5",
348 .num_resources = ARRAY_SIZE(sha1_md5_resources),
349 .resource = sha1_md5_resources,
352 static void omap_init_sha1_md5(void)
354 platform_device_register(&sha1_md5_device);
357 static inline void omap_init_sha1_md5(void) { }
360 /*-------------------------------------------------------------------------*/
362 #ifdef CONFIG_ARCH_OMAP3
364 #define MMCHS_SYSCONFIG 0x0010
365 #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
366 #define MMCHS_SYSSTATUS 0x0014
367 #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
369 static struct platform_device dummy_pdev = {
371 .bus = &platform_bus_type,
376 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
378 * Ensure that each MMC controller is fully reset. Controllers
379 * left in an unknown state (by bootloader) may prevent retention
380 * or OFF-mode. This is especially important in cases where the
381 * MMC driver is not enabled, _or_ built as a module.
383 * In order for reset to work, interface, functional and debounce
384 * clocks must be enabled. The debounce clock comes from func_32k_clk
385 * and is not under SW control, so we only enable i- and f-clocks.
387 static void __init omap_hsmmc_reset(void)
389 u32 i, nr_controllers = cpu_is_omap34xx() ? OMAP34XX_NR_MMC :
392 for (i = 0; i < nr_controllers; i++) {
394 struct clk *iclk, *fclk;
395 struct device *dev = &dummy_pdev.dev;
399 base = OMAP2_MMC1_BASE;
402 base = OMAP2_MMC2_BASE;
405 base = OMAP3_MMC3_BASE;
410 iclk = clk_get(dev, "mmchs_ick");
411 if (iclk && clk_enable(iclk))
414 fclk = clk_get(dev, "mmchs_fck");
415 if (fclk && clk_enable(fclk))
418 if (!iclk || !fclk) {
420 "%s: Unable to enable clocks for MMC%d, "
421 "cannot reset.\n", __func__, i);
425 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
426 v = omap_readl(base + MMCHS_SYSSTATUS);
427 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
428 MMCHS_SYSSTATUS_RESETDONE))
442 static inline void omap_hsmmc_reset(void) {}
445 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
446 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
448 static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
451 if (cpu_is_omap2420() && controller_nr == 0) {
452 omap_cfg_reg(H18_24XX_MMC_CMD);
453 omap_cfg_reg(H15_24XX_MMC_CLKI);
454 omap_cfg_reg(G19_24XX_MMC_CLKO);
455 omap_cfg_reg(F20_24XX_MMC_DAT0);
456 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
457 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
458 if (mmc_controller->slots[0].wires == 4) {
459 omap_cfg_reg(H14_24XX_MMC_DAT1);
460 omap_cfg_reg(E19_24XX_MMC_DAT2);
461 omap_cfg_reg(D19_24XX_MMC_DAT3);
462 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
463 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
464 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
468 * Use internal loop-back in MMC/SDIO Module Input Clock
471 if (mmc_controller->slots[0].internal_clock) {
472 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
474 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
479 void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
484 for (i = 0; i < nr_controllers; i++) {
485 unsigned long base, size;
486 unsigned int irq = 0;
491 omap2_mmc_mux(mmc_data[i], i);
495 base = OMAP2_MMC1_BASE;
496 irq = INT_24XX_MMC_IRQ;
499 base = OMAP2_MMC2_BASE;
500 irq = INT_24XX_MMC2_IRQ;
503 if (!cpu_is_omap34xx())
505 base = OMAP3_MMC3_BASE;
506 irq = INT_34XX_MMC3_IRQ;
512 if (cpu_is_omap2420())
513 size = OMAP2420_MMC_SIZE;
517 omap_mmc_add(i, base, size, irq, mmc_data[i]);
523 /*-------------------------------------------------------------------------*/
525 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
526 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
527 #define OMAP_HDQ_BASE 0x480B2000
529 static struct resource omap_hdq_resources[] = {
531 .start = OMAP_HDQ_BASE,
532 .end = OMAP_HDQ_BASE + 0x1C,
533 .flags = IORESOURCE_MEM,
536 .start = INT_24XX_HDQ_IRQ,
537 .flags = IORESOURCE_IRQ,
540 static struct platform_device omap_hdq_dev = {
544 .platform_data = NULL,
546 .num_resources = ARRAY_SIZE(omap_hdq_resources),
547 .resource = omap_hdq_resources,
549 static inline void omap_hdq_init(void)
551 (void) platform_device_register(&omap_hdq_dev);
554 static inline void omap_hdq_init(void) {}
557 /*-------------------------------------------------------------------------*/
559 static int __init omap2_init_devices(void)
561 /* please keep these calls, and their implementations above,
562 * in alphabetical order so they're easier to sort through.
570 omap_init_sha1_md5();
574 arch_initcall(omap2_init_devices);