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>
7 #include <mach/pxa-regs.h>
9 #include <mach/pxafb.h>
11 #include <mach/irda.h>
13 #include <mach/ohci.h>
14 #include <mach/pxa27x_keypad.h>
15 #include <mach/pxa2xx_spi.h>
16 #include <mach/camera.h>
17 #include <mach/audio.h>
18 #include <mach/pxa3xx_nand.h>
23 void __init
pxa_register_device(struct platform_device
*dev
, void *data
)
27 dev
->dev
.platform_data
= data
;
29 ret
= platform_device_register(dev
);
31 dev_err(&dev
->dev
, "unable to register device: %d\n", ret
);
34 static struct resource pxamci_resources
[] = {
38 .flags
= IORESOURCE_MEM
,
43 .flags
= IORESOURCE_IRQ
,
48 .flags
= IORESOURCE_DMA
,
53 .flags
= IORESOURCE_DMA
,
57 static u64 pxamci_dmamask
= 0xffffffffUL
;
59 struct platform_device pxa_device_mci
= {
63 .dma_mask
= &pxamci_dmamask
,
64 .coherent_dma_mask
= 0xffffffff,
66 .num_resources
= ARRAY_SIZE(pxamci_resources
),
67 .resource
= pxamci_resources
,
70 void __init
pxa_set_mci_info(struct pxamci_platform_data
*info
)
72 pxa_register_device(&pxa_device_mci
, info
);
76 static struct pxa2xx_udc_mach_info pxa_udc_info
;
78 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
80 memcpy(&pxa_udc_info
, info
, sizeof *info
);
83 static struct resource pxa2xx_udc_resources
[] = {
87 .flags
= IORESOURCE_MEM
,
92 .flags
= IORESOURCE_IRQ
,
96 static u64 udc_dma_mask
= ~(u32
)0;
98 struct platform_device pxa25x_device_udc
= {
101 .resource
= pxa2xx_udc_resources
,
102 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
104 .platform_data
= &pxa_udc_info
,
105 .dma_mask
= &udc_dma_mask
,
109 struct platform_device pxa27x_device_udc
= {
110 .name
= "pxa27x-udc",
112 .resource
= pxa2xx_udc_resources
,
113 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
115 .platform_data
= &pxa_udc_info
,
116 .dma_mask
= &udc_dma_mask
,
120 static struct resource pxafb_resources
[] = {
124 .flags
= IORESOURCE_MEM
,
129 .flags
= IORESOURCE_IRQ
,
133 static u64 fb_dma_mask
= ~(u64
)0;
135 struct platform_device pxa_device_fb
= {
139 .dma_mask
= &fb_dma_mask
,
140 .coherent_dma_mask
= 0xffffffff,
142 .num_resources
= ARRAY_SIZE(pxafb_resources
),
143 .resource
= pxafb_resources
,
146 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
148 pxa_register_device(&pxa_device_fb
, info
);
151 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
153 pxa_device_fb
.dev
.parent
= parent_dev
;
156 static struct resource pxa_resource_ffuart
[] = {
160 .flags
= IORESOURCE_MEM
,
164 .flags
= IORESOURCE_IRQ
,
168 struct platform_device pxa_device_ffuart
= {
169 .name
= "pxa2xx-uart",
171 .resource
= pxa_resource_ffuart
,
172 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
175 static struct resource pxa_resource_btuart
[] = {
179 .flags
= IORESOURCE_MEM
,
183 .flags
= IORESOURCE_IRQ
,
187 struct platform_device pxa_device_btuart
= {
188 .name
= "pxa2xx-uart",
190 .resource
= pxa_resource_btuart
,
191 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
194 static struct resource pxa_resource_stuart
[] = {
198 .flags
= IORESOURCE_MEM
,
202 .flags
= IORESOURCE_IRQ
,
206 struct platform_device pxa_device_stuart
= {
207 .name
= "pxa2xx-uart",
209 .resource
= pxa_resource_stuart
,
210 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
213 static struct resource pxa_resource_hwuart
[] = {
217 .flags
= IORESOURCE_MEM
,
221 .flags
= IORESOURCE_IRQ
,
225 struct platform_device pxa_device_hwuart
= {
226 .name
= "pxa2xx-uart",
228 .resource
= pxa_resource_hwuart
,
229 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
232 static struct resource pxai2c_resources
[] = {
236 .flags
= IORESOURCE_MEM
,
240 .flags
= IORESOURCE_IRQ
,
244 struct platform_device pxa_device_i2c
= {
245 .name
= "pxa2xx-i2c",
247 .resource
= pxai2c_resources
,
248 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
251 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
253 pxa_register_device(&pxa_device_i2c
, info
);
257 static struct resource pxa27x_resources_i2c_power
[] = {
261 .flags
= IORESOURCE_MEM
,
265 .flags
= IORESOURCE_IRQ
,
269 struct platform_device pxa27x_device_i2c_power
= {
270 .name
= "pxa2xx-i2c",
272 .resource
= pxa27x_resources_i2c_power
,
273 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
278 static struct resource pxa3xx_resources_i2c_power
[] = {
282 .flags
= IORESOURCE_MEM
,
286 .flags
= IORESOURCE_IRQ
,
290 struct platform_device pxa3xx_device_i2c_power
= {
291 .name
= "pxa2xx-i2c",
293 .resource
= pxa3xx_resources_i2c_power
,
294 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
298 static struct resource pxai2s_resources
[] = {
302 .flags
= IORESOURCE_MEM
,
306 .flags
= IORESOURCE_IRQ
,
310 struct platform_device pxa_device_i2s
= {
311 .name
= "pxa2xx-i2s",
313 .resource
= pxai2s_resources
,
314 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
317 static u64 pxaficp_dmamask
= ~(u32
)0;
319 struct platform_device pxa_device_ficp
= {
323 .dma_mask
= &pxaficp_dmamask
,
324 .coherent_dma_mask
= 0xffffffff,
328 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
330 pxa_register_device(&pxa_device_ficp
, info
);
333 static struct resource pxa_rtc_resources
[] = {
336 .end
= 0x40900000 + 0x3b,
337 .flags
= IORESOURCE_MEM
,
342 .flags
= IORESOURCE_IRQ
,
345 .start
= IRQ_RTCAlrm
,
347 .flags
= IORESOURCE_IRQ
,
351 struct platform_device sa1100_device_rtc
= {
352 .name
= "sa1100-rtc",
356 struct platform_device pxa_device_rtc
= {
359 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
360 .resource
= pxa_rtc_resources
,
363 static struct resource pxa_ac97_resources
[] = {
366 .end
= 0x40500000 + 0xfff,
367 .flags
= IORESOURCE_MEM
,
372 .flags
= IORESOURCE_IRQ
,
376 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
378 struct platform_device pxa_device_ac97
= {
379 .name
= "pxa2xx-ac97",
382 .dma_mask
= &pxa_ac97_dmamask
,
383 .coherent_dma_mask
= 0xffffffff,
385 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
386 .resource
= pxa_ac97_resources
,
389 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
391 pxa_register_device(&pxa_device_ac97
, ops
);
396 static struct resource pxa25x_resource_pwm0
[] = {
400 .flags
= IORESOURCE_MEM
,
404 struct platform_device pxa25x_device_pwm0
= {
405 .name
= "pxa25x-pwm",
407 .resource
= pxa25x_resource_pwm0
,
408 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
411 static struct resource pxa25x_resource_pwm1
[] = {
415 .flags
= IORESOURCE_MEM
,
419 struct platform_device pxa25x_device_pwm1
= {
420 .name
= "pxa25x-pwm",
422 .resource
= pxa25x_resource_pwm1
,
423 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
426 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
428 static struct resource pxa25x_resource_ssp
[] = {
432 .flags
= IORESOURCE_MEM
,
437 .flags
= IORESOURCE_IRQ
,
443 .flags
= IORESOURCE_DMA
,
449 .flags
= IORESOURCE_DMA
,
453 struct platform_device pxa25x_device_ssp
= {
454 .name
= "pxa25x-ssp",
457 .dma_mask
= &pxa25x_ssp_dma_mask
,
458 .coherent_dma_mask
= DMA_BIT_MASK(32),
460 .resource
= pxa25x_resource_ssp
,
461 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
464 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
466 static struct resource pxa25x_resource_nssp
[] = {
470 .flags
= IORESOURCE_MEM
,
475 .flags
= IORESOURCE_IRQ
,
481 .flags
= IORESOURCE_DMA
,
487 .flags
= IORESOURCE_DMA
,
491 struct platform_device pxa25x_device_nssp
= {
492 .name
= "pxa25x-nssp",
495 .dma_mask
= &pxa25x_nssp_dma_mask
,
496 .coherent_dma_mask
= DMA_BIT_MASK(32),
498 .resource
= pxa25x_resource_nssp
,
499 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
502 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
504 static struct resource pxa25x_resource_assp
[] = {
508 .flags
= IORESOURCE_MEM
,
513 .flags
= IORESOURCE_IRQ
,
519 .flags
= IORESOURCE_DMA
,
525 .flags
= IORESOURCE_DMA
,
529 struct platform_device pxa25x_device_assp
= {
530 /* ASSP is basically equivalent to NSSP */
531 .name
= "pxa25x-nssp",
534 .dma_mask
= &pxa25x_assp_dma_mask
,
535 .coherent_dma_mask
= DMA_BIT_MASK(32),
537 .resource
= pxa25x_resource_assp
,
538 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
540 #endif /* CONFIG_PXA25x */
542 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
544 static struct resource pxa27x_resource_keypad
[] = {
548 .flags
= IORESOURCE_MEM
,
553 .flags
= IORESOURCE_IRQ
,
557 struct platform_device pxa27x_device_keypad
= {
558 .name
= "pxa27x-keypad",
560 .resource
= pxa27x_resource_keypad
,
561 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
564 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
566 pxa_register_device(&pxa27x_device_keypad
, info
);
569 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
571 static struct resource pxa27x_resource_ohci
[] = {
575 .flags
= IORESOURCE_MEM
,
580 .flags
= IORESOURCE_IRQ
,
584 struct platform_device pxa27x_device_ohci
= {
585 .name
= "pxa27x-ohci",
588 .dma_mask
= &pxa27x_ohci_dma_mask
,
589 .coherent_dma_mask
= DMA_BIT_MASK(32),
591 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
592 .resource
= pxa27x_resource_ohci
,
595 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
597 pxa_register_device(&pxa27x_device_ohci
, info
);
600 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
602 static struct resource pxa27x_resource_ssp1
[] = {
606 .flags
= IORESOURCE_MEM
,
611 .flags
= IORESOURCE_IRQ
,
617 .flags
= IORESOURCE_DMA
,
623 .flags
= IORESOURCE_DMA
,
627 struct platform_device pxa27x_device_ssp1
= {
628 .name
= "pxa27x-ssp",
631 .dma_mask
= &pxa27x_ssp1_dma_mask
,
632 .coherent_dma_mask
= DMA_BIT_MASK(32),
634 .resource
= pxa27x_resource_ssp1
,
635 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
638 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
640 static struct resource pxa27x_resource_ssp2
[] = {
644 .flags
= IORESOURCE_MEM
,
649 .flags
= IORESOURCE_IRQ
,
655 .flags
= IORESOURCE_DMA
,
661 .flags
= IORESOURCE_DMA
,
665 struct platform_device pxa27x_device_ssp2
= {
666 .name
= "pxa27x-ssp",
669 .dma_mask
= &pxa27x_ssp2_dma_mask
,
670 .coherent_dma_mask
= DMA_BIT_MASK(32),
672 .resource
= pxa27x_resource_ssp2
,
673 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
676 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
678 static struct resource pxa27x_resource_ssp3
[] = {
682 .flags
= IORESOURCE_MEM
,
687 .flags
= IORESOURCE_IRQ
,
693 .flags
= IORESOURCE_DMA
,
699 .flags
= IORESOURCE_DMA
,
703 struct platform_device pxa27x_device_ssp3
= {
704 .name
= "pxa27x-ssp",
707 .dma_mask
= &pxa27x_ssp3_dma_mask
,
708 .coherent_dma_mask
= DMA_BIT_MASK(32),
710 .resource
= pxa27x_resource_ssp3
,
711 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
714 static struct resource pxa27x_resource_pwm0
[] = {
718 .flags
= IORESOURCE_MEM
,
722 struct platform_device pxa27x_device_pwm0
= {
723 .name
= "pxa27x-pwm",
725 .resource
= pxa27x_resource_pwm0
,
726 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
729 static struct resource pxa27x_resource_pwm1
[] = {
733 .flags
= IORESOURCE_MEM
,
737 struct platform_device pxa27x_device_pwm1
= {
738 .name
= "pxa27x-pwm",
740 .resource
= pxa27x_resource_pwm1
,
741 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
744 static struct resource pxa27x_resource_camera
[] = {
748 .flags
= IORESOURCE_MEM
,
753 .flags
= IORESOURCE_IRQ
,
757 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
759 static struct platform_device pxa27x_device_camera
= {
760 .name
= "pxa27x-camera",
761 .id
= 0, /* This is used to put cameras on this interface */
763 .dma_mask
= &pxa27x_dma_mask_camera
,
764 .coherent_dma_mask
= 0xffffffff,
766 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
767 .resource
= pxa27x_resource_camera
,
770 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
772 pxa_register_device(&pxa27x_device_camera
, info
);
774 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
777 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
779 static struct resource pxa3xx_resource_ssp4
[] = {
783 .flags
= IORESOURCE_MEM
,
788 .flags
= IORESOURCE_IRQ
,
794 .flags
= IORESOURCE_DMA
,
800 .flags
= IORESOURCE_DMA
,
804 struct platform_device pxa3xx_device_ssp4
= {
805 /* PXA3xx SSP is basically equivalent to PXA27x */
806 .name
= "pxa27x-ssp",
809 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
810 .coherent_dma_mask
= DMA_BIT_MASK(32),
812 .resource
= pxa3xx_resource_ssp4
,
813 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
816 static struct resource pxa3xx_resources_mci2
[] = {
820 .flags
= IORESOURCE_MEM
,
825 .flags
= IORESOURCE_IRQ
,
830 .flags
= IORESOURCE_DMA
,
835 .flags
= IORESOURCE_DMA
,
839 struct platform_device pxa3xx_device_mci2
= {
840 .name
= "pxa2xx-mci",
843 .dma_mask
= &pxamci_dmamask
,
844 .coherent_dma_mask
= 0xffffffff,
846 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
847 .resource
= pxa3xx_resources_mci2
,
850 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
852 pxa_register_device(&pxa3xx_device_mci2
, info
);
855 static struct resource pxa3xx_resources_mci3
[] = {
859 .flags
= IORESOURCE_MEM
,
864 .flags
= IORESOURCE_IRQ
,
869 .flags
= IORESOURCE_DMA
,
874 .flags
= IORESOURCE_DMA
,
878 struct platform_device pxa3xx_device_mci3
= {
879 .name
= "pxa2xx-mci",
882 .dma_mask
= &pxamci_dmamask
,
883 .coherent_dma_mask
= 0xffffffff,
885 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
886 .resource
= pxa3xx_resources_mci3
,
889 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
891 pxa_register_device(&pxa3xx_device_mci3
, info
);
894 static struct resource pxa3xx_resources_nand
[] = {
898 .flags
= IORESOURCE_MEM
,
903 .flags
= IORESOURCE_IRQ
,
906 /* DRCMR for Data DMA */
909 .flags
= IORESOURCE_DMA
,
912 /* DRCMR for Command DMA */
915 .flags
= IORESOURCE_DMA
,
919 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
921 struct platform_device pxa3xx_device_nand
= {
922 .name
= "pxa3xx-nand",
925 .dma_mask
= &pxa3xx_nand_dma_mask
,
926 .coherent_dma_mask
= DMA_BIT_MASK(32),
928 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
929 .resource
= pxa3xx_resources_nand
,
932 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
934 pxa_register_device(&pxa3xx_device_nand
, info
);
936 #endif /* CONFIG_PXA3xx */
938 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
939 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
940 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
942 struct platform_device
*pd
;
944 pd
= platform_device_alloc("pxa2xx-spi", id
);
946 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
951 pd
->dev
.platform_data
= info
;
952 platform_device_add(pd
);