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 #include <linux/spi/pxa2xx_spi.h>
10 #include <mach/pxa3xx-u2d.h>
11 #include <mach/pxafb.h>
13 #include <mach/irda.h>
14 #include <mach/ohci.h>
15 #include <plat/pxa27x_keypad.h>
16 #include <mach/camera.h>
17 #include <mach/audio.h>
18 #include <mach/hardware.h>
20 #include <plat/pxa3xx_nand.h>
25 void __init
pxa_register_device(struct platform_device
*dev
, void *data
)
29 dev
->dev
.platform_data
= data
;
31 ret
= platform_device_register(dev
);
33 dev_err(&dev
->dev
, "unable to register device: %d\n", ret
);
36 static struct resource pxa_resource_pmu
= {
39 .flags
= IORESOURCE_IRQ
,
42 struct platform_device pxa_device_pmu
= {
44 .id
= ARM_PMU_DEVICE_CPU
,
45 .resource
= &pxa_resource_pmu
,
49 static struct resource pxamci_resources
[] = {
53 .flags
= IORESOURCE_MEM
,
58 .flags
= IORESOURCE_IRQ
,
63 .flags
= IORESOURCE_DMA
,
68 .flags
= IORESOURCE_DMA
,
72 static u64 pxamci_dmamask
= 0xffffffffUL
;
74 struct platform_device pxa_device_mci
= {
78 .dma_mask
= &pxamci_dmamask
,
79 .coherent_dma_mask
= 0xffffffff,
81 .num_resources
= ARRAY_SIZE(pxamci_resources
),
82 .resource
= pxamci_resources
,
85 void __init
pxa_set_mci_info(struct pxamci_platform_data
*info
)
87 pxa_register_device(&pxa_device_mci
, info
);
91 static struct pxa2xx_udc_mach_info pxa_udc_info
= {
96 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
98 memcpy(&pxa_udc_info
, info
, sizeof *info
);
101 static struct resource pxa2xx_udc_resources
[] = {
105 .flags
= IORESOURCE_MEM
,
110 .flags
= IORESOURCE_IRQ
,
114 static u64 udc_dma_mask
= ~(u32
)0;
116 struct platform_device pxa25x_device_udc
= {
117 .name
= "pxa25x-udc",
119 .resource
= pxa2xx_udc_resources
,
120 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
122 .platform_data
= &pxa_udc_info
,
123 .dma_mask
= &udc_dma_mask
,
127 struct platform_device pxa27x_device_udc
= {
128 .name
= "pxa27x-udc",
130 .resource
= pxa2xx_udc_resources
,
131 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
133 .platform_data
= &pxa_udc_info
,
134 .dma_mask
= &udc_dma_mask
,
139 static struct resource pxa3xx_u2d_resources
[] = {
143 .flags
= IORESOURCE_MEM
,
148 .flags
= IORESOURCE_IRQ
,
152 struct platform_device pxa3xx_device_u2d
= {
153 .name
= "pxa3xx-u2d",
155 .resource
= pxa3xx_u2d_resources
,
156 .num_resources
= ARRAY_SIZE(pxa3xx_u2d_resources
),
159 void __init
pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data
*info
)
161 pxa_register_device(&pxa3xx_device_u2d
, info
);
163 #endif /* CONFIG_PXA3xx */
165 static struct resource pxafb_resources
[] = {
169 .flags
= IORESOURCE_MEM
,
174 .flags
= IORESOURCE_IRQ
,
178 static u64 fb_dma_mask
= ~(u64
)0;
180 struct platform_device pxa_device_fb
= {
184 .dma_mask
= &fb_dma_mask
,
185 .coherent_dma_mask
= 0xffffffff,
187 .num_resources
= ARRAY_SIZE(pxafb_resources
),
188 .resource
= pxafb_resources
,
191 void __init
pxa_set_fb_info(struct device
*parent
, struct pxafb_mach_info
*info
)
193 pxa_device_fb
.dev
.parent
= parent
;
194 pxa_register_device(&pxa_device_fb
, info
);
197 static struct resource pxa_resource_ffuart
[] = {
201 .flags
= IORESOURCE_MEM
,
205 .flags
= IORESOURCE_IRQ
,
209 struct platform_device pxa_device_ffuart
= {
210 .name
= "pxa2xx-uart",
212 .resource
= pxa_resource_ffuart
,
213 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
216 void __init
pxa_set_ffuart_info(void *info
)
218 pxa_register_device(&pxa_device_ffuart
, info
);
221 static struct resource pxa_resource_btuart
[] = {
225 .flags
= IORESOURCE_MEM
,
229 .flags
= IORESOURCE_IRQ
,
233 struct platform_device pxa_device_btuart
= {
234 .name
= "pxa2xx-uart",
236 .resource
= pxa_resource_btuart
,
237 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
240 void __init
pxa_set_btuart_info(void *info
)
242 pxa_register_device(&pxa_device_btuart
, info
);
245 static struct resource pxa_resource_stuart
[] = {
249 .flags
= IORESOURCE_MEM
,
253 .flags
= IORESOURCE_IRQ
,
257 struct platform_device pxa_device_stuart
= {
258 .name
= "pxa2xx-uart",
260 .resource
= pxa_resource_stuart
,
261 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
264 void __init
pxa_set_stuart_info(void *info
)
266 pxa_register_device(&pxa_device_stuart
, info
);
269 static struct resource pxa_resource_hwuart
[] = {
273 .flags
= IORESOURCE_MEM
,
277 .flags
= IORESOURCE_IRQ
,
281 struct platform_device pxa_device_hwuart
= {
282 .name
= "pxa2xx-uart",
284 .resource
= pxa_resource_hwuart
,
285 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
288 void __init
pxa_set_hwuart_info(void *info
)
291 pxa_register_device(&pxa_device_hwuart
, info
);
293 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
296 static struct resource pxai2c_resources
[] = {
300 .flags
= IORESOURCE_MEM
,
304 .flags
= IORESOURCE_IRQ
,
308 struct platform_device pxa_device_i2c
= {
309 .name
= "pxa2xx-i2c",
311 .resource
= pxai2c_resources
,
312 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
315 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
317 pxa_register_device(&pxa_device_i2c
, info
);
321 static struct resource pxa27x_resources_i2c_power
[] = {
325 .flags
= IORESOURCE_MEM
,
329 .flags
= IORESOURCE_IRQ
,
333 struct platform_device pxa27x_device_i2c_power
= {
334 .name
= "pxa2xx-i2c",
336 .resource
= pxa27x_resources_i2c_power
,
337 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
341 static struct resource pxai2s_resources
[] = {
345 .flags
= IORESOURCE_MEM
,
349 .flags
= IORESOURCE_IRQ
,
353 struct platform_device pxa_device_i2s
= {
354 .name
= "pxa2xx-i2s",
356 .resource
= pxai2s_resources
,
357 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
360 struct platform_device pxa_device_asoc_ssp1
= {
361 .name
= "pxa-ssp-dai",
365 struct platform_device pxa_device_asoc_ssp2
= {
366 .name
= "pxa-ssp-dai",
370 struct platform_device pxa_device_asoc_ssp3
= {
371 .name
= "pxa-ssp-dai",
375 struct platform_device pxa_device_asoc_ssp4
= {
376 .name
= "pxa-ssp-dai",
380 struct platform_device pxa_device_asoc_platform
= {
381 .name
= "pxa-pcm-audio",
385 static u64 pxaficp_dmamask
= ~(u32
)0;
387 struct platform_device pxa_device_ficp
= {
391 .dma_mask
= &pxaficp_dmamask
,
392 .coherent_dma_mask
= 0xffffffff,
396 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
398 pxa_register_device(&pxa_device_ficp
, info
);
401 static struct resource pxa_rtc_resources
[] = {
404 .end
= 0x40900000 + 0x3b,
405 .flags
= IORESOURCE_MEM
,
410 .flags
= IORESOURCE_IRQ
,
413 .start
= IRQ_RTCAlrm
,
415 .flags
= IORESOURCE_IRQ
,
419 struct platform_device sa1100_device_rtc
= {
420 .name
= "sa1100-rtc",
424 struct platform_device pxa_device_rtc
= {
427 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
428 .resource
= pxa_rtc_resources
,
431 static struct resource pxa_ac97_resources
[] = {
434 .end
= 0x40500000 + 0xfff,
435 .flags
= IORESOURCE_MEM
,
440 .flags
= IORESOURCE_IRQ
,
444 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
446 struct platform_device pxa_device_ac97
= {
447 .name
= "pxa2xx-ac97",
450 .dma_mask
= &pxa_ac97_dmamask
,
451 .coherent_dma_mask
= 0xffffffff,
453 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
454 .resource
= pxa_ac97_resources
,
457 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
459 pxa_register_device(&pxa_device_ac97
, ops
);
464 static struct resource pxa25x_resource_pwm0
[] = {
468 .flags
= IORESOURCE_MEM
,
472 struct platform_device pxa25x_device_pwm0
= {
473 .name
= "pxa25x-pwm",
475 .resource
= pxa25x_resource_pwm0
,
476 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
479 static struct resource pxa25x_resource_pwm1
[] = {
483 .flags
= IORESOURCE_MEM
,
487 struct platform_device pxa25x_device_pwm1
= {
488 .name
= "pxa25x-pwm",
490 .resource
= pxa25x_resource_pwm1
,
491 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
494 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
496 static struct resource pxa25x_resource_ssp
[] = {
500 .flags
= IORESOURCE_MEM
,
505 .flags
= IORESOURCE_IRQ
,
511 .flags
= IORESOURCE_DMA
,
517 .flags
= IORESOURCE_DMA
,
521 struct platform_device pxa25x_device_ssp
= {
522 .name
= "pxa25x-ssp",
525 .dma_mask
= &pxa25x_ssp_dma_mask
,
526 .coherent_dma_mask
= DMA_BIT_MASK(32),
528 .resource
= pxa25x_resource_ssp
,
529 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
532 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
534 static struct resource pxa25x_resource_nssp
[] = {
538 .flags
= IORESOURCE_MEM
,
543 .flags
= IORESOURCE_IRQ
,
549 .flags
= IORESOURCE_DMA
,
555 .flags
= IORESOURCE_DMA
,
559 struct platform_device pxa25x_device_nssp
= {
560 .name
= "pxa25x-nssp",
563 .dma_mask
= &pxa25x_nssp_dma_mask
,
564 .coherent_dma_mask
= DMA_BIT_MASK(32),
566 .resource
= pxa25x_resource_nssp
,
567 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
570 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
572 static struct resource pxa25x_resource_assp
[] = {
576 .flags
= IORESOURCE_MEM
,
581 .flags
= IORESOURCE_IRQ
,
587 .flags
= IORESOURCE_DMA
,
593 .flags
= IORESOURCE_DMA
,
597 struct platform_device pxa25x_device_assp
= {
598 /* ASSP is basically equivalent to NSSP */
599 .name
= "pxa25x-nssp",
602 .dma_mask
= &pxa25x_assp_dma_mask
,
603 .coherent_dma_mask
= DMA_BIT_MASK(32),
605 .resource
= pxa25x_resource_assp
,
606 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
608 #endif /* CONFIG_PXA25x */
610 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
611 static struct resource pxa27x_resource_camera
[] = {
615 .flags
= IORESOURCE_MEM
,
620 .flags
= IORESOURCE_IRQ
,
624 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
626 static struct platform_device pxa27x_device_camera
= {
627 .name
= "pxa27x-camera",
628 .id
= 0, /* This is used to put cameras on this interface */
630 .dma_mask
= &pxa27x_dma_mask_camera
,
631 .coherent_dma_mask
= 0xffffffff,
633 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
634 .resource
= pxa27x_resource_camera
,
637 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
639 pxa_register_device(&pxa27x_device_camera
, info
);
642 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
644 static struct resource pxa27x_resource_ohci
[] = {
648 .flags
= IORESOURCE_MEM
,
653 .flags
= IORESOURCE_IRQ
,
657 struct platform_device pxa27x_device_ohci
= {
658 .name
= "pxa27x-ohci",
661 .dma_mask
= &pxa27x_ohci_dma_mask
,
662 .coherent_dma_mask
= DMA_BIT_MASK(32),
664 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
665 .resource
= pxa27x_resource_ohci
,
668 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
670 pxa_register_device(&pxa27x_device_ohci
, info
);
672 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
674 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
675 static struct resource pxa27x_resource_keypad
[] = {
679 .flags
= IORESOURCE_MEM
,
684 .flags
= IORESOURCE_IRQ
,
688 struct platform_device pxa27x_device_keypad
= {
689 .name
= "pxa27x-keypad",
691 .resource
= pxa27x_resource_keypad
,
692 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
695 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
697 pxa_register_device(&pxa27x_device_keypad
, info
);
700 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
702 static struct resource pxa27x_resource_ssp1
[] = {
706 .flags
= IORESOURCE_MEM
,
711 .flags
= IORESOURCE_IRQ
,
717 .flags
= IORESOURCE_DMA
,
723 .flags
= IORESOURCE_DMA
,
727 struct platform_device pxa27x_device_ssp1
= {
728 .name
= "pxa27x-ssp",
731 .dma_mask
= &pxa27x_ssp1_dma_mask
,
732 .coherent_dma_mask
= DMA_BIT_MASK(32),
734 .resource
= pxa27x_resource_ssp1
,
735 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
738 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
740 static struct resource pxa27x_resource_ssp2
[] = {
744 .flags
= IORESOURCE_MEM
,
749 .flags
= IORESOURCE_IRQ
,
755 .flags
= IORESOURCE_DMA
,
761 .flags
= IORESOURCE_DMA
,
765 struct platform_device pxa27x_device_ssp2
= {
766 .name
= "pxa27x-ssp",
769 .dma_mask
= &pxa27x_ssp2_dma_mask
,
770 .coherent_dma_mask
= DMA_BIT_MASK(32),
772 .resource
= pxa27x_resource_ssp2
,
773 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
776 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
778 static struct resource pxa27x_resource_ssp3
[] = {
782 .flags
= IORESOURCE_MEM
,
787 .flags
= IORESOURCE_IRQ
,
793 .flags
= IORESOURCE_DMA
,
799 .flags
= IORESOURCE_DMA
,
803 struct platform_device pxa27x_device_ssp3
= {
804 .name
= "pxa27x-ssp",
807 .dma_mask
= &pxa27x_ssp3_dma_mask
,
808 .coherent_dma_mask
= DMA_BIT_MASK(32),
810 .resource
= pxa27x_resource_ssp3
,
811 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
814 static struct resource pxa27x_resource_pwm0
[] = {
818 .flags
= IORESOURCE_MEM
,
822 struct platform_device pxa27x_device_pwm0
= {
823 .name
= "pxa27x-pwm",
825 .resource
= pxa27x_resource_pwm0
,
826 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
829 static struct resource pxa27x_resource_pwm1
[] = {
833 .flags
= IORESOURCE_MEM
,
837 struct platform_device pxa27x_device_pwm1
= {
838 .name
= "pxa27x-pwm",
840 .resource
= pxa27x_resource_pwm1
,
841 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
843 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx || CONFIG_PXA95x*/
846 static struct resource pxa3xx_resources_mci2
[] = {
850 .flags
= IORESOURCE_MEM
,
855 .flags
= IORESOURCE_IRQ
,
860 .flags
= IORESOURCE_DMA
,
865 .flags
= IORESOURCE_DMA
,
869 struct platform_device pxa3xx_device_mci2
= {
870 .name
= "pxa2xx-mci",
873 .dma_mask
= &pxamci_dmamask
,
874 .coherent_dma_mask
= 0xffffffff,
876 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
877 .resource
= pxa3xx_resources_mci2
,
880 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
882 pxa_register_device(&pxa3xx_device_mci2
, info
);
885 static struct resource pxa3xx_resources_mci3
[] = {
889 .flags
= IORESOURCE_MEM
,
894 .flags
= IORESOURCE_IRQ
,
899 .flags
= IORESOURCE_DMA
,
904 .flags
= IORESOURCE_DMA
,
908 struct platform_device pxa3xx_device_mci3
= {
909 .name
= "pxa2xx-mci",
912 .dma_mask
= &pxamci_dmamask
,
913 .coherent_dma_mask
= 0xffffffff,
915 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
916 .resource
= pxa3xx_resources_mci3
,
919 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
921 pxa_register_device(&pxa3xx_device_mci3
, info
);
924 static struct resource pxa3xx_resources_gcu
[] = {
928 .flags
= IORESOURCE_MEM
,
933 .flags
= IORESOURCE_IRQ
,
937 static u64 pxa3xx_gcu_dmamask
= DMA_BIT_MASK(32);
939 struct platform_device pxa3xx_device_gcu
= {
940 .name
= "pxa3xx-gcu",
942 .num_resources
= ARRAY_SIZE(pxa3xx_resources_gcu
),
943 .resource
= pxa3xx_resources_gcu
,
945 .dma_mask
= &pxa3xx_gcu_dmamask
,
946 .coherent_dma_mask
= 0xffffffff,
950 #endif /* CONFIG_PXA3xx */
952 #if defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
953 static struct resource pxa3xx_resources_i2c_power
[] = {
957 .flags
= IORESOURCE_MEM
,
961 .flags
= IORESOURCE_IRQ
,
965 struct platform_device pxa3xx_device_i2c_power
= {
966 .name
= "pxa3xx-pwri2c",
968 .resource
= pxa3xx_resources_i2c_power
,
969 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
972 static struct resource pxa3xx_resources_nand
[] = {
976 .flags
= IORESOURCE_MEM
,
981 .flags
= IORESOURCE_IRQ
,
984 /* DRCMR for Data DMA */
987 .flags
= IORESOURCE_DMA
,
990 /* DRCMR for Command DMA */
993 .flags
= IORESOURCE_DMA
,
997 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
999 struct platform_device pxa3xx_device_nand
= {
1000 .name
= "pxa3xx-nand",
1003 .dma_mask
= &pxa3xx_nand_dma_mask
,
1004 .coherent_dma_mask
= DMA_BIT_MASK(32),
1006 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
1007 .resource
= pxa3xx_resources_nand
,
1010 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
1012 pxa_register_device(&pxa3xx_device_nand
, info
);
1015 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
1017 static struct resource pxa3xx_resource_ssp4
[] = {
1019 .start
= 0x41a00000,
1021 .flags
= IORESOURCE_MEM
,
1026 .flags
= IORESOURCE_IRQ
,
1032 .flags
= IORESOURCE_DMA
,
1038 .flags
= IORESOURCE_DMA
,
1042 struct platform_device pxa3xx_device_ssp4
= {
1043 /* PXA3xx SSP is basically equivalent to PXA27x */
1044 .name
= "pxa27x-ssp",
1047 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
1048 .coherent_dma_mask
= DMA_BIT_MASK(32),
1050 .resource
= pxa3xx_resource_ssp4
,
1051 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
1053 #endif /* CONFIG_PXA3xx || CONFIG_PXA95x */
1055 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1056 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1057 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
1059 struct platform_device
*pd
;
1061 pd
= platform_device_alloc("pxa2xx-spi", id
);
1063 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
1068 pd
->dev
.platform_data
= info
;
1069 platform_device_add(pd
);