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