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>
9 #include <mach/pxa3xx-u2d.h>
10 #include <mach/pxafb.h>
12 #include <mach/irda.h>
13 #include <mach/ohci.h>
14 #include <plat/pxa27x_keypad.h>
15 #include <mach/pxa2xx_spi.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
set_pxa_fb_info(struct pxafb_mach_info
*info
)
193 pxa_register_device(&pxa_device_fb
, info
);
196 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
198 pxa_device_fb
.dev
.parent
= parent_dev
;
201 static struct resource pxa_resource_ffuart
[] = {
205 .flags
= IORESOURCE_MEM
,
209 .flags
= IORESOURCE_IRQ
,
213 struct platform_device pxa_device_ffuart
= {
214 .name
= "pxa2xx-uart",
216 .resource
= pxa_resource_ffuart
,
217 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
220 void __init
pxa_set_ffuart_info(void *info
)
222 pxa_register_device(&pxa_device_ffuart
, info
);
225 static struct resource pxa_resource_btuart
[] = {
229 .flags
= IORESOURCE_MEM
,
233 .flags
= IORESOURCE_IRQ
,
237 struct platform_device pxa_device_btuart
= {
238 .name
= "pxa2xx-uart",
240 .resource
= pxa_resource_btuart
,
241 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
244 void __init
pxa_set_btuart_info(void *info
)
246 pxa_register_device(&pxa_device_btuart
, info
);
249 static struct resource pxa_resource_stuart
[] = {
253 .flags
= IORESOURCE_MEM
,
257 .flags
= IORESOURCE_IRQ
,
261 struct platform_device pxa_device_stuart
= {
262 .name
= "pxa2xx-uart",
264 .resource
= pxa_resource_stuart
,
265 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
268 void __init
pxa_set_stuart_info(void *info
)
270 pxa_register_device(&pxa_device_stuart
, info
);
273 static struct resource pxa_resource_hwuart
[] = {
277 .flags
= IORESOURCE_MEM
,
281 .flags
= IORESOURCE_IRQ
,
285 struct platform_device pxa_device_hwuart
= {
286 .name
= "pxa2xx-uart",
288 .resource
= pxa_resource_hwuart
,
289 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
292 void __init
pxa_set_hwuart_info(void *info
)
295 pxa_register_device(&pxa_device_hwuart
, info
);
297 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
300 static struct resource pxai2c_resources
[] = {
304 .flags
= IORESOURCE_MEM
,
308 .flags
= IORESOURCE_IRQ
,
312 struct platform_device pxa_device_i2c
= {
313 .name
= "pxa2xx-i2c",
315 .resource
= pxai2c_resources
,
316 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
319 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
321 pxa_register_device(&pxa_device_i2c
, info
);
325 static struct resource pxa27x_resources_i2c_power
[] = {
329 .flags
= IORESOURCE_MEM
,
333 .flags
= IORESOURCE_IRQ
,
337 struct platform_device pxa27x_device_i2c_power
= {
338 .name
= "pxa2xx-i2c",
340 .resource
= pxa27x_resources_i2c_power
,
341 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
346 static struct resource pxa3xx_resources_i2c_power
[] = {
350 .flags
= IORESOURCE_MEM
,
354 .flags
= IORESOURCE_IRQ
,
358 struct platform_device pxa3xx_device_i2c_power
= {
359 .name
= "pxa3xx-pwri2c",
361 .resource
= pxa3xx_resources_i2c_power
,
362 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
366 static struct resource pxai2s_resources
[] = {
370 .flags
= IORESOURCE_MEM
,
374 .flags
= IORESOURCE_IRQ
,
378 struct platform_device pxa_device_i2s
= {
379 .name
= "pxa2xx-i2s",
381 .resource
= pxai2s_resources
,
382 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
385 struct platform_device pxa_device_asoc_ssp1
= {
386 .name
= "pxa-ssp-dai",
390 struct platform_device pxa_device_asoc_ssp2
= {
391 .name
= "pxa-ssp-dai",
395 struct platform_device pxa_device_asoc_ssp3
= {
396 .name
= "pxa-ssp-dai",
400 struct platform_device pxa_device_asoc_ssp4
= {
401 .name
= "pxa-ssp-dai",
405 struct platform_device pxa_device_asoc_platform
= {
406 .name
= "pxa-pcm-audio",
410 static u64 pxaficp_dmamask
= ~(u32
)0;
412 struct platform_device pxa_device_ficp
= {
416 .dma_mask
= &pxaficp_dmamask
,
417 .coherent_dma_mask
= 0xffffffff,
421 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
423 pxa_register_device(&pxa_device_ficp
, info
);
426 static struct resource pxa_rtc_resources
[] = {
429 .end
= 0x40900000 + 0x3b,
430 .flags
= IORESOURCE_MEM
,
435 .flags
= IORESOURCE_IRQ
,
438 .start
= IRQ_RTCAlrm
,
440 .flags
= IORESOURCE_IRQ
,
444 struct platform_device sa1100_device_rtc
= {
445 .name
= "sa1100-rtc",
449 struct platform_device pxa_device_rtc
= {
452 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
453 .resource
= pxa_rtc_resources
,
456 static struct resource pxa_ac97_resources
[] = {
459 .end
= 0x40500000 + 0xfff,
460 .flags
= IORESOURCE_MEM
,
465 .flags
= IORESOURCE_IRQ
,
469 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
471 struct platform_device pxa_device_ac97
= {
472 .name
= "pxa2xx-ac97",
475 .dma_mask
= &pxa_ac97_dmamask
,
476 .coherent_dma_mask
= 0xffffffff,
478 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
479 .resource
= pxa_ac97_resources
,
482 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
484 pxa_register_device(&pxa_device_ac97
, ops
);
489 static struct resource pxa25x_resource_pwm0
[] = {
493 .flags
= IORESOURCE_MEM
,
497 struct platform_device pxa25x_device_pwm0
= {
498 .name
= "pxa25x-pwm",
500 .resource
= pxa25x_resource_pwm0
,
501 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
504 static struct resource pxa25x_resource_pwm1
[] = {
508 .flags
= IORESOURCE_MEM
,
512 struct platform_device pxa25x_device_pwm1
= {
513 .name
= "pxa25x-pwm",
515 .resource
= pxa25x_resource_pwm1
,
516 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
519 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
521 static struct resource pxa25x_resource_ssp
[] = {
525 .flags
= IORESOURCE_MEM
,
530 .flags
= IORESOURCE_IRQ
,
536 .flags
= IORESOURCE_DMA
,
542 .flags
= IORESOURCE_DMA
,
546 struct platform_device pxa25x_device_ssp
= {
547 .name
= "pxa25x-ssp",
550 .dma_mask
= &pxa25x_ssp_dma_mask
,
551 .coherent_dma_mask
= DMA_BIT_MASK(32),
553 .resource
= pxa25x_resource_ssp
,
554 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
557 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
559 static struct resource pxa25x_resource_nssp
[] = {
563 .flags
= IORESOURCE_MEM
,
568 .flags
= IORESOURCE_IRQ
,
574 .flags
= IORESOURCE_DMA
,
580 .flags
= IORESOURCE_DMA
,
584 struct platform_device pxa25x_device_nssp
= {
585 .name
= "pxa25x-nssp",
588 .dma_mask
= &pxa25x_nssp_dma_mask
,
589 .coherent_dma_mask
= DMA_BIT_MASK(32),
591 .resource
= pxa25x_resource_nssp
,
592 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
595 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
597 static struct resource pxa25x_resource_assp
[] = {
601 .flags
= IORESOURCE_MEM
,
606 .flags
= IORESOURCE_IRQ
,
612 .flags
= IORESOURCE_DMA
,
618 .flags
= IORESOURCE_DMA
,
622 struct platform_device pxa25x_device_assp
= {
623 /* ASSP is basically equivalent to NSSP */
624 .name
= "pxa25x-nssp",
627 .dma_mask
= &pxa25x_assp_dma_mask
,
628 .coherent_dma_mask
= DMA_BIT_MASK(32),
630 .resource
= pxa25x_resource_assp
,
631 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
633 #endif /* CONFIG_PXA25x */
635 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
637 static struct resource pxa27x_resource_keypad
[] = {
641 .flags
= IORESOURCE_MEM
,
646 .flags
= IORESOURCE_IRQ
,
650 struct platform_device pxa27x_device_keypad
= {
651 .name
= "pxa27x-keypad",
653 .resource
= pxa27x_resource_keypad
,
654 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
657 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
659 pxa_register_device(&pxa27x_device_keypad
, info
);
662 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
664 static struct resource pxa27x_resource_ohci
[] = {
668 .flags
= IORESOURCE_MEM
,
673 .flags
= IORESOURCE_IRQ
,
677 struct platform_device pxa27x_device_ohci
= {
678 .name
= "pxa27x-ohci",
681 .dma_mask
= &pxa27x_ohci_dma_mask
,
682 .coherent_dma_mask
= DMA_BIT_MASK(32),
684 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
685 .resource
= pxa27x_resource_ohci
,
688 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
690 pxa_register_device(&pxa27x_device_ohci
, info
);
693 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
695 static struct resource pxa27x_resource_ssp1
[] = {
699 .flags
= IORESOURCE_MEM
,
704 .flags
= IORESOURCE_IRQ
,
710 .flags
= IORESOURCE_DMA
,
716 .flags
= IORESOURCE_DMA
,
720 struct platform_device pxa27x_device_ssp1
= {
721 .name
= "pxa27x-ssp",
724 .dma_mask
= &pxa27x_ssp1_dma_mask
,
725 .coherent_dma_mask
= DMA_BIT_MASK(32),
727 .resource
= pxa27x_resource_ssp1
,
728 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
731 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
733 static struct resource pxa27x_resource_ssp2
[] = {
737 .flags
= IORESOURCE_MEM
,
742 .flags
= IORESOURCE_IRQ
,
748 .flags
= IORESOURCE_DMA
,
754 .flags
= IORESOURCE_DMA
,
758 struct platform_device pxa27x_device_ssp2
= {
759 .name
= "pxa27x-ssp",
762 .dma_mask
= &pxa27x_ssp2_dma_mask
,
763 .coherent_dma_mask
= DMA_BIT_MASK(32),
765 .resource
= pxa27x_resource_ssp2
,
766 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
769 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
771 static struct resource pxa27x_resource_ssp3
[] = {
775 .flags
= IORESOURCE_MEM
,
780 .flags
= IORESOURCE_IRQ
,
786 .flags
= IORESOURCE_DMA
,
792 .flags
= IORESOURCE_DMA
,
796 struct platform_device pxa27x_device_ssp3
= {
797 .name
= "pxa27x-ssp",
800 .dma_mask
= &pxa27x_ssp3_dma_mask
,
801 .coherent_dma_mask
= DMA_BIT_MASK(32),
803 .resource
= pxa27x_resource_ssp3
,
804 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
807 static struct resource pxa27x_resource_pwm0
[] = {
811 .flags
= IORESOURCE_MEM
,
815 struct platform_device pxa27x_device_pwm0
= {
816 .name
= "pxa27x-pwm",
818 .resource
= pxa27x_resource_pwm0
,
819 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
822 static struct resource pxa27x_resource_pwm1
[] = {
826 .flags
= IORESOURCE_MEM
,
830 struct platform_device pxa27x_device_pwm1
= {
831 .name
= "pxa27x-pwm",
833 .resource
= pxa27x_resource_pwm1
,
834 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
837 static struct resource pxa27x_resource_camera
[] = {
841 .flags
= IORESOURCE_MEM
,
846 .flags
= IORESOURCE_IRQ
,
850 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
852 static struct platform_device pxa27x_device_camera
= {
853 .name
= "pxa27x-camera",
854 .id
= 0, /* This is used to put cameras on this interface */
856 .dma_mask
= &pxa27x_dma_mask_camera
,
857 .coherent_dma_mask
= 0xffffffff,
859 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
860 .resource
= pxa27x_resource_camera
,
863 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
865 pxa_register_device(&pxa27x_device_camera
, info
);
867 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
870 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
872 static struct resource pxa3xx_resource_ssp4
[] = {
876 .flags
= IORESOURCE_MEM
,
881 .flags
= IORESOURCE_IRQ
,
887 .flags
= IORESOURCE_DMA
,
893 .flags
= IORESOURCE_DMA
,
897 struct platform_device pxa3xx_device_ssp4
= {
898 /* PXA3xx SSP is basically equivalent to PXA27x */
899 .name
= "pxa27x-ssp",
902 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
903 .coherent_dma_mask
= DMA_BIT_MASK(32),
905 .resource
= pxa3xx_resource_ssp4
,
906 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
909 static struct resource pxa3xx_resources_mci2
[] = {
913 .flags
= IORESOURCE_MEM
,
918 .flags
= IORESOURCE_IRQ
,
923 .flags
= IORESOURCE_DMA
,
928 .flags
= IORESOURCE_DMA
,
932 struct platform_device pxa3xx_device_mci2
= {
933 .name
= "pxa2xx-mci",
936 .dma_mask
= &pxamci_dmamask
,
937 .coherent_dma_mask
= 0xffffffff,
939 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
940 .resource
= pxa3xx_resources_mci2
,
943 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
945 pxa_register_device(&pxa3xx_device_mci2
, info
);
948 static struct resource pxa3xx_resources_mci3
[] = {
952 .flags
= IORESOURCE_MEM
,
957 .flags
= IORESOURCE_IRQ
,
962 .flags
= IORESOURCE_DMA
,
967 .flags
= IORESOURCE_DMA
,
971 struct platform_device pxa3xx_device_mci3
= {
972 .name
= "pxa2xx-mci",
975 .dma_mask
= &pxamci_dmamask
,
976 .coherent_dma_mask
= 0xffffffff,
978 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
979 .resource
= pxa3xx_resources_mci3
,
982 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
984 pxa_register_device(&pxa3xx_device_mci3
, info
);
987 static struct resource pxa3xx_resources_nand
[] = {
991 .flags
= IORESOURCE_MEM
,
996 .flags
= IORESOURCE_IRQ
,
999 /* DRCMR for Data DMA */
1002 .flags
= IORESOURCE_DMA
,
1005 /* DRCMR for Command DMA */
1008 .flags
= IORESOURCE_DMA
,
1012 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
1014 struct platform_device pxa3xx_device_nand
= {
1015 .name
= "pxa3xx-nand",
1018 .dma_mask
= &pxa3xx_nand_dma_mask
,
1019 .coherent_dma_mask
= DMA_BIT_MASK(32),
1021 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
1022 .resource
= pxa3xx_resources_nand
,
1025 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
1027 pxa_register_device(&pxa3xx_device_nand
, info
);
1030 static struct resource pxa3xx_resources_gcu
[] = {
1032 .start
= 0x54000000,
1034 .flags
= IORESOURCE_MEM
,
1039 .flags
= IORESOURCE_IRQ
,
1043 static u64 pxa3xx_gcu_dmamask
= DMA_BIT_MASK(32);
1045 struct platform_device pxa3xx_device_gcu
= {
1046 .name
= "pxa3xx-gcu",
1048 .num_resources
= ARRAY_SIZE(pxa3xx_resources_gcu
),
1049 .resource
= pxa3xx_resources_gcu
,
1051 .dma_mask
= &pxa3xx_gcu_dmamask
,
1052 .coherent_dma_mask
= 0xffffffff,
1056 #endif /* CONFIG_PXA3xx */
1058 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1059 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1060 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
1062 struct platform_device
*pd
;
1064 pd
= platform_device_alloc("pxa2xx-spi", id
);
1066 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
1071 pd
->dev
.platform_data
= info
;
1072 platform_device_add(pd
);