ARM: mx3: dynamically allocate mxc-ehci devices
[pandora-kernel.git] / 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/dma-mapping.h>
21 #include <linux/module.h>
22 #include <linux/platform_device.h>
23 #include <linux/serial.h>
24 #include <linux/gpio.h>
25 #include <mach/hardware.h>
26 #include <mach/irqs.h>
27 #include <mach/common.h>
28 #include <mach/mx3_camera.h>
29
30 #include "devices.h"
31
32 /* i.MX31 Image Processing Unit */
33
34 /* The resource order is important! */
35 static struct resource mx3_ipu_rsrc[] = {
36         {
37                 .start = MX3x_IPU_CTRL_BASE_ADDR,
38                 .end = MX3x_IPU_CTRL_BASE_ADDR + 0x5F,
39                 .flags = IORESOURCE_MEM,
40         }, {
41                 .start = MX3x_IPU_CTRL_BASE_ADDR + 0x88,
42                 .end = MX3x_IPU_CTRL_BASE_ADDR + 0xB3,
43                 .flags = IORESOURCE_MEM,
44         }, {
45                 .start = MX3x_INT_IPU_SYN,
46                 .end = MX3x_INT_IPU_SYN,
47                 .flags = IORESOURCE_IRQ,
48         }, {
49                 .start = MX3x_INT_IPU_ERR,
50                 .end = MX3x_INT_IPU_ERR,
51                 .flags = IORESOURCE_IRQ,
52         },
53 };
54
55 struct platform_device mx3_ipu = {
56         .name = "ipu-core",
57         .id = -1,
58         .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
59         .resource = mx3_ipu_rsrc,
60 };
61
62 static struct resource fb_resources[] = {
63         {
64                 .start  = MX3x_IPU_CTRL_BASE_ADDR + 0xB4,
65                 .end    = MX3x_IPU_CTRL_BASE_ADDR + 0x1BF,
66                 .flags  = IORESOURCE_MEM,
67         },
68 };
69
70 struct platform_device mx3_fb = {
71         .name           = "mx3_sdc_fb",
72         .id             = -1,
73         .num_resources  = ARRAY_SIZE(fb_resources),
74         .resource       = fb_resources,
75         .dev            = {
76                 .coherent_dma_mask = DMA_BIT_MASK(32),
77        },
78 };
79
80 static struct resource camera_resources[] = {
81         {
82                 .start  = MX3x_IPU_CTRL_BASE_ADDR + 0x60,
83                 .end    = MX3x_IPU_CTRL_BASE_ADDR + 0x87,
84                 .flags  = IORESOURCE_MEM,
85         },
86 };
87
88 struct platform_device mx3_camera = {
89         .name           = "mx3-camera",
90         .id             = 0,
91         .num_resources  = ARRAY_SIZE(camera_resources),
92         .resource       = camera_resources,
93         .dev            = {
94                 .coherent_dma_mask = DMA_BIT_MASK(32),
95         },
96 };
97
98 static struct resource imx_wdt_resources[] = {
99         {
100                 .flags = IORESOURCE_MEM,
101         },
102 };
103
104 struct platform_device imx_wdt_device0 = {
105         .name           = "imx2-wdt",
106         .id             = 0,
107         .num_resources  = ARRAY_SIZE(imx_wdt_resources),
108         .resource       = imx_wdt_resources,
109 };
110
111 static struct resource imx_rtc_resources[] = {
112         {
113                 .start  = MX31_RTC_BASE_ADDR,
114                 .end    = MX31_RTC_BASE_ADDR + 0x3fff,
115                 .flags  = IORESOURCE_MEM,
116         },
117         {
118                 .start  = MX31_INT_RTC,
119                 .flags  = IORESOURCE_IRQ,
120         },
121 };
122
123 struct platform_device imx_rtc_device0 = {
124         .name           = "mxc_rtc",
125         .id             = -1,
126         .num_resources  = ARRAY_SIZE(imx_rtc_resources),
127         .resource       = imx_rtc_resources,
128 };
129
130 static struct resource imx_kpp_resources[] = {
131         {
132                 .start  = MX3x_KPP_BASE_ADDR,
133                 .end    = MX3x_KPP_BASE_ADDR + 0xf,
134                 .flags  = IORESOURCE_MEM
135         }, {
136                 .start  = MX3x_INT_KPP,
137                 .end    = MX3x_INT_KPP,
138                 .flags  = IORESOURCE_IRQ,
139         },
140 };
141
142 struct platform_device imx_kpp_device = {
143         .name = "imx-keypad",
144         .id = -1,
145         .num_resources = ARRAY_SIZE(imx_kpp_resources),
146         .resource = imx_kpp_resources,
147 };
148
149 static int __init mx3_devices_init(void)
150 {
151 #if defined(CONFIG_ARCH_MX31)
152         if (cpu_is_mx31()) {
153                 imx_wdt_resources[0].start = MX31_WDOG_BASE_ADDR;
154                 imx_wdt_resources[0].end = MX31_WDOG_BASE_ADDR + 0x3fff;
155         }
156 #endif
157 #if defined(CONFIG_ARCH_MX35)
158         if (cpu_is_mx35()) {
159                 imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
160                 imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
161         }
162 #endif
163
164         return 0;
165 }
166
167 subsys_initcall(mx3_devices_init);