blob: d6c05b6eab359af09d97051bec813ccf67d8e61b [file] [log] [blame]
eric miao8f58de72007-12-19 17:14:02 +08001#include <linux/module.h>
2#include <linux/kernel.h>
3#include <linux/init.h>
4#include <linux/platform_device.h>
5#include <linux/dma-mapping.h>
6
7#include <asm/arch/gpio.h>
8#include <asm/arch/udc.h>
9#include <asm/arch/pxafb.h>
10#include <asm/arch/mmc.h>
11#include <asm/arch/irda.h>
12#include <asm/arch/i2c.h>
eric miaocd5604d2008-01-29 09:00:19 +080013#include <asm/arch/ohci.h>
eric miao37320982008-01-23 13:39:13 +080014#include <asm/arch/pxa27x_keypad.h>
Guennadi Liakhovetski3f3acef2008-04-11 22:19:45 +020015#include <asm/arch/camera.h>
eric miao8f58de72007-12-19 17:14:02 +080016
17#include "devices.h"
18
19void __init pxa_register_device(struct platform_device *dev, void *data)
20{
21 int ret;
22
23 dev->dev.platform_data = data;
24
25 ret = platform_device_register(dev);
26 if (ret)
27 dev_err(&dev->dev, "unable to register device: %d\n", ret);
28}
29
30static struct resource pxamci_resources[] = {
31 [0] = {
32 .start = 0x41100000,
33 .end = 0x41100fff,
34 .flags = IORESOURCE_MEM,
35 },
36 [1] = {
37 .start = IRQ_MMC,
38 .end = IRQ_MMC,
39 .flags = IORESOURCE_IRQ,
40 },
41 [2] = {
42 .start = 21,
43 .end = 21,
44 .flags = IORESOURCE_DMA,
45 },
46 [3] = {
47 .start = 22,
48 .end = 22,
49 .flags = IORESOURCE_DMA,
50 },
51};
52
53static u64 pxamci_dmamask = 0xffffffffUL;
54
55struct platform_device pxa_device_mci = {
56 .name = "pxa2xx-mci",
Bridge Wufafc9d32007-12-21 19:00:13 +080057 .id = 0,
eric miao8f58de72007-12-19 17:14:02 +080058 .dev = {
59 .dma_mask = &pxamci_dmamask,
60 .coherent_dma_mask = 0xffffffff,
61 },
62 .num_resources = ARRAY_SIZE(pxamci_resources),
63 .resource = pxamci_resources,
64};
65
66void __init pxa_set_mci_info(struct pxamci_platform_data *info)
67{
68 pxa_register_device(&pxa_device_mci, info);
69}
70
71
72static struct pxa2xx_udc_mach_info pxa_udc_info;
73
74void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
75{
76 memcpy(&pxa_udc_info, info, sizeof *info);
77}
78
79static struct resource pxa2xx_udc_resources[] = {
80 [0] = {
81 .start = 0x40600000,
82 .end = 0x4060ffff,
83 .flags = IORESOURCE_MEM,
84 },
85 [1] = {
86 .start = IRQ_USB,
87 .end = IRQ_USB,
88 .flags = IORESOURCE_IRQ,
89 },
90};
91
92static u64 udc_dma_mask = ~(u32)0;
93
94struct platform_device pxa_device_udc = {
95 .name = "pxa2xx-udc",
96 .id = -1,
97 .resource = pxa2xx_udc_resources,
98 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
99 .dev = {
100 .platform_data = &pxa_udc_info,
101 .dma_mask = &udc_dma_mask,
102 }
103};
104
105static struct resource pxafb_resources[] = {
106 [0] = {
107 .start = 0x44000000,
108 .end = 0x4400ffff,
109 .flags = IORESOURCE_MEM,
110 },
111 [1] = {
112 .start = IRQ_LCD,
113 .end = IRQ_LCD,
114 .flags = IORESOURCE_IRQ,
115 },
116};
117
118static u64 fb_dma_mask = ~(u64)0;
119
120struct platform_device pxa_device_fb = {
121 .name = "pxa2xx-fb",
122 .id = -1,
123 .dev = {
124 .dma_mask = &fb_dma_mask,
125 .coherent_dma_mask = 0xffffffff,
126 },
127 .num_resources = ARRAY_SIZE(pxafb_resources),
128 .resource = pxafb_resources,
129};
130
131void __init set_pxa_fb_info(struct pxafb_mach_info *info)
132{
133 pxa_register_device(&pxa_device_fb, info);
134}
135
136void __init set_pxa_fb_parent(struct device *parent_dev)
137{
138 pxa_device_fb.dev.parent = parent_dev;
139}
140
141static struct resource pxa_resource_ffuart[] = {
142 {
143 .start = __PREG(FFUART),
144 .end = __PREG(FFUART) + 35,
145 .flags = IORESOURCE_MEM,
146 }, {
147 .start = IRQ_FFUART,
148 .end = IRQ_FFUART,
149 .flags = IORESOURCE_IRQ,
150 }
151};
152
153struct platform_device pxa_device_ffuart= {
154 .name = "pxa2xx-uart",
155 .id = 0,
156 .resource = pxa_resource_ffuart,
157 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
158};
159
160static struct resource pxa_resource_btuart[] = {
161 {
162 .start = __PREG(BTUART),
163 .end = __PREG(BTUART) + 35,
164 .flags = IORESOURCE_MEM,
165 }, {
166 .start = IRQ_BTUART,
167 .end = IRQ_BTUART,
168 .flags = IORESOURCE_IRQ,
169 }
170};
171
172struct platform_device pxa_device_btuart = {
173 .name = "pxa2xx-uart",
174 .id = 1,
175 .resource = pxa_resource_btuart,
176 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
177};
178
179static struct resource pxa_resource_stuart[] = {
180 {
181 .start = __PREG(STUART),
182 .end = __PREG(STUART) + 35,
183 .flags = IORESOURCE_MEM,
184 }, {
185 .start = IRQ_STUART,
186 .end = IRQ_STUART,
187 .flags = IORESOURCE_IRQ,
188 }
189};
190
191struct platform_device pxa_device_stuart = {
192 .name = "pxa2xx-uart",
193 .id = 2,
194 .resource = pxa_resource_stuart,
195 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
196};
197
198static struct resource pxa_resource_hwuart[] = {
199 {
200 .start = __PREG(HWUART),
201 .end = __PREG(HWUART) + 47,
202 .flags = IORESOURCE_MEM,
203 }, {
204 .start = IRQ_HWUART,
205 .end = IRQ_HWUART,
206 .flags = IORESOURCE_IRQ,
207 }
208};
209
210struct platform_device pxa_device_hwuart = {
211 .name = "pxa2xx-uart",
212 .id = 3,
213 .resource = pxa_resource_hwuart,
214 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
215};
216
217static struct resource pxai2c_resources[] = {
218 {
219 .start = 0x40301680,
220 .end = 0x403016a3,
221 .flags = IORESOURCE_MEM,
222 }, {
223 .start = IRQ_I2C,
224 .end = IRQ_I2C,
225 .flags = IORESOURCE_IRQ,
226 },
227};
228
229struct platform_device pxa_device_i2c = {
230 .name = "pxa2xx-i2c",
231 .id = 0,
232 .resource = pxai2c_resources,
233 .num_resources = ARRAY_SIZE(pxai2c_resources),
234};
235
236void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
237{
238 pxa_register_device(&pxa_device_i2c, info);
239}
240
241static struct resource pxai2s_resources[] = {
242 {
243 .start = 0x40400000,
244 .end = 0x40400083,
245 .flags = IORESOURCE_MEM,
246 }, {
247 .start = IRQ_I2S,
248 .end = IRQ_I2S,
249 .flags = IORESOURCE_IRQ,
250 },
251};
252
253struct platform_device pxa_device_i2s = {
254 .name = "pxa2xx-i2s",
255 .id = -1,
256 .resource = pxai2s_resources,
257 .num_resources = ARRAY_SIZE(pxai2s_resources),
258};
259
260static u64 pxaficp_dmamask = ~(u32)0;
261
262struct platform_device pxa_device_ficp = {
263 .name = "pxa2xx-ir",
264 .id = -1,
265 .dev = {
266 .dma_mask = &pxaficp_dmamask,
267 .coherent_dma_mask = 0xffffffff,
268 },
269};
270
271void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
272{
273 pxa_register_device(&pxa_device_ficp, info);
274}
275
276struct platform_device pxa_device_rtc = {
277 .name = "sa1100-rtc",
278 .id = -1,
279};
280
281#ifdef CONFIG_PXA25x
282
283static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
284
285static struct resource pxa25x_resource_ssp[] = {
286 [0] = {
287 .start = 0x41000000,
288 .end = 0x4100001f,
289 .flags = IORESOURCE_MEM,
290 },
291 [1] = {
292 .start = IRQ_SSP,
293 .end = IRQ_SSP,
294 .flags = IORESOURCE_IRQ,
295 },
296 [2] = {
297 /* DRCMR for RX */
298 .start = 13,
299 .end = 13,
300 .flags = IORESOURCE_DMA,
301 },
302 [3] = {
303 /* DRCMR for TX */
304 .start = 14,
305 .end = 14,
306 .flags = IORESOURCE_DMA,
307 },
308};
309
310struct platform_device pxa25x_device_ssp = {
311 .name = "pxa25x-ssp",
312 .id = 0,
313 .dev = {
314 .dma_mask = &pxa25x_ssp_dma_mask,
315 .coherent_dma_mask = DMA_BIT_MASK(32),
316 },
317 .resource = pxa25x_resource_ssp,
318 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
319};
320
321static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
322
323static struct resource pxa25x_resource_nssp[] = {
324 [0] = {
325 .start = 0x41400000,
326 .end = 0x4140002f,
327 .flags = IORESOURCE_MEM,
328 },
329 [1] = {
330 .start = IRQ_NSSP,
331 .end = IRQ_NSSP,
332 .flags = IORESOURCE_IRQ,
333 },
334 [2] = {
335 /* DRCMR for RX */
336 .start = 15,
337 .end = 15,
338 .flags = IORESOURCE_DMA,
339 },
340 [3] = {
341 /* DRCMR for TX */
342 .start = 16,
343 .end = 16,
344 .flags = IORESOURCE_DMA,
345 },
346};
347
348struct platform_device pxa25x_device_nssp = {
349 .name = "pxa25x-nssp",
350 .id = 1,
351 .dev = {
352 .dma_mask = &pxa25x_nssp_dma_mask,
353 .coherent_dma_mask = DMA_BIT_MASK(32),
354 },
355 .resource = pxa25x_resource_nssp,
356 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
357};
358
359static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
360
361static struct resource pxa25x_resource_assp[] = {
362 [0] = {
363 .start = 0x41500000,
364 .end = 0x4150002f,
365 .flags = IORESOURCE_MEM,
366 },
367 [1] = {
368 .start = IRQ_ASSP,
369 .end = IRQ_ASSP,
370 .flags = IORESOURCE_IRQ,
371 },
372 [2] = {
373 /* DRCMR for RX */
374 .start = 23,
375 .end = 23,
376 .flags = IORESOURCE_DMA,
377 },
378 [3] = {
379 /* DRCMR for TX */
380 .start = 24,
381 .end = 24,
382 .flags = IORESOURCE_DMA,
383 },
384};
385
386struct platform_device pxa25x_device_assp = {
387 /* ASSP is basically equivalent to NSSP */
388 .name = "pxa25x-nssp",
389 .id = 2,
390 .dev = {
391 .dma_mask = &pxa25x_assp_dma_mask,
392 .coherent_dma_mask = DMA_BIT_MASK(32),
393 },
394 .resource = pxa25x_resource_assp,
395 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
396};
397#endif /* CONFIG_PXA25x */
398
399#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
400
eric miao37320982008-01-23 13:39:13 +0800401static struct resource pxa27x_resource_keypad[] = {
402 [0] = {
403 .start = 0x41500000,
404 .end = 0x4150004c,
405 .flags = IORESOURCE_MEM,
406 },
407 [1] = {
408 .start = IRQ_KEYPAD,
409 .end = IRQ_KEYPAD,
410 .flags = IORESOURCE_IRQ,
411 },
412};
413
414struct platform_device pxa27x_device_keypad = {
415 .name = "pxa27x-keypad",
416 .id = -1,
417 .resource = pxa27x_resource_keypad,
418 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
419};
420
421void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
422{
423 pxa_register_device(&pxa27x_device_keypad, info);
424}
425
eric miaoec68e452007-12-12 09:29:33 +0800426static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
427
428static struct resource pxa27x_resource_ohci[] = {
429 [0] = {
430 .start = 0x4C000000,
431 .end = 0x4C00ff6f,
432 .flags = IORESOURCE_MEM,
433 },
434 [1] = {
435 .start = IRQ_USBH1,
436 .end = IRQ_USBH1,
437 .flags = IORESOURCE_IRQ,
438 },
439};
440
441struct platform_device pxa27x_device_ohci = {
442 .name = "pxa27x-ohci",
443 .id = -1,
444 .dev = {
445 .dma_mask = &pxa27x_ohci_dma_mask,
446 .coherent_dma_mask = DMA_BIT_MASK(32),
447 },
448 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
449 .resource = pxa27x_resource_ohci,
450};
451
452void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
453{
454 pxa_register_device(&pxa27x_device_ohci, info);
455}
456
eric miao8f58de72007-12-19 17:14:02 +0800457static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
458
459static struct resource pxa27x_resource_ssp1[] = {
460 [0] = {
461 .start = 0x41000000,
462 .end = 0x4100003f,
463 .flags = IORESOURCE_MEM,
464 },
465 [1] = {
466 .start = IRQ_SSP,
467 .end = IRQ_SSP,
468 .flags = IORESOURCE_IRQ,
469 },
470 [2] = {
471 /* DRCMR for RX */
472 .start = 13,
473 .end = 13,
474 .flags = IORESOURCE_DMA,
475 },
476 [3] = {
477 /* DRCMR for TX */
478 .start = 14,
479 .end = 14,
480 .flags = IORESOURCE_DMA,
481 },
482};
483
484struct platform_device pxa27x_device_ssp1 = {
485 .name = "pxa27x-ssp",
486 .id = 0,
487 .dev = {
488 .dma_mask = &pxa27x_ssp1_dma_mask,
489 .coherent_dma_mask = DMA_BIT_MASK(32),
490 },
491 .resource = pxa27x_resource_ssp1,
492 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
493};
494
495static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
496
497static struct resource pxa27x_resource_ssp2[] = {
498 [0] = {
499 .start = 0x41700000,
500 .end = 0x4170003f,
501 .flags = IORESOURCE_MEM,
502 },
503 [1] = {
504 .start = IRQ_SSP2,
505 .end = IRQ_SSP2,
506 .flags = IORESOURCE_IRQ,
507 },
508 [2] = {
509 /* DRCMR for RX */
510 .start = 15,
511 .end = 15,
512 .flags = IORESOURCE_DMA,
513 },
514 [3] = {
515 /* DRCMR for TX */
516 .start = 16,
517 .end = 16,
518 .flags = IORESOURCE_DMA,
519 },
520};
521
522struct platform_device pxa27x_device_ssp2 = {
523 .name = "pxa27x-ssp",
524 .id = 1,
525 .dev = {
526 .dma_mask = &pxa27x_ssp2_dma_mask,
527 .coherent_dma_mask = DMA_BIT_MASK(32),
528 },
529 .resource = pxa27x_resource_ssp2,
530 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
531};
532
533static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
534
535static struct resource pxa27x_resource_ssp3[] = {
536 [0] = {
537 .start = 0x41900000,
538 .end = 0x4190003f,
539 .flags = IORESOURCE_MEM,
540 },
541 [1] = {
542 .start = IRQ_SSP3,
543 .end = IRQ_SSP3,
544 .flags = IORESOURCE_IRQ,
545 },
546 [2] = {
547 /* DRCMR for RX */
548 .start = 66,
549 .end = 66,
550 .flags = IORESOURCE_DMA,
551 },
552 [3] = {
553 /* DRCMR for TX */
554 .start = 67,
555 .end = 67,
556 .flags = IORESOURCE_DMA,
557 },
558};
559
560struct platform_device pxa27x_device_ssp3 = {
561 .name = "pxa27x-ssp",
562 .id = 2,
563 .dev = {
564 .dma_mask = &pxa27x_ssp3_dma_mask,
565 .coherent_dma_mask = DMA_BIT_MASK(32),
566 },
567 .resource = pxa27x_resource_ssp3,
568 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
569};
Guennadi Liakhovetski3f3acef2008-04-11 22:19:45 +0200570
571static struct resource pxa27x_resource_camera[] = {
572 [0] = {
573 .start = 0x50000000,
574 .end = 0x50000fff,
575 .flags = IORESOURCE_MEM,
576 },
577 [1] = {
578 .start = IRQ_CAMERA,
579 .end = IRQ_CAMERA,
580 .flags = IORESOURCE_IRQ,
581 },
582};
583
584static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
585
586static struct platform_device pxa27x_device_camera = {
587 .name = "pxa27x-camera",
588 .id = 0, /* This is used to put cameras on this interface */
589 .dev = {
590 .dma_mask = &pxa27x_dma_mask_camera,
591 .coherent_dma_mask = 0xffffffff,
592 },
593 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
594 .resource = pxa27x_resource_camera,
595};
596
597void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
598{
599 pxa_register_device(&pxa27x_device_camera, info);
600}
eric miao8f58de72007-12-19 17:14:02 +0800601#endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
602
603#ifdef CONFIG_PXA3xx
604static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
605
606static struct resource pxa3xx_resource_ssp4[] = {
607 [0] = {
608 .start = 0x41a00000,
609 .end = 0x41a0003f,
610 .flags = IORESOURCE_MEM,
611 },
612 [1] = {
613 .start = IRQ_SSP4,
614 .end = IRQ_SSP4,
615 .flags = IORESOURCE_IRQ,
616 },
617 [2] = {
618 /* DRCMR for RX */
619 .start = 2,
620 .end = 2,
621 .flags = IORESOURCE_DMA,
622 },
623 [3] = {
624 /* DRCMR for TX */
625 .start = 3,
626 .end = 3,
627 .flags = IORESOURCE_DMA,
628 },
629};
630
631struct platform_device pxa3xx_device_ssp4 = {
632 /* PXA3xx SSP is basically equivalent to PXA27x */
633 .name = "pxa27x-ssp",
634 .id = 3,
635 .dev = {
636 .dma_mask = &pxa3xx_ssp4_dma_mask,
637 .coherent_dma_mask = DMA_BIT_MASK(32),
638 },
639 .resource = pxa3xx_resource_ssp4,
640 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
641};
Bridge Wu8d33b052007-12-21 19:15:36 +0800642
643static struct resource pxa3xx_resources_mci2[] = {
644 [0] = {
645 .start = 0x42000000,
646 .end = 0x42000fff,
647 .flags = IORESOURCE_MEM,
648 },
649 [1] = {
650 .start = IRQ_MMC2,
651 .end = IRQ_MMC2,
652 .flags = IORESOURCE_IRQ,
653 },
654 [2] = {
655 .start = 93,
656 .end = 93,
657 .flags = IORESOURCE_DMA,
658 },
659 [3] = {
660 .start = 94,
661 .end = 94,
662 .flags = IORESOURCE_DMA,
663 },
664};
665
666struct platform_device pxa3xx_device_mci2 = {
667 .name = "pxa2xx-mci",
668 .id = 1,
669 .dev = {
670 .dma_mask = &pxamci_dmamask,
671 .coherent_dma_mask = 0xffffffff,
672 },
673 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
674 .resource = pxa3xx_resources_mci2,
675};
676
677void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
678{
679 pxa_register_device(&pxa3xx_device_mci2, info);
680}
681
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800682static struct resource pxa3xx_resources_mci3[] = {
683 [0] = {
684 .start = 0x42500000,
685 .end = 0x42500fff,
686 .flags = IORESOURCE_MEM,
687 },
688 [1] = {
689 .start = IRQ_MMC3,
690 .end = IRQ_MMC3,
691 .flags = IORESOURCE_IRQ,
692 },
693 [2] = {
694 .start = 100,
695 .end = 100,
696 .flags = IORESOURCE_DMA,
697 },
698 [3] = {
699 .start = 101,
700 .end = 101,
701 .flags = IORESOURCE_DMA,
702 },
703};
704
705struct platform_device pxa3xx_device_mci3 = {
706 .name = "pxa2xx-mci",
707 .id = 2,
708 .dev = {
709 .dma_mask = &pxamci_dmamask,
710 .coherent_dma_mask = 0xffffffff,
711 },
712 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
713 .resource = pxa3xx_resources_mci3,
714};
715
716void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
717{
718 pxa_register_device(&pxa3xx_device_mci3, info);
719}
720
eric miao8f58de72007-12-19 17:14:02 +0800721#endif /* CONFIG_PXA3xx */