Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / arch / arm / mach-pxa / devices.c
1 #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>
13 #include <asm/arch/ohci.h>
14 #include <asm/arch/pxa27x_keypad.h>
15 #include <asm/arch/camera.h>
16
17 #include "devices.h"
18
19 void __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
30 static 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
53 static u64 pxamci_dmamask = 0xffffffffUL;
54
55 struct platform_device pxa_device_mci = {
56         .name           = "pxa2xx-mci",
57         .id             = 0,
58         .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
66 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
67 {
68         pxa_register_device(&pxa_device_mci, info);
69 }
70
71
72 static struct pxa2xx_udc_mach_info pxa_udc_info;
73
74 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
75 {
76         memcpy(&pxa_udc_info, info, sizeof *info);
77 }
78
79 static 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
92 static u64 udc_dma_mask = ~(u32)0;
93
94 struct 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
105 static 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
118 static u64 fb_dma_mask = ~(u64)0;
119
120 struct 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
131 void __init set_pxa_fb_info(struct pxafb_mach_info *info)
132 {
133         pxa_register_device(&pxa_device_fb, info);
134 }
135
136 void __init set_pxa_fb_parent(struct device *parent_dev)
137 {
138         pxa_device_fb.dev.parent = parent_dev;
139 }
140
141 static 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
153 struct 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
160 static 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
172 struct 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
179 static 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
191 struct 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
198 static 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
210 struct 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
217 static 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
229 struct 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
236 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
237 {
238         pxa_register_device(&pxa_device_i2c, info);
239 }
240
241 static 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
253 struct 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
260 static u64 pxaficp_dmamask = ~(u32)0;
261
262 struct 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
271 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
272 {
273         pxa_register_device(&pxa_device_ficp, info);
274 }
275
276 struct platform_device pxa_device_rtc = {
277         .name           = "sa1100-rtc",
278         .id             = -1,
279 };
280
281 #ifdef CONFIG_PXA25x
282
283 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
284
285 static 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
310 struct 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
321 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
322
323 static 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
348 struct 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
359 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
360
361 static 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
386 struct 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
401 static 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
414 struct 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
421 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
422 {
423         pxa_register_device(&pxa27x_device_keypad, info);
424 }
425
426 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
427
428 static 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
441 struct 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
452 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
453 {
454         pxa_register_device(&pxa27x_device_ohci, info);
455 }
456
457 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
458
459 static 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
484 struct 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
495 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
496
497 static 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
522 struct 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
533 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
534
535 static 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
560 struct 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 };
570
571 static 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
584 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
585
586 static 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
597 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
598 {
599         pxa_register_device(&pxa27x_device_camera, info);
600 }
601 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
602
603 #ifdef CONFIG_PXA3xx
604 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
605
606 static 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
631 struct 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 };
642
643 static 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
666 struct 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
677 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
678 {
679         pxa_register_device(&pxa3xx_device_mci2, info);
680 }
681
682 static 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
705 struct 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
716 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
717 {
718         pxa_register_device(&pxa3xx_device_mci3, info);
719 }
720
721 #endif /* CONFIG_PXA3xx */