Commit | Line | Data |
---|---|---|
fc80a5e3 JB |
1 | /* |
2 | * Author: MontaVista Software, Inc. | |
3 | * <source@mvista.com> | |
4 | * | |
5 | * Based on the OMAP devices.c | |
6 | * | |
7 | * 2005 (c) MontaVista Software, Inc. This file is licensed under the | |
8 | * terms of the GNU General Public License version 2. This program is | |
9 | * licensed "as is" without any warranty of any kind, whether express | |
10 | * or implied. | |
11 | * | |
12 | * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved. | |
13 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | |
14 | * | |
15 | * This program is free software; you can redistribute it and/or | |
16 | * modify it under the terms of the GNU General Public License | |
17 | * as published by the Free Software Foundation; either version 2 | |
18 | * of the License, or (at your option) any later version. | |
19 | * This program is distributed in the hope that it will be useful, | |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | * GNU General Public License for more details. | |
23 | * | |
24 | * You should have received a copy of the GNU General Public License | |
25 | * along with this program; if not, write to the Free Software | |
26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
27 | * MA 02110-1301, USA. | |
28 | */ | |
29 | #include <linux/module.h> | |
30 | #include <linux/kernel.h> | |
31 | #include <linux/init.h> | |
32 | #include <linux/platform_device.h> | |
33 | #include <linux/gpio.h> | |
34 | ||
80b02c17 | 35 | #include <mach/irqs.h> |
a09e64fb | 36 | #include <mach/hardware.h> |
058b7a6f | 37 | #include <mach/common.h> |
1a02be0e | 38 | #include <mach/mmc.h> |
058b7a6f HS |
39 | |
40 | #include "devices.h" | |
fc80a5e3 | 41 | |
f420db84 SH |
42 | /* |
43 | * SPI master controller | |
44 | * | |
45 | * - i.MX1: 2 channel (slighly different register setting) | |
46 | * - i.MX21: 2 channel | |
47 | * - i.MX27: 3 channel | |
48 | */ | |
68c94b40 UKK |
49 | #define DEFINE_IMX_SPI_DEVICE(n, baseaddr, irq) \ |
50 | static struct resource mxc_spi_resources ## n[] = { \ | |
51 | { \ | |
52 | .start = baseaddr, \ | |
53 | .end = baseaddr + SZ_4K - 1, \ | |
54 | .flags = IORESOURCE_MEM, \ | |
55 | }, { \ | |
56 | .start = irq, \ | |
57 | .end = irq, \ | |
58 | .flags = IORESOURCE_IRQ, \ | |
59 | }, \ | |
60 | }; \ | |
61 | \ | |
62 | struct platform_device mxc_spi_device ## n = { \ | |
63 | .name = "spi_imx", \ | |
64 | .id = n, \ | |
65 | .num_resources = ARRAY_SIZE(mxc_spi_resources ## n), \ | |
66 | .resource = mxc_spi_resources ## n, \ | |
67 | } | |
f420db84 | 68 | |
68c94b40 UKK |
69 | DEFINE_IMX_SPI_DEVICE(0, MX2x_CSPI1_BASE_ADDR, MX2x_INT_CSPI1); |
70 | DEFINE_IMX_SPI_DEVICE(1, MX2x_CSPI2_BASE_ADDR, MX2x_INT_CSPI2); | |
f420db84 SH |
71 | |
72 | #ifdef CONFIG_MACH_MX27 | |
68c94b40 | 73 | DEFINE_IMX_SPI_DEVICE(2, MX27_CSPI3_BASE_ADDR, MX27_INT_CSPI3); |
f420db84 SH |
74 | #endif |
75 | ||
fc80a5e3 JB |
76 | /* |
77 | * General Purpose Timer | |
bf50bcc2 SH |
78 | * - i.MX21: 3 timers |
79 | * - i.MX27: 6 timers | |
fc80a5e3 | 80 | */ |
2b84a364 UKK |
81 | #define DEFINE_IMX_GPT_DEVICE(n, baseaddr, irq) \ |
82 | static struct resource timer ## n ##_resources[] = { \ | |
83 | { \ | |
84 | .start = baseaddr, \ | |
85 | .end = baseaddr + SZ_4K - 1, \ | |
86 | .flags = IORESOURCE_MEM, \ | |
87 | }, { \ | |
88 | .start = irq, \ | |
89 | .end = irq, \ | |
90 | .flags = IORESOURCE_IRQ, \ | |
91 | } \ | |
92 | }; \ | |
93 | \ | |
94 | struct platform_device mxc_gpt ## n = { \ | |
95 | .name = "imx_gpt", \ | |
96 | .id = n, \ | |
97 | .num_resources = ARRAY_SIZE(timer ## n ## _resources), \ | |
98 | .resource = timer ## n ## _resources, \ | |
fc80a5e3 | 99 | } |
fc80a5e3 | 100 | |
2b84a364 UKK |
101 | /* We use gpt1 as system timer, so do not add a device for this one */ |
102 | DEFINE_IMX_GPT_DEVICE(1, MX2x_GPT2_BASE_ADDR, MX2x_INT_GPT2); | |
103 | DEFINE_IMX_GPT_DEVICE(2, MX2x_GPT3_BASE_ADDR, MX2x_INT_GPT3); | |
fc80a5e3 JB |
104 | |
105 | #ifdef CONFIG_MACH_MX27 | |
2b84a364 UKK |
106 | DEFINE_IMX_GPT_DEVICE(3, MX27_GPT4_BASE_ADDR, MX27_INT_GPT4); |
107 | DEFINE_IMX_GPT_DEVICE(4, MX27_GPT5_BASE_ADDR, MX27_INT_GPT5); | |
108 | DEFINE_IMX_GPT_DEVICE(5, MX27_GPT6_BASE_ADDR, MX27_INT_GPT6); | |
fc80a5e3 JB |
109 | #endif |
110 | ||
111 | /* | |
112 | * Watchdog: | |
113 | * - i.MX1 | |
114 | * - i.MX21 | |
115 | * - i.MX27 | |
116 | */ | |
117 | static struct resource mxc_wdt_resources[] = { | |
118 | { | |
58152a16 UKK |
119 | .start = MX2x_WDOG_BASE_ADDR, |
120 | .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1, | |
121 | .flags = IORESOURCE_MEM, | |
fc80a5e3 JB |
122 | }, |
123 | }; | |
124 | ||
125 | struct platform_device mxc_wdt = { | |
126 | .name = "mxc_wdt", | |
127 | .id = 0, | |
128 | .num_resources = ARRAY_SIZE(mxc_wdt_resources), | |
129 | .resource = mxc_wdt_resources, | |
130 | }; | |
131 | ||
3d89baa7 SH |
132 | static struct resource mxc_w1_master_resources[] = { |
133 | { | |
58152a16 UKK |
134 | .start = MX2x_OWIRE_BASE_ADDR, |
135 | .end = MX2x_OWIRE_BASE_ADDR + SZ_4K - 1, | |
3d89baa7 SH |
136 | .flags = IORESOURCE_MEM, |
137 | }, | |
138 | }; | |
139 | ||
140 | struct platform_device mxc_w1_master_device = { | |
141 | .name = "mxc_w1", | |
142 | .id = 0, | |
143 | .num_resources = ARRAY_SIZE(mxc_w1_master_resources), | |
144 | .resource = mxc_w1_master_resources, | |
145 | }; | |
146 | ||
02870978 SH |
147 | static struct resource mxc_nand_resources[] = { |
148 | { | |
58152a16 UKK |
149 | .start = NFC_BASE_ADDR, |
150 | .end = NFC_BASE_ADDR + SZ_4K - 1, | |
151 | .flags = IORESOURCE_MEM, | |
02870978 | 152 | }, { |
58152a16 UKK |
153 | .start = MX2x_INT_NANDFC, |
154 | .end = MX2x_INT_NANDFC, | |
155 | .flags = IORESOURCE_IRQ, | |
02870978 SH |
156 | }, |
157 | }; | |
158 | ||
159 | struct platform_device mxc_nand_device = { | |
160 | .name = "mxc_nand", | |
161 | .id = 0, | |
162 | .num_resources = ARRAY_SIZE(mxc_nand_resources), | |
163 | .resource = mxc_nand_resources, | |
164 | }; | |
165 | ||
e4813551 HS |
166 | /* |
167 | * lcdc: | |
168 | * - i.MX1: the basic controller | |
169 | * - i.MX21: to be checked | |
170 | * - i.MX27: like i.MX1, with slightly variations | |
171 | */ | |
172 | static struct resource mxc_fb[] = { | |
173 | { | |
58152a16 UKK |
174 | .start = MX2x_LCDC_BASE_ADDR, |
175 | .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1, | |
e4813551 | 176 | .flags = IORESOURCE_MEM, |
bf50bcc2 | 177 | }, { |
58152a16 UKK |
178 | .start = MX2x_INT_LCDC, |
179 | .end = MX2x_INT_LCDC, | |
e4813551 HS |
180 | .flags = IORESOURCE_IRQ, |
181 | } | |
182 | }; | |
183 | ||
184 | /* mxc lcd driver */ | |
185 | struct platform_device mxc_fb_device = { | |
186 | .name = "imx-fb", | |
187 | .id = 0, | |
188 | .num_resources = ARRAY_SIZE(mxc_fb), | |
189 | .resource = mxc_fb, | |
190 | .dev = { | |
191 | .coherent_dma_mask = 0xFFFFFFFF, | |
192 | }, | |
193 | }; | |
194 | ||
879fea1b SH |
195 | #ifdef CONFIG_MACH_MX27 |
196 | static struct resource mxc_fec_resources[] = { | |
197 | { | |
58152a16 UKK |
198 | .start = MX27_FEC_BASE_ADDR, |
199 | .end = MX27_FEC_BASE_ADDR + SZ_4K - 1, | |
200 | .flags = IORESOURCE_MEM, | |
879fea1b | 201 | }, { |
58152a16 UKK |
202 | .start = MX27_INT_FEC, |
203 | .end = MX27_INT_FEC, | |
204 | .flags = IORESOURCE_IRQ, | |
879fea1b SH |
205 | }, |
206 | }; | |
207 | ||
208 | struct platform_device mxc_fec_device = { | |
209 | .name = "fec", | |
210 | .id = 0, | |
211 | .num_resources = ARRAY_SIZE(mxc_fec_resources), | |
212 | .resource = mxc_fec_resources, | |
213 | }; | |
e4813551 HS |
214 | #endif |
215 | ||
9309b2ba UKK |
216 | #define DEFINE_IMX_I2C_DEVICE(n, baseaddr, irq) \ |
217 | static struct resource mxc_i2c_resources ## n[] = { \ | |
218 | { \ | |
219 | .start = baseaddr, \ | |
220 | .end = baseaddr + SZ_4K - 1, \ | |
221 | .flags = IORESOURCE_MEM, \ | |
222 | }, { \ | |
223 | .start = irq, \ | |
224 | .end = irq, \ | |
225 | .flags = IORESOURCE_IRQ, \ | |
226 | } \ | |
227 | }; \ | |
228 | \ | |
229 | struct platform_device mxc_i2c_device ## n = { \ | |
230 | .name = "imx-i2c", \ | |
231 | .id = n, \ | |
232 | .num_resources = ARRAY_SIZE(mxc_i2c_resources ## n), \ | |
233 | .resource = mxc_i2c_resources ## n, \ | |
c5d4dbff | 234 | } |
c5d4dbff | 235 | |
9309b2ba | 236 | DEFINE_IMX_I2C_DEVICE(0, MX2x_I2C_BASE_ADDR, MX2x_INT_I2C); |
c5d4dbff SH |
237 | |
238 | #ifdef CONFIG_MACH_MX27 | |
9309b2ba | 239 | DEFINE_IMX_I2C_DEVICE(1, MX27_I2C2_BASE_ADDR, MX27_INT_I2C2); |
c5d4dbff SH |
240 | #endif |
241 | ||
824b16e6 | 242 | static struct resource mxc_pwm_resources[] = { |
bf50bcc2 | 243 | { |
58152a16 UKK |
244 | .start = MX2x_PWM_BASE_ADDR, |
245 | .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1, | |
246 | .flags = IORESOURCE_MEM, | |
bf50bcc2 | 247 | }, { |
58152a16 UKK |
248 | .start = MX2x_INT_PWM, |
249 | .end = MX2x_INT_PWM, | |
250 | .flags = IORESOURCE_IRQ, | |
824b16e6 SH |
251 | } |
252 | }; | |
253 | ||
254 | struct platform_device mxc_pwm_device = { | |
255 | .name = "mxc_pwm", | |
256 | .id = 0, | |
257 | .num_resources = ARRAY_SIZE(mxc_pwm_resources), | |
bf50bcc2 | 258 | .resource = mxc_pwm_resources, |
824b16e6 SH |
259 | }; |
260 | ||
1a02be0e SH |
261 | /* |
262 | * Resource definition for the MXC SDHC | |
263 | */ | |
ccd0e42c UKK |
264 | #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \ |
265 | static struct resource mxc_sdhc_resources ## n[] = { \ | |
266 | { \ | |
267 | .start = baseaddr, \ | |
268 | .end = baseaddr + SZ_4K - 1, \ | |
269 | .flags = IORESOURCE_MEM, \ | |
270 | }, { \ | |
271 | .start = irq, \ | |
272 | .end = irq, \ | |
273 | .flags = IORESOURCE_IRQ, \ | |
274 | }, { \ | |
275 | .start = dmareq, \ | |
276 | .end = dmareq, \ | |
277 | .flags = IORESOURCE_DMA, \ | |
278 | }, \ | |
279 | }; \ | |
280 | \ | |
281 | static u64 mxc_sdhc ## n ## _dmamask = 0xffffffffUL; \ | |
282 | \ | |
283 | struct platform_device mxc_sdhc_device ## n = { \ | |
284 | .name = "mxc-mmc", \ | |
285 | .id = n, \ | |
286 | .dev = { \ | |
287 | .dma_mask = &mxc_sdhc ## n ## _dmamask, \ | |
288 | .coherent_dma_mask = 0xffffffff, \ | |
289 | }, \ | |
290 | .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \ | |
291 | .resource = mxc_sdhc_resources ## n, \ | |
292 | } | |
1a02be0e | 293 | |
ccd0e42c UKK |
294 | DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1); |
295 | DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2); | |
1a02be0e | 296 | |
f6d2fa7d | 297 | #ifdef CONFIG_MACH_MX27 |
627fb3b9 M |
298 | static struct resource otg_resources[] = { |
299 | { | |
58152a16 UKK |
300 | .start = MX27_USBOTG_BASE_ADDR, |
301 | .end = MX27_USBOTG_BASE_ADDR + 0x1ff, | |
302 | .flags = IORESOURCE_MEM, | |
627fb3b9 | 303 | }, { |
58152a16 UKK |
304 | .start = MX27_INT_USB3, |
305 | .end = MX27_INT_USB3, | |
306 | .flags = IORESOURCE_IRQ, | |
627fb3b9 M |
307 | }, |
308 | }; | |
309 | ||
310 | static u64 otg_dmamask = 0xffffffffUL; | |
311 | ||
312 | /* OTG gadget device */ | |
313 | struct platform_device mxc_otg_udc_device = { | |
58152a16 UKK |
314 | .name = "fsl-usb2-udc", |
315 | .id = -1, | |
316 | .dev = { | |
317 | .dma_mask = &otg_dmamask, | |
318 | .coherent_dma_mask = 0xffffffffUL, | |
627fb3b9 | 319 | }, |
58152a16 UKK |
320 | .resource = otg_resources, |
321 | .num_resources = ARRAY_SIZE(otg_resources), | |
627fb3b9 M |
322 | }; |
323 | ||
324 | /* OTG host */ | |
325 | struct platform_device mxc_otg_host = { | |
326 | .name = "mxc-ehci", | |
327 | .id = 0, | |
328 | .dev = { | |
329 | .coherent_dma_mask = 0xffffffff, | |
330 | .dma_mask = &otg_dmamask, | |
331 | }, | |
332 | .resource = otg_resources, | |
333 | .num_resources = ARRAY_SIZE(otg_resources), | |
334 | }; | |
335 | ||
336 | /* USB host 1 */ | |
337 | ||
338 | static u64 usbh1_dmamask = 0xffffffffUL; | |
339 | ||
340 | static struct resource mxc_usbh1_resources[] = { | |
341 | { | |
58152a16 UKK |
342 | .start = MX27_USBOTG_BASE_ADDR + 0x200, |
343 | .end = MX27_USBOTG_BASE_ADDR + 0x3ff, | |
627fb3b9 M |
344 | .flags = IORESOURCE_MEM, |
345 | }, { | |
58152a16 UKK |
346 | .start = MX27_INT_USB1, |
347 | .end = MX27_INT_USB1, | |
627fb3b9 M |
348 | .flags = IORESOURCE_IRQ, |
349 | }, | |
350 | }; | |
351 | ||
352 | struct platform_device mxc_usbh1 = { | |
353 | .name = "mxc-ehci", | |
354 | .id = 1, | |
355 | .dev = { | |
356 | .coherent_dma_mask = 0xffffffff, | |
357 | .dma_mask = &usbh1_dmamask, | |
358 | }, | |
359 | .resource = mxc_usbh1_resources, | |
360 | .num_resources = ARRAY_SIZE(mxc_usbh1_resources), | |
361 | }; | |
362 | ||
363 | /* USB host 2 */ | |
364 | static u64 usbh2_dmamask = 0xffffffffUL; | |
365 | ||
366 | static struct resource mxc_usbh2_resources[] = { | |
367 | { | |
58152a16 UKK |
368 | .start = MX27_USBOTG_BASE_ADDR + 0x400, |
369 | .end = MX27_USBOTG_BASE_ADDR + 0x5ff, | |
627fb3b9 M |
370 | .flags = IORESOURCE_MEM, |
371 | }, { | |
58152a16 UKK |
372 | .start = MX27_INT_USB2, |
373 | .end = MX27_INT_USB2, | |
627fb3b9 M |
374 | .flags = IORESOURCE_IRQ, |
375 | }, | |
376 | }; | |
377 | ||
378 | struct platform_device mxc_usbh2 = { | |
379 | .name = "mxc-ehci", | |
380 | .id = 2, | |
381 | .dev = { | |
382 | .coherent_dma_mask = 0xffffffff, | |
383 | .dma_mask = &usbh2_dmamask, | |
384 | }, | |
385 | .resource = mxc_usbh2_resources, | |
386 | .num_resources = ARRAY_SIZE(mxc_usbh2_resources), | |
387 | }; | |
f6d2fa7d | 388 | #endif |
627fb3b9 | 389 | |
69ddb488 UKK |
390 | #define DEFINE_IMX_SSI_DMARES(_name, ssin, suffix) \ |
391 | { \ | |
392 | .name = _name, \ | |
393 | .start = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \ | |
394 | .end = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \ | |
395 | .flags = IORESOURCE_DMA, \ | |
396 | } | |
23291df4 | 397 | |
69ddb488 UKK |
398 | #define DEFINE_IMX_SSI_DEVICE(n, ssin, baseaddr, irq) \ |
399 | static struct resource imx_ssi_resources ## n[] = { \ | |
400 | { \ | |
401 | .start = MX2x_SSI ## ssin ## _BASE_ADDR, \ | |
402 | .end = MX2x_SSI ## ssin ## _BASE_ADDR + 0x6f, \ | |
403 | .flags = IORESOURCE_MEM, \ | |
404 | }, { \ | |
405 | .start = MX2x_INT_SSI1, \ | |
406 | .end = MX2x_INT_SSI1, \ | |
407 | .flags = IORESOURCE_IRQ, \ | |
408 | }, \ | |
409 | DEFINE_IMX_SSI_DMARES("tx0", ssin, TX0), \ | |
410 | DEFINE_IMX_SSI_DMARES("rx0", ssin, RX0), \ | |
411 | DEFINE_IMX_SSI_DMARES("tx1", ssin, TX1), \ | |
412 | DEFINE_IMX_SSI_DMARES("rx1", ssin, RX1), \ | |
413 | }; \ | |
414 | \ | |
415 | struct platform_device imx_ssi_device ## n = { \ | |
416 | .name = "imx-ssi", \ | |
417 | .id = n, \ | |
418 | .num_resources = ARRAY_SIZE(imx_ssi_resources ## n), \ | |
419 | .resource = imx_ssi_resources ## n, \ | |
420 | } | |
23291df4 | 421 | |
69ddb488 UKK |
422 | DEFINE_IMX_SSI_DEVICE(0, 1, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1); |
423 | DEFINE_IMX_SSI_DEVICE(1, 2, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1); | |
23291df4 | 424 | |
fc80a5e3 JB |
425 | /* GPIO port description */ |
426 | static struct mxc_gpio_port imx_gpio_ports[] = { | |
bf50bcc2 | 427 | { |
fc80a5e3 | 428 | .chip.label = "gpio-0", |
58152a16 UKK |
429 | .irq = MX2x_INT_GPIO, |
430 | .base = IO_ADDRESS(MX2x_GPIO_BASE_ADDR), | |
9d631b83 | 431 | .virtual_irq_start = MXC_GPIO_IRQ_START, |
bf50bcc2 | 432 | }, { |
fc80a5e3 | 433 | .chip.label = "gpio-1", |
58152a16 | 434 | .base = IO_ADDRESS(MX2x_GPIO_BASE_ADDR + 0x100), |
9d631b83 | 435 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32, |
bf50bcc2 | 436 | }, { |
fc80a5e3 | 437 | .chip.label = "gpio-2", |
58152a16 | 438 | .base = IO_ADDRESS(MX2x_GPIO_BASE_ADDR + 0x200), |
9d631b83 | 439 | .virtual_irq_start = MXC_GPIO_IRQ_START + 64, |
bf50bcc2 | 440 | }, { |
fc80a5e3 | 441 | .chip.label = "gpio-3", |
58152a16 | 442 | .base = IO_ADDRESS(MX2x_GPIO_BASE_ADDR + 0x300), |
9d631b83 | 443 | .virtual_irq_start = MXC_GPIO_IRQ_START + 96, |
bf50bcc2 | 444 | }, { |
fc80a5e3 | 445 | .chip.label = "gpio-4", |
58152a16 | 446 | .base = IO_ADDRESS(MX2x_GPIO_BASE_ADDR + 0x400), |
9d631b83 | 447 | .virtual_irq_start = MXC_GPIO_IRQ_START + 128, |
bf50bcc2 | 448 | }, { |
fc80a5e3 | 449 | .chip.label = "gpio-5", |
58152a16 | 450 | .base = IO_ADDRESS(MX2x_GPIO_BASE_ADDR + 0x500), |
9d631b83 | 451 | .virtual_irq_start = MXC_GPIO_IRQ_START + 160, |
fc80a5e3 JB |
452 | } |
453 | }; | |
454 | ||
455 | int __init mxc_register_gpios(void) | |
456 | { | |
457 | return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); | |
458 | } |