mx31moboard: add sdhc support (v3)
[linux-2.6] / arch / arm / mach-mx3 / devices.c
1 /*
2  * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3  * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/module.h>
21 #include <linux/platform_device.h>
22 #include <linux/serial.h>
23 #include <linux/gpio.h>
24 #include <mach/hardware.h>
25 #include <mach/irqs.h>
26 #include <mach/common.h>
27 #include <mach/imx-uart.h>
28
29 #include "devices.h"
30
31 static struct resource uart0[] = {
32         {
33                 .start = UART1_BASE_ADDR,
34                 .end = UART1_BASE_ADDR + 0x0B5,
35                 .flags = IORESOURCE_MEM,
36         }, {
37                 .start = MXC_INT_UART1,
38                 .end = MXC_INT_UART1,
39                 .flags = IORESOURCE_IRQ,
40         },
41 };
42
43 struct platform_device mxc_uart_device0 = {
44         .name = "imx-uart",
45         .id = 0,
46         .resource = uart0,
47         .num_resources = ARRAY_SIZE(uart0),
48 };
49
50 static struct resource uart1[] = {
51         {
52                 .start = UART2_BASE_ADDR,
53                 .end = UART2_BASE_ADDR + 0x0B5,
54                 .flags = IORESOURCE_MEM,
55         }, {
56                 .start = MXC_INT_UART2,
57                 .end = MXC_INT_UART2,
58                 .flags = IORESOURCE_IRQ,
59         },
60 };
61
62 struct platform_device mxc_uart_device1 = {
63         .name = "imx-uart",
64         .id = 1,
65         .resource = uart1,
66         .num_resources = ARRAY_SIZE(uart1),
67 };
68
69 static struct resource uart2[] = {
70         {
71                 .start = UART3_BASE_ADDR,
72                 .end = UART3_BASE_ADDR + 0x0B5,
73                 .flags = IORESOURCE_MEM,
74         }, {
75                 .start = MXC_INT_UART3,
76                 .end = MXC_INT_UART3,
77                 .flags = IORESOURCE_IRQ,
78         },
79 };
80
81 struct platform_device mxc_uart_device2 = {
82         .name = "imx-uart",
83         .id = 2,
84         .resource = uart2,
85         .num_resources = ARRAY_SIZE(uart2),
86 };
87
88 #ifdef CONFIG_ARCH_MX31
89 static struct resource uart3[] = {
90         {
91                 .start = UART4_BASE_ADDR,
92                 .end = UART4_BASE_ADDR + 0x0B5,
93                 .flags = IORESOURCE_MEM,
94         }, {
95                 .start = MXC_INT_UART4,
96                 .end = MXC_INT_UART4,
97                 .flags = IORESOURCE_IRQ,
98         },
99 };
100
101 struct platform_device mxc_uart_device3 = {
102         .name = "imx-uart",
103         .id = 3,
104         .resource = uart3,
105         .num_resources = ARRAY_SIZE(uart3),
106 };
107
108 static struct resource uart4[] = {
109         {
110                 .start = UART5_BASE_ADDR,
111                 .end = UART5_BASE_ADDR + 0x0B5,
112                 .flags = IORESOURCE_MEM,
113         }, {
114                 .start = MXC_INT_UART5,
115                 .end = MXC_INT_UART5,
116                 .flags = IORESOURCE_IRQ,
117         },
118 };
119
120 struct platform_device mxc_uart_device4 = {
121         .name = "imx-uart",
122         .id = 4,
123         .resource = uart4,
124         .num_resources = ARRAY_SIZE(uart4),
125 };
126 #endif /* CONFIG_ARCH_MX31 */
127
128 /* GPIO port description */
129 static struct mxc_gpio_port imx_gpio_ports[] = {
130         [0] = {
131                 .chip.label = "gpio-0",
132                 .base = IO_ADDRESS(GPIO1_BASE_ADDR),
133                 .irq = MXC_INT_GPIO1,
134                 .virtual_irq_start = MXC_GPIO_IRQ_START,
135         },
136         [1] = {
137                 .chip.label = "gpio-1",
138                 .base = IO_ADDRESS(GPIO2_BASE_ADDR),
139                 .irq = MXC_INT_GPIO2,
140                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
141         },
142         [2] = {
143                 .chip.label = "gpio-2",
144                 .base = IO_ADDRESS(GPIO3_BASE_ADDR),
145                 .irq = MXC_INT_GPIO3,
146                 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
147         }
148 };
149
150 int __init mxc_register_gpios(void)
151 {
152         return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
153 }
154
155 static struct resource mxc_w1_master_resources[] = {
156         {
157                 .start = OWIRE_BASE_ADDR,
158                 .end   = OWIRE_BASE_ADDR + SZ_4K - 1,
159                 .flags = IORESOURCE_MEM,
160         },
161 };
162
163 struct platform_device mxc_w1_master_device = {
164         .name = "mxc_w1",
165         .id = 0,
166         .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
167         .resource = mxc_w1_master_resources,
168 };
169
170 static struct resource mxc_nand_resources[] = {
171         {
172                 .start  = 0, /* runtime dependent */
173                 .end    = 0,
174                 .flags  = IORESOURCE_MEM
175         }, {
176                 .start  = MXC_INT_NANDFC,
177                 .end    = MXC_INT_NANDFC,
178                 .flags  = IORESOURCE_IRQ
179         },
180 };
181
182 struct platform_device mxc_nand_device = {
183         .name = "mxc_nand",
184         .id = 0,
185         .num_resources = ARRAY_SIZE(mxc_nand_resources),
186         .resource = mxc_nand_resources,
187 };
188
189 static struct resource mxc_i2c0_resources[] = {
190         {
191                 .start = I2C_BASE_ADDR,
192                 .end = I2C_BASE_ADDR + SZ_4K - 1,
193                 .flags = IORESOURCE_MEM,
194         },
195         {
196                 .start = MXC_INT_I2C,
197                 .end = MXC_INT_I2C,
198                 .flags = IORESOURCE_IRQ,
199         },
200 };
201
202 struct platform_device mxc_i2c_device0 = {
203         .name = "imx-i2c",
204         .id = 0,
205         .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
206         .resource = mxc_i2c0_resources,
207 };
208
209 static struct resource mxc_i2c1_resources[] = {
210         {
211                 .start = I2C2_BASE_ADDR,
212                 .end = I2C2_BASE_ADDR + SZ_4K - 1,
213                 .flags = IORESOURCE_MEM,
214         },
215         {
216                 .start = MXC_INT_I2C2,
217                 .end = MXC_INT_I2C2,
218                 .flags = IORESOURCE_IRQ,
219         },
220 };
221
222 struct platform_device mxc_i2c_device1 = {
223         .name = "imx-i2c",
224         .id = 1,
225         .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
226         .resource = mxc_i2c1_resources,
227 };
228
229 static struct resource mxc_i2c2_resources[] = {
230         {
231                 .start = I2C3_BASE_ADDR,
232                 .end = I2C3_BASE_ADDR + SZ_4K - 1,
233                 .flags = IORESOURCE_MEM,
234         },
235         {
236                 .start = MXC_INT_I2C3,
237                 .end = MXC_INT_I2C3,
238                 .flags = IORESOURCE_IRQ,
239         },
240 };
241
242 struct platform_device mxc_i2c_device2 = {
243         .name = "imx-i2c",
244         .id = 2,
245         .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
246         .resource = mxc_i2c2_resources,
247 };
248
249 #ifdef CONFIG_ARCH_MX31
250 static struct resource mxcsdhc0_resources[] = {
251         {
252                 .start = MMC_SDHC1_BASE_ADDR,
253                 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
254                 .flags = IORESOURCE_MEM,
255         }, {
256                 .start = MXC_INT_MMC_SDHC1,
257                 .end = MXC_INT_MMC_SDHC1,
258                 .flags = IORESOURCE_IRQ,
259         },
260 };
261
262 static struct resource mxcsdhc1_resources[] = {
263         {
264                 .start = MMC_SDHC2_BASE_ADDR,
265                 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
266                 .flags = IORESOURCE_MEM,
267         }, {
268                 .start = MXC_INT_MMC_SDHC2,
269                 .end = MXC_INT_MMC_SDHC2,
270                 .flags = IORESOURCE_IRQ,
271         },
272 };
273
274 struct platform_device mxcsdhc_device0 = {
275         .name = "mxc-mmc",
276         .id = 0,
277         .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
278         .resource = mxcsdhc0_resources,
279 };
280
281 struct platform_device mxcsdhc_device1 = {
282         .name = "mxc-mmc",
283         .id = 1,
284         .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
285         .resource = mxcsdhc1_resources,
286 };
287
288 static struct resource rnga_resources[] = {
289         {
290                 .start = RNGA_BASE_ADDR,
291                 .end = RNGA_BASE_ADDR + 0x28,
292                 .flags = IORESOURCE_MEM,
293         },
294 };
295
296 struct platform_device mxc_rnga_device = {
297         .name = "mxc_rnga",
298         .id = -1,
299         .num_resources = 1,
300         .resource = rnga_resources,
301 };
302 #endif /* CONFIG_ARCH_MX31 */
303
304 /* i.MX31 Image Processing Unit */
305
306 /* The resource order is important! */
307 static struct resource mx3_ipu_rsrc[] = {
308         {
309                 .start = IPU_CTRL_BASE_ADDR,
310                 .end = IPU_CTRL_BASE_ADDR + 0x5F,
311                 .flags = IORESOURCE_MEM,
312         }, {
313                 .start = IPU_CTRL_BASE_ADDR + 0x88,
314                 .end = IPU_CTRL_BASE_ADDR + 0xB3,
315                 .flags = IORESOURCE_MEM,
316         }, {
317                 .start = MXC_INT_IPU_SYN,
318                 .end = MXC_INT_IPU_SYN,
319                 .flags = IORESOURCE_IRQ,
320         }, {
321                 .start = MXC_INT_IPU_ERR,
322                 .end = MXC_INT_IPU_ERR,
323                 .flags = IORESOURCE_IRQ,
324         },
325 };
326
327 struct platform_device mx3_ipu = {
328         .name = "ipu-core",
329         .id = -1,
330         .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
331         .resource = mx3_ipu_rsrc,
332 };
333
334 static struct resource fb_resources[] = {
335         {
336                 .start  = IPU_CTRL_BASE_ADDR + 0xB4,
337                 .end    = IPU_CTRL_BASE_ADDR + 0x1BF,
338                 .flags  = IORESOURCE_MEM,
339         },
340 };
341
342 struct platform_device mx3_fb = {
343         .name           = "mx3_sdc_fb",
344         .id             = -1,
345         .num_resources  = ARRAY_SIZE(fb_resources),
346         .resource       = fb_resources,
347         .dev            = {
348                 .coherent_dma_mask = 0xffffffff,
349        },
350 };
351
352 #ifdef CONFIG_ARCH_MX35
353 static struct resource mxc_fec_resources[] = {
354         {
355                 .start  = MXC_FEC_BASE_ADDR,
356                 .end    = MXC_FEC_BASE_ADDR + 0xfff,
357                 .flags  = IORESOURCE_MEM
358         }, {
359                 .start  = MXC_INT_FEC,
360                 .end    = MXC_INT_FEC,
361                 .flags  = IORESOURCE_IRQ
362         },
363 };
364
365 struct platform_device mxc_fec_device = {
366         .name = "fec",
367         .id = 0,
368         .num_resources = ARRAY_SIZE(mxc_fec_resources),
369         .resource = mxc_fec_resources,
370 };
371 #endif
372
373 static int mx3_devices_init(void)
374 {
375         if (cpu_is_mx31()) {
376                 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
377                 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
378                 mxc_register_device(&mxc_rnga_device, NULL);
379         }
380         if (cpu_is_mx35()) {
381                 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
382                 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
383         }
384
385         return 0;
386 }
387
388 subsys_initcall(mx3_devices_init);