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/pxafb.h>
11 #include <mach/irda.h>
12 #include <mach/ohci.h>
13 #include <mach/pxa27x_keypad.h>
14 #include <mach/pxa2xx_spi.h>
15 #include <mach/camera.h>
16 #include <mach/audio.h>
17 #include <mach/hardware.h>
19 #include <plat/pxa3xx_nand.h>
24 void __init
pxa_register_device(struct platform_device
*dev
, void *data
)
28 dev
->dev
.platform_data
= data
;
30 ret
= platform_device_register(dev
);
32 dev_err(&dev
->dev
, "unable to register device: %d\n", ret
);
35 static struct resource pxa_resource_pmu
= {
38 .flags
= IORESOURCE_IRQ
,
41 struct platform_device pxa_device_pmu
= {
43 .id
= ARM_PMU_DEVICE_CPU
,
44 .resource
= &pxa_resource_pmu
,
48 static struct resource pxamci_resources
[] = {
52 .flags
= IORESOURCE_MEM
,
57 .flags
= IORESOURCE_IRQ
,
62 .flags
= IORESOURCE_DMA
,
67 .flags
= IORESOURCE_DMA
,
71 static u64 pxamci_dmamask
= 0xffffffffUL
;
73 struct platform_device pxa_device_mci
= {
77 .dma_mask
= &pxamci_dmamask
,
78 .coherent_dma_mask
= 0xffffffff,
80 .num_resources
= ARRAY_SIZE(pxamci_resources
),
81 .resource
= pxamci_resources
,
84 void __init
pxa_set_mci_info(struct pxamci_platform_data
*info
)
86 pxa_register_device(&pxa_device_mci
, info
);
90 static struct pxa2xx_udc_mach_info pxa_udc_info
= {
95 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
97 memcpy(&pxa_udc_info
, info
, sizeof *info
);
100 static struct resource pxa2xx_udc_resources
[] = {
104 .flags
= IORESOURCE_MEM
,
109 .flags
= IORESOURCE_IRQ
,
113 static u64 udc_dma_mask
= ~(u32
)0;
115 struct platform_device pxa25x_device_udc
= {
116 .name
= "pxa25x-udc",
118 .resource
= pxa2xx_udc_resources
,
119 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
121 .platform_data
= &pxa_udc_info
,
122 .dma_mask
= &udc_dma_mask
,
126 struct platform_device pxa27x_device_udc
= {
127 .name
= "pxa27x-udc",
129 .resource
= pxa2xx_udc_resources
,
130 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
132 .platform_data
= &pxa_udc_info
,
133 .dma_mask
= &udc_dma_mask
,
137 static struct resource pxafb_resources
[] = {
141 .flags
= IORESOURCE_MEM
,
146 .flags
= IORESOURCE_IRQ
,
150 static u64 fb_dma_mask
= ~(u64
)0;
152 struct platform_device pxa_device_fb
= {
156 .dma_mask
= &fb_dma_mask
,
157 .coherent_dma_mask
= 0xffffffff,
159 .num_resources
= ARRAY_SIZE(pxafb_resources
),
160 .resource
= pxafb_resources
,
163 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
165 pxa_register_device(&pxa_device_fb
, info
);
168 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
170 pxa_device_fb
.dev
.parent
= parent_dev
;
173 static struct resource pxa_resource_ffuart
[] = {
177 .flags
= IORESOURCE_MEM
,
181 .flags
= IORESOURCE_IRQ
,
185 struct platform_device pxa_device_ffuart
= {
186 .name
= "pxa2xx-uart",
188 .resource
= pxa_resource_ffuart
,
189 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
192 void __init
pxa_set_ffuart_info(void *info
)
194 pxa_register_device(&pxa_device_ffuart
, info
);
197 static struct resource pxa_resource_btuart
[] = {
201 .flags
= IORESOURCE_MEM
,
205 .flags
= IORESOURCE_IRQ
,
209 struct platform_device pxa_device_btuart
= {
210 .name
= "pxa2xx-uart",
212 .resource
= pxa_resource_btuart
,
213 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
216 void __init
pxa_set_btuart_info(void *info
)
218 pxa_register_device(&pxa_device_btuart
, info
);
221 static struct resource pxa_resource_stuart
[] = {
225 .flags
= IORESOURCE_MEM
,
229 .flags
= IORESOURCE_IRQ
,
233 struct platform_device pxa_device_stuart
= {
234 .name
= "pxa2xx-uart",
236 .resource
= pxa_resource_stuart
,
237 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
240 void __init
pxa_set_stuart_info(void *info
)
242 pxa_register_device(&pxa_device_stuart
, info
);
245 static struct resource pxa_resource_hwuart
[] = {
249 .flags
= IORESOURCE_MEM
,
253 .flags
= IORESOURCE_IRQ
,
257 struct platform_device pxa_device_hwuart
= {
258 .name
= "pxa2xx-uart",
260 .resource
= pxa_resource_hwuart
,
261 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
264 void __init
pxa_set_hwuart_info(void *info
)
267 pxa_register_device(&pxa_device_hwuart
, info
);
269 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
272 static struct resource pxai2c_resources
[] = {
276 .flags
= IORESOURCE_MEM
,
280 .flags
= IORESOURCE_IRQ
,
284 struct platform_device pxa_device_i2c
= {
285 .name
= "pxa2xx-i2c",
287 .resource
= pxai2c_resources
,
288 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
291 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
293 pxa_register_device(&pxa_device_i2c
, info
);
297 static struct resource pxa27x_resources_i2c_power
[] = {
301 .flags
= IORESOURCE_MEM
,
305 .flags
= IORESOURCE_IRQ
,
309 struct platform_device pxa27x_device_i2c_power
= {
310 .name
= "pxa2xx-i2c",
312 .resource
= pxa27x_resources_i2c_power
,
313 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
318 static struct resource pxa3xx_resources_i2c_power
[] = {
322 .flags
= IORESOURCE_MEM
,
326 .flags
= IORESOURCE_IRQ
,
330 struct platform_device pxa3xx_device_i2c_power
= {
331 .name
= "pxa3xx-pwri2c",
333 .resource
= pxa3xx_resources_i2c_power
,
334 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
338 static struct resource pxai2s_resources
[] = {
342 .flags
= IORESOURCE_MEM
,
346 .flags
= IORESOURCE_IRQ
,
350 struct platform_device pxa_device_i2s
= {
351 .name
= "pxa2xx-i2s",
353 .resource
= pxai2s_resources
,
354 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
357 struct platform_device pxa_device_asoc_ssp1
= {
358 .name
= "pxa-ssp-dai",
362 struct platform_device pxa_device_asoc_ssp2
= {
363 .name
= "pxa-ssp-dai",
367 struct platform_device pxa_device_asoc_ssp3
= {
368 .name
= "pxa-ssp-dai",
372 struct platform_device pxa_device_asoc_ssp4
= {
373 .name
= "pxa-ssp-dai",
377 struct platform_device pxa_device_asoc_platform
= {
378 .name
= "pxa-pcm-audio",
382 static u64 pxaficp_dmamask
= ~(u32
)0;
384 struct platform_device pxa_device_ficp
= {
388 .dma_mask
= &pxaficp_dmamask
,
389 .coherent_dma_mask
= 0xffffffff,
393 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
395 pxa_register_device(&pxa_device_ficp
, info
);
398 static struct resource pxa_rtc_resources
[] = {
401 .end
= 0x40900000 + 0x3b,
402 .flags
= IORESOURCE_MEM
,
407 .flags
= IORESOURCE_IRQ
,
410 .start
= IRQ_RTCAlrm
,
412 .flags
= IORESOURCE_IRQ
,
416 struct platform_device sa1100_device_rtc
= {
417 .name
= "sa1100-rtc",
421 struct platform_device pxa_device_rtc
= {
424 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
425 .resource
= pxa_rtc_resources
,
428 static struct resource pxa_ac97_resources
[] = {
431 .end
= 0x40500000 + 0xfff,
432 .flags
= IORESOURCE_MEM
,
437 .flags
= IORESOURCE_IRQ
,
441 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
443 struct platform_device pxa_device_ac97
= {
444 .name
= "pxa2xx-ac97",
447 .dma_mask
= &pxa_ac97_dmamask
,
448 .coherent_dma_mask
= 0xffffffff,
450 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
451 .resource
= pxa_ac97_resources
,
454 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
456 pxa_register_device(&pxa_device_ac97
, ops
);
461 static struct resource pxa25x_resource_pwm0
[] = {
465 .flags
= IORESOURCE_MEM
,
469 struct platform_device pxa25x_device_pwm0
= {
470 .name
= "pxa25x-pwm",
472 .resource
= pxa25x_resource_pwm0
,
473 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
476 static struct resource pxa25x_resource_pwm1
[] = {
480 .flags
= IORESOURCE_MEM
,
484 struct platform_device pxa25x_device_pwm1
= {
485 .name
= "pxa25x-pwm",
487 .resource
= pxa25x_resource_pwm1
,
488 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
491 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
493 static struct resource pxa25x_resource_ssp
[] = {
497 .flags
= IORESOURCE_MEM
,
502 .flags
= IORESOURCE_IRQ
,
508 .flags
= IORESOURCE_DMA
,
514 .flags
= IORESOURCE_DMA
,
518 struct platform_device pxa25x_device_ssp
= {
519 .name
= "pxa25x-ssp",
522 .dma_mask
= &pxa25x_ssp_dma_mask
,
523 .coherent_dma_mask
= DMA_BIT_MASK(32),
525 .resource
= pxa25x_resource_ssp
,
526 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
529 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
531 static struct resource pxa25x_resource_nssp
[] = {
535 .flags
= IORESOURCE_MEM
,
540 .flags
= IORESOURCE_IRQ
,
546 .flags
= IORESOURCE_DMA
,
552 .flags
= IORESOURCE_DMA
,
556 struct platform_device pxa25x_device_nssp
= {
557 .name
= "pxa25x-nssp",
560 .dma_mask
= &pxa25x_nssp_dma_mask
,
561 .coherent_dma_mask
= DMA_BIT_MASK(32),
563 .resource
= pxa25x_resource_nssp
,
564 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
567 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
569 static struct resource pxa25x_resource_assp
[] = {
573 .flags
= IORESOURCE_MEM
,
578 .flags
= IORESOURCE_IRQ
,
584 .flags
= IORESOURCE_DMA
,
590 .flags
= IORESOURCE_DMA
,
594 struct platform_device pxa25x_device_assp
= {
595 /* ASSP is basically equivalent to NSSP */
596 .name
= "pxa25x-nssp",
599 .dma_mask
= &pxa25x_assp_dma_mask
,
600 .coherent_dma_mask
= DMA_BIT_MASK(32),
602 .resource
= pxa25x_resource_assp
,
603 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
605 #endif /* CONFIG_PXA25x */
607 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
609 static struct resource pxa27x_resource_keypad
[] = {
613 .flags
= IORESOURCE_MEM
,
618 .flags
= IORESOURCE_IRQ
,
622 struct platform_device pxa27x_device_keypad
= {
623 .name
= "pxa27x-keypad",
625 .resource
= pxa27x_resource_keypad
,
626 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
629 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
631 pxa_register_device(&pxa27x_device_keypad
, info
);
634 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
636 static struct resource pxa27x_resource_ohci
[] = {
640 .flags
= IORESOURCE_MEM
,
645 .flags
= IORESOURCE_IRQ
,
649 struct platform_device pxa27x_device_ohci
= {
650 .name
= "pxa27x-ohci",
653 .dma_mask
= &pxa27x_ohci_dma_mask
,
654 .coherent_dma_mask
= DMA_BIT_MASK(32),
656 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
657 .resource
= pxa27x_resource_ohci
,
660 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
662 pxa_register_device(&pxa27x_device_ohci
, info
);
665 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
667 static struct resource pxa27x_resource_ssp1
[] = {
671 .flags
= IORESOURCE_MEM
,
676 .flags
= IORESOURCE_IRQ
,
682 .flags
= IORESOURCE_DMA
,
688 .flags
= IORESOURCE_DMA
,
692 struct platform_device pxa27x_device_ssp1
= {
693 .name
= "pxa27x-ssp",
696 .dma_mask
= &pxa27x_ssp1_dma_mask
,
697 .coherent_dma_mask
= DMA_BIT_MASK(32),
699 .resource
= pxa27x_resource_ssp1
,
700 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
703 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
705 static struct resource pxa27x_resource_ssp2
[] = {
709 .flags
= IORESOURCE_MEM
,
714 .flags
= IORESOURCE_IRQ
,
720 .flags
= IORESOURCE_DMA
,
726 .flags
= IORESOURCE_DMA
,
730 struct platform_device pxa27x_device_ssp2
= {
731 .name
= "pxa27x-ssp",
734 .dma_mask
= &pxa27x_ssp2_dma_mask
,
735 .coherent_dma_mask
= DMA_BIT_MASK(32),
737 .resource
= pxa27x_resource_ssp2
,
738 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
741 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
743 static struct resource pxa27x_resource_ssp3
[] = {
747 .flags
= IORESOURCE_MEM
,
752 .flags
= IORESOURCE_IRQ
,
758 .flags
= IORESOURCE_DMA
,
764 .flags
= IORESOURCE_DMA
,
768 struct platform_device pxa27x_device_ssp3
= {
769 .name
= "pxa27x-ssp",
772 .dma_mask
= &pxa27x_ssp3_dma_mask
,
773 .coherent_dma_mask
= DMA_BIT_MASK(32),
775 .resource
= pxa27x_resource_ssp3
,
776 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
779 static struct resource pxa27x_resource_pwm0
[] = {
783 .flags
= IORESOURCE_MEM
,
787 struct platform_device pxa27x_device_pwm0
= {
788 .name
= "pxa27x-pwm",
790 .resource
= pxa27x_resource_pwm0
,
791 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
794 static struct resource pxa27x_resource_pwm1
[] = {
798 .flags
= IORESOURCE_MEM
,
802 struct platform_device pxa27x_device_pwm1
= {
803 .name
= "pxa27x-pwm",
805 .resource
= pxa27x_resource_pwm1
,
806 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
809 static struct resource pxa27x_resource_camera
[] = {
813 .flags
= IORESOURCE_MEM
,
818 .flags
= IORESOURCE_IRQ
,
822 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
824 static struct platform_device pxa27x_device_camera
= {
825 .name
= "pxa27x-camera",
826 .id
= 0, /* This is used to put cameras on this interface */
828 .dma_mask
= &pxa27x_dma_mask_camera
,
829 .coherent_dma_mask
= 0xffffffff,
831 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
832 .resource
= pxa27x_resource_camera
,
835 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
837 pxa_register_device(&pxa27x_device_camera
, info
);
839 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
842 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
844 static struct resource pxa3xx_resource_ssp4
[] = {
848 .flags
= IORESOURCE_MEM
,
853 .flags
= IORESOURCE_IRQ
,
859 .flags
= IORESOURCE_DMA
,
865 .flags
= IORESOURCE_DMA
,
869 struct platform_device pxa3xx_device_ssp4
= {
870 /* PXA3xx SSP is basically equivalent to PXA27x */
871 .name
= "pxa27x-ssp",
874 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
875 .coherent_dma_mask
= DMA_BIT_MASK(32),
877 .resource
= pxa3xx_resource_ssp4
,
878 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
881 static struct resource pxa3xx_resources_mci2
[] = {
885 .flags
= IORESOURCE_MEM
,
890 .flags
= IORESOURCE_IRQ
,
895 .flags
= IORESOURCE_DMA
,
900 .flags
= IORESOURCE_DMA
,
904 struct platform_device pxa3xx_device_mci2
= {
905 .name
= "pxa2xx-mci",
908 .dma_mask
= &pxamci_dmamask
,
909 .coherent_dma_mask
= 0xffffffff,
911 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
912 .resource
= pxa3xx_resources_mci2
,
915 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
917 pxa_register_device(&pxa3xx_device_mci2
, info
);
920 static struct resource pxa3xx_resources_mci3
[] = {
924 .flags
= IORESOURCE_MEM
,
929 .flags
= IORESOURCE_IRQ
,
934 .flags
= IORESOURCE_DMA
,
939 .flags
= IORESOURCE_DMA
,
943 struct platform_device pxa3xx_device_mci3
= {
944 .name
= "pxa2xx-mci",
947 .dma_mask
= &pxamci_dmamask
,
948 .coherent_dma_mask
= 0xffffffff,
950 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
951 .resource
= pxa3xx_resources_mci3
,
954 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
956 pxa_register_device(&pxa3xx_device_mci3
, info
);
959 static struct resource pxa3xx_resources_nand
[] = {
963 .flags
= IORESOURCE_MEM
,
968 .flags
= IORESOURCE_IRQ
,
971 /* DRCMR for Data DMA */
974 .flags
= IORESOURCE_DMA
,
977 /* DRCMR for Command DMA */
980 .flags
= IORESOURCE_DMA
,
984 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
986 struct platform_device pxa3xx_device_nand
= {
987 .name
= "pxa3xx-nand",
990 .dma_mask
= &pxa3xx_nand_dma_mask
,
991 .coherent_dma_mask
= DMA_BIT_MASK(32),
993 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
994 .resource
= pxa3xx_resources_nand
,
997 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
999 pxa_register_device(&pxa3xx_device_nand
, info
);
1002 static struct resource pxa3xx_resources_gcu
[] = {
1004 .start
= 0x54000000,
1006 .flags
= IORESOURCE_MEM
,
1011 .flags
= IORESOURCE_IRQ
,
1015 static u64 pxa3xx_gcu_dmamask
= DMA_BIT_MASK(32);
1017 struct platform_device pxa3xx_device_gcu
= {
1018 .name
= "pxa3xx-gcu",
1020 .num_resources
= ARRAY_SIZE(pxa3xx_resources_gcu
),
1021 .resource
= pxa3xx_resources_gcu
,
1023 .dma_mask
= &pxa3xx_gcu_dmamask
,
1024 .coherent_dma_mask
= 0xffffffff,
1028 #endif /* CONFIG_PXA3xx */
1030 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1031 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1032 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
1034 struct platform_device
*pd
;
1036 pd
= platform_device_alloc("pxa2xx-spi", id
);
1038 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
1043 pd
->dev
.platform_data
= info
;
1044 platform_device_add(pd
);