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>
18 #include <mach/hardware.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/map.h>
22 #include <mach/control.h>
24 #include <mach/board.h>
26 #include <mach/gpio.h>
30 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
32 static struct resource cam_resources[] = {
34 .start = OMAP24XX_CAMERA_BASE,
35 .end = OMAP24XX_CAMERA_BASE + 0xfff,
36 .flags = IORESOURCE_MEM,
39 .start = INT_24XX_CAM_IRQ,
40 .flags = IORESOURCE_IRQ,
44 static struct platform_device omap_cam_device = {
45 .name = "omap24xxcam",
47 .num_resources = ARRAY_SIZE(cam_resources),
48 .resource = cam_resources,
51 static inline void omap_init_camera(void)
53 platform_device_register(&omap_cam_device);
56 #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
58 static struct resource cam_resources[] = {
60 .start = OMAP34XX_CAMERA_BASE,
61 .end = OMAP34XX_CAMERA_BASE + 0x1B70,
62 .flags = IORESOURCE_MEM,
65 .start = INT_34XX_CAM_IRQ,
66 .flags = IORESOURCE_IRQ,
70 static struct platform_device omap_cam_device = {
71 .name = "omap34xxcam",
73 .num_resources = ARRAY_SIZE(cam_resources),
74 .resource = cam_resources,
77 static inline void omap_init_camera(void)
79 platform_device_register(&omap_cam_device);
82 static inline void omap_init_camera(void)
87 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
88 #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
90 static struct resource mbox_resources[] = {
92 .start = OMAP2_MBOX_BASE,
93 .end = OMAP2_MBOX_BASE + 0x11f,
94 .flags = IORESOURCE_MEM,
97 .start = INT_24XX_MAIL_U0_MPU,
98 .flags = IORESOURCE_IRQ,
101 .start = INT_24XX_MAIL_U3_MPU,
102 .flags = IORESOURCE_IRQ,
106 static struct platform_device mbox_device = {
109 .num_resources = ARRAY_SIZE(mbox_resources),
110 .resource = mbox_resources,
113 static inline void omap_init_mbox(void)
115 platform_device_register(&mbox_device);
118 static inline void omap_init_mbox(void) { }
121 #if defined(CONFIG_OMAP_STI)
123 #if defined(CONFIG_ARCH_OMAP2)
125 #define OMAP2_STI_BASE 0x48068000
126 #define OMAP2_STI_CHANNEL_BASE 0x54000000
127 #define OMAP2_STI_IRQ 4
129 static struct resource sti_resources[] = {
131 .start = OMAP2_STI_BASE,
132 .end = OMAP2_STI_BASE + 0x7ff,
133 .flags = IORESOURCE_MEM,
136 .start = OMAP2_STI_CHANNEL_BASE,
137 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
138 .flags = IORESOURCE_MEM,
141 .start = OMAP2_STI_IRQ,
142 .flags = IORESOURCE_IRQ,
145 #elif defined(CONFIG_ARCH_OMAP3)
147 #define OMAP3_SDTI_BASE 0x54500000
148 #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
150 static struct resource sti_resources[] = {
152 .start = OMAP3_SDTI_BASE,
153 .end = OMAP3_SDTI_BASE + 0xFFF,
154 .flags = IORESOURCE_MEM,
157 .start = OMAP3_SDTI_CHANNEL_BASE,
158 .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
159 .flags = IORESOURCE_MEM,
165 static struct platform_device sti_device = {
168 .num_resources = ARRAY_SIZE(sti_resources),
169 .resource = sti_resources,
172 static inline void omap_init_sti(void)
174 platform_device_register(&sti_device);
177 static inline void omap_init_sti(void) {}
180 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
182 #include <mach/mcspi.h>
184 #define OMAP2_MCSPI1_BASE 0x48098000
185 #define OMAP2_MCSPI2_BASE 0x4809a000
186 #define OMAP2_MCSPI3_BASE 0x480b8000
187 #define OMAP2_MCSPI4_BASE 0x480ba000
189 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
193 static struct resource omap2_mcspi1_resources[] = {
195 .start = OMAP2_MCSPI1_BASE,
196 .end = OMAP2_MCSPI1_BASE + 0xff,
197 .flags = IORESOURCE_MEM,
201 static struct platform_device omap2_mcspi1 = {
202 .name = "omap2_mcspi",
204 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
205 .resource = omap2_mcspi1_resources,
207 .platform_data = &omap2_mcspi1_config,
211 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
215 static struct resource omap2_mcspi2_resources[] = {
217 .start = OMAP2_MCSPI2_BASE,
218 .end = OMAP2_MCSPI2_BASE + 0xff,
219 .flags = IORESOURCE_MEM,
223 static struct platform_device omap2_mcspi2 = {
224 .name = "omap2_mcspi",
226 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
227 .resource = omap2_mcspi2_resources,
229 .platform_data = &omap2_mcspi2_config,
233 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
234 static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
238 static struct resource omap2_mcspi3_resources[] = {
240 .start = OMAP2_MCSPI3_BASE,
241 .end = OMAP2_MCSPI3_BASE + 0xff,
242 .flags = IORESOURCE_MEM,
246 static struct platform_device omap2_mcspi3 = {
247 .name = "omap2_mcspi",
249 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
250 .resource = omap2_mcspi3_resources,
252 .platform_data = &omap2_mcspi3_config,
257 #ifdef CONFIG_ARCH_OMAP3
258 static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
262 static struct resource omap2_mcspi4_resources[] = {
264 .start = OMAP2_MCSPI4_BASE,
265 .end = OMAP2_MCSPI4_BASE + 0xff,
266 .flags = IORESOURCE_MEM,
270 static struct platform_device omap2_mcspi4 = {
271 .name = "omap2_mcspi",
273 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
274 .resource = omap2_mcspi4_resources,
276 .platform_data = &omap2_mcspi4_config,
281 static void omap_init_mcspi(void)
283 platform_device_register(&omap2_mcspi1);
284 platform_device_register(&omap2_mcspi2);
285 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
286 if (cpu_is_omap2430() || cpu_is_omap343x())
287 platform_device_register(&omap2_mcspi3);
289 #ifdef CONFIG_ARCH_OMAP3
290 if (cpu_is_omap343x())
291 platform_device_register(&omap2_mcspi4);
296 static inline void omap_init_mcspi(void) {}
299 #ifdef CONFIG_SND_OMAP24XX_EAC
301 #define OMAP2_EAC_BASE (L4_24XX_BASE + 0x90000)
303 static struct resource omap2_eac_resources[] = {
305 .start = OMAP2_EAC_BASE,
306 .end = OMAP2_EAC_BASE + 0xfff,
307 .flags = IORESOURCE_MEM,
311 static struct platform_device omap2_eac_device = {
312 .name = "omap24xx-eac",
314 .num_resources = ARRAY_SIZE(omap2_eac_resources),
315 .resource = omap2_eac_resources,
317 .platform_data = NULL,
321 void omap_init_eac(struct eac_platform_data *pdata)
323 omap2_eac_device.dev.platform_data = pdata;
324 platform_device_register(&omap2_eac_device);
328 void omap_init_eac(struct eac_platform_data *pdata) {}
331 #ifdef CONFIG_OMAP_SHA1_MD5
332 static struct resource sha1_md5_resources[] = {
334 .start = OMAP24XX_SEC_SHA1MD5_BASE,
335 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
336 .flags = IORESOURCE_MEM,
339 .start = INT_24XX_SHA1MD5,
340 .flags = IORESOURCE_IRQ,
344 static struct platform_device sha1_md5_device = {
345 .name = "OMAP SHA1/MD5",
347 .num_resources = ARRAY_SIZE(sha1_md5_resources),
348 .resource = sha1_md5_resources,
351 static void omap_init_sha1_md5(void)
353 platform_device_register(&sha1_md5_device);
356 static inline void omap_init_sha1_md5(void) { }
359 /*-------------------------------------------------------------------------*/
361 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
362 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
364 static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
367 if (cpu_is_omap2420() && controller_nr == 0) {
368 omap_cfg_reg(H18_24XX_MMC_CMD);
369 omap_cfg_reg(H15_24XX_MMC_CLKI);
370 omap_cfg_reg(G19_24XX_MMC_CLKO);
371 omap_cfg_reg(F20_24XX_MMC_DAT0);
372 omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
373 omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
374 if (mmc_controller->slots[0].wire4) {
375 omap_cfg_reg(H14_24XX_MMC_DAT1);
376 omap_cfg_reg(E19_24XX_MMC_DAT2);
377 omap_cfg_reg(D19_24XX_MMC_DAT3);
378 omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
379 omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
380 omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
384 * Use internal loop-back in MMC/SDIO Module Input Clock
387 if (mmc_controller->slots[0].internal_clock) {
388 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
390 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
395 void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
400 for (i = 0; i < nr_controllers; i++) {
401 unsigned long base, size;
402 unsigned int irq = 0;
407 omap2_mmc_mux(mmc_data[i], i);
411 base = OMAP2_MMC1_BASE;
412 irq = INT_24XX_MMC_IRQ;
415 base = OMAP2_MMC2_BASE;
416 irq = INT_24XX_MMC2_IRQ;
419 if (!cpu_is_omap34xx())
421 base = OMAP3_MMC3_BASE;
422 irq = INT_34XX_MMC3_IRQ;
428 if (cpu_is_omap2420())
429 size = OMAP2420_MMC_SIZE;
433 omap_mmc_add(i, base, size, irq, mmc_data[i]);
439 /*-------------------------------------------------------------------------*/
441 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
442 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
443 #define OMAP_HDQ_BASE 0x480B2000
445 static struct resource omap_hdq_resources[] = {
447 .start = OMAP_HDQ_BASE,
448 .end = OMAP_HDQ_BASE + 0x1C,
449 .flags = IORESOURCE_MEM,
452 .start = INT_24XX_HDQ_IRQ,
453 .flags = IORESOURCE_IRQ,
456 static struct platform_device omap_hdq_dev = {
460 .platform_data = NULL,
462 .num_resources = ARRAY_SIZE(omap_hdq_resources),
463 .resource = omap_hdq_resources,
465 static inline void omap_hdq_init(void)
467 (void) platform_device_register(&omap_hdq_dev);
470 static inline void omap_hdq_init(void) {}
473 /*-------------------------------------------------------------------------*/
475 static int __init omap2_init_devices(void)
477 /* please keep these calls, and their implementations above,
478 * in alphabetical order so they're easier to sort through.
485 omap_init_sha1_md5();
489 arch_initcall(omap2_init_devices);