]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/devices.c
376b49ff28f7891167e562e56fdbe372262dc08a
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / devices.c
1 /*
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
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16
17 #include <asm/hardware.h>
18 #include <asm/io.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/map.h>
21
22 #include <asm/arch/tc.h>
23 #include <asm/arch/board.h>
24 #include <asm/arch/mux.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/eac.h>
27
28 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
29
30 static struct resource cam_resources[] = {
31         {
32                 .start          = OMAP24XX_CAMERA_BASE,
33                 .end            = OMAP24XX_CAMERA_BASE + 0xfff,
34                 .flags          = IORESOURCE_MEM,
35         },
36         {
37                 .start          = INT_24XX_CAM_IRQ,
38                 .flags          = IORESOURCE_IRQ,
39         }
40 };
41
42 static struct platform_device omap_cam_device = {
43         .name           = "omap24xxcam",
44         .id             = -1,
45         .num_resources  = ARRAY_SIZE(cam_resources),
46         .resource       = cam_resources,
47 };
48
49 static inline void omap_init_camera(void)
50 {
51         platform_device_register(&omap_cam_device);
52 }
53 #else
54 static inline void omap_init_camera(void)
55 {
56 }
57 #endif
58
59 #if     !defined(CONFIG_ARCH_OMAP243X)
60 #if     defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
61
62 #define OMAP2_I2C_BASE2         0x48072000
63 #define OMAP2_I2C_INT2          57
64
65 static u32 omap2_i2c2_clkrate   = 100;
66 static struct resource i2c_resources2[] = {
67         {
68                 .start          = OMAP2_I2C_BASE2,
69                 .end            = OMAP2_I2C_BASE2 + 0x3f,
70                 .flags          = IORESOURCE_MEM,
71         },
72         {
73                 .start          = OMAP2_I2C_INT2,
74                 .flags          = IORESOURCE_IRQ,
75         },
76 };
77
78 static struct platform_device omap_i2c_device2 = {
79         .name           = "i2c_omap",
80         .id             = 2,
81         .num_resources  = ARRAY_SIZE(i2c_resources2),
82         .resource       = i2c_resources2,
83         .dev            = {
84                 .platform_data  = &omap2_i2c2_clkrate,
85         },
86 };
87
88 /* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
89 static void omap_init_i2c(void)
90 {
91         /* REVISIT: Second I2C not in use on H4? */
92         if (machine_is_omap_h4())
93                 return;
94
95         omap_cfg_reg(J15_24XX_I2C2_SCL);
96         omap_cfg_reg(H19_24XX_I2C2_SDA);
97
98         (void) platform_device_register(&omap_i2c_device2);
99 }
100
101 #else
102
103 static void omap_init_i2c(void) {}
104
105 #endif
106 #endif
107
108 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
109 #define OMAP2_MBOX_BASE         IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
110
111 static struct resource mbox_resources[] = {
112         {
113                 .start          = OMAP2_MBOX_BASE,
114                 .end            = OMAP2_MBOX_BASE + 0x11f,
115                 .flags          = IORESOURCE_MEM,
116         },
117         {
118                 .start          = INT_24XX_MAIL_U0_MPU,
119                 .flags          = IORESOURCE_IRQ,
120         },
121         {
122                 .start          = INT_24XX_MAIL_U3_MPU,
123                 .flags          = IORESOURCE_IRQ,
124         },
125 };
126
127 static struct platform_device mbox_device = {
128         .name           = "mailbox",
129         .id             = -1,
130         .num_resources  = ARRAY_SIZE(mbox_resources),
131         .resource       = mbox_resources,
132 };
133
134 static inline void omap_init_mbox(void)
135 {
136         platform_device_register(&mbox_device);
137 }
138 #else
139 static inline void omap_init_mbox(void) { }
140 #endif
141
142 #if defined(CONFIG_OMAP_STI)
143
144 #define OMAP2_STI_BASE          IO_ADDRESS(0x48068000)
145 #define OMAP2_STI_CHANNEL_BASE  0x54000000
146 #define OMAP2_STI_IRQ           4
147
148 static struct resource sti_resources[] = {
149         {
150                 .start          = OMAP2_STI_BASE,
151                 .end            = OMAP2_STI_BASE + 0x7ff,
152                 .flags          = IORESOURCE_MEM,
153         },
154         {
155                 .start          = OMAP2_STI_CHANNEL_BASE,
156                 .end            = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
157                 .flags          = IORESOURCE_MEM,
158         },
159         {
160                 .start          = OMAP2_STI_IRQ,
161                 .flags          = IORESOURCE_IRQ,
162         }
163 };
164
165 static struct platform_device sti_device = {
166         .name           = "sti",
167         .id             = -1,
168         .num_resources  = ARRAY_SIZE(sti_resources),
169         .resource       = sti_resources,
170 };
171
172 static inline void omap_init_sti(void)
173 {
174         platform_device_register(&sti_device);
175 }
176 #else
177 static inline void omap_init_sti(void) {}
178 #endif
179
180 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
181
182 #include <asm/arch/mcspi.h>
183
184 #define OMAP2_MCSPI1_BASE               0x48098000
185 #define OMAP2_MCSPI2_BASE               0x4809a000
186
187 static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
188         .num_cs         = 4,
189 };
190
191 static struct resource omap2_mcspi1_resources[] = {
192         {
193                 .start          = OMAP2_MCSPI1_BASE,
194                 .end            = OMAP2_MCSPI1_BASE + 0xff,
195                 .flags          = IORESOURCE_MEM,
196         },
197 };
198
199 struct platform_device omap2_mcspi1 = {
200         .name           = "omap2_mcspi",
201         .id             = 1,
202         .num_resources  = ARRAY_SIZE(omap2_mcspi1_resources),
203         .resource       = omap2_mcspi1_resources,
204         .dev            = {
205                 .platform_data = &omap2_mcspi1_config,
206         },
207 };
208
209 static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
210         .num_cs         = 2,
211 };
212
213 static struct resource omap2_mcspi2_resources[] = {
214         {
215                 .start          = OMAP2_MCSPI2_BASE,
216                 .end            = OMAP2_MCSPI2_BASE + 0xff,
217                 .flags          = IORESOURCE_MEM,
218         },
219 };
220
221 struct platform_device omap2_mcspi2 = {
222         .name           = "omap2_mcspi",
223         .id             = 2,
224         .num_resources  = ARRAY_SIZE(omap2_mcspi2_resources),
225         .resource       = omap2_mcspi2_resources,
226         .dev            = {
227                 .platform_data = &omap2_mcspi2_config,
228         },
229 };
230
231 static void omap_init_mcspi(void)
232 {
233         platform_device_register(&omap2_mcspi1);
234         platform_device_register(&omap2_mcspi2);
235 }
236
237 #else
238 static inline void omap_init_mcspi(void) {}
239 #endif
240
241 #ifdef CONFIG_SND_OMAP24XX_EAC
242
243 #define OMAP2_EAC_BASE                  0x48090000
244
245 static struct resource omap2_eac_resources[] = {
246         {
247                 .start          = OMAP2_EAC_BASE,
248                 .end            = OMAP2_EAC_BASE + 0x109,
249                 .flags          = IORESOURCE_MEM,
250         },
251 };
252
253 static struct platform_device omap2_eac_device = {
254         .name           = "omap24xx-eac",
255         .id             = -1,
256         .num_resources  = ARRAY_SIZE(omap2_eac_resources),
257         .resource       = omap2_eac_resources,
258         .dev = {
259                 .platform_data = NULL,
260         },
261 };
262
263 void omap_init_eac(struct eac_platform_data *pdata)
264 {
265         omap2_eac_device.dev.platform_data = pdata;
266         platform_device_register(&omap2_eac_device);
267 }
268
269 #else
270 void omap_init_eac(struct eac_platform_data *pdata) {}
271 #endif
272
273 /*-------------------------------------------------------------------------*/
274
275 static int __init omap2_init_devices(void)
276 {
277         /* please keep these calls, and their implementations above,
278          * in alphabetical order so they're easier to sort through.
279          */
280         omap_init_camera();
281         if (!cpu_is_omap2430()) {
282                 omap_init_i2c();
283         }
284         omap_init_mbox();
285         omap_init_mcspi();
286         omap_init_sti();
287
288         return 0;
289 }
290 arch_initcall(omap2_init_devices);