blob: 7a7f02559075fc9ce8538c5f64d26c538ef03bc3 [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>
16
Russell Kinga09e64f2008-08-05 16:14:15 +010017#include <mach/hardware.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000018#include <asm/io.h>
19#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 Lindgren1dbae812005-11-10 14:26:51 +000026
Tony Lindgrend82973d2007-01-26 12:01:17 -080027#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
Tony Lindgren1dbae812005-11-10 14:26:51 +000028
29#define OMAP2_I2C_BASE2 0x48072000
30#define OMAP2_I2C_INT2 57
31
32static struct resource i2c_resources2[] = {
33 {
34 .start = OMAP2_I2C_BASE2,
35 .end = OMAP2_I2C_BASE2 + 0x3f,
36 .flags = IORESOURCE_MEM,
37 },
38 {
39 .start = OMAP2_I2C_INT2,
40 .flags = IORESOURCE_IRQ,
41 },
42};
43
44static struct platform_device omap_i2c_device2 = {
Tony Lindgrend82973d2007-01-26 12:01:17 -080045 .name = "i2c_omap",
46 .id = 2,
Tony Lindgren1dbae812005-11-10 14:26:51 +000047 .num_resources = ARRAY_SIZE(i2c_resources2),
48 .resource = i2c_resources2,
49};
50
51/* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
52static void omap_init_i2c(void)
53{
54 /* REVISIT: Second I2C not in use on H4? */
55 if (machine_is_omap_h4())
56 return;
57
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080058 if (!cpu_is_omap2430()) {
59 omap_cfg_reg(J15_24XX_I2C2_SCL);
60 omap_cfg_reg(H19_24XX_I2C2_SDA);
61 }
Tony Lindgren1dbae812005-11-10 14:26:51 +000062 (void) platform_device_register(&omap_i2c_device2);
63}
64
65#else
66
67static void omap_init_i2c(void) {}
68
69#endif
70
Tony Lindgrenc40fae92006-12-07 13:58:10 -080071#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
72#define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
73
74static struct resource mbox_resources[] = {
75 {
76 .start = OMAP2_MBOX_BASE,
77 .end = OMAP2_MBOX_BASE + 0x11f,
78 .flags = IORESOURCE_MEM,
79 },
80 {
81 .start = INT_24XX_MAIL_U0_MPU,
82 .flags = IORESOURCE_IRQ,
83 },
84 {
85 .start = INT_24XX_MAIL_U3_MPU,
86 .flags = IORESOURCE_IRQ,
87 },
88};
89
90static struct platform_device mbox_device = {
91 .name = "mailbox",
92 .id = -1,
93 .num_resources = ARRAY_SIZE(mbox_resources),
94 .resource = mbox_resources,
95};
96
97static inline void omap_init_mbox(void)
98{
99 platform_device_register(&mbox_device);
100}
101#else
102static inline void omap_init_mbox(void) { }
103#endif
104
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100105#if defined(CONFIG_OMAP_STI)
106
107#define OMAP2_STI_BASE IO_ADDRESS(0x48068000)
108#define OMAP2_STI_CHANNEL_BASE 0x54000000
109#define OMAP2_STI_IRQ 4
110
111static struct resource sti_resources[] = {
112 {
113 .start = OMAP2_STI_BASE,
114 .end = OMAP2_STI_BASE + 0x7ff,
115 .flags = IORESOURCE_MEM,
116 },
117 {
118 .start = OMAP2_STI_CHANNEL_BASE,
119 .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
120 .flags = IORESOURCE_MEM,
121 },
122 {
123 .start = OMAP2_STI_IRQ,
124 .flags = IORESOURCE_IRQ,
125 }
126};
127
128static struct platform_device sti_device = {
129 .name = "sti",
130 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100131 .num_resources = ARRAY_SIZE(sti_resources),
132 .resource = sti_resources,
133};
134
135static inline void omap_init_sti(void)
136{
137 platform_device_register(&sti_device);
138}
139#else
140static inline void omap_init_sti(void) {}
141#endif
142
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700143#if defined(CONFIG_SPI_OMAP24XX)
144
Russell Kinga09e64f2008-08-05 16:14:15 +0100145#include <mach/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700146
147#define OMAP2_MCSPI1_BASE 0x48098000
148#define OMAP2_MCSPI2_BASE 0x4809a000
149
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700150static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700151 .num_cs = 4,
152};
153
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800154static struct resource omap2_mcspi1_resources[] = {
155 {
156 .start = OMAP2_MCSPI1_BASE,
157 .end = OMAP2_MCSPI1_BASE + 0xff,
158 .flags = IORESOURCE_MEM,
159 },
160};
161
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700162struct platform_device omap2_mcspi1 = {
163 .name = "omap2_mcspi",
164 .id = 1,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800165 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
166 .resource = omap2_mcspi1_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700167 .dev = {
168 .platform_data = &omap2_mcspi1_config,
169 },
170};
171
172static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700173 .num_cs = 2,
174};
175
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800176static struct resource omap2_mcspi2_resources[] = {
177 {
178 .start = OMAP2_MCSPI2_BASE,
179 .end = OMAP2_MCSPI2_BASE + 0xff,
180 .flags = IORESOURCE_MEM,
181 },
182};
183
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700184struct platform_device omap2_mcspi2 = {
185 .name = "omap2_mcspi",
186 .id = 2,
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800187 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
188 .resource = omap2_mcspi2_resources,
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700189 .dev = {
190 .platform_data = &omap2_mcspi2_config,
191 },
192};
193
194static void omap_init_mcspi(void)
195{
196 platform_device_register(&omap2_mcspi1);
197 platform_device_register(&omap2_mcspi2);
198}
199
200#else
201static inline void omap_init_mcspi(void) {}
202#endif
203
Tony Lindgren1dbae812005-11-10 14:26:51 +0000204/*-------------------------------------------------------------------------*/
205
206static int __init omap2_init_devices(void)
207{
208 /* please keep these calls, and their implementations above,
209 * in alphabetical order so they're easier to sort through.
210 */
211 omap_init_i2c();
Tony Lindgrenc40fae92006-12-07 13:58:10 -0800212 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700213 omap_init_mcspi();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100214 omap_init_sti();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000215
216 return 0;
217}
218arch_initcall(omap2_init_devices);