blob: 20655fb10a57cf8ef1717cc621785d856dc62805 [file] [log] [blame]
Juergen Beisertfc80a5e2008-07-05 10:02:57 +02001/*
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
Uwe Kleine-König07469492010-06-14 15:56:58 +020014 * 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>
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020017 *
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.
26 *
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,
30 * MA 02110-1301, USA.
31 */
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>
Martin Fuzzey3eb352c2009-11-21 12:14:54 +010037#include <linux/dma-mapping.h>
Uwe Kleine-Könige9ec2a12010-06-10 17:34:59 +020038#include <linux/serial.h>
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020039
Russell King80b02c12009-01-08 10:01:47 +000040#include <mach/irqs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/hardware.h>
Holger Schurig058b7a62009-01-26 16:34:51 +010042#include <mach/common.h>
Sascha Hauer1a02be02008-12-19 14:32:07 +010043#include <mach/mmc.h>
Holger Schurig058b7a62009-01-26 16:34:51 +010044
45#include "devices.h"
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020046
Uwe Kleine-König07469492010-06-14 15:56:58 +020047#if defined(CONFIG_ARCH_MX1)
Uwe Kleine-König07469492010-06-14 15:56:58 +020048/* GPIO port description */
49static struct mxc_gpio_port imx_gpio_ports[] = {
50 {
51 .chip.label = "gpio-0",
Uwe Kleine-Königcf3a6ab2010-10-25 15:54:58 +020052 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
Uwe Kleine-König07469492010-06-14 15:56:58 +020053 .irq = MX1_GPIO_INT_PORTA,
54 .virtual_irq_start = MXC_GPIO_IRQ_START,
55 }, {
56 .chip.label = "gpio-1",
Uwe Kleine-Königcf3a6ab2010-10-25 15:54:58 +020057 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
Uwe Kleine-König07469492010-06-14 15:56:58 +020058 .irq = MX1_GPIO_INT_PORTB,
59 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
60 }, {
61 .chip.label = "gpio-2",
Uwe Kleine-Königcf3a6ab2010-10-25 15:54:58 +020062 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
Uwe Kleine-König07469492010-06-14 15:56:58 +020063 .irq = MX1_GPIO_INT_PORTC,
64 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
65 }, {
66 .chip.label = "gpio-3",
Uwe Kleine-Königcf3a6ab2010-10-25 15:54:58 +020067 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
Uwe Kleine-König07469492010-06-14 15:56:58 +020068 .irq = MX1_GPIO_INT_PORTD,
69 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
70 }
71};
72
73int __init imx1_register_gpios(void)
74{
75 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
76}
77#endif
78
79#if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
Holger Schurige4813552009-01-26 16:34:56 +010080/*
81 * lcdc:
82 * - i.MX1: the basic controller
83 * - i.MX21: to be checked
84 * - i.MX27: like i.MX1, with slightly variations
85 */
86static struct resource mxc_fb[] = {
87 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +010088 .start = MX2x_LCDC_BASE_ADDR,
89 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
Holger Schurige4813552009-01-26 16:34:56 +010090 .flags = IORESOURCE_MEM,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020091 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +010092 .start = MX2x_INT_LCDC,
93 .end = MX2x_INT_LCDC,
Holger Schurige4813552009-01-26 16:34:56 +010094 .flags = IORESOURCE_IRQ,
95 }
96};
97
98/* mxc lcd driver */
99struct platform_device mxc_fb_device = {
100 .name = "imx-fb",
101 .id = 0,
102 .num_resources = ARRAY_SIZE(mxc_fb),
103 .resource = mxc_fb,
104 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100105 .coherent_dma_mask = DMA_BIT_MASK(32),
Holger Schurige4813552009-01-26 16:34:56 +0100106 },
107};
108
Sascha Hauer824b16e2009-01-16 15:17:46 +0100109static struct resource mxc_pwm_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200110 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100111 .start = MX2x_PWM_BASE_ADDR,
112 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
113 .flags = IORESOURCE_MEM,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200114 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100115 .start = MX2x_INT_PWM,
116 .end = MX2x_INT_PWM,
117 .flags = IORESOURCE_IRQ,
Sascha Hauer824b16e2009-01-16 15:17:46 +0100118 }
119};
120
121struct platform_device mxc_pwm_device = {
122 .name = "mxc_pwm",
123 .id = 0,
124 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200125 .resource = mxc_pwm_resources,
Sascha Hauer824b16e2009-01-16 15:17:46 +0100126};
127
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100128#define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
129 static struct resource mxc_sdhc_resources ## n[] = { \
130 { \
131 .start = baseaddr, \
132 .end = baseaddr + SZ_4K - 1, \
133 .flags = IORESOURCE_MEM, \
134 }, { \
135 .start = irq, \
136 .end = irq, \
137 .flags = IORESOURCE_IRQ, \
138 }, { \
139 .start = dmareq, \
140 .end = dmareq, \
141 .flags = IORESOURCE_DMA, \
142 }, \
143 }; \
144 \
Russell King988addf2010-03-08 20:21:04 +0000145 static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100146 \
147 struct platform_device mxc_sdhc_device ## n = { \
148 .name = "mxc-mmc", \
149 .id = n, \
150 .dev = { \
151 .dma_mask = &mxc_sdhc ## n ## _dmamask, \
Russell King988addf2010-03-08 20:21:04 +0000152 .coherent_dma_mask = DMA_BIT_MASK(32), \
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100153 }, \
154 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
155 .resource = mxc_sdhc_resources ## n, \
156 }
Sascha Hauer1a02be02008-12-19 14:32:07 +0100157
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100158DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
159DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
Sascha Hauer1a02be02008-12-19 14:32:07 +0100160
Sascha Hauerf6d2fa72009-08-13 10:02:30 +0200161#ifdef CONFIG_MACH_MX27
javier Martin627fb3b2009-07-15 15:26:21 +0200162static struct resource otg_resources[] = {
163 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100164 .start = MX27_USBOTG_BASE_ADDR,
165 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
166 .flags = IORESOURCE_MEM,
javier Martin627fb3b2009-07-15 15:26:21 +0200167 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100168 .start = MX27_INT_USB3,
169 .end = MX27_INT_USB3,
170 .flags = IORESOURCE_IRQ,
javier Martin627fb3b2009-07-15 15:26:21 +0200171 },
172};
173
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100174static u64 otg_dmamask = DMA_BIT_MASK(32);
javier Martin627fb3b2009-07-15 15:26:21 +0200175
176/* OTG gadget device */
177struct platform_device mxc_otg_udc_device = {
178 .name = "fsl-usb2-udc",
179 .id = -1,
180 .dev = {
181 .dma_mask = &otg_dmamask,
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100182 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200183 },
184 .resource = otg_resources,
185 .num_resources = ARRAY_SIZE(otg_resources),
186};
187
188/* OTG host */
189struct platform_device mxc_otg_host = {
190 .name = "mxc-ehci",
191 .id = 0,
192 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100193 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200194 .dma_mask = &otg_dmamask,
195 },
196 .resource = otg_resources,
197 .num_resources = ARRAY_SIZE(otg_resources),
198};
199
200/* USB host 1 */
201
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100202static u64 usbh1_dmamask = DMA_BIT_MASK(32);
javier Martin627fb3b2009-07-15 15:26:21 +0200203
204static struct resource mxc_usbh1_resources[] = {
205 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100206 .start = MX27_USBOTG_BASE_ADDR + 0x200,
207 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
javier Martin627fb3b2009-07-15 15:26:21 +0200208 .flags = IORESOURCE_MEM,
209 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100210 .start = MX27_INT_USB1,
211 .end = MX27_INT_USB1,
javier Martin627fb3b2009-07-15 15:26:21 +0200212 .flags = IORESOURCE_IRQ,
213 },
214};
215
216struct platform_device mxc_usbh1 = {
217 .name = "mxc-ehci",
218 .id = 1,
219 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100220 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200221 .dma_mask = &usbh1_dmamask,
222 },
223 .resource = mxc_usbh1_resources,
224 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
225};
226
227/* USB host 2 */
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100228static u64 usbh2_dmamask = DMA_BIT_MASK(32);
javier Martin627fb3b2009-07-15 15:26:21 +0200229
230static struct resource mxc_usbh2_resources[] = {
231 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100232 .start = MX27_USBOTG_BASE_ADDR + 0x400,
233 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
javier Martin627fb3b2009-07-15 15:26:21 +0200234 .flags = IORESOURCE_MEM,
235 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100236 .start = MX27_INT_USB2,
237 .end = MX27_INT_USB2,
javier Martin627fb3b2009-07-15 15:26:21 +0200238 .flags = IORESOURCE_IRQ,
239 },
240};
241
242struct platform_device mxc_usbh2 = {
243 .name = "mxc-ehci",
244 .id = 2,
245 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100246 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200247 .dma_mask = &usbh2_dmamask,
248 },
249 .resource = mxc_usbh2_resources,
250 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
251};
Sascha Hauerf6d2fa72009-08-13 10:02:30 +0200252#endif
javier Martin627fb3b2009-07-15 15:26:21 +0200253
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200254/* GPIO port description */
Uwe Kleine-König897359d52010-02-05 17:40:28 +0100255#define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
256 { \
257 .chip.label = "gpio-" #n, \
258 .irq = _irq, \
259 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
260 n * 0x100), \
261 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200262 }
Uwe Kleine-König897359d52010-02-05 17:40:28 +0100263
264#define DEFINE_MXC_GPIO_PORT(SOC, n) \
265 { \
266 .chip.label = "gpio-" #n, \
267 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
268 n * 0x100), \
269 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
270 }
271
272#define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
273 static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
274 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
275 DEFINE_MXC_GPIO_PORT(SOC, 1), \
276 DEFINE_MXC_GPIO_PORT(SOC, 2), \
277 DEFINE_MXC_GPIO_PORT(SOC, 3), \
278 DEFINE_MXC_GPIO_PORT(SOC, 4), \
279 DEFINE_MXC_GPIO_PORT(SOC, 5), \
280 }
281
282#ifdef CONFIG_MACH_MX21
283DEFINE_MXC_GPIO_PORTS(MX21, imx21);
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200284
285int __init imx21_register_gpios(void)
286{
287 return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
288}
Uwe Kleine-König897359d52010-02-05 17:40:28 +0100289#endif
290
291#ifdef CONFIG_MACH_MX27
292DEFINE_MXC_GPIO_PORTS(MX27, imx27);
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200293
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200294int __init imx27_register_gpios(void)
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200295{
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200296 return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200297}
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200298#endif
Martin Fuzzey4e0fa902009-11-21 12:14:58 +0100299
300#ifdef CONFIG_MACH_MX21
301static struct resource mx21_usbhc_resources[] = {
302 {
Wolfram Sange1695302010-05-15 11:25:35 +0100303 .start = MX21_USBOTG_BASE_ADDR,
304 .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
Martin Fuzzey4e0fa902009-11-21 12:14:58 +0100305 .flags = IORESOURCE_MEM,
306 },
307 {
Russell King988addf2010-03-08 20:21:04 +0000308 .start = MX21_INT_USBHOST,
309 .end = MX21_INT_USBHOST,
Martin Fuzzey4e0fa902009-11-21 12:14:58 +0100310 .flags = IORESOURCE_IRQ,
311 },
312};
313
314struct platform_device mx21_usbhc_device = {
315 .name = "imx21-hcd",
316 .id = 0,
317 .dev = {
318 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
319 .coherent_dma_mask = DMA_BIT_MASK(32),
320 },
321 .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
322 .resource = mx21_usbhc_resources,
323};
324#endif
325
Eric Bénard0896a9e2010-05-19 18:46:06 +0200326static struct resource imx_kpp_resources[] = {
327 {
328 .start = MX2x_KPP_BASE_ADDR,
329 .end = MX2x_KPP_BASE_ADDR + 0xf,
330 .flags = IORESOURCE_MEM
331 }, {
332 .start = MX2x_INT_KPP,
333 .end = MX2x_INT_KPP,
334 .flags = IORESOURCE_IRQ,
335 },
336};
337
338struct platform_device imx_kpp_device = {
339 .name = "imx-keypad",
340 .id = -1,
341 .num_resources = ARRAY_SIZE(imx_kpp_resources),
342 .resource = imx_kpp_resources,
343};
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200344
Uwe Kleine-König07469492010-06-14 15:56:58 +0200345#endif