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 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
80 /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
81 static struct resource mxc_wdt_resources[] = {
83 .start = MX2x_WDOG_BASE_ADDR,
84 .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
85 .flags = IORESOURCE_MEM,
89 struct platform_device mxc_wdt = {
92 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
93 .resource = mxc_wdt_resources,
98 * - i.MX1: the basic controller
99 * - i.MX21: to be checked
100 * - i.MX27: like i.MX1, with slightly variations
102 static struct resource mxc_fb[] = {
104 .start = MX2x_LCDC_BASE_ADDR,
105 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
106 .flags = IORESOURCE_MEM,
108 .start = MX2x_INT_LCDC,
109 .end = MX2x_INT_LCDC,
110 .flags = IORESOURCE_IRQ,
115 struct platform_device mxc_fb_device = {
118 .num_resources = ARRAY_SIZE(mxc_fb),
121 .coherent_dma_mask = DMA_BIT_MASK(32),
125 static struct resource mxc_pwm_resources[] = {
127 .start = MX2x_PWM_BASE_ADDR,
128 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
129 .flags = IORESOURCE_MEM,
131 .start = MX2x_INT_PWM,
133 .flags = IORESOURCE_IRQ,
137 struct platform_device mxc_pwm_device = {
140 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
141 .resource = mxc_pwm_resources,
144 #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
145 static struct resource mxc_sdhc_resources ## n[] = { \
148 .end = baseaddr + SZ_4K - 1, \
149 .flags = IORESOURCE_MEM, \
153 .flags = IORESOURCE_IRQ, \
157 .flags = IORESOURCE_DMA, \
161 static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
163 struct platform_device mxc_sdhc_device ## n = { \
167 .dma_mask = &mxc_sdhc ## n ## _dmamask, \
168 .coherent_dma_mask = DMA_BIT_MASK(32), \
170 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
171 .resource = mxc_sdhc_resources ## n, \
174 DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
175 DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
177 #ifdef CONFIG_MACH_MX27
178 static struct resource otg_resources[] = {
180 .start = MX27_USBOTG_BASE_ADDR,
181 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
182 .flags = IORESOURCE_MEM,
184 .start = MX27_INT_USB3,
185 .end = MX27_INT_USB3,
186 .flags = IORESOURCE_IRQ,
190 static u64 otg_dmamask = DMA_BIT_MASK(32);
192 /* OTG gadget device */
193 struct platform_device mxc_otg_udc_device = {
194 .name = "fsl-usb2-udc",
197 .dma_mask = &otg_dmamask,
198 .coherent_dma_mask = DMA_BIT_MASK(32),
200 .resource = otg_resources,
201 .num_resources = ARRAY_SIZE(otg_resources),
205 struct platform_device mxc_otg_host = {
209 .coherent_dma_mask = DMA_BIT_MASK(32),
210 .dma_mask = &otg_dmamask,
212 .resource = otg_resources,
213 .num_resources = ARRAY_SIZE(otg_resources),
218 static u64 usbh1_dmamask = DMA_BIT_MASK(32);
220 static struct resource mxc_usbh1_resources[] = {
222 .start = MX27_USBOTG_BASE_ADDR + 0x200,
223 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
224 .flags = IORESOURCE_MEM,
226 .start = MX27_INT_USB1,
227 .end = MX27_INT_USB1,
228 .flags = IORESOURCE_IRQ,
232 struct platform_device mxc_usbh1 = {
236 .coherent_dma_mask = DMA_BIT_MASK(32),
237 .dma_mask = &usbh1_dmamask,
239 .resource = mxc_usbh1_resources,
240 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
244 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
246 static struct resource mxc_usbh2_resources[] = {
248 .start = MX27_USBOTG_BASE_ADDR + 0x400,
249 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
250 .flags = IORESOURCE_MEM,
252 .start = MX27_INT_USB2,
253 .end = MX27_INT_USB2,
254 .flags = IORESOURCE_IRQ,
258 struct platform_device mxc_usbh2 = {
262 .coherent_dma_mask = DMA_BIT_MASK(32),
263 .dma_mask = &usbh2_dmamask,
265 .resource = mxc_usbh2_resources,
266 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
270 /* GPIO port description */
271 #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
273 .chip.label = "gpio-" #n, \
275 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
277 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
280 #define DEFINE_MXC_GPIO_PORT(SOC, n) \
282 .chip.label = "gpio-" #n, \
283 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
285 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
288 #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
289 static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
290 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
291 DEFINE_MXC_GPIO_PORT(SOC, 1), \
292 DEFINE_MXC_GPIO_PORT(SOC, 2), \
293 DEFINE_MXC_GPIO_PORT(SOC, 3), \
294 DEFINE_MXC_GPIO_PORT(SOC, 4), \
295 DEFINE_MXC_GPIO_PORT(SOC, 5), \
298 #ifdef CONFIG_MACH_MX21
299 DEFINE_MXC_GPIO_PORTS(MX21, imx21);
301 int __init imx21_register_gpios(void)
303 return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
307 #ifdef CONFIG_MACH_MX27
308 DEFINE_MXC_GPIO_PORTS(MX27, imx27);
310 int __init imx27_register_gpios(void)
312 return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
316 #ifdef CONFIG_MACH_MX21
317 static struct resource mx21_usbhc_resources[] = {
319 .start = MX21_USBOTG_BASE_ADDR,
320 .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
321 .flags = IORESOURCE_MEM,
324 .start = MX21_INT_USBHOST,
325 .end = MX21_INT_USBHOST,
326 .flags = IORESOURCE_IRQ,
330 struct platform_device mx21_usbhc_device = {
334 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
335 .coherent_dma_mask = DMA_BIT_MASK(32),
337 .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
338 .resource = mx21_usbhc_resources,
342 static struct resource imx_kpp_resources[] = {
344 .start = MX2x_KPP_BASE_ADDR,
345 .end = MX2x_KPP_BASE_ADDR + 0xf,
346 .flags = IORESOURCE_MEM
348 .start = MX2x_INT_KPP,
350 .flags = IORESOURCE_IRQ,
354 struct platform_device imx_kpp_device = {
355 .name = "imx-keypad",
357 .num_resources = ARRAY_SIZE(imx_kpp_resources),
358 .resource = imx_kpp_resources,