70b76d16391c8db9ea956a79c7034d67ddf9c7f4
[pandora-kernel.git] / arch / arm / mach-mx5 / devices.c
1 /*
2  * Copyright 2009 Amit Kucheria <amit.kucheria@canonical.com>
3  * Copyright (C) 2010 Freescale Semiconductor, Inc.
4  *
5  * The code contained herein is licensed under the GNU General Public
6  * License. You may obtain a copy of the GNU General Public License
7  * Version 2 or later at the following locations:
8  *
9  * http://www.opensource.org/licenses/gpl-license.html
10  * http://www.gnu.org/copyleft/gpl.html
11  */
12
13 #include <linux/platform_device.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/gpio.h>
16 #include <mach/hardware.h>
17 #include <mach/imx-uart.h>
18 #include <mach/irqs.h>
19
20 static struct resource uart0[] = {
21         {
22                 .start = MX51_UART1_BASE_ADDR,
23                 .end = MX51_UART1_BASE_ADDR + 0xfff,
24                 .flags = IORESOURCE_MEM,
25         }, {
26                 .start = MX51_MXC_INT_UART1,
27                 .end = MX51_MXC_INT_UART1,
28                 .flags = IORESOURCE_IRQ,
29         },
30 };
31
32 struct platform_device mxc_uart_device0 = {
33         .name = "imx-uart",
34         .id = 0,
35         .resource = uart0,
36         .num_resources = ARRAY_SIZE(uart0),
37 };
38
39 static struct resource uart1[] = {
40         {
41                 .start = MX51_UART2_BASE_ADDR,
42                 .end = MX51_UART2_BASE_ADDR + 0xfff,
43                 .flags = IORESOURCE_MEM,
44         }, {
45                 .start = MX51_MXC_INT_UART2,
46                 .end = MX51_MXC_INT_UART2,
47                 .flags = IORESOURCE_IRQ,
48         },
49 };
50
51 struct platform_device mxc_uart_device1 = {
52         .name = "imx-uart",
53         .id = 1,
54         .resource = uart1,
55         .num_resources = ARRAY_SIZE(uart1),
56 };
57
58 static struct resource uart2[] = {
59         {
60                 .start = MX51_UART3_BASE_ADDR,
61                 .end = MX51_UART3_BASE_ADDR + 0xfff,
62                 .flags = IORESOURCE_MEM,
63         }, {
64                 .start = MX51_MXC_INT_UART3,
65                 .end = MX51_MXC_INT_UART3,
66                 .flags = IORESOURCE_IRQ,
67         },
68 };
69
70 struct platform_device mxc_uart_device2 = {
71         .name = "imx-uart",
72         .id = 2,
73         .resource = uart2,
74         .num_resources = ARRAY_SIZE(uart2),
75 };
76
77 static struct resource mxc_fec_resources[] = {
78         {
79                 .start  = MX51_MXC_FEC_BASE_ADDR,
80                 .end    = MX51_MXC_FEC_BASE_ADDR + 0xfff,
81                 .flags  = IORESOURCE_MEM,
82         }, {
83                 .start  = MX51_MXC_INT_FEC,
84                 .end    = MX51_MXC_INT_FEC,
85                 .flags  = IORESOURCE_IRQ,
86         },
87 };
88
89 struct platform_device mxc_fec_device = {
90         .name = "fec",
91         .id = 0,
92         .num_resources = ARRAY_SIZE(mxc_fec_resources),
93         .resource = mxc_fec_resources,
94 };
95
96 static struct resource mxc_hsi2c_resources[] = {
97         {
98                 .start = MX51_HSI2C_DMA_BASE_ADDR,
99                 .end = MX51_HSI2C_DMA_BASE_ADDR + SZ_16K - 1,
100                 .flags = IORESOURCE_MEM,
101         },
102         {
103                 .start = MX51_MXC_INT_HS_I2C,
104                 .end = MX51_MXC_INT_HS_I2C,
105                 .flags = IORESOURCE_IRQ,
106         },
107 };
108
109 struct platform_device mxc_hsi2c_device = {
110         .name = "imx-i2c",
111         .id = 2,
112         .num_resources = ARRAY_SIZE(mxc_hsi2c_resources),
113         .resource = mxc_hsi2c_resources
114 };
115
116 static u64 usb_dma_mask = DMA_BIT_MASK(32);
117
118 static struct resource usbotg_resources[] = {
119         {
120                 .start = MX51_OTG_BASE_ADDR,
121                 .end = MX51_OTG_BASE_ADDR + 0x1ff,
122                 .flags = IORESOURCE_MEM,
123         },
124         {
125                 .start = MX51_MXC_INT_USB_OTG,
126                 .flags = IORESOURCE_IRQ,
127         },
128 };
129
130 /* OTG gadget device */
131 struct platform_device mxc_usbdr_udc_device = {
132         .name           = "fsl-usb2-udc",
133         .id             = -1,
134         .num_resources  = ARRAY_SIZE(usbotg_resources),
135         .resource       = usbotg_resources,
136         .dev            = {
137                 .dma_mask               = &usb_dma_mask,
138                 .coherent_dma_mask      = DMA_BIT_MASK(32),
139         },
140 };
141
142 struct platform_device mxc_usbdr_host_device = {
143         .name = "mxc-ehci",
144         .id = 0,
145         .num_resources = ARRAY_SIZE(usbotg_resources),
146         .resource = usbotg_resources,
147         .dev = {
148                 .dma_mask = &usb_dma_mask,
149                 .coherent_dma_mask = DMA_BIT_MASK(32),
150         },
151 };
152
153 static struct resource usbh1_resources[] = {
154         {
155                 .start = MX51_OTG_BASE_ADDR + 0x200,
156                 .end = MX51_OTG_BASE_ADDR + 0x200 + 0x1ff,
157                 .flags = IORESOURCE_MEM,
158         },
159         {
160                 .start = MX51_MXC_INT_USB_H1,
161                 .flags = IORESOURCE_IRQ,
162         },
163 };
164
165 struct platform_device mxc_usbh1_device = {
166         .name = "mxc-ehci",
167         .id = 1,
168         .num_resources = ARRAY_SIZE(usbh1_resources),
169         .resource = usbh1_resources,
170         .dev = {
171                 .dma_mask = &usb_dma_mask,
172                 .coherent_dma_mask = DMA_BIT_MASK(32),
173         },
174 };
175
176 static struct resource mxc_wdt_resources[] = {
177         {
178                 .start = MX51_WDOG_BASE_ADDR,
179                 .end = MX51_WDOG_BASE_ADDR + SZ_16K - 1,
180                 .flags = IORESOURCE_MEM,
181         },
182 };
183
184 struct platform_device mxc_wdt = {
185         .name = "imx2-wdt",
186         .id = 0,
187         .num_resources = ARRAY_SIZE(mxc_wdt_resources),
188         .resource = mxc_wdt_resources,
189 };
190
191 static struct resource mxc_kpp_resources[] = {
192         {
193                 .start = MX51_MXC_INT_KPP,
194                 .end = MX51_MXC_INT_KPP,
195                 .flags = IORESOURCE_IRQ,
196         } , {
197                 .start = MX51_KPP_BASE_ADDR,
198                 .end = MX51_KPP_BASE_ADDR + 0x8 - 1,
199                 .flags = IORESOURCE_MEM,
200         },
201 };
202
203 struct platform_device mxc_keypad_device = {
204         .name = "imx-keypad",
205         .id = 0,
206         .num_resources = ARRAY_SIZE(mxc_kpp_resources),
207         .resource = mxc_kpp_resources,
208 };
209
210 static struct mxc_gpio_port mxc_gpio_ports[] = {
211         {
212                 .chip.label = "gpio-0",
213                 .base = MX51_IO_ADDRESS(MX51_GPIO1_BASE_ADDR),
214                 .irq = MX51_MXC_INT_GPIO1_LOW,
215                 .irq_high = MX51_MXC_INT_GPIO1_HIGH,
216                 .virtual_irq_start = MXC_GPIO_IRQ_START
217         },
218         {
219                 .chip.label = "gpio-1",
220                 .base = MX51_IO_ADDRESS(MX51_GPIO2_BASE_ADDR),
221                 .irq = MX51_MXC_INT_GPIO2_LOW,
222                 .irq_high = MX51_MXC_INT_GPIO2_HIGH,
223                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 1
224         },
225         {
226                 .chip.label = "gpio-2",
227                 .base = MX51_IO_ADDRESS(MX51_GPIO3_BASE_ADDR),
228                 .irq = MX51_MXC_INT_GPIO3_LOW,
229                 .irq_high = MX51_MXC_INT_GPIO3_HIGH,
230                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 2
231         },
232         {
233                 .chip.label = "gpio-3",
234                 .base = MX51_IO_ADDRESS(MX51_GPIO4_BASE_ADDR),
235                 .irq = MX51_MXC_INT_GPIO4_LOW,
236                 .irq_high = MX51_MXC_INT_GPIO4_HIGH,
237                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 3
238         },
239 };
240
241 int __init imx51_register_gpios(void)
242 {
243         return mxc_gpio_init(mxc_gpio_ports, ARRAY_SIZE(mxc_gpio_ports));
244 }