]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - arch/arm/mach-mx25/devices.c
ARM: imx: dynamically register spi_imx devices (imx25)
[mirror_ubuntu-jammy-kernel.git] / arch / arm / mach-mx25 / devices.c
1 /*
2 * Copyright 2009 Sascha Hauer, <kernel@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19 #include <linux/platform_device.h>
20 #include <linux/dma-mapping.h>
21 #include <linux/gpio.h>
22 #include <mach/mx25.h>
23 #include <mach/irqs.h>
24
25 static struct resource uart0[] = {
26 {
27 .start = 0x43f90000,
28 .end = 0x43f93fff,
29 .flags = IORESOURCE_MEM,
30 }, {
31 .start = 45,
32 .end = 45,
33 .flags = IORESOURCE_IRQ,
34 },
35 };
36
37 struct platform_device mxc_uart_device0 = {
38 .name = "imx-uart",
39 .id = 0,
40 .resource = uart0,
41 .num_resources = ARRAY_SIZE(uart0),
42 };
43
44 static struct resource uart1[] = {
45 {
46 .start = 0x43f94000,
47 .end = 0x43f97fff,
48 .flags = IORESOURCE_MEM,
49 }, {
50 .start = 32,
51 .end = 32,
52 .flags = IORESOURCE_IRQ,
53 },
54 };
55
56 struct platform_device mxc_uart_device1 = {
57 .name = "imx-uart",
58 .id = 1,
59 .resource = uart1,
60 .num_resources = ARRAY_SIZE(uart1),
61 };
62
63 static struct resource uart2[] = {
64 {
65 .start = 0x5000c000,
66 .end = 0x5000ffff,
67 .flags = IORESOURCE_MEM,
68 }, {
69 .start = 18,
70 .end = 18,
71 .flags = IORESOURCE_IRQ,
72 },
73 };
74
75 struct platform_device mxc_uart_device2 = {
76 .name = "imx-uart",
77 .id = 2,
78 .resource = uart2,
79 .num_resources = ARRAY_SIZE(uart2),
80 };
81
82 static struct resource uart3[] = {
83 {
84 .start = 0x50008000,
85 .end = 0x5000bfff,
86 .flags = IORESOURCE_MEM,
87 }, {
88 .start = 5,
89 .end = 5,
90 .flags = IORESOURCE_IRQ,
91 },
92 };
93
94 struct platform_device mxc_uart_device3 = {
95 .name = "imx-uart",
96 .id = 3,
97 .resource = uart3,
98 .num_resources = ARRAY_SIZE(uart3),
99 };
100
101 static struct resource uart4[] = {
102 {
103 .start = 0x5002c000,
104 .end = 0x5002ffff,
105 .flags = IORESOURCE_MEM,
106 }, {
107 .start = 40,
108 .end = 40,
109 .flags = IORESOURCE_IRQ,
110 },
111 };
112
113 struct platform_device mxc_uart_device4 = {
114 .name = "imx-uart",
115 .id = 4,
116 .resource = uart4,
117 .num_resources = ARRAY_SIZE(uart4),
118 };
119
120 #define MX25_OTG_BASE_ADDR 0x53FF4000
121
122 static u64 otg_dmamask = DMA_BIT_MASK(32);
123
124 static struct resource mxc_otg_resources[] = {
125 {
126 .start = MX25_OTG_BASE_ADDR,
127 .end = MX25_OTG_BASE_ADDR + 0x1ff,
128 .flags = IORESOURCE_MEM,
129 }, {
130 .start = 37,
131 .end = 37,
132 .flags = IORESOURCE_IRQ,
133 },
134 };
135
136 struct platform_device mxc_otg = {
137 .name = "mxc-ehci",
138 .id = 0,
139 .dev = {
140 .coherent_dma_mask = 0xffffffff,
141 .dma_mask = &otg_dmamask,
142 },
143 .resource = mxc_otg_resources,
144 .num_resources = ARRAY_SIZE(mxc_otg_resources),
145 };
146
147 /* OTG gadget device */
148 struct platform_device otg_udc_device = {
149 .name = "fsl-usb2-udc",
150 .id = -1,
151 .dev = {
152 .dma_mask = &otg_dmamask,
153 .coherent_dma_mask = 0xffffffff,
154 },
155 .resource = mxc_otg_resources,
156 .num_resources = ARRAY_SIZE(mxc_otg_resources),
157 };
158
159 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
160
161 static struct resource mxc_usbh2_resources[] = {
162 {
163 .start = MX25_OTG_BASE_ADDR + 0x400,
164 .end = MX25_OTG_BASE_ADDR + 0x5ff,
165 .flags = IORESOURCE_MEM,
166 }, {
167 .start = 35,
168 .end = 35,
169 .flags = IORESOURCE_IRQ,
170 },
171 };
172
173 struct platform_device mxc_usbh2 = {
174 .name = "mxc-ehci",
175 .id = 1,
176 .dev = {
177 .coherent_dma_mask = 0xffffffff,
178 .dma_mask = &usbh2_dmamask,
179 },
180 .resource = mxc_usbh2_resources,
181 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
182 };
183
184 static struct resource mxc_pwm_resources0[] = {
185 {
186 .start = 0x53fe0000,
187 .end = 0x53fe3fff,
188 .flags = IORESOURCE_MEM,
189 }, {
190 .start = 26,
191 .end = 26,
192 .flags = IORESOURCE_IRQ,
193 }
194 };
195
196 struct platform_device mxc_pwm_device0 = {
197 .name = "mxc_pwm",
198 .id = 0,
199 .num_resources = ARRAY_SIZE(mxc_pwm_resources0),
200 .resource = mxc_pwm_resources0,
201 };
202
203 static struct resource mxc_pwm_resources1[] = {
204 {
205 .start = 0x53fa0000,
206 .end = 0x53fa3fff,
207 .flags = IORESOURCE_MEM,
208 }, {
209 .start = 36,
210 .end = 36,
211 .flags = IORESOURCE_IRQ,
212 }
213 };
214
215 struct platform_device mxc_pwm_device1 = {
216 .name = "mxc_pwm",
217 .id = 1,
218 .num_resources = ARRAY_SIZE(mxc_pwm_resources1),
219 .resource = mxc_pwm_resources1,
220 };
221
222 static struct resource mxc_pwm_resources2[] = {
223 {
224 .start = 0x53fa8000,
225 .end = 0x53fabfff,
226 .flags = IORESOURCE_MEM,
227 }, {
228 .start = 41,
229 .end = 41,
230 .flags = IORESOURCE_IRQ,
231 }
232 };
233
234 struct platform_device mxc_pwm_device2 = {
235 .name = "mxc_pwm",
236 .id = 2,
237 .num_resources = ARRAY_SIZE(mxc_pwm_resources2),
238 .resource = mxc_pwm_resources2,
239 };
240
241 static struct resource mxc_keypad_resources[] = {
242 {
243 .start = 0x43fa8000,
244 .end = 0x43fabfff,
245 .flags = IORESOURCE_MEM,
246 }, {
247 .start = 24,
248 .end = 24,
249 .flags = IORESOURCE_IRQ,
250 }
251 };
252
253 struct platform_device mxc_keypad_device = {
254 .name = "mxc-keypad",
255 .id = -1,
256 .num_resources = ARRAY_SIZE(mxc_keypad_resources),
257 .resource = mxc_keypad_resources,
258 };
259
260 static struct resource mxc_pwm_resources3[] = {
261 {
262 .start = 0x53fc8000,
263 .end = 0x53fcbfff,
264 .flags = IORESOURCE_MEM,
265 }, {
266 .start = 42,
267 .end = 42,
268 .flags = IORESOURCE_IRQ,
269 }
270 };
271
272 struct platform_device mxc_pwm_device3 = {
273 .name = "mxc_pwm",
274 .id = 3,
275 .num_resources = ARRAY_SIZE(mxc_pwm_resources3),
276 .resource = mxc_pwm_resources3,
277 };
278
279 static struct mxc_gpio_port imx_gpio_ports[] = {
280 {
281 .chip.label = "gpio-0",
282 .base = (void __iomem *)MX25_GPIO1_BASE_ADDR_VIRT,
283 .irq = 52,
284 .virtual_irq_start = MXC_GPIO_IRQ_START,
285 }, {
286 .chip.label = "gpio-1",
287 .base = (void __iomem *)MX25_GPIO2_BASE_ADDR_VIRT,
288 .irq = 51,
289 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
290 }, {
291 .chip.label = "gpio-2",
292 .base = (void __iomem *)MX25_GPIO3_BASE_ADDR_VIRT,
293 .irq = 16,
294 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
295 }, {
296 .chip.label = "gpio-3",
297 .base = (void __iomem *)MX25_GPIO4_BASE_ADDR_VIRT,
298 .irq = 23,
299 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
300 }
301 };
302
303 int __init imx25_register_gpios(void)
304 {
305 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
306 }
307
308 static struct resource mx25_fec_resources[] = {
309 {
310 .start = MX25_FEC_BASE_ADDR,
311 .end = MX25_FEC_BASE_ADDR + 0xfff,
312 .flags = IORESOURCE_MEM,
313 },
314 {
315 .start = MX25_INT_FEC,
316 .end = MX25_INT_FEC,
317 .flags = IORESOURCE_IRQ,
318 },
319 };
320
321 struct platform_device mx25_fec_device = {
322 .name = "fec",
323 .id = 0,
324 .num_resources = ARRAY_SIZE(mx25_fec_resources),
325 .resource = mx25_fec_resources,
326 };
327
328 static struct resource mx25_rtc_resources[] = {
329 {
330 .start = MX25_DRYICE_BASE_ADDR,
331 .end = MX25_DRYICE_BASE_ADDR + 0x40,
332 .flags = IORESOURCE_MEM,
333 },
334 {
335 .start = MX25_INT_DRYICE,
336 .flags = IORESOURCE_IRQ
337 },
338 };
339
340 struct platform_device mx25_rtc_device = {
341 .name = "imxdi_rtc",
342 .id = 0,
343 .num_resources = ARRAY_SIZE(mx25_rtc_resources),
344 .resource = mx25_rtc_resources,
345 };
346
347 static struct resource mx25_fb_resources[] = {
348 {
349 .start = MX25_LCDC_BASE_ADDR,
350 .end = MX25_LCDC_BASE_ADDR + 0xfff,
351 .flags = IORESOURCE_MEM,
352 },
353 {
354 .start = MX25_INT_LCDC,
355 .end = MX25_INT_LCDC,
356 .flags = IORESOURCE_IRQ,
357 },
358 };
359
360 struct platform_device mx25_fb_device = {
361 .name = "imx-fb",
362 .id = 0,
363 .resource = mx25_fb_resources,
364 .num_resources = ARRAY_SIZE(mx25_fb_resources),
365 .dev = {
366 .coherent_dma_mask = 0xFFFFFFFF,
367 },
368 };
369
370 static struct resource mxc_wdt_resources[] = {
371 {
372 .start = MX25_WDOG_BASE_ADDR,
373 .end = MX25_WDOG_BASE_ADDR + SZ_16K - 1,
374 .flags = IORESOURCE_MEM,
375 },
376 };
377
378 struct platform_device mxc_wdt = {
379 .name = "imx2-wdt",
380 .id = 0,
381 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
382 .resource = mxc_wdt_resources,
383 };