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
14 * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
15 * Copyright (c) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
16 * Copyright (c) 2008 Darius Augulis <darius.augulis@teltonika.lt>
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
32 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/init.h>
35 #include <linux/platform_device.h>
36 #include <linux/gpio.h>
37 #include <linux/dma-mapping.h>
38 #include <linux/serial.h>
40 #include <mach/irqs.h>
41 #include <mach/hardware.h>
42 #include <mach/common.h>
47 #if defined(CONFIG_ARCH_MX1)
48 /* GPIO port description */
49 static struct mxc_gpio_port imx_gpio_ports
[] = {
51 .chip
.label
= "gpio-0",
52 .base
= MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR
),
53 .irq
= MX1_GPIO_INT_PORTA
,
54 .virtual_irq_start
= MXC_GPIO_IRQ_START
,
56 .chip
.label
= "gpio-1",
57 .base
= MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR
+ 0x100),
58 .irq
= MX1_GPIO_INT_PORTB
,
59 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 32,
61 .chip
.label
= "gpio-2",
62 .base
= MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR
+ 0x200),
63 .irq
= MX1_GPIO_INT_PORTC
,
64 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 64,
66 .chip
.label
= "gpio-3",
67 .base
= MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR
+ 0x300),
68 .irq
= MX1_GPIO_INT_PORTD
,
69 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 96,
73 int __init
imx1_register_gpios(void)
75 return mxc_gpio_init(imx_gpio_ports
, ARRAY_SIZE(imx_gpio_ports
));
79 #ifdef CONFIG_MACH_MX27
80 static struct resource otg_resources
[] = {
82 .start
= MX27_USB_OTG_BASE_ADDR
,
83 .end
= MX27_USB_OTG_BASE_ADDR
+ 0x1ff,
84 .flags
= IORESOURCE_MEM
,
86 .start
= MX27_INT_USB_OTG
,
87 .end
= MX27_INT_USB_OTG
,
88 .flags
= IORESOURCE_IRQ
,
92 static u64 otg_dmamask
= DMA_BIT_MASK(32);
94 /* OTG gadget device */
95 struct platform_device mxc_otg_udc_device
= {
96 .name
= "fsl-usb2-udc",
99 .dma_mask
= &otg_dmamask
,
100 .coherent_dma_mask
= DMA_BIT_MASK(32),
102 .resource
= otg_resources
,
103 .num_resources
= ARRAY_SIZE(otg_resources
),
107 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
108 /* GPIO port description */
109 #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
111 .chip.label = "gpio-" #n, \
113 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
115 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
118 #define DEFINE_MXC_GPIO_PORT(SOC, n) \
120 .chip.label = "gpio-" #n, \
121 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
123 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
126 #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
127 static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
128 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
129 DEFINE_MXC_GPIO_PORT(SOC, 1), \
130 DEFINE_MXC_GPIO_PORT(SOC, 2), \
131 DEFINE_MXC_GPIO_PORT(SOC, 3), \
132 DEFINE_MXC_GPIO_PORT(SOC, 4), \
133 DEFINE_MXC_GPIO_PORT(SOC, 5), \
136 #ifdef CONFIG_MACH_MX21
137 DEFINE_MXC_GPIO_PORTS(MX21
, imx21
);
139 int __init
imx21_register_gpios(void)
141 return mxc_gpio_init(imx21_gpio_ports
, ARRAY_SIZE(imx21_gpio_ports
));
145 #ifdef CONFIG_MACH_MX27
146 DEFINE_MXC_GPIO_PORTS(MX27
, imx27
);
148 int __init
imx27_register_gpios(void)
150 return mxc_gpio_init(imx27_gpio_ports
, ARRAY_SIZE(imx27_gpio_ports
));
154 #ifdef CONFIG_MACH_MX21
155 static struct resource mx21_usbhc_resources
[] = {
157 .start
= MX21_USBOTG_BASE_ADDR
,
158 .end
= MX21_USBOTG_BASE_ADDR
+ SZ_8K
- 1,
159 .flags
= IORESOURCE_MEM
,
162 .start
= MX21_INT_USBHOST
,
163 .end
= MX21_INT_USBHOST
,
164 .flags
= IORESOURCE_IRQ
,
168 struct platform_device mx21_usbhc_device
= {
172 .dma_mask
= &mx21_usbhc_device
.dev
.coherent_dma_mask
,
173 .coherent_dma_mask
= DMA_BIT_MASK(32),
175 .num_resources
= ARRAY_SIZE(mx21_usbhc_resources
),
176 .resource
= mx21_usbhc_resources
,
180 static struct resource imx_kpp_resources
[] = {
182 .start
= MX2x_KPP_BASE_ADDR
,
183 .end
= MX2x_KPP_BASE_ADDR
+ 0xf,
184 .flags
= IORESOURCE_MEM
186 .start
= MX2x_INT_KPP
,
188 .flags
= IORESOURCE_IRQ
,
192 struct platform_device imx_kpp_device
= {
193 .name
= "imx-keypad",
195 .num_resources
= ARRAY_SIZE(imx_kpp_resources
),
196 .resource
= imx_kpp_resources
,