blob: ab090602cea46fcd4dde3bd1212115e333a80e84 [file] [log] [blame]
Sascha Hauere3d13ff2008-07-05 10:02:48 +02001/*
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>
Juergen Beisert07bd1a62008-07-05 10:02:49 +020023#include <linux/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/hardware.h>
Russell King80b02c12009-01-08 10:01:47 +000025#include <mach/irqs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/imx-uart.h>
Sascha Hauere3d13ff2008-07-05 10:02:48 +020027
Sascha Hauer87bbb192009-01-29 16:00:23 +010028#include "devices.h"
29
Sascha Hauere3d13ff2008-07-05 10:02:48 +020030static struct resource uart0[] = {
31 {
32 .start = UART1_BASE_ADDR,
33 .end = UART1_BASE_ADDR + 0x0B5,
34 .flags = IORESOURCE_MEM,
35 }, {
36 .start = MXC_INT_UART1,
37 .end = MXC_INT_UART1,
38 .flags = IORESOURCE_IRQ,
39 },
40};
41
Sascha Hauer5cf09422008-09-09 10:19:41 +020042struct platform_device mxc_uart_device0 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020043 .name = "imx-uart",
44 .id = 0,
45 .resource = uart0,
46 .num_resources = ARRAY_SIZE(uart0),
47};
48
49static struct resource uart1[] = {
50 {
51 .start = UART2_BASE_ADDR,
52 .end = UART2_BASE_ADDR + 0x0B5,
53 .flags = IORESOURCE_MEM,
54 }, {
55 .start = MXC_INT_UART2,
56 .end = MXC_INT_UART2,
57 .flags = IORESOURCE_IRQ,
58 },
59};
60
Sascha Hauer5cf09422008-09-09 10:19:41 +020061struct platform_device mxc_uart_device1 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020062 .name = "imx-uart",
63 .id = 1,
64 .resource = uart1,
65 .num_resources = ARRAY_SIZE(uart1),
66};
67
68static struct resource uart2[] = {
69 {
70 .start = UART3_BASE_ADDR,
71 .end = UART3_BASE_ADDR + 0x0B5,
72 .flags = IORESOURCE_MEM,
73 }, {
74 .start = MXC_INT_UART3,
75 .end = MXC_INT_UART3,
76 .flags = IORESOURCE_IRQ,
77 },
78};
79
Sascha Hauer5cf09422008-09-09 10:19:41 +020080struct platform_device mxc_uart_device2 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020081 .name = "imx-uart",
82 .id = 2,
83 .resource = uart2,
84 .num_resources = ARRAY_SIZE(uart2),
85};
86
Sascha Hauer9536ff32009-02-06 15:38:51 +010087#ifdef CONFIG_ARCH_MX31
Sascha Hauere3d13ff2008-07-05 10:02:48 +020088static struct resource uart3[] = {
89 {
90 .start = UART4_BASE_ADDR,
91 .end = UART4_BASE_ADDR + 0x0B5,
92 .flags = IORESOURCE_MEM,
93 }, {
94 .start = MXC_INT_UART4,
95 .end = MXC_INT_UART4,
96 .flags = IORESOURCE_IRQ,
97 },
98};
99
Sascha Hauer5cf09422008-09-09 10:19:41 +0200100struct platform_device mxc_uart_device3 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200101 .name = "imx-uart",
102 .id = 3,
103 .resource = uart3,
104 .num_resources = ARRAY_SIZE(uart3),
105};
106
107static struct resource uart4[] = {
108 {
109 .start = UART5_BASE_ADDR,
110 .end = UART5_BASE_ADDR + 0x0B5,
111 .flags = IORESOURCE_MEM,
112 }, {
113 .start = MXC_INT_UART5,
114 .end = MXC_INT_UART5,
115 .flags = IORESOURCE_IRQ,
116 },
117};
118
Sascha Hauer5cf09422008-09-09 10:19:41 +0200119struct platform_device mxc_uart_device4 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200120 .name = "imx-uart",
121 .id = 4,
122 .resource = uart4,
123 .num_resources = ARRAY_SIZE(uart4),
124};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100125#endif /* CONFIG_ARCH_MX31 */
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200126
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200127/* GPIO port description */
128static struct mxc_gpio_port imx_gpio_ports[] = {
129 [0] = {
130 .chip.label = "gpio-0",
131 .base = IO_ADDRESS(GPIO1_BASE_ADDR),
132 .irq = MXC_INT_GPIO1,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100133 .virtual_irq_start = MXC_GPIO_IRQ_START,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200134 },
135 [1] = {
136 .chip.label = "gpio-1",
137 .base = IO_ADDRESS(GPIO2_BASE_ADDR),
138 .irq = MXC_INT_GPIO2,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100139 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200140 },
141 [2] = {
142 .chip.label = "gpio-2",
143 .base = IO_ADDRESS(GPIO3_BASE_ADDR),
144 .irq = MXC_INT_GPIO3,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100145 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200146 }
147};
148
149int __init mxc_register_gpios(void)
150{
151 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
152}
Sascha Hauera8405922008-12-01 14:15:39 -0800153
154static struct resource mxc_w1_master_resources[] = {
155 {
156 .start = OWIRE_BASE_ADDR,
157 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
158 .flags = IORESOURCE_MEM,
159 },
160};
161
162struct platform_device mxc_w1_master_device = {
163 .name = "mxc_w1",
164 .id = 0,
165 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
166 .resource = mxc_w1_master_resources,
167};
Sascha Hauercb96cf12008-11-11 15:15:39 +0100168
169static struct resource mxc_nand_resources[] = {
170 {
Sascha Hauer9536ff32009-02-06 15:38:51 +0100171 .start = 0, /* runtime dependent */
172 .end = 0,
Sascha Hauercb96cf12008-11-11 15:15:39 +0100173 .flags = IORESOURCE_MEM
174 }, {
175 .start = MXC_INT_NANDFC,
176 .end = MXC_INT_NANDFC,
177 .flags = IORESOURCE_IRQ
178 },
179};
180
181struct platform_device mxc_nand_device = {
182 .name = "mxc_nand",
183 .id = 0,
184 .num_resources = ARRAY_SIZE(mxc_nand_resources),
185 .resource = mxc_nand_resources,
186};
Mark Brown39d1dc02009-01-15 16:14:27 +0000187
188static struct resource mxc_i2c0_resources[] = {
189 {
190 .start = I2C_BASE_ADDR,
191 .end = I2C_BASE_ADDR + SZ_4K - 1,
192 .flags = IORESOURCE_MEM,
193 },
194 {
195 .start = MXC_INT_I2C,
196 .end = MXC_INT_I2C,
197 .flags = IORESOURCE_IRQ,
198 },
199};
200
201struct platform_device mxc_i2c_device0 = {
202 .name = "imx-i2c",
203 .id = 0,
204 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
205 .resource = mxc_i2c0_resources,
206};
207
208static struct resource mxc_i2c1_resources[] = {
209 {
210 .start = I2C2_BASE_ADDR,
211 .end = I2C2_BASE_ADDR + SZ_4K - 1,
212 .flags = IORESOURCE_MEM,
213 },
214 {
215 .start = MXC_INT_I2C2,
216 .end = MXC_INT_I2C2,
217 .flags = IORESOURCE_IRQ,
218 },
219};
220
221struct platform_device mxc_i2c_device1 = {
222 .name = "imx-i2c",
223 .id = 1,
224 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
225 .resource = mxc_i2c1_resources,
226};
227
228static struct resource mxc_i2c2_resources[] = {
229 {
230 .start = I2C3_BASE_ADDR,
231 .end = I2C3_BASE_ADDR + SZ_4K - 1,
232 .flags = IORESOURCE_MEM,
233 },
234 {
235 .start = MXC_INT_I2C3,
236 .end = MXC_INT_I2C3,
237 .flags = IORESOURCE_IRQ,
238 },
239};
240
241struct platform_device mxc_i2c_device2 = {
242 .name = "imx-i2c",
243 .id = 2,
244 .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
245 .resource = mxc_i2c2_resources,
246};
Valentin Longchampca489f82009-02-16 12:47:52 +0100247
248/* i.MX31 Image Processing Unit */
249
250/* The resource order is important! */
251static struct resource mx3_ipu_rsrc[] = {
252 {
253 .start = IPU_CTRL_BASE_ADDR,
254 .end = IPU_CTRL_BASE_ADDR + 0x5F,
255 .flags = IORESOURCE_MEM,
256 }, {
257 .start = IPU_CTRL_BASE_ADDR + 0x88,
258 .end = IPU_CTRL_BASE_ADDR + 0xB3,
259 .flags = IORESOURCE_MEM,
260 }, {
261 .start = MXC_INT_IPU_SYN,
262 .end = MXC_INT_IPU_SYN,
263 .flags = IORESOURCE_IRQ,
264 }, {
265 .start = MXC_INT_IPU_ERR,
266 .end = MXC_INT_IPU_ERR,
267 .flags = IORESOURCE_IRQ,
268 },
269};
270
271struct platform_device mx3_ipu = {
272 .name = "ipu-core",
273 .id = -1,
274 .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
275 .resource = mx3_ipu_rsrc,
276};
277
278static struct resource fb_resources[] = {
279 {
280 .start = IPU_CTRL_BASE_ADDR + 0xB4,
281 .end = IPU_CTRL_BASE_ADDR + 0x1BF,
282 .flags = IORESOURCE_MEM,
283 },
284};
285
286struct platform_device mx3_fb = {
287 .name = "mx3_sdc_fb",
288 .id = -1,
289 .num_resources = ARRAY_SIZE(fb_resources),
290 .resource = fb_resources,
291 .dev = {
292 .coherent_dma_mask = 0xffffffff,
293 },
294};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100295
296#ifdef CONFIG_ARCH_MX35
297static struct resource mxc_fec_resources[] = {
298 {
299 .start = MXC_FEC_BASE_ADDR,
300 .end = MXC_FEC_BASE_ADDR + 0xfff,
301 .flags = IORESOURCE_MEM
302 }, {
303 .start = MXC_INT_FEC,
304 .end = MXC_INT_FEC,
305 .flags = IORESOURCE_IRQ
306 },
307};
308
309struct platform_device mxc_fec_device = {
310 .name = "fec",
311 .id = 0,
312 .num_resources = ARRAY_SIZE(mxc_fec_resources),
313 .resource = mxc_fec_resources,
314};
315#endif
316
317static int mx3_devices_init(void)
318{
319 if (cpu_is_mx31()) {
320 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
321 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
322 }
323 if (cpu_is_mx35()) {
324 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
325 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
326 }
327
328 return 0;
329}
330
331subsys_initcall(mx3_devices_init);