2 * Author: MontaVista Software, Inc.
5 * Based on the OMAP devices.c
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
12 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
13 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
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.
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,
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>
35 #include <mach/irqs.h>
36 #include <mach/hardware.h>
37 #include <mach/common.h>
43 * General Purpose Timer
48 /* We use gpt0 as system timer, so do not add a device for this one */
50 static struct resource timer1_resources
[] = {
52 .start
= GPT2_BASE_ADDR
,
53 .end
= GPT2_BASE_ADDR
+ 0x17,
54 .flags
= IORESOURCE_MEM
,
56 .start
= MXC_INT_GPT2
,
58 .flags
= IORESOURCE_IRQ
,
62 struct platform_device mxc_gpt1
= {
65 .num_resources
= ARRAY_SIZE(timer1_resources
),
66 .resource
= timer1_resources
,
69 static struct resource timer2_resources
[] = {
71 .start
= GPT3_BASE_ADDR
,
72 .end
= GPT3_BASE_ADDR
+ 0x17,
73 .flags
= IORESOURCE_MEM
,
75 .start
= MXC_INT_GPT3
,
77 .flags
= IORESOURCE_IRQ
,
81 struct platform_device mxc_gpt2
= {
84 .num_resources
= ARRAY_SIZE(timer2_resources
),
85 .resource
= timer2_resources
,
88 #ifdef CONFIG_MACH_MX27
89 static struct resource timer3_resources
[] = {
91 .start
= GPT4_BASE_ADDR
,
92 .end
= GPT4_BASE_ADDR
+ 0x17,
93 .flags
= IORESOURCE_MEM
,
95 .start
= MXC_INT_GPT4
,
97 .flags
= IORESOURCE_IRQ
,
101 struct platform_device mxc_gpt3
= {
104 .num_resources
= ARRAY_SIZE(timer3_resources
),
105 .resource
= timer3_resources
,
108 static struct resource timer4_resources
[] = {
110 .start
= GPT5_BASE_ADDR
,
111 .end
= GPT5_BASE_ADDR
+ 0x17,
112 .flags
= IORESOURCE_MEM
,
114 .start
= MXC_INT_GPT5
,
116 .flags
= IORESOURCE_IRQ
,
120 struct platform_device mxc_gpt4
= {
123 .num_resources
= ARRAY_SIZE(timer4_resources
),
124 .resource
= timer4_resources
,
127 static struct resource timer5_resources
[] = {
129 .start
= GPT6_BASE_ADDR
,
130 .end
= GPT6_BASE_ADDR
+ 0x17,
131 .flags
= IORESOURCE_MEM
,
133 .start
= MXC_INT_GPT6
,
135 .flags
= IORESOURCE_IRQ
,
139 struct platform_device mxc_gpt5
= {
142 .num_resources
= ARRAY_SIZE(timer5_resources
),
143 .resource
= timer5_resources
,
153 static struct resource mxc_wdt_resources
[] = {
155 .start
= WDOG_BASE_ADDR
,
156 .end
= WDOG_BASE_ADDR
+ 0x30,
157 .flags
= IORESOURCE_MEM
,
161 struct platform_device mxc_wdt
= {
164 .num_resources
= ARRAY_SIZE(mxc_wdt_resources
),
165 .resource
= mxc_wdt_resources
,
168 static struct resource mxc_w1_master_resources
[] = {
170 .start
= OWIRE_BASE_ADDR
,
171 .end
= OWIRE_BASE_ADDR
+ SZ_4K
- 1,
172 .flags
= IORESOURCE_MEM
,
176 struct platform_device mxc_w1_master_device
= {
179 .num_resources
= ARRAY_SIZE(mxc_w1_master_resources
),
180 .resource
= mxc_w1_master_resources
,
183 static struct resource mxc_nand_resources
[] = {
185 .start
= NFC_BASE_ADDR
,
186 .end
= NFC_BASE_ADDR
+ 0xfff,
187 .flags
= IORESOURCE_MEM
,
189 .start
= MXC_INT_NANDFC
,
190 .end
= MXC_INT_NANDFC
,
191 .flags
= IORESOURCE_IRQ
,
195 struct platform_device mxc_nand_device
= {
198 .num_resources
= ARRAY_SIZE(mxc_nand_resources
),
199 .resource
= mxc_nand_resources
,
204 * - i.MX1: the basic controller
205 * - i.MX21: to be checked
206 * - i.MX27: like i.MX1, with slightly variations
208 static struct resource mxc_fb
[] = {
210 .start
= LCDC_BASE_ADDR
,
211 .end
= LCDC_BASE_ADDR
+ 0xFFF,
212 .flags
= IORESOURCE_MEM
,
214 .start
= MXC_INT_LCDC
,
216 .flags
= IORESOURCE_IRQ
,
221 struct platform_device mxc_fb_device
= {
224 .num_resources
= ARRAY_SIZE(mxc_fb
),
227 .coherent_dma_mask
= 0xFFFFFFFF,
231 #ifdef CONFIG_MACH_MX27
232 static struct resource mxc_fec_resources
[] = {
234 .start
= FEC_BASE_ADDR
,
235 .end
= FEC_BASE_ADDR
+ 0xfff,
236 .flags
= IORESOURCE_MEM
,
238 .start
= MXC_INT_FEC
,
240 .flags
= IORESOURCE_IRQ
,
244 struct platform_device mxc_fec_device
= {
247 .num_resources
= ARRAY_SIZE(mxc_fec_resources
),
248 .resource
= mxc_fec_resources
,
252 static struct resource mxc_i2c_1_resources
[] = {
254 .start
= I2C_BASE_ADDR
,
255 .end
= I2C_BASE_ADDR
+ 0x0fff,
256 .flags
= IORESOURCE_MEM
,
258 .start
= MXC_INT_I2C
,
260 .flags
= IORESOURCE_IRQ
,
264 struct platform_device mxc_i2c_device0
= {
267 .num_resources
= ARRAY_SIZE(mxc_i2c_1_resources
),
268 .resource
= mxc_i2c_1_resources
,
271 #ifdef CONFIG_MACH_MX27
272 static struct resource mxc_i2c_2_resources
[] = {
274 .start
= I2C2_BASE_ADDR
,
275 .end
= I2C2_BASE_ADDR
+ 0x0fff,
276 .flags
= IORESOURCE_MEM
,
278 .start
= MXC_INT_I2C2
,
280 .flags
= IORESOURCE_IRQ
,
284 struct platform_device mxc_i2c_device1
= {
287 .num_resources
= ARRAY_SIZE(mxc_i2c_2_resources
),
288 .resource
= mxc_i2c_2_resources
,
292 static struct resource mxc_pwm_resources
[] = {
294 .start
= PWM_BASE_ADDR
,
295 .end
= PWM_BASE_ADDR
+ 0x0fff,
296 .flags
= IORESOURCE_MEM
,
298 .start
= MXC_INT_PWM
,
300 .flags
= IORESOURCE_IRQ
,
304 struct platform_device mxc_pwm_device
= {
307 .num_resources
= ARRAY_SIZE(mxc_pwm_resources
),
308 .resource
= mxc_pwm_resources
,
312 * Resource definition for the MXC SDHC
314 static struct resource mxc_sdhc1_resources
[] = {
316 .start
= SDHC1_BASE_ADDR
,
317 .end
= SDHC1_BASE_ADDR
+ SZ_4K
- 1,
318 .flags
= IORESOURCE_MEM
,
320 .start
= MXC_INT_SDHC1
,
321 .end
= MXC_INT_SDHC1
,
322 .flags
= IORESOURCE_IRQ
,
324 .start
= DMA_REQ_SDHC1
,
325 .end
= DMA_REQ_SDHC1
,
326 .flags
= IORESOURCE_DMA
,
330 static u64 mxc_sdhc1_dmamask
= 0xffffffffUL
;
332 struct platform_device mxc_sdhc_device0
= {
336 .dma_mask
= &mxc_sdhc1_dmamask
,
337 .coherent_dma_mask
= 0xffffffff,
339 .num_resources
= ARRAY_SIZE(mxc_sdhc1_resources
),
340 .resource
= mxc_sdhc1_resources
,
343 static struct resource mxc_sdhc2_resources
[] = {
345 .start
= SDHC2_BASE_ADDR
,
346 .end
= SDHC2_BASE_ADDR
+ SZ_4K
- 1,
347 .flags
= IORESOURCE_MEM
,
349 .start
= MXC_INT_SDHC2
,
350 .end
= MXC_INT_SDHC2
,
351 .flags
= IORESOURCE_IRQ
,
353 .start
= DMA_REQ_SDHC2
,
354 .end
= DMA_REQ_SDHC2
,
355 .flags
= IORESOURCE_DMA
,
359 static u64 mxc_sdhc2_dmamask
= 0xffffffffUL
;
361 struct platform_device mxc_sdhc_device1
= {
365 .dma_mask
= &mxc_sdhc2_dmamask
,
366 .coherent_dma_mask
= 0xffffffff,
368 .num_resources
= ARRAY_SIZE(mxc_sdhc2_resources
),
369 .resource
= mxc_sdhc2_resources
,
372 static struct resource otg_resources
[] = {
374 .start
= OTG_BASE_ADDR
,
375 .end
= OTG_BASE_ADDR
+ 0x1ff,
376 .flags
= IORESOURCE_MEM
,
378 .start
= MXC_INT_USB3
,
380 .flags
= IORESOURCE_IRQ
,
384 static u64 otg_dmamask
= 0xffffffffUL
;
386 /* OTG gadget device */
387 struct platform_device mxc_otg_udc_device
= {
388 .name
= "fsl-usb2-udc",
391 .dma_mask
= &otg_dmamask
,
392 .coherent_dma_mask
= 0xffffffffUL
,
394 .resource
= otg_resources
,
395 .num_resources
= ARRAY_SIZE(otg_resources
),
399 struct platform_device mxc_otg_host
= {
403 .coherent_dma_mask
= 0xffffffff,
404 .dma_mask
= &otg_dmamask
,
406 .resource
= otg_resources
,
407 .num_resources
= ARRAY_SIZE(otg_resources
),
412 static u64 usbh1_dmamask
= 0xffffffffUL
;
414 static struct resource mxc_usbh1_resources
[] = {
416 .start
= OTG_BASE_ADDR
+ 0x200,
417 .end
= OTG_BASE_ADDR
+ 0x3ff,
418 .flags
= IORESOURCE_MEM
,
420 .start
= MXC_INT_USB1
,
422 .flags
= IORESOURCE_IRQ
,
426 struct platform_device mxc_usbh1
= {
430 .coherent_dma_mask
= 0xffffffff,
431 .dma_mask
= &usbh1_dmamask
,
433 .resource
= mxc_usbh1_resources
,
434 .num_resources
= ARRAY_SIZE(mxc_usbh1_resources
),
438 static u64 usbh2_dmamask
= 0xffffffffUL
;
440 static struct resource mxc_usbh2_resources
[] = {
442 .start
= OTG_BASE_ADDR
+ 0x400,
443 .end
= OTG_BASE_ADDR
+ 0x5ff,
444 .flags
= IORESOURCE_MEM
,
446 .start
= MXC_INT_USB2
,
448 .flags
= IORESOURCE_IRQ
,
452 struct platform_device mxc_usbh2
= {
456 .coherent_dma_mask
= 0xffffffff,
457 .dma_mask
= &usbh2_dmamask
,
459 .resource
= mxc_usbh2_resources
,
460 .num_resources
= ARRAY_SIZE(mxc_usbh2_resources
),
464 /* GPIO port description */
465 static struct mxc_gpio_port imx_gpio_ports
[] = {
467 .chip
.label
= "gpio-0",
469 .base
= IO_ADDRESS(GPIO_BASE_ADDR
),
470 .virtual_irq_start
= MXC_GPIO_IRQ_START
,
472 .chip
.label
= "gpio-1",
473 .base
= IO_ADDRESS(GPIO_BASE_ADDR
+ 0x100),
474 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 32,
476 .chip
.label
= "gpio-2",
477 .base
= IO_ADDRESS(GPIO_BASE_ADDR
+ 0x200),
478 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 64,
480 .chip
.label
= "gpio-3",
481 .base
= IO_ADDRESS(GPIO_BASE_ADDR
+ 0x300),
482 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 96,
484 .chip
.label
= "gpio-4",
485 .base
= IO_ADDRESS(GPIO_BASE_ADDR
+ 0x400),
486 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 128,
488 .chip
.label
= "gpio-5",
489 .base
= IO_ADDRESS(GPIO_BASE_ADDR
+ 0x500),
490 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 160,
494 int __init
mxc_register_gpios(void)
496 return mxc_gpio_init(imx_gpio_ports
, ARRAY_SIZE(imx_gpio_ports
));